How to Convert HTML to PDF in Power Automate? [With & Without Using Premium Connector]

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:

ColumnsData Types
Name (Title)Single line of text
Course NameSingle line of text
ScoreNumber
DateDate and time
how to convert html to pdf using power automate

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>
power automate convert to pdf not working

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.

convert html to pdf power automate onedrive

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.
Convert HTML to PDF using Power Automate

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.

how to convert html to pdf in power automate

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.

how to convert html file to pdf in power automate

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.
Power Automate Convert HTML to PDF

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'])
How to convert HTML file to PDF using Power Automate

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.

Power automate flow convert html to pdf via onedrive issue

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.

Power Automate Covert Single HTML to PDF

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.
How to Convert HTML to PDF in PowerAutomate

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.
Converting HTML to PDF with Power Automate

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.

How to Convert HTML to PDF Power Automate

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

Html to Pdf converter for Power Automate

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

How to use Microsoft Flow to Convert HTML to PDF

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

Convert HTML to PDF using Microsoft Flow

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.

How to convert HTML file to PDF in Power Automate flow

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.

Power Automate Convert HTML to PDF without using Premium Connector

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

Power Automate without using premium connector covert html to pdf

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

how to create PDF from HTML without using Premium Connector in Power Automate

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.

Power Automate Convert HTML to PDF using Premium Connector

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

convert html to pdf power automate using Premium Connector

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>
html to pdf power automate Using Premium Connector

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.
power automate html to pdf Premium Connector

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.
Convert HTML to PDF Using Premium Connector in Power Automate

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

How to Convert HTML to PDF Using Premium Connector in Power Automate

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

How to Convert HTML to PDF Using Premium Connector using Power Automate

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:

  • >

    Build a High-Performance Project Management Site in SharePoint Online

    User registration Power Apps canvas app

    DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

    Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

    Power Platform Tutorial FREE PDF Download

    FREE Power Platform Tutorial PDF

    Download 135 Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…