CRM Crate

In this blog post, you will learn how to generate PDF documents using the Power FX function in your Canvas App. Before we begin, be sure to subscribe to CRM Crate to stay updated in the field of Power Platform.

Generating PDF Documents using contents from screen in Canvas App

Power FX is a low-code language used within Microsoft Power Apps, including Canvas Apps, to define logic and expressions. It’s designed to be intuitive and easy to understand, resembling Excel formulas in many ways. Power FX allows users to create dynamic formulas to control app behavior, manipulate data, and automate processes.

Using PDF function for generating PDF in Canvas App

The PDF function lets you choose either a whole screen or specific parts of a screen to be exported into a PDF file in the form blob. The generation of PDFs occurs directly on the device where the app is being used. Keep in mind that the capabilities for generating PDFs may vary depending on the device being used, whether it’s a desktop computer or a mobile device.
Creating a PDF with a very large file size may cause the app to crash, depending on the device’s capabilities. It’s important to consider factors like the size and quantity of images, as well as the amount of data you’re including in the PDF, especially for apps designed for mobile devices.

PDF (Screen or control name [,{Size, DPI, Margin, Orientation, ExpandContainers}])

1. Control name –  It is a required parameter and should contain the screen or control containing the content to use to generate the PDF. The given are the supported list of controls available in PWF generation feature: Vertical Gallery, Vertical Layout Container, Horizontal Layout Container, Container, Screen.
2. Size (Page Size) – It is an optional feature and should contain the dimensions of the generated PDF.
3. DPI – It is an optional feature and should contain the scaling/resolution of the generated PDF. ]
4. Margin – It is an optional parameter and should contain a string specifying the size of the space reserved between the content and the outer edge of the generated PDF.
5. Orientation – It is an optional parameter and should contain an information statis whether the generated PDF has a portrait (vertical) or landscape (horizontal) orientation. The default value is portrait (vertical).
6. ExpandContainers – It is an optional parameter and should contain a Boolean information stating whether certain containers with contents that exceed their allocated size expand to display all content in the generated PDF. Impacted controls include screens, containers, vertical and horizontal containers, vertical fixed-height galleries (not nested), forms, and scrollable canvas controls.

Below are some use-cases of PDF Power FX function in Canvas App.

PDF(Screen1)Creates a PDF object using the default settings.A PDF object is generated based on the visible content of Screen1.
PDF(Container1, {Size: A4})Creates a PDF object with the paper size configured to A4.A PDF object of A4 size is generated from the visible contents within Container1.
PDF(Screen1, {DPI: 74, Margin: “25mm”, Orientation: “Landscape”})Creates a PDF object with a resolution (DPI) of 74, a margin of 25 millimeters, and a landscape (Horizontal) orientation.A PDF with the specified DPI, margin, and orientation is created in the default size (dependent on locale) from the visible content on Screen1.
PDF(Screen1, {ExpandContainers: true})Creates a PDF object with relevant controls expanded.A PDF is generated where any containers/galleries containing more content than what is currently visible are expanded to display all content within the resulting PDF.

The below example demonstrates the usage of PDF function for generating PDF document.

Generating PDF Documents using contents from screen in Canvas App

What are the limitations of PDF function?

The PDF Power FX function offers valuable features but also has its constraints. Here are the limitations of the PDF function.

  1. For certain fonts, non-Latin script types and font variations like bold and italic might not be visible in the generated PDF.
  2. Some controls are not currently compatible. These include charts, Power BI tiles, maps, and certain configurations of third-party PCF controls.
  3. Support for nested galleries is not available.
  4. The creation of PDFs with fillable forms is not supported.

5 1 vote
Article Rating
Notify of
Inline Feedbacks
View all comments
error: CRM Crate Security Engine - Disabled Right Click & Selection!


Well Done,
Welcome to CRM Crate

Stay tuned with us and get all latest updates and learning in Microsoft CRM and related techonologes.