Your Microsoft Technology Development and Consulting Experts - Operating since 2000

Location
Australia WideSydney, NSWMelbourne, VicBrisbane, QldPerth, WAAdelaide, SACanberra, ACTNorthern Rivers, NSWWollongong, NSWRichmond, VicDarwin, NT
emailconsult@officeexperts.com.au
Phone1300 102 810
Office experts logo
Contact Us

Power Apps PDF Function - The Best Way to Export to PDF?

Microsoft’s PDF function turns a Power Apps screen into a PDF file with a single formula. Here’s how to switch it on, save the result to SharePoint, tune the page layout and avoid the problems that catch most makers out.

By Marcello Brocchi

Updated · 11 min read

A Power Apps screen becoming a PDFAn app screen with a summary header, two tiles, a list of records and an Export PDF button. The PDF formula turns it into a finished A4 page with the same header, tiles and table, which can then be emailed, saved to SharePoint or downloaded.Your Power Apps screenContainer1Export PDFPDF( )PDFEmailSharePointDownload

1 formula

Screen to PDF

PDF(Screen1) is all it takes to make a first PDF.

5 settings

Page control

Size, DPI, Margin, Orientation and ExpandContainers.

Experimental

Status today

Off by default, and not meant for production use yet.

Introduction

Microsoft has added a new PDF generation capability to Power Apps, making it easier than ever to create PDF documents directly from your applications. While the feature is still labelled experimental, it’s available now and is a real improvement on the workarounds makers have relied on until now.

In this guide you’ll learn how to enable and use the PDF function, create PDFs from your screens or containers, and give users a smooth way to view and download what they generate. We’ve also added the settings, limits and mistakes we’ve run into, so you can decide whether it’s ready for your app.

Prefer to watch the video?

Head over to my YouTube channel Chino Does Stuff to watch the video tutorial. You’ll find a variety of videos there, with loads of tricks and tips on the entire Power Platform suite.

Why use the PDF function?

Getting a PDF out of a canvas app has usually meant building a second copy of the layout somewhere else, such as a Word template or an HTML page inside a flow, then converting it. That works, but it’s a lot of moving parts for what is often a one-page summary.

The PDF function takes a different route. You point it at a screen or container that already exists, and it hands back a file.

Your layout is the PDF

What users see in the app is what lands on the page, so there’s no second template to design and keep in step.

One formula, no conversion

You don’t need an HTML template or a document-conversion step just to make the file. A flow is only needed if you want to store it.

Fits the connectors you use

The result is a file you can pass to the Outlook connector or a Power Automate flow, like any other file.

Quick to try

Switch it on, point it at a screen or container, and you can have a first PDF in a few minutes.

How the PDF function works

The PDF function is straightforward. It converts a screen or control into a PDF document and returns the file, which you can keep in a variable or hand to another action. Microsoft’s documentation describes the output as held in memory.

The basic syntax is:

Syntax
PDF( ScreenOrControl [, { Size, DPI, Margin, Orientation, ExpandContainers } ] )

The first argument is what to convert. It can be:

  • A screen
  • A container, including vertical and horizontal layout containers
  • A vertical gallery

The second argument is an optional record of settings, covered below. The function returns a file you can use to:

  • Preview the PDF in a PDF viewer control
  • Save the PDF to SharePoint or other storage with a flow
  • Email the PDF as an attachment
  • Open or download the PDF on the user’s device
What goes into the PDF function and where the result goesA screen, a container or a vertical gallery goes into the PDF function. Five optional settings control size, DPI, margin, orientation and whether containers expand. The result is a PDF file held in memory that you can attach to an Outlook email, pass to a Power Automate flow, preview in a PDF viewer or keep in a variable. Charts, maps and Power BI tiles are not supported.ScreenThe visible oneContainerAny containerGalleryVertical onlyNot supportedCharts, maps, Power BIPDF( )Runs on the deviceOptional settingsSizeDPIMarginOrientationExpandContainersResult: a PDF file held in memoryOutlook emailAs an attachmentPower AutomateSave to SharePointPDF viewerPreview in the appVariableReuse it later
What goes into PDF() and where the result can go.

What the PDF function can and can’t do

Knowing the edges early saves rework. These come from Microsoft’s current documentation for the experimental feature, so check it again if you’re reading this a while after we updated it.

Works well

  • Screens, containers and vertical galleries
  • Vertical and horizontal layout containers
  • Passing the file to an Outlook email or a flow
  • Using it in OnSelect, OnVisible, OnHidden or any other behaviour property
  • Tall content, when ExpandContainers is set to true

Watch out for

  • Only the screen that is currently showing can be exported
  • Charts, maps and Power BI tiles aren’t supported
  • Nested galleries aren’t supported
  • Fillable PDFs aren’t supported
  • Non-Latin text and bold or italic styles may not render correctly with some fonts
  • The PDF is generated on the user’s device, so very large files or many large images can crash the app, mostly on mobile

Which route should your PDF take?

Making the PDF is only half the job. What happens to it next decides what you need to build around it. Answer two questions before you start.

Which route should your PDF take?Start with the question of whether anyone needs a stored copy. If yes, save the PDF to SharePoint with a flow and open it with Launch, which is the recommended route. If no, ask whether it needs to reach someone else. If yes, email it as an attachment through the Outlook connector. If no, preview it in a PDF viewer control.You need a PDFDoes anyone needa stored copy?YesSave it to SharePoint with a flowThen Launch the file’s URL so the user can open or download it.Our recommended route for anything you need to keep.NoDoes it need to reachsomeone else?YesEmail itAttach it with theOutlook connectorNoPreview it firstShow it in a PDFviewer controlFirst, switch it onThe PDF function is off by defaultin Upcoming features.
Decision flow: pick the route before you build.

For most apps we start with the SharePoint route, because the PDF is still there after the app closes and anyone with access can open it again. That’s the route we build below.

Creating a PDF export button

Let’s build a solution that creates a PDF and lets users view and download it. We’ll use a flow to save the PDF to SharePoint and then open it in a new browser tab.

  1. Enabling the experimental PDF function

    Because the PDF function is still experimental, you’ll need to switch it on in the app you’re editing:

    1. Open your Power App in the maker portal.
    2. Select Settings (the gear icon).
    3. Select “Upcoming features”.
    4. Go to the “Experimental” tab.
    5. Find the PDF function and toggle it to “On”.
    6. Save your changes.

    Once it’s on, the PDF function and the PDF viewer control are available in your app.

    Pro tip: Turn it on in each app that will use the function. If the formula isn’t recognised, check the setting first.

  2. Adding the button

    Add a button to the screen you want to export and give it an icon that suggests a PDF. The function can only export the screen that’s currently showing, so the button needs to live on that screen.

    Pro tip: Disable the button, or show a spinner, while the PDF is being generated so nobody taps it twice.

  3. Connecting to SharePoint for PDF storage

    The formula in the next step calls a flow named SaveFileToSharePoint. It’s a standard Power Automate flow that saves a file to a SharePoint document library. If you don’t already have one, you’ll need to create it.

    For detailed instructions on building a file upload flow, see our guide to file attachments in Power Apps, which walks through the same kind of flow step by step.

    The flow should:

    • Accept an ID parameter and a file object with contentBytes and name properties
    • Use the “Create file” action to save the file to a SharePoint document library
    • Return the URL of the saved file (optional)

    Pro tip: If you can, have the flow return the saved file’s URL and launch that, so you never have to build the link by hand.

  4. Writing the OnSelect formula

    Add this to the button’s OnSelect property:

    OnSelect
    // 1. Build the file name once, so the saved file and the opened link always match
    Set(
        varFileName,
        "PDF_" & Text(Now(), "yyyymmdd_hhmmss") & "_export.pdf"
    );
    
    // 2. Turn the current screen into a PDF
    Set(
        varPDF,
        PDF(ViewIssue) // the screen to convert
    );
    
    // 3. Save the PDF to SharePoint with the SaveFileToSharePoint flow
    SaveFileToSharePoint.Run(
        varFileName,
        {
            file: {
                contentBytes: varPDF,
                name: varFileName
            }
        }
    );
    
    // 4. Open the saved PDF in a new browser tab
    Launch(
        "https://yoursharepoint.com/sites/yoursite/Shared%20Documents/" & varFileName
    );

    This formula does four things:

    • Builds the file name once, so it can be reused
    • Creates a PDF from the current screen and stores it in a variable
    • Uses the flow to save the PDF to SharePoint
    • Opens the saved PDF in a new browser tab with the Launch function

    Pro tip: Swap in your own library address. Spaces in the path need to be encoded, such as %20 for a space in “Shared Documents”.

  5. Testing with real content

    Run it with your longest real record and open the PDF from a normal user account, not just your own. Check the page breaks, the fonts and that the file opens from the link.

    Pro tip: Try it on a phone as well as a laptop. The PDF is made on the device running the app, so results can differ.

