One of my clients recently asked me how to convert HTML to PDF in Power Automate. Initially, I suggested using the Convert – HTML to PDF action from Encodian, a premium connector. However, they mentioned that they couldn’t use premium connectors. After some research, I found an alternative approach that doesn’t require any premium connectors! Using the Convert file action from OneDrive, we can easily convert HTML files to PDF without additional cost.
In this tutorial, I will explain how to convert HTML to PDF in Power Automate, both with and without using the Premium Connector.
Convert HTML to PDF in Power Automate
Suppose you want to create a PDF certificate after a learner completes a course. The requirement was to pull the learner’s name, course title, Score, and completion date from a SharePoint list and then create a PDF.
First, I created a SharePoint List named Course Completion with the below column and data types:
| Columns | Data Types |
|---|---|
| Name (Title) | Single line of text |
| Course Name | Single line of text |
| Score | Number |
| Date | Date and time |

Also, I already created the HTML script. Check the script below:
<div style="width: 550px; height: 600px; padding: 20px; text-align: center; border: 10px solid #787878; margin: auto;">
<table style="width: 100%;">
<tr>
<td style="width: 5%; text-align: center;">
<img src="https://your-logo-url.com/logo.png" alt="Company Logo" width="100" height="100">
</td>
</tr>
</table>
<h1>Certificate of Completion</h1>
<table style="width: 100%;">
<tr>
<td style="text-align: center;">
<p>
This is to certify that <strong>[Name]</strong> has successfully completed the course <strong>[CourseName]</strong> with a score of <strong>[Score]%</strong>.
</p>
<p>
Date of Completion: <strong>[Date]</strong>
</p>
</td>
</tr>
</table>
<table style="margin-top: 50px; width: 100%;">
<tr>
<td style="width: 50%; text-align: center;">
<img src="https://Instructor's Signature.png" alt="Instructor's Signature" width="100" height="100">
<p>_____________________________</p>
<p>Instructor's Signature</p>
</td>
<td style="width: 50%; text-align: center;">
<img src="https://Authorized Signature" alt="Authorized Signature" width="100" height="100">
<p>_____________________________</p>
<p>Authorized Signature</p>
</td>
</tr>
</table>
</div>
You might be wondering about the HTML boilerplate and CSS. Adding these can sometimes cause issues when converting to PDF. To avoid problems, use simple tags like <table> instead to create your HTML.
Convert HTML to PDF without Using Premium Connector
Add SharePoint List value to HTML using Power Automate
1. Create an automated cloud flow. Give the flow name and select the trigger When an item is created. Also, provide the Site Address and List Name.

2. We need to store the HTML script in the flow. To do this, I add an Initialize variable action and set below parameters:
- Name: Give a name to identify quickly. I give it varPdfTemplate
- Type: String from dropdown.
- Value: you HTML script.

3. Next, in the HTML script, I need to specify the keys we want to replace, such as Name, CourseName, Score, etc.. These will be replaced with values from the SharePoint list. To do this, I added a ‘Compose‘ action and provided the keys and values in JSON format. Check the screenshot below.

Now that our key-value pairs are set, we must replace them in the HTML script using the ‘Parse JSON‘ action. You must provide a sample schema to use the ‘Parse JSON’ action. To obtain this schema, save the flow and run it once. Then copy the ‘Compose’ action output.

4. Then edit the flow and Add a Parse JSON action. Also, provide the below parameter:
- Content: Provide the dynamic content output of the compose action.
- Schema: click Use Sample payload to generate schema, past the ‘Compose’ action output, then click Done.

5. Next, we need to replace the key with a value. I put the formula below in the expression to do this in the create a compose action.
replace(variables('varPdfTemplate'),concat('[',items('For_each')['Key'],']'),items('For_each')['Value'])
It will add for each action automatically.
This expression replaces a template’s specific placeholder(like [Name]) with a new value.
- variables(‘varPdfTemplate’): This is the name of the Initialize variable.
- concat(‘[‘,items(‘For_each’)[‘Key’],’]’): The placeholder in the template (e.g., [Name]).
- items(‘For_each’)[‘Value’]: The value to replace the placeholder.
6. Inside each action, add a set variable action and provide the parameters like Name as varPdfTemplate from the drop-down and Value as the output of the compose action, where we put the replace function.

Convert HTML to PDF using Power Automate
Now that our HTML is complete, we need to convert it to a PDF. To do this, follow the below steps:
1. In the above flow, add a create file action in OneDrive for business. Then, provide the folder path, file name, and file content from the dynamic content.

2. Now, we need to convert that HTML file to pdf. For this, I add a convert file action and provide the parameters below
- File: Provide Id from the create file dynamic content
- Target Type: Select the PDF from the drop-down.

