Tutorial: Making PDF's in Retool

Giving a ton of credit to @church for their thread here, PDFs Another Way: Custom Component + html2pdf - #7 by domjammoo -

Leveraging @church's previous work in the linked thread above, I've created a generic module built on the html2PDF JS library.

You can insert the module into any project, pass in an HTML string, and the component will provide a base64 binary output of the PDF, which you can then render inside of a standard Retool PDF component or output using the utils.downloadFile() function. The module contains hidden elements to make it easy for you to preview the generated PDF, but you can hide the module itself in your app.

This provides an additional means of generating highly-formatted PDFs without having to pay for a third-party service for PDF generation or hosting separate PDF-generation APIs.

https://storage.googleapis.com/public_shares/HTML_PDF_Export.json

2 Likes