Learn how to create a PDF file from HTML with Power Automate without any premium connectors.
Step by step: How to create PDF from HTML with Power automate
Learn how to create a PDF file from HTML step by step.
-
Create a flow with manual trigger
Create instant flow
-
Add a ‘Compose’ action
Add Compose Step
-
Copy the HTML into Compose
Paste HTML
-
Add a ‘Create file’ action
Create file
-
Set ‘Create file’ Folder Path, File Name and File Content
Create HTML File configuration
-
Add a ‘Convert file using path’ action
Convert file using path
-
Configure ‘Convert file using path’ action’s File Path and set Target Type to PDF
Convert file using path configuration
-
Add another ‘Create File’ action
Create file action
-
Set ‘Create file’ Folder Path, File Name and File Content
Configuration of ‘Create file’
-
Add a ‘Send an email (V2)’ action
Send an email (V2)
-
Finally send the PDF file via email
Configuration ‘Send an email (V2)’
HTML for Copy and Paste
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<style>
* {
font-family: Arial;
font-size: 11px;
}
th,td {
padding:6px;
text-align: start;
vertical-align: text-top;
}
th{
max-width: 100px;
min-width: 100px;
}
td{
max-width: 340px;
min-width: 340px;
}
h3{
font-size: 20px;
font-weight: bolder;
padding-bottom: 4px;
margin-bottom: 0px;
}
td{
background-color:#f3f3f3;
}
</style>
<h3>Sample PDF</h3>
<table>
<tr>
<th>First name </th>
<td>John</td>
<th>Last name</th>
<td>Doe</td>
</tr>
<tr>
<th>Age</th>
<td>27</td>
<th>Gender</th>
<td>Male</td>
</tr>
<tr>
<th>Country</th>
<td>USA</td>
<th>City</th>
<td>New York</td>
</tr>
</table>
</body>
</html>
Hi
I tried the above-mentioned steps, I am able to create the pdf as attachment into the received email but getting an error while opening that PDF as:
“Something went wrong
Unable to open the file”
Please guide me what is the possible solution for this.
Hard to say,maybe your HTML is incorrect?
You may paste it here to check https://validator.w3.org/#validate_by_input
I too was receiving that error and found a solution. In step 9 above, the `File Content` field shows to use the dynamic content `Body`. However, when I used that, it said it was Blob Meta Data. And when opening the pdf in VSCode it was just a JSON object of the meta data, not the actual file contents. So, I changed the `File Content field` to the dynamic data called `File Content` in step 9 and in the attachment of the email, and this corrected the error.
THANK YOU Steve for taking the time to pointing to the solution! I’ve adjusted the image.
same issue i have
Use File Content instead of Body.