Hi friends, in one of my previous blog posts I explained how to convert HTML to PDF using PDFShift API. PDFShift is a paid product and can be used in specific scenarios like converting to PDF by passing the URL of the page and other complex sacnorao.
If you do not have any complex requirement and you have data coming from SharePoint or anywhere from Office 365 ecosystem, then you can user OneDrive actions to convert HTML to PDF.
Following example will show you how to read the data for newly added list item and convert it to PDF and send an email it as attachment.
I have created a sample SharePoint list with name as “Test” with columns ‘Title’, ‘Name’ and ‘Address’ –

Created a flow with ‘item created’ event. Selected my SharePoint list and added ‘Get item’ activity to get the newly created item. You can change it according to your requirement and according to suitable event for your requirement.

After getting the list item, we can create a HTML for that item. I used following formula to get the HTML string for list item,
Value : concat('<html><body><table height="100%" width="100%" style="background-color:powderblue"><tr><th>Title</th><th>Name</th><th>Address</th></tr><tr><td>',outputs('Get_item')?['body/Title'],'</td><td>',outputs('Get_item')?['body/Name'],'</td><td>',outputs('Get_item')?['body/Address'],'</td></tr></table></body></html>')

Once we get created the HTML for list item then we need to use ‘Create file’ action of OneDrive to create a HTML file.
File Name: concat(outputs('Get_item')?['body/Name'],'.html')
File Content: HTML string created in previous step

After creating HTML file in OneDrive, we need to use ‘Convert file using path’ connector of OneDrive to convert HTML file to PDF file.
File Path: Path of the HTML file created in previous step
Target Type: PDF

Now save the converted PDF content to a PDF file using ‘Create File’ action of OneDrive.
Folder Path: root (/)
File Name: concat(outputs('Get_item')?['body/Name'],'.pdf')
File Content: File Content from previous step











Bujjibabu KJPosted Jul 3, 2021, 6:54 PM
Hi, I have tried Microsoft Power Platform - Convert HTML To PDF Using OneDrive Actions In Power Automate and working upto Creation of file but I am unable to attach file because Variable "PDFAttachmentArr" is not visible at final step to attach email. Request you help me to resolve this issue.