Recently I worked on PDFShift for converting HTML to PDF with header and footer. I checked if we have any article which will explain how to use PDFShift API to convert HTML to CSS, but I do not find any article on this. Hence, I tried myself and made it through.
We have some other service provider for PDF conversion API’s which are already available in form of connection in Microsoft 365, example Muhimbi, Plumsail and others. So, after your evaluation of cost and features, if you have chosen PDFShift then you can use this article.
This article will explain you how we can call PDFShift API to convert the list item data in PDF and send the pdf as email.
PDFShift provides API to convert html to pdf, multiple features are provided with PDFShift. You can check more details and pricing details at https://pdfshift.io/#pricing
Some of the important feature of PDFShift like following –
Parallel conversions – Process multiple documents in parallel to increase conversion speed.
Asynchronous request – Use our powerful webhook system to be notified once a conversion is done.
Raw HTML support – No need to make your private page public. Simply send us your raw HTML data instead and we will convert it.
High-Fidelity PDF – Generate a high-fidelity document, close to your original HTML, in a few seconds.
Privacy-focused – That’s why your documents are not stored on our server (except when explicitly requested) and are not kept for more than 2 days.
Asynchronous request feature is most important feature in real life sacnorao.
I tried to search any readily available connector for PDFShift, but do not found one.
I have created a sample SharePoint list with name as “Temp” with following columns –
Created a flow with item created. 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 this getting the list item, we can create a HTML for that item. I used following formula to get the HTML for list item in Value
Once we get the HTML for list item, we used the HTTP action to call the PDFShift convert API. As PDFShift uses basic authentication, we used basic authentication in HTTP action to authenticate.
You need to provide the API key you get in the “Password” field and in “UserName” field pass value api
Now, we need to create a Variable of type “Object” to collect the output of the HTTP action.
In the next step create an “Array” type variable to create the Attachment array to be send with email.
After creating Array variable, we need to assign the value which we get from HTTP call.
For attachment name let’s use the formula as following –
For PDF content let’s get the value from ‘’PDFOutput’ variable, like following –
After creating the array variable, we need to pass the array variable for Send email action.
Let’s pass the Attachment array variable in the ‘Send an email (V2)’ action like following.
The complete flow will look like following –
After creating a new item in the list ‘Temp’, our flow will get triggered and you will get the generated PDF attached in your inbox like following –
Converted PDF in email attachment will look like following –
If we explore the value of HTTP action and check the value of ‘PDFOutput’ variable, you will found the value like following where $content gives you PDF content in Base64 format.
You can use this approach in many application , for example insurance kind of application where details get filled from a Power app and gets stored in the SharePoint list, so as proof of the proposal the selected options get converted into PDF and stored in the SharePoint list as well as sent as an email.
Some more scenarios can be addressed similar ways.
You can add HEADER and FOOTER to PDF as well while calling the convert API, you can explore more options at PDFShift documentation at https://docs.pdfshift.io/
Some important points to consider –
- HTTP Request action is a premium action and require premium licensing.
- PDFShift service is also paid service, you can visit their site for more details.
I have attached the exported flow Download and rename it to .zip
In upcoming blog, I will explain the real world monitoring sacnorao using the PDFShift and Power Automate to monitor the usage of the API.