April 24, 2024

SamTech 365

PowerPlatform, Power Apps, Power Automate, PVA, SharePoint, C#, .Net, SQL, Azure News, Tips ….etc

PowerApps Export to PDF (PDF Function)

One of the PowerApps functions which I personally think would take some of your apps to the next level is the PDF Function.

This function allows you to generate Pdf blob content directly from your apps’ screens. You can export entire screens, containers or galleries.

In todays’ article, I will give you a quick introduction of this function.

1- Build the demo app.

I have built this quick demo application, in which I have a two containers.

On the left side, the content I wanted to export as PDF.

The right side contains only a PDF viewer, to view what has been generated.

 

 

2- Turn on the PDF feature in your application

The PDF function has been sitting in the experimental section of power Apps features for a while now.

3- Generate your PDF document

Once you are done with your Screens design, you can call the PDF function, which takes couple of parameters.

By default, you can just pass the screen, container or gallery you want to export as pdf, without worrying too much about the

The function of the “Generate PDF” button is as simple as follow:

Set(MyPDFInvoice,PDF(Container2))

Which will set to the varialbe MyPDFInvoice, the PDF document.

In the PDF viewer control, we set the document to MyPDFInvoice.

4- Sending the PDF as an email attachment

If you want to include the generated pdf in an email as an attachment, you can simply use the Office365Outlook.SendEmailV2 function, Which is available from the Office365Outlook connector.

The button’s action is as follow:

Office365Outlook.SendEmailV2(
    User().Email,
    "Invoice #2023-0099",
    "Please find Attached the Invoice #2023-0099",
    {
        Attachments: Table(
            {
                Name: "invoice2023-0099.pdf",
                ContentBytes: MyPDFInvoice
            }
        )
    }
)

 

 

1