How to Convert HTML to PDF Using Power Automate? [Without Using Premium Connectors]

One of my clients asked me 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.

To meet this requirement, I created an HTML template that dynamically inserted these details and then converted the HTML into a PDF, all without using any premium connectors.

In this Power Automate, I will show you how to convert HTML to PDF using Power Automate without using any premium connector.

Convert HTML to PDF Using Power Automate

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.

Now, follow these steps to add SharePoint values to the HTML and convert the HTML to PDF:

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

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

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.

I hope you follow all the steps to convert PDFs from HTML. If you have any doubts, you can freely ask in the comment box.

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…