Skip to main content

Generate PDFs

Learn how to generate PDFs using the built-in PDF exporter resource.

Retool provides a built-in PDF exporter to generate PDFs based on data in your Retool apps. To download the entire view of your Retool app as a PDF, you can instead use the utils.downloadPage() method.

PDF exporter example

Write queries using the PDF resource

Select the PDF Exporter (exporter) resource in the query editor and configure the following fields. On query success, a PDF file with the given contents is downloaded to the user's browser.

PDF content

The PDF content field accepts Markdown for formatting. To convert data, such as the contents of a table, to a format usable for Markdown, you may need to write additional transformers.

The following transformer constructs Markdown table formatting for {{ }}.

const headers = [Object.keys({{ }}[0])];
const breaks = [headers[0].map(() => "---")];
const rows = {{ }}.map((r) => Object.values(r));
const tableEntries = headers.concat(breaks).concat(rows);
return => "|" + row.join("|") + "|").join("\n");


Use the Filename field to specify a PDF file name. This field accepts dynamic inputs. For example, set it to user_{{ }}_data to download the file as user_<selected_user_ID>_data.pdf.