DEV Community

Cover image for Dynamic PDF generation made simple
Karan
Karan

Posted on

Dynamic PDF generation made simple

One major challenge every developer faces is generating reports and sending it as emails, coping up with the client's everchanging requirements over the templates, and data configuration.

The traditional way of doing it, is by creating a HTML Pug template for the requested PDF and place template placeholders and pass the real-time data as dynamic variables. Most probably we'll end up using Puppeteer or PDFKit. Customizing these templates as the requirement changes is a tedious and repetitive work.

To tackle these issues, why not ask the business people to design their PDF templates and customize it as per their requirements. As a developer our focus is to prepare data for the reports and call a service that will take care of the PDF Generation. We created an service that does exactly this.

How exaclty?

PDFHippo a tool that let you business people design their report just using an Excel and map the cells that's going to render dynamic data using the syntax var:customer_name and define the cell ranges.

To render array of data like invoice table we can use the formula

table syntax

Upload the excel and save it as a template in PDFHippo and it will give you and unique api end point for the template.

Prepare the JSON data using your favorite programming language and call the template api. Save the blob and boom... Now you can share it with your clients, send it an email or save it in your bucket.
Best part: None of your data is getting saved in PDFHippo.

Documentation: https://pdf-hippo.readme.io/reference/getting-started-with-your-api

Give it a try and let me know what we can do to build up on this!

Top comments (0)