In this blog, you will learn how to download a PDF file from Power Apps data using Power Automate flows and the OneDrive connector. We will cover generating the HTML, passing parameters from PowerApps to flow, generating the PDF file using the standard OneDrive connector and download locally. This guide will help you understand how to Export PDF in PowerApps quickly and efficiently.
Required:
Solution:
Now apply the below code to icon “OnSelect” property.
Clear(ColExportData);
Notify("Exporting PDF..",NotificationType.Information);
ForAll(GalRFI.AllItems,
Collect(ColExportData,
{Number: ThisRecord.Number,
Subject:ThisRecord.Subject,
Status:ThisRecord.Status.Value,
Assignees:Left(Concat(ThisRecord.Assignees,DisplayName & ","),Len(Concat(ThisRecord.Assignees,DisplayName & ",")) -1),
RFIManager:ThisRecord.'RFI Manager'.DisplayName,
ResponsibleContarctor:ThisRecord.'Responsible Contractor'.DisplayName,
ReceivedFrom:ThisRecord.'Received From'.DisplayName,
DateInitiated:Text(ThisRecord.Created,"yyyy-mm-dd"),
DueDate:ThisRecord.'Due Date',
ClosedDate:ThisRecord.'Closed Date'
}
)
);
Set(PdfLink,'SBEnergy-RFI-ExportPDF'.Run(JSON(ColExportData,JSONFormat.IncludeBinaryData)).varlink);
Launch(PdfLink);
Power Automate: Created a flow “SBEnergy-RFI-ExportPDF” using below actions
Action 1: PowerApps: It is PowerApps trigger which triggered from PowerApps.
Action 2: Json Data (Compose action in flow. Renamed as Json Data): Pass the JSON data from PowerApps.
Action 3: Parse Json: Take the output from compose action and pass to this action.
Action 4: Create HTML Table: Create this action by using the body of Parse Json and its values.
Action 5: HTML (Which is Compose action and renamed as HTML): Pass the below code to this action.
@{body(‘Create_HTML_table’)}
Action 6: Create HTML File (Create file action of OneDrive): Create a file using OneDrive connector by passing the output from previous compose action.
Action 7: Convert file using path (Preview): Take this action from OneDrive and pass the path of previous create file action.
Action 8: Create Pdf File: Take this action From OneDrive pass the content from “Convert file using path”
Action 9: Create Share Link: Crate this action from OneDrive and pass the ID from “Create PDF file” action.
Action 10: Delete HTML file(Delete file from OneDrive. Renamed here): Pass the “Id” form “Create html file” action.
Action 11: Respond to a PowerApps or flow: pass the “Web URL” from “Create Share Link” action. And append “?Download=1” and pass that value to “VarLink”
You can download the pdf file from PowerApps by using below two lines of code
Set(PdfLink,'SBEnergy-RFI-ExportPDF'.Run(JSON(ColExportData,JSONFormat.IncludeBinaryData)).varlink);
Launch(PdfLink);
Conclusion:
Finally, you will see below pdf format once click on icon in PowerApps.
======
Plus read