Generate the PDF/Word/Excel/PowerPoint dynamically (Office Automation/Word Automation) from the template. (From JSON data source).
Introduction
During our development journey, we may encounter various requirements for dynamic document generation from the pre-existing template. For example, we generate a dynamic resume (PDF/Word) with existing employee details and generate dynamic invoices from the various invoice templates.
We have an easy, wonderful, and affordable third-party library to achieve the requirements related to document processing through programming.
This article will show the third-party library used to generate the documents from the pre-existing template.
Templater
Templater is a library designed to generate documents from existing Office templates. This allows you to create beautiful reports in a fraction of the time compared to other solutions.
Templater's unique minimal and stable interface allows trivial integration into third-party apps without custom coding.
By leveraging Microsoft Office tools, designers and domain experts will be much more productive. Your product can get a distinguishing feature through the customization of templates by application users.
Templater understands most Word, Excel, and PowerPoint features, allowing companies, non-profits, and individuals worldwide to create documents/spreadsheets/presentations most cost-effectively and efficiently. I found this library very comfortable and affordable to work in after my long search on the internet.
It is beneficial if we need to generate the document dynamically from our system using respective document templates. We can source the data to the document as a JSON file.
We will see implementation detail below,
Step 1
First, we need to finalize our document template and place respective placeholders to fill our dynamic data from the JSON source; Values given inside [[]] double square brackets will be considered placeholders. If we pass the same value from JSON, it will take that as dynamic data. Iteration values should be given in the following format [[rootname.valuename]]
Template Sample

Step 2
Create the JSON data according to the template placeholders we discussed above,


Join the conversation! Your thoughts help the community grow.