At this point, our PDF file is created in OneDrive. Where you store it depends on your preference. In my case, I want to store it in a SharePoint library.
So, I added a create file action from the SharePoint connector using the below parameter:
- Site Address: Provide which site you want to store.
- Folder Path: Provide Where you wish to store.
- File Name: Provide file name. You can give a different name, but I want the same name as onedrive.
- File Content: Provide the File content from dynamic content.

Lastly, add an action that deletes the Onedrive pdf file. To do this, add a delete file action from OneDrive for business. Then, provide an ID from dynamic content.

Now save the flow and test it manually. To do this, go to the SharePoint List and put the item on the SharePoint list.

A PDF file will be created in the SharePoint library when the flow runs successfully.

However, the images are not converted here. To do this, go to OneDrive, create a folder, and put the required image.

Then, edit the flow and get the image using the Get file content action. I use three images here, so I use Get file content three times.

Then, open the script variable where you store the HTML script. In the side src, add the expression, give dataUri (the file content of the get file content), and then click the add button to add the expression.

Then, save the flow, go to the SharePoint list, and add an item.

When the flow runs successfully, a PDF file will be created in the SharePoint library.

This way, you can convert PDFs from HTML without using the Premium Connector in Power Automate.
Convert HTML to PDF Using Premium Connector
In the previous example, we saw how to Convert HTML to PDF without using the Premium Connector. However, this process was lengthy. Now, let me show you how to Convert HTML to PDF using the Premium Connector with the Convert—HTML to PDF action from Encodian, significantly simplifying the process.
To use the Encodian action, you need an API key. Fill out and submit the form to generate an API key. Later, you can configure the Encodian action with the generated API key.
Now follow the below steps:
1. Create an automated cloud flow. Give the flow name and select the trigger When an item is created. Also, provide the Site Address and List Name.

2. Add the Get file content action and select the images. I use three images here, so I use Get file content three times.

3. Add a compose action and provide below HTML:
<div style="width: 550px; height: 600px; padding: 20px; text-align: center; border: 10px solid #787878; margin: auto;">
<table style="width: 100%;">
<tr>
<td style="width: 5%; text-align: center;">
<img src="@{dataUri(body('Get_file_content_2'))}" alt="Company Logo" width="100" height="100">
</td>
</tr>
</table>
<h1>Certificate of Completion</h1>
<table style="width: 100%;">
<tr>
<td style="text-align: center;">
<p>
This is to certify that <strong>@{triggerBody()?['Title']}</strong> has successfully completed the course <strong>@{triggerBody()?['CourseName']}</strong> with a score of <strong>@{triggerBody()?['Score']}%</strong>.
</p>
<p>
Date of Completion: <strong>@{triggerBody()?['Date']}</strong>
</p>
</td>
</tr>
</table>
<table style="margin-top: 50px; width: 100%;">
<tr>
<td style="width: 50%; text-align: center;">
<img src="@{dataUri(body('Get_file_content_1'))}" alt="Instructor's Signature" width="100" height="100">
<p>_____________________________</p>
<p>Instructor's Signature</p>
</td>
<td style="width: 50%; text-align: center;">
<img src="@{dataUri(body('Get_file_content'))}" alt="Authorized Signature" width="100" height="100">
<p>_____________________________</p>
<p>Authorized Signature</p>
</td>
</tr>
</table>
</div>
4. Add Convert—HTML to PDF action from Encodian and provide below parameters:
- PDF file name: Provide the pdf file name.
- HTML Data: Provide the output of the composed action from the dynamic content.

5. Add a create file action from the SharePoint connector using the below parameter:
- Site Address: Provide which site you want to store.
- Folder Path: Provide Where you wish to store.
- File Name: Provide the file name from dynamic content.
- File Content: Provide the file content from dynamic content.

Then, save the flow, go to the SharePoint list, and add an item.

When the flow runs successfully, a PDF file will be created in the SharePoint library.

Conclusion
This tutorial explored two methods for converting HTML to PDF in Power Automate. First, we covered a cost-effective approach using the Convert file action from OneDrive. Next, we learned a more straightforward and efficient method using the premium Encodian Convert – HTML to PDF action, which requires minimal configuration to convert PDF from HTML in Power Automate.
Also, you may like some more Power Automate tutorials:
- Convert Word Files to PDF Using Power Automate
- Send Monthly Email Reminder for a Due Date Using Power Automate
- Convert PDF to Base64 Using Power Automate
- Convert SharePoint list item to PDF using Power Automate
- Create PDF from Excel using Power Automate
- Create PDF from Microsoft Forms via Power Automate

After working for more than 18 years in Microsoft technologies like SharePoint, Microsoft 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (12 times). I have also worked in companies like HP, TCS, KPIT, etc.
Hi there, this tutorial worked perfectly. How would you now attach that same pdf to an email?