Convert HTML to PDF in Power Automate

This article demonstrates how to convert an HTML document or an HTML string to PDF with the help of Power Automate (Microsoft Flow).

We will take an invoice as a sample HTML document:

Select fields

Use this link to download it.

Note

If you need custom fonts or multilingual support, review the documentation article describing how to work with various fonts and how to convert foreign characters correctly.

Our documents have to be stored somewhere. Power Automate (Microsoft Flow) has a lot of connectors for different systems. Here are just a few of them:

  • SharePoint

  • Salesforce

  • Box

  • OneDrive

  • Google Drive

  • Dropbox

  • SFTP

  • File System

You can store your files anywhere. In this example, we will store our documents in SharePoint. Our Flow will get an HTML file from a SharePoint document library, convert it to PDF and store generated file back to the SharePoint document library.

This is how complete flow looks:

HTML to PDF flow example

Here is the step-by-step description of the flow:

Flow trigger

You can actually pick any trigger. For example, you can start Flow on file creation in a SharePoint document library. We use “Manually trigger a flow” trigger here to simplify the Flow.

Get file content

This action gets file content of the specified file from the SharePoint document library. You just specify the SharePoint site URL and the path to your file.

You can use any other connector to get files from your system.

Convert HTML to PDF

This is an action from the Plumsail Documents connector.

add convert html to pdf action

If this is your first time using the Plumsail Documents connector, Power Automate will request the Connection Name and API Key.

Create connection in Power Automate flow

You can type any name for the connection, for example Plumsail Documents.

Once the connection name is filled out, create an API key in your Plumsail Account, copy and paste it into the Access Key field, and then click Create.

Copying an API key from the account

Then just put HTML file content from the output of the previous action and receive PDF file content as an output of this action. You can also use raw HTML string as a source HTML.

You can find more information about this action here.

Create file

Now you need to store the HTML file somewhere. In our example, we use the “Create file” action from the SharePoint connector to store the PDF document into the SharePoint document library.

Select fields

You can use any other connector to store PDF documents into your system.