Apex Aide apexaide

Using Flow to Generate PDF Files in Salesforce

Salesforce Time· ·Intermediate ·Admin ·3 min read
Summary

Salesforce now allows generating PDF files directly from Apex using Blob.toPdf(), eliminating the need for Visualforce pages or third-party tools. A new Flow action is available that takes HTML input and outputs a PDF file as a Salesforce File, optionally attached to a record. You can dynamically create PDF content using Text Templates or render Email Templates with real merge field values to produce polished documents like invoices. This can be embedded in Flows triggered by record changes to automate document generation and emailing.

Takeaways
  • Use the 'Generate PDF File' Flow action to convert HTML to PDF and save as Salesforce Files.
  • Pass HTML built with Text Templates or rendered Email Templates to generate polished PDFs.
  • Optionally attach generated PDF files to Salesforce records by providing a recordId input.
  • Leverage record-triggered Flows to automate PDF creation and emailing upon record changes.
  • Salesforce Spring '26 release supports PDF generation directly from Apex using Blob.toPdf().

PDF files are still a common requirement in Salesforce processes. For example, quotes/proposals, invoices, or documents you want to share and store in a consistent format. Until now, generating PDF files usually meant rendering a Visualforce page or using a third-party document generation tool. In the Spring '26 release, Salesforce introduced a new Apex capability that lets us generate PDF files directly from Apex, so it's no longer a must to use Visualforce pages. In this post, you'll find a Flow action that uses Blob.toPdf() to generate PDF files and save them as Salesforce Files (Content Version), optionally attaching them to Salesforce records. How to Configure the Action 1- Install the action using the installation links below. 2- Add a new action to your flow and search for "Generate PDF File". This is the name of the action that you installed. 3- This action has 3 input values. html: The HTML markup you want to convert into a PDF.

Flow BuilderFlowFlow ActionsPackages