Author Details

avatar-teacher

Evolvous

We are a team of tech enthusiast and this section is where we love to share our experience and our knowledge. We try our best to help you understand technical topics by giving you live instances of how-to’s, guides, tips, FAQ’s and troubleshoots.

If you like it or have questions, do share your feedback in the comments section below.

Export PDF in PowerApps

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.

Required:

  • SharePoint
  • PowerApps
  • Power Automate
  • OneDrive

Solution:

  • SharePoint: Create a SharePoint list.
  • PowerApps: Take a gallery control and set the data source as SharePoint list (or else take as per your requirement). Also Place an icon to download the pdf from PowerApps.

Solution for SharePoint and powerapps - Evolvous

Now apply the below code to icon “OnSelect” property.

“OnSelect” property - Evolvous

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

Power Automate

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.

PowerApps: It is PowerApps trigger which triggered from PowerApps - Evolvous

Action 3: Parse Json: Take the output from compose action and pass to this action.

Parse Json - Evolvous

Action 4: Create HTML Table: Create this action by using the body of Parse Json and its values.

Create HTML Table - Evolvous

Action 5: HTML (Which is Compose action and renamed as HTML): Pass the below code to this action.

HTML (Which is Compose action and renamed as HTML) - Evolvous


 

RFI Reports

@{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.

Create HTML File (Create file action of OneDrive) - Evolvous

Action 7: Convert file using path (Preview): Take this action from OneDrive and pass the path of previous create file action.

Convert file using path Export PDF in PowerApps - Evolvous

Action 8: Create Pdf File: Take this action From OneDrive pass the content from “Convert file using path”

Create PDF File. Export PDF in PowerApps - Evolvous

Action 9: Create Share Link: Crate this action from OneDrive and pass the ID from “Create PDF file” action.

Create Share Link Export PDF in PowerApps - Evolvous

Action 10: Delete HTML file(Delete file from OneDrive. Renamed here): Pass the “Id” form “Create html file” action.

Delete HTML File Export PDF in PowerApps - Evolvous

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

Respond to a PowerApps or flow - Evolvous

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.

Conclusion Export PDF in PowerApps - Evolvous