0% found this document useful (0 votes)
81 views

Work With The PDF Function (Experimental) - Power Apps - Microsoft Learn

The PDF function in Power Apps (experimental) allows you to generate a PDF document from the contents of a screen or controls. You can then use the generated PDF file in various ways like viewing it using a PDF viewer, emailing it as an attachment, or storing it in a document library by passing it to a Power Automate flow. The PDF function is disabled by default and must be enabled in the app settings under upcoming features.

Uploaded by

vbharghavreddy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views

Work With The PDF Function (Experimental) - Power Apps - Microsoft Learn

The PDF function in Power Apps (experimental) allows you to generate a PDF document from the contents of a screen or controls. You can then use the generated PDF file in various ways like viewing it using a PDF viewer, emailing it as an attachment, or storing it in a document library by passing it to a Power Automate flow. The PDF function is disabled by default and must be enabled in the app settings under upcoming features.

Uploaded by

vbharghavreddy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Work with the PDF function

(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

This is an experimental feature. Experimental features aren't meant for


production use and may have restricted functionality. These features are
available before an official release so that customers can get early access and
provide feedback. Understand experimental, preview, and retired features in
canvas apps.
You must turn on the PDF function in Settings > Upcoming features >
Experimental. As an experimental feature, it's disabled by default.
Send your feedback in the Power Apps experimental features community
forum .

Turn on the PDF function


Since the PDF function is an experimental feature, it's turned off by default. To use it in your
apps, you need to turn it on manually.

1. Sign in to Power Apps and create a canvas app or open an existing app.

2. In Power Apps Studio, on the command bar, select Settings.


3. Select Upcoming features.

4. On the Experimental tab, turn on PDF function.

Use the PDF function to generate a PDF file


In the following example, we use the PDF function in the OnSelect property of a button to
generate a PDF file. You can also use the PDF function in OnVisible , OnHidden , or any

other behavior property.

1. Select an existing button or add a new button to your canvas app.


2. In the button's OnSelect property, add the PDF function and enter the target of the
function as a parameter. Enter the formula: PDF(SubmitInspectionScreen);

In this example, we're targeting the screen SubmitInspectionScreen to generate a


PDF file from the contents of our sample app's Inspection screen. Replace it with the
name of a screen in your app.

3. Select Save and publish.

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.

Work with the generated PDF file


You can use the generated PDF file in many ways. Here are a few, using the example in the
previous section.
View the file with the PDF viewer control
1. In your canvas app, select the button that you created in the previous example or add
a new button.
2. In the button's property, enter the following formula, replacing
OnSelect

SubmitInspectionScreen with the name of a screen in your app: Set(myPDF,


PDF(SubmitInspectionScreen));

3. Select Insert > PDF viewer (experimental).


4. From the properties list, select the Document property and then enter myPDF in the
formula bar.
5. Select Save and publish.

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).

Use an action connector


In this example, we generate a PDF file that we send as an email attachment using the
Office 365 Outlook connector.

1. In your canvas app, select the button that you created in the previous example or add
a new button.

2. In the button's OnSelect property, enter the following formula:

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.

Use in a Power Automate flow


In this example, we generate a PDF file and pass it to a Power Automate flow that stores
the file in a document library using the SharePoint connector. This example replaces the
default PowerApps trigger in Power Automate with the PowerApps (V2) trigger.

Create a flow to use in your app


1. In your canvas app, select the button that you created in the previous example or add
a new button.
2. In the app authoring menu, select Power Automate > Create new flow.

3. Select Create from blank.


4. To delete the default PowerApps trigger, select the trigger menu (…), and then select
Delete.
5. Search for and select PowerApps (V2).

6. Select the PowerApps V2 trigger to expand the node, and then select Add an input.

7. Select File as the type of user 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.

Add the flow to a button in your app


1. Select the button in your app canvas. In the button's OnSelect property, enter the
following formula, replacing the flow name and generated PDF file name with your
own:

'PowerAppV2->Createfile'.Run(
"NewInspectionReport.pdf",
{
file: {
name: "NewInspectionReport.pdf",
contentBytes: PDF(InspectionDetails)
}
}
);

2. Select Save and publish.


Play the app and select the button you added. The Power Automate flow runs and adds the
generated PDF file into the document library.

See also
PDF function in Power Apps (experimental)

You might also like