Power Apps / Automate – Create a PDF file from an HTML control
10 steps
Introduction:
This is the blueprint on how to create a PDF file, save it in a particular location, all from an HTML control in Power Apps. This requires Power Apps and Power Automate
Step 1:
From a blank Canvas Power App, create a blank flow and entitle it Create PDF file from HTML
Step 2:
In the PowerApps (V2) trigger. Add the following inputs:
Content
Step 3:
Add the action below:
Create file
Folder Path /
File Name example.html
File Content
Step 4:
Add the action below:
Convert file using path
File Path
Target Type PDF
Step 5:
Add the action below:
Create file 2
Folder Path /
File Name example.pdf
File Path
Step 6:
Go to settings of Create file 2. Turn Allow Chunking to Off so that the file will overwrite existing ones.
Step 7:
Add the action below:
Create share link
File
Link Type View
Link Scope Organization
Step 8:
Add the action below:
Respond to a PowerApp or flow
Add the following output:
link =
Checking:
Save the flow and exit. You should return from the Power App studio.
The flow named Create PDF file from HTML should be in your Power Automate pane.
Step 9:
On the canvas of your Power app, insert an HTML text named HtmlText1. Change the following properties:
HtmlText property
"
<div style='border:solid black 1px; height:799px;text-align:center'>Page 1 of 3</div>
<div style='border:solid black 1px; height:799px;text-align:center'>Page 2 of 3</div>
<div style='border:solid black 1px; height:799px;text-align:center'>Page 3 of 3</div>
"
Step 10:
Insert a button named Button1. Change the following properties:
Text property
"Create PDF"
OnSelect property
Launch(CreatePDFfilefromHTML.Run(HtmlText1.HtmlText).link);
Conclusion:
To test on play mode, click the Create PDF button. After it loads, it will open a new tab that opens a PDF file saved in your OneDrive.
You can change the html of the HtmlText1 Control to your desired content. You can also change the location on where to save the PDF file, be it on OneDrive or SharePoint.
Note: If the new tab does not open, your browser might be blocking it. Click on Allow opening tabs on this site if prompted.
Did this article help? Let us know how we can improve. Send us a message by clicking the “Contact Us” button below.
Article last updated on Apr 10, 2024
Need expert guidance on Power Apps?