Introduction to the PDF function in Power Apps Microsoft Office 365 PDF Function feacture

Have you ever wanted to create a PDF from your Power Apps Screens? Now you can using a the new PDF function in Power Apps

Enabling the PDF Function

To enable this new experimental feature all you have to do is look for the PDF function feature in the Experimental tab and enable it.

Introduction to the PDF function in Power Apps Microsoft Office 365 PDF Function feacture

Using the PDF function

Now straight away you will be able to use the PDF function as shown below.

PDF Function used to generate PDF.Set(result, PDF(Screen1))

Now the result variable is set to the content of the file. In the screenshot below I’m displaying the content in the PDF Viewer control, but you can of course do a lot more with it. If you generate a PDF, you might as well store the file in SharePoint or send it as an attachment in an email.

Introduction to the PDF function in Power Apps Microsoft Office 365 image 5

The PDF function Options

So what are the options available?

Introduction to the PDF function in Power Apps Microsoft Office 365 image 6

The PDF function isn’t documented yet. So it isn’t easy to figure out what the options are.

The only place where I ‘ve seen these documented is on a community blog page by Hiro

Introduction to the PDF function in Power Apps Microsoft Office 365 image 9

Ok, so we have a few options.

Orientation – You can set this to Landscape or Portrait.

Size – you have many options. If you type “Papersize.” the intellisense in Power Apps will do the rest for you

Introduction to the PDF function in Power Apps Microsoft Office 365 image 10

Margin – With the Margin property you have some control over the margins of your page. You will have to give 4 values. Left, Top, Right and Bottom.

DPI – This setting makes it possible to control the quality ( and the size) of your PDF.

Then the final option is Expand Containers. This last option needs a bit of a further explanation and also a warning.

Imagine if you have a Gallery ( or any other container with a scroll bar) and only some of the content is visible. you can now expand that content to make it possible to see all of the content within your PDF. Just set the ExpandContainers property to true.

But… Like I already mentioned the expand property does come with a warning.

As shown below I managed to expand my gallery, however the content following the container doesn’t move with it. So if you want to generate PODFs form your Power Apps Pages, be careful not to add any additional content underneath the container.

Introduction to the PDF function in Power Apps Microsoft Office 365 image 7
Avatar for Pieter Veenstra

By Pieter Veenstra

Business Applications and Office Apps & Services Microsoft MVP working as a Microsoft Productivity Principal Consultant at HybrIT Services. You can contact me using contact@veenstra.me.uk.

2 thoughts on “Introduction to the PDF function in Power Apps”
  1. Hi Peter,
    Yes very nice but one item I still have not solved.
    I added a Portrait Printable screen (only to get the A4 sizing) and a HTML text box with a form including graphics on it – printed very nicely.
    I can then attach the PDF to an email (we are looking at invoices) with
    Office365Outlook.SendEmailV2(
    “MailAddress@Here”,
    “Subject here”,
    “Body here”,
    {
    Attachments: {
    Name: “FileNameHere”,
    ContentBytes: varInvoice
    }
    }
    );
    Works great – now I want to attach the PDF to the file. I know I can do it the “old” way by sending the HTML to OneDrive and PDFing it there, but when I send the Variable as the file content to a Flow, I get no errors and the PDF attaches, but the file format is invalid and will not open. I have also tried JSON to Base64 (the output looks like Base64), but the Flow fails on conversion base64ToBinary.

  2. Hi Peter,
    Error on my part – works perfectly with JSON if the header and leading/trailing quotes are stripped. So you can both attach to emails and also create files or attachments with it.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.