PDF Generation Made Easy Using Ready-Made Templates and JSON to PDF API

27 September 2022 Hershil Bhana

The DynamicDocs API is JSON to PDF API based on LaTeX, which provides a quick way to generate PDFs documents in bulk with the ability to include graphics and logic in the templates. In this article, we will explain the API's new feature - JSON to PDF Templates, which allows users to generate PDFs using ready-made templates.

JSON to PDF Templates are ready-made templates available across all plans (including the free plan). Using JSON to PDF Templates is the easiest way of getting started with the DynamicDocs API, as no LaTeX knowledge is required. Instead, the contents of these templates are controlled by the JSON payload in the API request. The user simply edits a pre-defined JSON payload corresponding to the type of template they wish to create. After that, the user calls the API with their JSON data payload and is able to download a newly created PDF document thereafter.

DynamicDocs API JSON to PDF Templates
DynamicDocs API - JSON to PDF Templates

Furthermore, these PDF documents are entirely dynamic and customisable. Users can include their text, data, colours, snippets of LaTeX code (if necessary) and images encoded as Base64 in the JSON payload. This allows the creation of genuinely dynamic documents, which are generated within a few seconds. The downside to the JSON to PDF Templates is that users are restricted to the templates currently available. In the upcoming months, we will be working on expanding the current template library.

What JSON to PDF Templates are currently available?

At the time of writing, there are currently seven templates available for use via the DynamicDocs API, with more to be added in future. These include five simple templates and two Tex to PDF templates.

Simple Templates

The simple template range consists of basic templates for everyday business and individual use. These include Simple Invoice Template, Simple Statement Template, Simple Quote Template, Simple Credit Note Template, and Simple Terms of Service Template. Each template page provides an API end point and a sample of the JSON payload. For a full list of the available templates, visit our JSON to PDF Templates page.

DynamicDocs API Simple Invoice
Simple Invoice Template

Tex to PDF Templates

The Tex to PDF template range consists of two general templates allowing users to upload their own tex file, with Base64 encoded images in the JSON payload. After that, the PDF is generated using one of the two compilers available through the PDFLaTeX Template or the LuaLaTex Template.

DynamicDocs Tex to PDF Templates
Tex to PDF Template

Trying out JSON to PDF Templates with FREE plan

The DynamicDocs JSON to PDF Templates are currently available directly via ADVICEment.io. Users can sign up for an account and be automatically given a free plan. The FREE plan allows one to create a limited number of monthly API calls. For more information the different plans, visit the DynamicDocs pricing page.

JSON to PDF Templates collection available on Postman public workspace

The DynamicDocs API Postman - Public Workspace is a dedicated Postman workspace for users who are looking to integrate with DynamicDocs API. The public workspace eliminates any difficulty integrating with DynamicDocs API as it provides examples of requests to the API. Various folders contain the API requests for the corresponding templates. Simply select the folder corresponding to the template you would like to generate.

Before hitting 'Send' on the POST request, users must get the API Key and set it as a parameter dynamicDocsAPIKey in the Environments tab. Alternatively, you can authenticate your API requests with the API key as Adv-Security-Token in the header tab of the request. Visit DynamicDocs authenticatiion guide for more information.

Users can edit the template by changing the JSON Payload in the Body tab of the request. Once they are happy with the design of the document, they click 'Send' on the POST request. The POST will respond with the URL location of the status JSON of the initial request. Once the API generates the PDF, the status JSON will be updated, and users can download the document using the link in the status JSON.

DynamicDocs Postman Public Workspace
DynamicDocs API Postman - Public Workspace

Using Postman to generate PDFs via DynamicDocs API

Now let's go through the steps again, using Simple Invoice v1 template as an example. Here are the steps:

  1. Fork the DynamicDocs API Postman - Postman Public Workspace into your Private Postman Workspace.
  2. Use your API key to authenticate the POST Simple Invoice v1 request by adding the Adv-Security-Token header parameter (alternatively, you can use the API key as dynamicDocsAPIKey parameter in your current environment). To get your API key, sign up on advicement.io and generate the key in your account dashboard.
  3. Click Send on the POST Simple Invoice v1 request (you can change the JSON payload in the Body tab). The API request will send back the location of the status JSON, which describes the status of the PDF.
  4. By clicking Send on the GET Simple Invoice v1 Progress JSON, you will use the location of the Status JSON in Step 3 and get its content. This is done by using Postman variables which we programmed in the requests.
  5. Finally, if you see that the status JSON has status code 200, you can click Send on the Simple Invoice v1 Document request. This action will use the download link in the status JSON and download the PDF.

The above steps work with all the JSON to PDF Templates and follow the same logic. Click on the Postman button below to open the DynamicDocs API - JSON to PDF Templates workspace.

Summary

JSON to PDF Templates are ready-made templates which are available across all price plans on ADVICEment.io. They are easy to use and require no LaTeX knowledge since the JSON payload controls their content. The fastest way to get started is to fork and use the DynamicDocs API – Public Workspace via Postman.