Work With The PDF Function (Experimental) - Power Apps - Microsoft Learn
Work With The PDF Function (Experimental) - Power Apps - Microsoft Learn
(experimental)
Article • 04/11/2023
The PDF function in Power Apps generates a PDF document from the contents of a screen
or certain types of controls. You can pass the generated file to an action connector—for
example, to send it in an email using the Office 365 Outlook connector—or to a Power
Automate flow as part of an automation scenario.
) Important
1. Sign in to Power Apps and create a canvas app or open an existing app.
Play the app and select the button you added. The PDF file is generated and stored in
memory for future use. The following section suggests a few ways to work with the PDF file
in your app.
The PDF function can only target the screen that's currently visible. You can pass the entire
screen, as in our example, or enter more parameters to specify a container or gallery to
limit the content to pass.
Play the app and select the button you added. The PDF file is generated, stored in the
variable myPDF , and visible in the PDF viewer control.
The PDF viewer control appears as a black shape inside the generated PDF file. To exclude
the control from the generated file, place the content you want to turn into a PDF file
inside a container or gallery and target that instead of the screen; for
example, PDF(Container1) or PDF(Gallery1).
1. In your canvas app, select the button that you created in the previous example or add
a new button.
Office365Outlook.SendEmailV2(
"[email protected]",
"New Safety Inspection"
"A new safety inspection has been submitted for your review.
Please see attached.",
{
Attachments: Table(
{
Name: "submittedInspection.pdf",
ContentBytes: PDF(SubmitInspectionScreen)
}
)
}
);
3. Select Save and publish.
Play the app and select the button you added. The PDF file is generated, and an email is
sent to the specified email address with the generated PDF file attached.
6. Select the PowerApps V2 trigger to expand the node, and then select Add an input.
8. Select Add an input again, and then select Text as the type of user input.
9. Rename the input File Name and change the description to Please enter the name of
the file.
Add the SharePoint connector to the flow
1. Select New step to add an action. Search for SharePoint and select Create file.
2. In Site Address, select a SharePoint site that you have permission to add files to.
3. In Folder Path, select a document library that you have permission to add files to.
4. Select the File Name input. In the Dynamic content tab, select a file name under
PowerApps (V2).
5. Select the File Content input, and then select File Content in the list.
6. Select Save, and then select the x in the upper-right corner to close the Power
Automate window.
7. The Power Automate pane refreshes, and the new PowerApps (V2) flow, Create file,
appears in the list.
'PowerAppV2->Createfile'.Run(
"NewInspectionReport.pdf",
{
file: {
name: "NewInspectionReport.pdf",
contentBytes: PDF(InspectionDetails)
}
}
);
See also
PDF function in Power Apps (experimental)