Printing in Power Apps used to require an extensive workaround, but now it’s much easier. We walk through how to print and review the workaround if you still need to use it.
Back in 2018, I wrote a blog post on how to print a form in Power Apps, which essentially involved creating an HTML report and then dumping that out into an email to print.
While it wasn’t very pretty, it got the job done since there wasn’t a native printing support in Power Apps. Since then, Microsoft has finally added the print ability so many people wanted. So, how does it work?
Print()
That’s it! It’s a very simple command that takes no parameters and sends the screen off to the printer of your choice. In the screenshots below, I spun up a template of an app, added a “Print” button, and set the “On Select Formula” of the button to Print():
Now, when I click that button, I am presented with a print preview of the screen where the Print button is located.
While that’s not very print friendly, there are also some options to allow you to customize a printable view. For instance, you could add a new screen using the built-in Print Layouts (portrait or horizontal) and then build a printable report from there.
By default, these screens come with a “Print” button with the Print() command already defined. From here you can format the printed report to anything you want.
While this does provide some much-needed functionality, there are some caveats to using the Print button. I’m hopeful Microsoft will eventually plug these gaps in the product, as some are fairly glaring, especially the “currently doesn’t work on mobile devices” limitation.
How Can I Get Around Those Limitations?
Even with these limitations, there is still the option I previously wrote about. Here’s a breakdown of what you need to do.
I have two screens for a Power App I have built, and I want users to be able to print the form after it has been submitted. Here is what my form looks like:
It’s a pretty standard form for a badge request. So, how do we get it to print? The answer lies with HTML and Microsoft Flow.
My first step is to add a “Print Form” button on the first item in my Requests Gallery. I used a simple icon for my button. Make sure you insert it into this box, so the icon ties itself to each item in the gallery.
Next, you will need to generate a printable view of your form from HTML. You can use any HTML tool to do this. You can even copy and paste the HTML code from InfoPath if you are migrating a form and you had a printable view in it. For this example, I created a simple two-column HTML table and replaced the first column with all of my Display Names for my form. We will be adding the values for the right column in the next step. (Special thanks to html-online.com for the easy and free HTML Generator.)
Back in your Power App, insert an “HTMLText Input” box into the first item of your gallery, and change the Visible Property to false. For the HTMLText Property, copy and paste your HTML code between the “” (NOTE: If your HTML Code uses double quotes, do a find/replace and replace double quotes with single quotes).
We can now insert the values of the form into the second column. For example:
<td style=’width: 230px;’><strong>Request Type</strong></td>
<td>”&ThisItem.Request_x0020_Type.Value &”</td>
Notice, I am coming out of the closed quotes, and then appending the current items’ “Request Type Value,” and then appending the other HTML again.
Now, I have my HTML form which will have all of my values. Next, I will create a flow for this icon by selecting the icon, clicking the “Flow” button on the top toolbar, and creating a new flow for this button.
I have named my button ‘Send Printable Form,’ and I will be sending the HTML in an email. Add the Outlook 365 “Send an Email” action and fill out the settings. The two most important things here are to make sure you use the “Ask in Power Apps” for the body, and change the “Is HTML” to “Yes.”
Click “Create Flow,” switch back to your Power App, and then click the new flow you just created to assign it to that button.
In the formula bar, pass any of the variables you defined in flow. In my case, I will be sending the First Name (which will be added to the Subject) and HTMLText2.HTMLText (which is my HTML Text Box, and the HTMLText Property of that Box).
Now just preview the app and click your Print button. You (or whomever was in the “To:” field of your flow), will receive an email with a filled-out form that you can print.
NOTE: Because this is HTML, you can customize the look and feel as much as you want.
Bonus: If You Hate Printing Out of Your Email Client
You can also take that HTML content and add it to an HTML file. In my case, I saved all of the content out to an HTML file in my One Drive for Business by adding an extra step to the flow.
Now when the flow runs, I can simply download and open the HTML file from my browser and print it from there.
In Conclusion
I hope this is something you may find useful, especially if you have a strong need to print in Power Apps.
Part three of a series.