cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
memsim1010
Level: Powered On

HTML Text to Flow - Convert html file to PDF

Hey there PowerUsers,

 

I am 100% sure I am doing something wrong but I cannot figure out what it is.  Please help!

I have a PowerApp that displays a waiver in an HTML Text control.

I have a button and the OnSubmit function runs a flow that saves the HTML.HTMLText as an .htm file in OneDrive.

This is all working fine but, when I add an action to the flow to convert the .htm to a PDF, the resulting PDF shows all the HTML tags...

 

I followed the article written by @paulculmsee here: http://www.cleverworkarounds.com/2018/03/09/three-ways-to-convert-html-to-pdf-using-microsoft-flow/

"<p><strong>SIGNATURE OF PARENT OR LEGAL GUARDIAN REQUIRED</strong></p>
<p>As the parent or legal guardian of the minor child Participant named above, I hereby make and enter into each and every agreement, representation, waiver, and release described above on behalf of myself, the Participant, and any other parent or legal guardian of the Participant, intending that they be binding on me, the Participant, and our respective heirs, executors, administrators, and assigns. By affixing my signature below I represent that I possess the authority to act on behalf of all of the minor child Participant&rsquo;s parents or legal guardians and that I intend to give up my right, and the right of any other parent or legal guardian to maintain any claim or suit against HOST arising out of the Participant&rsquo;s participation in any Activities involving HOST in any way. I further agree to hold harmless, defend, and indemnify HOST of and from any claims from third parties arising from the minor child Participant&rsquo;s participation in any activities affiliated with HOST.</p>"

 

I have attached the resulting .htm and the .pdf.  If anyone has any insight, please let me know. 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: HTML Text to Flow - Convert html file to PDF

Hello,

I found images a bit trickier - just inserting the <img src tag with the path doesn't work for the PDF.

You have to get the file content of the image first, create a variable with that and use that in the <img src tag.

I have attached how the flow looks, I'm putting the HTML and Img tag together in the concat. My image is stored in a SharePoint list.

Hope that helps!

Kind Regards
Manuela
15 REPLIES 15
Highlighted

Re: HTML Text to Flow - Convert html file to PDF

Hello,

 

I have recently implemented this as well; not sure if it makes any difference but I'm saving my file as .html file. 

 

I can share screenshots of my flow and the html input,  if that helps! 

 

Kind Regards,

Manuela 

memsim1010
Level: Powered On

Re: HTML Text to Flow - Convert html file to PDF

@ManuelaPichler, that would be great, thank you!


@ManuelaPichler wrote:

Hello,

 

I have recently implemented this as well; not sure if it makes any difference but I'm saving my file as .html file. 

 

I can share screenshots of my flow and the html input,  if that helps! 

 

Kind Regards,

Manuela 


 

memsim1010
Level: Powered On

Re: HTML Text to Flow - Convert html file to PDF

I just tweaked my Flow to save the file as an html but, that didnt help. Smiley Sad

Re: HTML Text to Flow - Convert html file to PDF

Hello,
 
when you're saving the file to your OneDrive, are you concat-ing it with the <html> tags? 
 html3.JPG
 
Here's my excerpt:
 
concat('<!DOCTYPE html>
<html>
<head>
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}

td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}

tr:nth-child(even) {
background-color: #dddddd;
}
</style>
</head>
<body>', triggerBody()['Createfile_FileContent'], '<img src="', variables('logo') ,'"></body></html>'
memsim1010
Level: Powered On

Re: HTML Text to Flow - Convert html file to PDF

@ManuelaPichler

 

Gotcha,  no, my HTML comes from an HTML Text Input in PowerApps.  The format is: "<p>Some HTML Text</p>".  I will say that this was working last week but has since stopped working.  


Re: HTML Text to Flow - Convert html file to PDF

Try wrapping your text in the HTML and Body tags like I posted above or like this.

<!DOCTYPE html>
<html> <body> <p>Your Text</p> </body> </html>

You can either do this by extending the HTML Input Text in your PowerApps, or using the concat function in Flow. I believe that is necessary so the "Convert file" function in Flow recognizes it as an HTML file.

 

 

memsim1010
Level: Powered On

Re: HTML Text to Flow - Convert html file to PDF

@ManuelaPichler THANK YOU!

 

That got me a lot closer.  My test HTML worked great, however when I run it with the full waiver I get this error in Flow:

{
  "error": {
    "code": 502,
    "source": "flow-apim-msmanaged-na-northcentralus-01.azure-apim.net",
    "clientRequestId": "c0c0f946-6ecb-4c61-bfb6-d36faec9905a",
    "message": "BadGateway",
    "innerError": {
      "status": 502,
      "message": "ObjectDisposedException: Cannot access a closed Stream.\nInnerExceptionMessage: \nStackTrace:    at System.IO.__Error.StreamIsClosed()\r\n   at System.IO.MemoryStream.Seek(Int64 offset, SeekOrigin loc)\r\n   at OneDrive.Media.Transforms.HtmlTransform.<ExtractHtmlFromStreamAsync>d__7.MoveNext() in C:\\agent\\2\\_work\\3\\s\\Transforms\\HtmlTransform.cs:line 235\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at OneDrive.Media.Transforms.HtmlTransform.<ExtractHtmlFromContent>d__4.MoveNext() in C:\\agent\\2\\_work\\3\\s\\Transforms\\HtmlTransform.cs:line 90\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at OneDrive.Media.Transforms.Rasterizers.HtmlRasterizer.<ConvertHtmlAsync>d__17.MoveNext() in C:\\agent\\2\\_work\\3\\s\\Transforms\\Rasterizers\\HtmlRasterizer.cs:line 98\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at OneDrive.Media.Transforms.Rasterizers.HtmlRasterizer.<ConvertWithinSandboxAsync>d__16.MoveNext() in C:\\agent\\2\\_work\\3\\s\\Transforms\\Rasterizers\\HtmlRasterizer.cs:line 83\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at OneDrive.Media.Utilities.Sandbox.SandboxService.<RunRequestAsync>d__1.MoveNext() in C:\\agent\\2\\_work\\3\\s\\Sandbox\\SandboxService.cs:line 55\n ThrowSite: ",
      "source": "api.connectorp.svc.ms"
    }
  }
}

Re: HTML Text to Flow - Convert html file to PDF

Hello, 

 

how strange!

 

I've just mocked up a simple test and got it working, here's the setup:

HTML Text:

html5.JPG

 

OnSelect of the button in PowerApps:

html6.JPG

 

Flow that is kicked off from the PowerApps:

html4.JPG

memsim1010
Level: Powered On

Re: HTML Text to Flow - Convert html file to PDF

@ManuelaPichler

 

Hey there, that error seems resolved now.  I closed my browser and cleared the cache.

 

Now my PDF is working!  However, the images (arguably the most important part) are not.  See attachment.

 

They images appear in the html file but not the PDF.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

Follow PowerApps on Twitter

Stay Up-to-Date by following PowerApps on Twitter

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

Users Online
Currently online: 90 members 3,927 guests
Please welcome our newest community members: