Microsoft has released a brand new function in Power Apps, called Print(). This is a very welcome addition to the list of possibilities with Power Apps, and has been a frequent request from customers. It is really a print screen functionality, since there is no scrolling.
The function is very simple:
Just as with any action in Power Apps, you can use this function with a button, an icon, a label, whatever you’d like to click in order to print. Here is a very simple example. I have added an icon of a printer here at the top right corner of this screen:
What happens next? When I publish or preview the app, and click the print button, this is what I see:
A couple of things about this screen. I am using the Chrome browser, so this print preview screen may look slightly different per various browsers and operating systems. None of the settings on this screen can be controlled from the Power App, these are on the user’s desktop computer.
Destination: This is the default printer on my computer.
(Mine is actually a LaserJet printer, but I switched it over to “Save as PDF”, which is built into Windows, for this demo. End users can use this method to quickly save the form as a PDF!)
Pages: It will always just have one page. Even if you make your Power App screen very tall, it will not scroll to another print page.
Layout: This will default to the last setting that you used. Mine had a default of Portrait, but I changed it to Landscape for this screenshot, since it looks nicer.
Notice that in this printout, although the fill color does not render, the “Submit” button and the arrow at the top left are showing. With this new Print function, there is also the ability to hide and show certain objects on the screen depending on if it’s currently being printed. I’ve already done that with the print icon, here’s the syntax. Select the control that you’d like to hide, and go to the Visible property. The name of my current screen is scrProjectForm, and the Printing parameter returns a boolean letting me know if the screen is currently printing or not. The ! (exclamation mark) at the beginning of this formula means the opposite. So, therefore this button is only visible if this screen is NOT currently printing. Therefore, it’s hidden when it IS printing.
Another thing that you could potentially do, is send other commands and/or even use a completely different screen for printing. Microsoft has added a couple of new screens to the list of available screens, specifically for this purpose:
When you use the print function, one idea is to navigate to the screen that has the printable layout, right before the print function, and if you wanted the form to look like a read-only form, you could also use the ViewForm command, too. You can even put another command that will navigate you back after printing.
Idea: Add a printer icon to the top of the screen, and in the OnSelect property:
Navigate(name of the screen you want to print);
ViewForm(name of the form on that screen);
Navigate(name of the screen you started on)
Now, you don’t *have* to navigate or have a special screen just for printing, you can simply print the screen you’re on. Navigating is just an option, and it is definitely time consuming to build multiple forms on multiple screens.
Another idea – NO form control
The following is very time consuming, but can give you very printer-perfect results if your form needs to look a certain way, but it’s still not going to scroll.
You can use mostly labels and not use the form control at all. Doing this solution entails having a record variable that stores all of the field data about the form, and this is something that I have in place in all of the apps that I create anyway, so it’s easy to implement. When I click on the existing item / list item that I want to view, I always set a variable with that form data.
OnSelect before navigating to that item. Set(varSelectedRecord, ThisItem) Like this. Notice that the whole gallery is what I’ve selected here.
Anyway, so once you have this record in a variable, you can use that data to display it for print.
This leads me to the next creative thing that you can do when you create a printable screen. Once you’re on the screen, the one that people fill out, the one with the form control, you can add a cute little printer icon, and set up this other screen, so that when the print icon is clicked, this is what gets printed:
This is a screen with a bunch of labels on it. The name of each field is a label, and the value of the data in the field is a label. Since I’ve set the record into a variable, I can refer to that in each label. Here are some examples:
For a text field called Project Name, see I’ve typed varSelectedRecord.’Project Name’ for the label’s text.
Project Manager is a people field:
Priority is a choice column:
And then project description is long, and the length of the description can vary, so I set the property called AutoHeight to TRUE for that label.
Here is an hour long video where Joelle and I demonstrated the Print function. The last part of this blog post with the labels is something I came up with later, so that is not in the video, but I do show a lot of tips and tricks in working with this function, and even show how to create a pop-up box that lets the user choose landscape or portrait.
Here is the official Microsoft documentation on this function: