How to Convert HTML to PDF with PDF.co Connector for Power Automate Cloud
This flow converts raw HTML into a PDF using PDF.co, then saves the generated file in SharePoint.
Use HTML to PDF for HTML markup. To convert an existing web page by its address, use the separate URL to PDF action.
Step 1: Create the Flow and Connection
Create an Instant cloud flow with Manually trigger a flow.
Add the official PDFco connector, select HTML to PDF, and connect using your PDF.co API key.
PDFco is a Premium connector in Power Automate, so confirm that your account and environment permit its use.
Step 2: Add the HTML
Paste this complete example into HTML:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Service summary</title>
<style>
body {
font-family: Arial, sans-serif;
font-size: 12pt;
}
h1 {
font-size: 20pt;
}
table {
width: 100%;
border-collapse: collapse;
}
th, td {
border: 1px solid #ccc;
padding: 8px;
text-align: left;
}
</style>
</head>
<body>
<h1>Service summary</h1>
<p>Reference: EXAMPLE-101</p>
<table>
<tr>
<th>Service</th>
<th>Quantity</th>
</tr>
<tr>
<td>Document review</td>
<td>2</td>
</tr>
</table>
</body>
</html>Set the conversion options:
- Name:
service-summary.pdf. - Paper Size:
A4. - Orientation: Portrait.
- margins:
15mm. - Async: No.
The example contains its own text and styles and requires no external images or stylesheets.
Save and test the flow. Confirm that the conversion succeeds and open the returned PDF URL to review the fixed example.
Step 3: Add a Dynamic Reference
Add a Text input named Reference to the manual trigger.
Insert two Compose actions between the trigger and HTML to PDF:
- Name the first action
Reference_value. Set its input to the trigger’s Reference dynamic-content token. - Name the second action
Reference_html. In its Expression editor, enter:
replace(replace(replace(string(outputs('Reference_value')), '&', '&'), '<', '<'), '>', '>')In the HTML field, replace only EXAMPLE-101 with the Outputs token from Reference_html. Keep the surrounding paragraph tags and the Reference: label.
This expression encodes &, <, and > so the reference is inserted as text between HTML tags. Do not encode the entire HTML document. This method is not intended for inserting values into HTML attributes or scripts.
See Microsoft’s workflow expression reference for the functions used here.
Step 4: Download and Save the PDF
Continue only after the conversion completes successfully and its Error output is false.
Add an HTTP action:
- Method:
GET. - URI: Map the completed conversion’s URL output.
Then add SharePoint’s Create file action:
- Site Address: Select the destination site.
- Folder Path: Select the destination folder.
- File Name: Enter
service-summary.pdf. - File Content: Map the HTTP action’s Body output.
This stores the PDF’s contents, not the URL text. The Power Automate file guide explains this download-and-save route.
For repeated runs, use a unique filename. If you later enable asynchronous processing, use Background Jobs Check and wait for success before downloading.
Step 5: Review the Stored PDF
Save and run the flow with a reference such as JOB-2026-101. Open the SharePoint copy and confirm that:
- The heading and reference are correct.
- The table contains the expected service and quantity.
- The text and margins are readable.
- The file opens as a PDF.
Run another test with a reference such as JOB & REVIEW <101> and confirm that those characters appear as text.
The PDF.co output URL is temporary, so complete the download and storage steps before it expires.
Related Tutorials

