Tutorials/Power Apps/From Screen to PDF: Generate, Preview, and Download Documents with Power Apps
Power Appsintermediate

From Screen to PDF: Generate, Preview, and Download Documents with Power Apps

Learn how to use the PDF function to capture any control or screen as a PDF, view it, and save a copy locally—all with a standard Power Apps license.

NA
Narmer Abader
@narmer · Published June 3, 2026

Generating a PDF directly from a canvas app used to mean third‑party services or complex workarounds. With the native PDF function, you can capture any control or screen as a PDF file without leaving Power Apps—and it works with a standard license. In this guide you’ll build an invoice viewer that creates a PDF, lets you preview it, and then downloads a copy to your device.

Let’s walk through the entire flow: setting up a SharePoint list, building the app UI, generating the PDF, viewing it in a dedicated screen, and finally saving it using Power Automate.

Scenario Overview

Consider a small consulting firm that needs to turn service invoices into PDFs. Their app displays invoice details in a read‑only form, and the user should be able to:

  • Generate a PDF of the current invoice
  • Preview the PDF inside the app
  • Download the PDF to their device

We’ll create a canvas app that does exactly that. The data lives in a SharePoint list named Invoices.

Setting Up the Data Source

Create a new SharePoint list with these columns:

Column NameType
InvoiceNumberNumber
ClientNameSingle line of text
IssueDateDate only
ServiceDescMultiple lines of text (plain)
TotalAmountCurrency (US Dollar)
CompanyLogoImage (full size)

Add one sample row that we’ll display in the app:

  • InvoiceNumber: 1001
  • ClientName: Contoso Consulting
  • IssueDate: 5/12/2026
  • ServiceDesc: Q2 strategic planning sessions and market analysis
  • TotalAmount: 4500.00
  • CompanyLogo: Upload a company logo image

Now create a new blank canvas app in tablet layout, and connect it to this list via the Data pane.

Building the Invoice Form

We cannot generate a PDF directly from an Edit Form, so we place the form inside a container and generate the PDF from that container.

Step 1: Insert a Vertical Container

Add a Vertical container to the screen, then set its key properties in the formula bar:

powerfxContainer size and alignment
con_InvoiceContainer.X = 0
con_InvoiceContainer.Y = 0
con_InvoiceContainer.Width = App.Width
con_InvoiceContainer.Height = App.Height
con_InvoiceContainer.LayoutAlignItems = LayoutAlignItems.Stretch

Step 2: Add a Title Label

Inside the container, place a label for the header. Set its Text to "Invoice Summary", its Fill to a dark blue, and the font color to white.

Step 3: Insert an Edit Form

Inside the same container, add an Edit form control (from the Insert menu). Set its DataSource to the Invoices list. In the properties pane, choose a vertical layout with 1 column, and add the fields you want: ClientName, IssueDate, ServiceDesc, TotalAmount, and CompanyLogo.

Use this expression in the Item property of the form to load the first record:

powerfxForm data source
LookUp('Invoices', InvoiceNumber=1001)

Switch the form to read‑only mode so users cannot accidentally edit the data. Set its DisplayMode to DisplayMode.View.

At this point your screen should resemble a typical invoice viewer.

Generating the PDF

The PDF function works with any control or screen. We’ll capture the container con_InvoiceContainer.

First, ensure the PDF feature is enabled: go to Settings (File menu) > Upcoming features > PDF function and toggle it on if it’s not already.

Next, add a PDF icon (from the Icons menu) to the title bar. In its OnSelect property, write:

powerfxGenerate PDF and navigate
Set(
  varInvoicePDF,
  PDF(
      con_InvoiceContainer,
      {ExpandContainers: true}
  )
);
Navigate('InvoicePreviewScreen')

The ExpandContainers argument tells the PDF function to fully render any containers that might contain hidden or off‑screen controls. This prevents a blank or truncated PDF.

Previewing the PDF

Create a new screen named InvoicePreviewScreen. Add a dark‑blue title bar with the text “Invoice PDF” and a left‑arrow icon in the top‑left corner.