Prefer to email the PDF?

If nobody needs a stored copy, skip SharePoint. The PDF can go straight into an email as an attachment through the Office 365 Outlook connector:

Email instead
// Email the PDF as an attachment, no SharePoint needed
Office365Outlook.SendEmailV2(
    "someone@example.com",
    "Your inspection report",
    "Your report is attached.",
    {
        Attachments: Table(
            {
                Name: "Inspection report.pdf",
                ContentBytes: varPDF
            }
        )
    }
);

Customising your PDFs

The PDF function also accepts an optional record that changes the page. Here are two examples:

PDF settings
// A whole screen, with page settings
PDF(
    Screen1,
    {
        Size: "A4",
        DPI: 150,
        Margin: "20mm",
        Orientation: "Portrait"
    }
)

// One container only, landscape, with long content expanded
PDF(
    Container1,
    {
        Size: "A3",
        Orientation: "Landscape",
        ExpandContainers: true
    }
)

You can choose to convert only a specific container instead of an entire screen, which gives you more control over what appears in the PDF. These are the settings available:

SettingWhat it doesDefault
SizeThe page size, for example “A4”, “A3” or “Letter”.Letter in the US and Canada, A4 elsewhere
DPIThe resolution. It must be greater than 0, and content that doesn’t fit inside the margins may end up at a higher effective DPI.96
MarginThe page margin, written with a unit such as in, cm, mm, pt or px.0.5 inch (12.7 mm) on every side
Orientation“Portrait” or “Landscape”.Portrait
ExpandContainersWhen true, expands screens, containers and scrollable controls so all of their content shows. Nested galleries still aren’t supported.false

Setting names and defaults are taken from Microsoft’s documentation at the time of writing. The feature is experimental, so confirm them against the current documentation.

In Australia, set Size to “A4” yourself if you want to be sure, rather than relying on the default. A higher DPI than the default can mean bigger files and more strain on the device, so raise it only when you’ve tested the result.

Using the PDF viewer control

If you want to show a preview of the PDF before saving or downloading it, you can use the PDF viewer control. Add it to your screen and set its Document property to the variable that holds the PDF:

Document property
// PDF viewer control, Document property
varPDF

Tips for better PDF generation

To get the best results from the PDF function, design the page before you write the formula. A screen built for PDF output looks quite different from one built for tapping.

Anatomy of a screen designed for PDF outputAn A4 portrait page with a header container, two summary tiles, a vertical gallery of records and a totals strip, all inside a dashed margin line. Five numbered notes explain the header, the summary tiles, the single vertical gallery, using text instead of charts, and the page margins.1Header containerLogo, title and datestay together.3One vertical galleryNested galleries arenot supported.5Mind the marginsDefault is 0.5 in a side.Change it with Margin.2Summary tilesFixed size, so nothingis cut off.4Text, not chartsCharts and maps arenot supported.12345
A screen designed to become one A4 page.

Design PDF-specific layouts

Build the report area for paper, not for tapping.

  1. Choose a dedicated container, or a dedicated screen you navigate to before calling PDF().
  2. Take out buttons, menus and input controls from that area.
  3. Size it for A4 portrait or landscape so it isn’t squashed to fit.

Plan for long content

Real records are longer than the sample you built with.

  1. Use a single vertical gallery for the rows.
  2. Set ExpandContainers to true so every row shows.
  3. Test with the longest record you have, not the tidiest.

Show that something’s happening

PDF generation can take a few seconds.

  1. Set a variable such as varBusy to true before you call PDF().
  2. Show a spinner or message while it’s true.
  3. Set it back to false once the file is saved or opened.

Test on real devices

Output can vary with the device running the app.

  1. Try a phone or tablet as well as a laptop.
  2. Use compressed images and keep the layout lean.
  3. Check fonts, especially non-Latin text, bold and italic.

Use cases for PDF generation

The PDF function opens up many possibilities for Power Apps:

  • Reports and documentation

    Create professional reports that users can download and share, straight from the data they’re looking at.

  • Certificates and confirmations

    Generate certificates of completion or booking confirmations the moment someone finishes a task.

  • Forms and agreements

    Turn a completed form into a PDF record for the file. It’s a static copy, not a fillable form.

  • Invoices and receipts

    Produce clean invoices and receipts that can be downloaded or emailed to the customer.

  • Work orders and instructions

    Give field teams a printable work order or set of instructions with the job details already filled in.

