cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Darkjedithx
Frequent Visitor

trying to send complete report as pdf

For the love of god I hope someone can help, I have created an app for reporting but would like to send all the info onto a pdf sheet. to an email address. here is what the app looks like. and the Pdf Background where the text needs to go on.Skærmbillede 2022-04-11 094408.pngSkærmbillede 2022-04-11 094443.pngSkærmbillede 2022-04-11 094510.pngSkærmbillede 2022-04-11 094224.png

10 REPLIES 10
WannaBePro
Advocate I
Advocate I

Just a note - you can't 'preview' the pdf without actually creating the pdf, so it is a bit redundant because you have to send the data to flow to create the pdf, then return the pdf content back to PowerApps so it can display the pdf, at which point you then want to 'send' the pdf....which means triggering flow again.... doesn't really make sense.

Probably easier to 'preview' the PDF using the HTML Text control as I mentioned, then just trigger the flow to convert and send in one shot...but either way, let's demonstrate the thinking;

I built a quick PowerApp mock-up that does just that - on the page you can see inputs for the fields, an HTML text control that is showing you what the HTML markup of a PDF form might look like, and below that the HTML code inside the control that has the inputs integrated.  By 'integrated' I mean HTML markup has been injected with the input text fields, like this;

 

"<p>HTML CODE " & injectionVariable & " more HTML code"

eg: "<TD>First Name:</TD><TD>" & TextInput.Text & "</TD>"

 

When "View PDF" is clicked, the HTML control's HtmlText value, (HtmlTextControl.HtmlText), and the email addres input value (emailTextInput.Text) is sent to a Power Automate flow.  

The flow uses the HtmlText input from PowerApps to create an HTML file.  It then converts the HTML file to PDF, and sends the PDF content back to PowerApps so it can be displayed. 

 

Note: I don't send any emails in my flow, but you can add a step to send an email and attach the converted PDF content to it.

 

Notice, we send the PDF content back to the PDF viewer - not a link to a PDF file.  This is because the PowerApps PDF viewer is very fussy, and you won't get it to display PDF files from a secure source like SPO - so, rather than trying to save PDF's somewhere public for it to process, it's better to pass it the PDF content of the file straight from flow.  We do this by converting the converted base64 pdf content into binary, then convert that into a data URI that the PDF Viewer in PowerApps can translate and display without 'connecting' to a file.  To do this we use a compose step with the following custom expression;

 

 

datauri(base64ToBinary(body('Convert_file')?['$content']))

 

 

Here's what the flow looks like;

wbphtmlpdflow.png

 

If you like, you can create a file from your conversion data - the Convert function no longer creates the file for you, it just returns the converted content inside the flow - so if you actually want a PDF file saved in the users OneDrive you need to create it from the converted content - hence the 'Create file 2' step.  This isn't actually necessary unless you want a saved file somewhere though - you can easily attach the converted content onto an email without creating a file as well.

What's nice about a file though, is that you can create a sharable link from it and feed that back to PowerApps as well, in case you want the user to view the PDF in their browser instead of the viewer - and then they have the file in their OneDrive....anyway....

Also optional - you can delete the HTML file you created - it served it's purpose.  I didn't in my flow, but you can add a remove file step.

 

Once you're done, you pass the Convert step content output plus whatever else you want back to PowerApps using a "Respond to a PowerApp or flow" action.  You then use this as input into your PDF Viewer's Document: property.

Obviously, the flow can just as easily email the PDF once it's been created....here's how it looks....

wbphtmlpdf.gif

 So the View PDF button triggers the flow like this;

 

 

Set(ConvertFlowResponse, myConversionFlow.Run(emailaddressInput.Text, HTMLText1.HtmlText))

 

 

and the PDF Viewer becomes visible once the response comes back from Power Automate and it's Document: property looks something like this;

 

 

ConvertFlowResponse.pdfContent

 

 

That should be enough to get you going - good luck! 

WBP

 

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (5,092)