Dynamic PDF Generation with Retool

Creating documents can be slow and tedious, especially if you need to generate multiple versions with different information. Retool can be your secret weapon for building an efficient dynamic PDF generation system. Here’s how it simplifies the process:

Imagine this: You have a product with different versions, each needing its own user guide. Traditionally, you’d create separate guides for each version, leading to confusion and wasted time.

Retool to the rescue! Here’s what it offers:

  • Build User Interfaces Quickly: Think of Retool as a toolbox with pre-built components. You can drag and drop these elements to create a user-friendly interface for your PDF generation app. No coding needed!

  • Connecting Retool to Your Data: Retool can connect to various sources of information, like databases or spreadsheets. This means you can pull in product details, pricing, or any other data you need to populate your PDFs automatically.

  • Easy Template Magic: Create a single template for your user guides. This template acts like a blueprint, where you can define sections for things like product names, features, or images.

  • Dynamic Data Insertion: Here’s where things get exciting! Retool lets you insert dynamic fields into your template. These fields act like placeholders that get filled with the data you pull in from those connected sources.

  • Automation Power: Want to generate a PDF with a single click? Retool allows you to set up automatic actions. For example, clicking a button could trigger the creation of a PDF with all the latest product information filled into your template.

Getting Started with Retool

Let’s leverage Retool to create an application that streamlines the process of generating technical documentation by providing a range of automation options.


I have set up a manage template section with Retool’s rich text editor component, as shown in the screenshot below. Each variable has a technical value. The manage templates tab allows you to handle the templates. Each template is associated with a model. While one model may have multiple feature values, we can use one template instead of creating multiple templates for each feature value. These variable placeholders enable us to insert dynamic values when downloading a PDF.

Dynamic pdf generation in retool

The second tab is for managing technical variables. You can connect a data source here. Retool provides a large number of data source integrations. Please visit their documentation for more detailed information. I added a few variables that represent the value of a model feature. You can manage variables in this section by adding or editing it. Editing is inline available.

The third and final tab is the Edit document. You can edit the document again in Retool’s Rich text editor and modify it according to your needs. Variable placeholders are still there; you can change their location if required. After your modifications, you must click the download pdf button in Retool’s dashboard to download the document.

Using JS to replace variables with the data

At this point, there is nothing special that you need to do. Retool provides an amicable way to build a dashboard where you can work with data manipulation. However, generating a PDF after replacing all the variables is tricky. But thanks to Retool’s JS support, you can write custom Java Script inside Retool and enhance your application’s ability in many ways. 
The download PDF button uses a JS query behind the scenes to find the variable placeholders inside the document and replace them with the actual value.

pdf exporter resource retool

Download application from Github

I’ve uploaded this application to GitHub. You can download it from there and then import it into your Retool instance to test it. I’m using Retool’s database to store the information. You need to create two tables, one with the name “variables” and the second would be “docgen_templates”. The application maintains the added records in the database so you can add as many as you want.


This application is just an idea of a commercial application we can use to solve the document generation problem. We can increase its boundaries and complexity to incorporate real-world business challenges. We can introduce different levels of roles when it comes to template editing and variable management. However, for the starting point, we can use this application to play with it and see more possibilities in Retool.

I can help! Whether you need guidance on navigating Retool or a hand with the technical aspects, I offer both Retool consultation and developer services to make your dashboard vision a reality. Contact me today, and let’s turn your data into a powerful story!

Scroll to Top