Power Platform - Canvas Apps - guide to printing (part 1)


Introduction

I decided to write this post because so far it is not possible to natively print out of Canvas App. However, before you continue to read you should know this idea has been around Microsoft's top requests from customers for a while and Microsoft has announced this feature is on the roadmap, however, it hasn't shared details about it release date. In the meantime you can consider the options I'll outlay here. 


Background

There are several scenarios where you may need to print something out of your Canvas App. For example, you may have a table, or a gallery. Most of the times, you will want to print only a portion of your screen. 

As said, printing is not supported in Canvas App, nonetheless, there are workarounds you may consider before "coding null for an answer". 

Additionally, you also need to have in mind that not every scenario will have the same solution. In the following I'll outline the scenarios I've stumble with and how I have approach them successfully.

One more very important thing to consider is the difference between printing in the PowerApps app, and printing through the web browser. If running the app in the web browser is an acceptable solution then you can use the print functionality, like if were any other webpage, however, you should consider to create screens that are exactly how your print will look like, and also solve the pagination Issue. 

An example to this you can find in the following PCF component: https://pcf.gallery/print-it/

If you are running your app from the PowerApps app then you are even in worst scenario since there is no way to open a Print dialog until the feature is added. See https://docs.microsoft.com/en-us/power-platform-release-plan/2020wave1/microsoft-powerapps/enabling-printable-pages-canvas-apps  

For details about the current state of the product feature details to be announced have a look here https://powerusers.microsoft.com/t5/Power-Apps-Ideas/Printing/idi-p/846


The layout

Normally you shouldn't be worry about the layout, is simple what you are looking on the screen. But considering that your are printing a screen on an app, the layout is not always "user-friendly". 

To define the layout I've seen people creating PDF files using Power Automate / fair enough although cumbersome as you need to involve Power Automate and/or Onedrive. https://youtu.be/IhE0-HumNNo

Other people have created a PCF component to display a new screen along with the print dialog / Open a new screen only works on web browser as javascript window.open() is needed.  

Once you have your layout you can narrow down the options available. If building a PDF using Power Automate, and the PDF will travel to your mailbox so you can print it as any other PDF file is acceptable for your use case, then is your way to go. Or if you can execute your canvas app from the web browser and opening a new Print dialog window is acceptable for your use case, then is also an option you could take.


No layout printing 

Other scenarios I have seen are related to more industrial ones, like printing ZPL labels. This printing doesn't have a layout, as the layout is given by the printer capability to interpretate ZPL language (ZPL stands for Zebra printer language). In practical terms, you just need to solve the problem of sending a set of characters to the printer. 

I completely discourage trying to build the layout out of the ZPL language in your canvas app. Is not a good design decission as the value of the ZPL language is just like it, be a language that let the printer make that for you. 

For a no layout printing solution (also works for normal files) you can refer to my previous post here: 



In the part 2 of this post I'll show how to build a custom layout ready to print using PCF components. 
Finally, in part 3, I'll share the solution I built for printing barcodes that were generated by a canvasapp directly into the printer listed on the mobile phone (no Power Automate tricks :)) 




 




Comments

Popular posts from this blog

Telemetry and Monitory with Applications Insights and Dynamics 365 F&O

Creating a DMF data package from files stored in an Azure blob storage