DEV Community

Cover image for Technology Options for Automated Dynamic PDF Generation
IgorR for ADVICEment

Posted on • Originally published at advicement.io

Technology Options for Automated Dynamic PDF Generation

Effective dynamic documents can add immense value to any business looking to engage with their clients through personalisation. These documents can take many forms, including customised statements, invoices, welcome letters, product schedules. However, production challenges with dynamic documents can set organisations back significantly in terms of time, budget and resources spent. This article will review the possible technology options available to businesses. Having the right technology to produce dynamic documents is crucial in keeping operations running optimally, creating documents quickly, and maintaining a consistent level of quality.

We highlight three technology approaches below.

HTML to PDF

A common option for producing dynamic documents is to write the template using HTML and CSS and then convert it into a PDF. To achieve this, a user will need a good understanding of HTML and CSS. Multiple libraries are available, as well as online solutions, including APIs. Most of the solutions implement an HTML to PDF converter such as wkhtmltopdf, which is open source. In some cases, the quality of produced PDF documents has been poor, but this has improved with time as new versions were, and continue to be, released.

Typically, users will design an HTML page, which becomes a template, and then use another piece of software to change the HTML with data dynamically. One of the downsides of this approach is that developers will be required to use different software to create the documents, the choice of which is mainly dependent on (and limited by) their technology stack.

HTML and CSS are well-known frameworks, making this approach a popular choice for developers when generating dynamic PDF documents. However, we caution against using this approach. It may feel like putting together a jigsaw puzzle that requires substantial testing and tinkering by the developers, resulting in an additional codebase needed to be maintained. Notwithstanding these limitations, having proficient skills in HTML with an already developed CSS library may mean that this approach is more than suitable for some businesses.

Word to PDF or similar

In this category, we group the various solutions that enable a user to write a template in a program, such as MS Word, define the template's dynamic components, and then call the template with the data. The software then converts the newly created document into a PDF.

There is a range of solutions available in this category, primarily targeting the enterprise type client, including some big technology providers such as Adobe and Microsoft.

As each solution has its unique features, they are required to be evaluated individually. The core focus of the evaluation should centre on the usability of template building and the ease of integration for the development team. PDF quality and price are other important factors to be considered in evaluating each solution. Enterprise pricing is often a significant stumbling block for many businesses and can usually only be carried by larger companies with substantial budgets allocated for this. By way of example, the Adobe InDesign Server premium license is $13,500 per annum as of June 2021, which may not be feasible for start-ups and SMEs.

It is essential to evaluate specific features of each solution against the particular business needs, as creating dynamic charts and dynamic tables with user-provided data may prove to be complex and incompatible with some solutions. The ease of use and pricing of the proposed solution are the most important items to evaluate in selecting an appropriate approach. Ultimately, both will have a cost impact on a user's business.

Tex to PDF

A third approach is to use LaTeX (a document preparation software for high-quality typesetting) to create dynamic PDF documents using files with a tex extension. One reason for LaTeX popularity is that it enables authors to write extensive documents in a mark-up style language. This approach bodes well if users are looking to generate high-quality PDF documents which are styled with maximum precision.

To the best of our knowledge, DynamicDocs API, developed by ADVICEment, is the first API product that uses LaTeX to generate PDF documents with dynamic text, tables, and charts. The template files are written on the ADVICEment platform using LaTeX, where they can be tested and compiled. The dynamic data used in the documents are passed in the JSON format as the body of the API call. In the template files, one can indicate where the dynamic data needs to be placed and takes the form of stylised text, tables, or charts.

The main disadvantage of this approach is that LaTeX may seem complicated to pick up as a certain amount of initial time is needed to learn the mark-up language. However, this investment in time is definitely worth it as users gain consistent programmatic formatting throughout the document based on the rules which they have defined. The benefit of separating content and design in LaTeX cannot be overstated.

Another advantage of using DynamicDocs API is that PDF template files are available in a user's ADVICEment account, and changes can be implemented quickly and effectively. As with many API products, users pay for what they use, and there is a pricing plan with various pricing options suitable for users' needs. Users can also try the API with the simple PDF generation form or sign up for a FREE plan to access the API.

Using LaTeX to write document templates and create dynamic PDF documents is one of the most effective and efficient approaches. LaTeX offers a higher level of quality and possibility for these types of documents. Most importantly, you can use DynamicDocs API to automate and maintain the PDF generation process with high-quality results.

Summing-up

Dynamic documents can add immense value to any organisation. Creating effective dynamic documents comes down to the quality of the template and the conversion method used. Whilst effective results can be achieved from various options and service providers; it is imperative for businesses to do their due diligence. Due diligence must consider business-specific needs (special formatting requirements such as dynamic charts and tables) and take into account the existing technology stack.

In this consideration, we note that a built-for-purpose dynamic documents API using LaTeX is a strong contender for the most efficient and effective method to use.

Top comments (1)

Collapse
 
taneltahepold profile image
Tanel Tähepõld

Interesting reading; I would also pick LaTeX over other solutions. Sometimes, it makes sense to skip building and use a purpose-built document generation API. Nordic API listed their TOP5 picks some time ago: nordicapis.com/5-apis-for-automati...