Common mistakes to avoid

These are the slips we see most often when a first PDF export goes from a demo to real use.

Exporting the live working screen

Menus, buttons and inputs end up on the page, and the layout is built for a phone or a mouse, not paper.

InsteadBuild a dedicated report container or screen sized for A4.

Putting charts, maps or Power BI tiles on the page

Microsoft lists these as unsupported, so they’re likely to be missing or wrong in the PDF.

InsteadShow the figures as labels or a gallery of rows instead.

Calling Now() twice for the file name

Each call returns a new time, so the saved file and the link you open can differ by a second or two.

InsteadStore the name in a variable once and reuse it.

Letting a fixed-height list cut rows off

Rows below the visible area are easy to lose, and nobody notices until a customer does.

InsteadUse one vertical gallery and set ExpandContainers to true.

Saving the PDF where users can’t open it

It works for you as the owner, then fails for everyone else with a permissions error.

InsteadSave to a library your audience can already read, and test with a normal user account.

Check before you share the app

  • The PDF function is switched on in the app
  • The button sits on the screen being exported
  • The export area has no charts, maps or Power BI tiles
  • The longest realistic record still fits
  • Page size and orientation match how it will be printed
  • The file name is built once and reused
  • The flow saves to a library users can open
  • It has been tested on a phone or tablet as well as a laptop
  • A loading message shows while the PDF is generated
  • Someone knows the feature is experimental and has a fallback

When to get help

Need a hand with Power Apps PDFs?

A first PDF export is quick. A reliable one, with the right layout, a storage flow and the right permissions, takes a little more care. Our Power Platform team can build it with you or for you, and train your people to maintain it.

If you’d rather learn it yourself, Microsoft support and training covers Power Platform too, and business process automation is where we help when the PDF is one step in a longer workflow.

Frequently asked questions

Is the Power Apps PDF function ready for production?

Microsoft labels it experimental and says experimental features aren’t meant for production use. It’s switched off by default. It suits prototypes and internal tools you can test thoroughly, but for anything critical keep a fallback, such as a Power Automate document flow, in your plan.

Can the PDF function create fillable PDFs?

No. Microsoft lists fillable PDFs as not supported. The function produces a static PDF of what’s on the screen, so use it for records, reports and confirmations rather than forms people complete in a PDF reader.

Why is my chart or map missing from the PDF?

Charts, maps and Power BI tiles aren’t supported by the function. Show the same figures as labels or a gallery of rows, and keep any visual-only content out of the area you export.

Why did my app slow down or crash while making a PDF?

The PDF is generated on the device running the app, so large files, or many or large images, can cause problems, particularly on phones. Compress images, keep the layout lean and test on a typical user device before you roll it out.

Can I email the PDF without saving it first?

Yes. The function returns a file you can pass straight to an action connector, such as the Office 365 Outlook connector, or to a Power Automate flow. You only need SharePoint when you want a stored copy.

Conclusion

The new PDF function in Power Apps is a welcome addition that makes it much easier to generate PDF documents directly from your apps. While it’s still experimental, it works well for the right jobs and gives you a cleaner, more integrated solution than the older workarounds.

By combining the PDF function with a SharePoint storage flow and the Launch function, you can give users a smooth way to create, view and download PDFs from your Power Apps.

As the feature moves out of experimental status, we can expect more capabilities and better integration with the rest of the Power Platform. In the meantime, this approach is a practical solution for PDF generation needs, as long as you plan for the limits above.

If you’d like to see more Power Apps tips and techniques, head over to the YouTube channel and leave a comment there. I actively monitor and respond to all YouTube comments!

About the author

Marcello Brocchi

Marcello is a lead developer at Office Experts Group, an Australian Microsoft consultancy established in 2000. He specialises in computer science and Power Platform integration, and is the founder of the YouTube channel ChinoDoesStuff. If you have any questions, please get in touch using the form below, or find him on LinkedIn.

Contact Us

Get in touch with our team for general enquiries and support. We're here to help with any questions you might have about our services.

Need to attach a file?

Need pricing for a specific project? Fill out our quote form and we'll provide you with a detailed estimate tailored to your needs.