In the OnSelect of the arrow, clear the variable and go back:

powerfxBack to the form screen
Set(varInvoicePDF, Blank());
Navigate('Invoice Screen')

Now insert a PDF viewer control (under Media) and size it to fill the rest of the screen. Set its Document property to varInvoicePDF.

Run the app. Tap the PDF icon, and you should see the PDF appear in the viewer.

Saving a Copy to the Device

To let users download the PDF, we need a temporary storage location and a small Power Automate flow that returns a download link.

Step 1: SharePoint Document Library

Create a new document library named Exported Invoices. No extra columns are needed.

Step 2: Power Automate Flow

Open Power Automate and create an instant flow that triggers from Power Apps. Call it SaveInvoicePDF.

  1. Trigger: Use the PowerApps button trigger.
  2. Add an input called file of type object (make it required). This object will have name (string) and contentBytes (binary data).
  3. Action: Create file (SharePoint). Choose your site and the Exported Invoices library. Set the File Name to:
powerfxFile name expression
triggerBody()['file']['name']

Set the File Content to:

powerfxFile content expression
triggerBody()['file']['contentBytes']
  1. Action: Respond to PowerApps (or “Return to Power Apps”). Add an output named path of type string, and set its value to a download URL that bypasses the SharePoint document viewer. Use this pattern (replace <tenant>, <site>, and <library> with your actual values):
htmlDownload URL pattern
https://<tenant>.sharepoint.com/sites/<site>/_layouts/15/download.aspx?SourceUrl=/sites/<site>/<library>/@{outputs('Compose_FileName')}

(You can build the file name inside the flow with a Compose action that concatenates the file name from the trigger.)

Test the flow and ensure it returns the correct path.

Step 3: Wire Up the Download in the App

Back in Power Apps, add the SaveInvoicePDF flow to the app via the Data pane.

On the InvoicePreviewScreen, insert a save icon (or button) and set its OnSelect to:

powerfxDownload PDF
Download(
  SaveInvoicePDF.Run(
      {
          name: "Invoice_" & Text(Now(), "yyyymmddhhmmss") & ".pdf",
          contentBytes: varInvoicePDF
      }
  ).path
)

The Download function takes a URL and forces the browser to download the file. The flow returns the path of the file we created in SharePoint, now prefixed with the download.aspx URL.

Run the app again, preview the PDF, and tap the save icon. Your device should download the PDF.

Performance and Security Considerations

  • The PDF function renders the control client‑side. Very large containers with many controls (especially images) can impact memory and speed. Use ExpandContainers: true to catch any content that might be collapsed.
  • Because PDF rendering is local, no data leaves your app session—the generated PDF exists only in the app until you export it via the flow.
  • For the flow, ensure the service account or the user running the flow has write permissions to the document library.
  • If you plan to share the PDF link externally, consider using a SharePoint permission‑controlled library.

Common Mistakes and Troubleshooting

ProblemLikely causeFix
PDF is blankContainer does not include all controls, or ExpandContainers is missing.Verify the container wraps every control. Add {ExpandContainers: true}.
PDF viewer shows nothingVariable varInvoicePDF is blank or not in scope.Make sure the variable is set before navigating to the preview screen.
Form appears editableDisplayMode of the form is not View.Set DisplayMode = DisplayMode.View.
Download fails or no file savedFlow input is incorrect or permissions are missing.Check flow run history. Ensure the SharePoint library exists and the user has write access.
Download URL not workingThe download.aspx URL is malformed.Test the URL manually in a browser to see if it triggers a download.

Final Recommendation

The native PDF function is a game‑changer for simple document generation inside Power Apps. It is fast, license‑friendly, and fully integrated. Combine it with a flow for persistent storage, and you have a self‑contained solution for generating and delivering PDFs from your app.

For advanced scenarios (e.g., multi‑page PDFs or complex layouts), look into using HTML templates with the JSON function, but for most single‑page forms the PDF function is your best bet.

References