Muhimbi has an excellent BLOG which Convert PowerApps data to PDF (with some help from Microsoft Flow), however the article has its own limitation.
- It has a dependency on FLOW.
- You cannot pass Images(from Camera Control) from PowerAPP to FLOW(Nothing to do with Muhimbi, its a Microsoft-FLOW limitation).
In this example, we will Convert PowerAPPs data, including images to PDF without the help of Microsoft FLOW. So, let’s get started.
The focus of this post is on how to use PowerApps to capture data and turn that data into a richly formatted PDF. Please note, that this article is NOT about converting the layout of the PowerApp screen to PDF. Due to architectural difficulties, that is currently not possible.
In this post we will:
- Create a simple PowerApps form to capture user data.
- Use, Muhimbi Methods to use the captured data, enrich it with HTML, and convert it to PDF.
To keeps thing easy to understand, we carry out the actual PDF generation, display it on the PowerAPPs PDF viewer and then send the PDF as an email.
Before you begin, please make sure the following prerequisites are in place:
- An Office 365 subscription with access to PowerApps
- Muhimbi PDF Converter Services Online full, free or trial subscription(Start Trial)
- The appropriate privileges to create PowerApps.
- Working knowledge of PowerApps. This is not a generic PowerApps Tutorial.
Note: Using the below approach all works well, but on deployment to end users, each user need their own account in Muhimbi system (to authenticate with Muhimbi Flow Connector), or they all need to enter a shared account. The workaround would be to use the indirect approach mentioned here.
Step 1: Building the PowerApps.
Let’s begin by creating a PowerApp. It doesn’t really matter what it looks like, as long as it contains two text fields named EmailTextInput, TextInputName two a buttons named ViewPDFButton, Send PDF and PDFViewer1.
Step 2:Adding the Data-Source.
Click on the top “View” tab Data source, in the Data pane (which opens automatically), click “+ Add a data source” and add the MuhimbiPDF and Office365(Outlook) data sources.
Step 3: Understanding Muhimbi Action and Method.
Now, this is where things get slightly tricky, as we need to Set the variable for the data and pass it to Muhimbi [MuhimbiPDF.converthtm] action as HTML String. Note: The sky is the limit when it comes to HTML formatting but let’s not go overboard for this simple example. In this case the contents of the TextInputName.Text and EmailTextInput.Text and Camera1.Photo fields.
We build and associate the Formula, to “View the PDF” button.
The Fomula’s for both “View the PDF” and “Send PDF as Email” can be downloaded at:Download Fomula’s
The Final formula looks like:
Let’s break down the above formula to understand it better.
We are setting the “image” variable to Camera1.Photo.
Set the Variable PDF to MuhimbiPDF.converthtml Muhimbi Action.
The MuhimbiPDF.converthtm excepts an HTML String Input so we build the HTML String with the help of “Concatenate” function in PowerAPP.
Note: I am using the Concatenate method so that I can easily pass PowerApps Data field “TextInputName.Text” and “EmailTextInput.Text” and “Camera1.Photo” Image variable to the MuhimbiPDF.converthtm Action. Generating the HTML String is a bit Tricky, so be very careful when you are building the HTML String.
The Formula associate with “View the PDF” Button, OnSelect Function.
Step 4: Associating the PdfViewer1, Document property to PDF.processed_file_content.
The PDF.processed_file_content hold the Base64 Converted PDF file string.
It will Display the Converted PDF Content in the PDF viewer.
Step 5: Associate the “Send PDF as Email” Button OnSelect function, to the Formula below.
Step 6: Output when you click, “Send PDF as Email” button. It includes the PDF
I hope this article will help you in building Powerful PowerApps with Muhimbi Converter Service Online.
Thanks for reading and Happy Converting with Muhimbi Converter Service Online 🙂.