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 (ContentVersion), 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. This string becomes the actual PDF content (what you'll see when you open the file). This input is required.
- title: The name of the file. This input is required.
- recordId: The Salesforce record you want to "publish" (attach) the generated file to. If you provide it, the action creates the file under that record in Files (and creates a ContentDocumentLink). If you leave it null, the PDF is still created as a file, but it won't be linked to any record automatically. This input is optional.

As an output, it returns the ContentVersion record Id, so you can use a Get Records element to retrieve the file and use it in your Flow.
Using Email Templates to Generate PDF Files in Flow
To generate a PDF file in Flow, you need to pass an HTML string into this action. The simplest way is to build that HTML inside Flow using a Text Template resource.

If you want to design a reusable, polished PDF layout (for example, an invoice template), you can create it as an Email Template instead. Since the action still requires an HTML string, you first need to render the email template so Salesforce replaces the merge fields with real values. You can do that with the Render Email Template action, and then pass the rendered HTML output into the action.
For example, let's assume that we have a classic email template to generate invoice files (it can be a lightning email template too).

Here's a record-triggered flow that runs when an Opportunity becomes Closed Won. It retrieves the email template, renders it (so merge fields are populated), generates a PDF file from the rendered HTML, and then emails it as an attachment.

Here's the PDF file created under the Opportunity record. Everything happens automatically, no need to click a button.

Installation Links
Use this link to install in production or developer edition environments.
Use this link to install in sandbox environments.
Leave a Reply