cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Problem inserting image into HTML text for PDF

Hello!

 

I have a flow that converts my HTML text to a PDF in SharePoint. I need to attach my company logo to the PDF however, the image always appears as an  x (see image). 

pdfimageproblem.PNG

My HTML code is 

 

"<center> Confidential Information - For Internal Use Only - Do Not Redistribute </center>
<h3> Risk Details </h3>
<img src='https://extranet.companyname.ca/?r=489&k=41e75be41d' alt='Logo'>" & ...

 

Please help me insert an image into my pdf! Thanks!

8 REPLIES 8
Pstork1
Dual Super User III
Dual Super User III

The first thing I noticed is that you don't have a file extension on your image link.  Without that extension the PDF won't recognize it as an image file.  Ist it a .JPG, .PNG or what? 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Anonymous
Not applicable

I have the files downloaded to my computer as  PNG and I just tried using the link I grabbed from sharepoint (https://mycompanyonline.sharepoint.com/sites/BusinessIntelligenceandAnalytics/Shared%20Documents/Pow...) however, I have the same error! Note: I changed the URL for privacy reasons.

Anonymous
Not applicable

Update: The image is visible in the html text in the app however it does not show up in the pdf.

Pstork1
Dual Super User III
Dual Super User III

Take a look at the following Blog post from John Liu.  Evidently to embed it in the PDF you need to convert the image to a binary represnation.

http://johnliu.net/blog/2017/10/generate-any-pdf-documents-from-html-with-flow



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
v-xida-msft
Community Support
Community Support

Hi @Anonymous ,

Do you want to embed the image into a PDF file?

Do you pass the Html text from a canvas app to a flow (MS Flow), and then create a PDF file?

 

I agree with @Pstork1 's thought almost. If you want to embed an image into a PDF file, you need to convert the image content into a dataUrl string firstly.

 

On your side, you could consier store your image file within a cloud storage, e.g. OneDrive folder, SP Library, etc. Then get the file content of the image file stored in your cloud storage, and concatenate it with the HTML text string passed from your app.

After that, create a HTML file based on the concatenated string, and then convert the HTML file into a PDF file using the "Convert file using path" action or "Convert file" action of OneDrive connector, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @v-xida-msft ,

 

Yes, I do want to embed an image into my PDF file and yes, my flow takes the html from a canvas app to create a file in sharepoint (following Shane Young's video).

How/where do I convert the image content into a dataUrl string? 

 

Also, following your other instructions do I need to change anything once the image is a dataURI string?

 

Thank you so much for your help, I really appreciate it!

Hi @Anonymous ,

Within your flow, you should configure it as below:1.JPG

within the "Initialize variable" action, you should set the Name field to dataUriString, specify Type to String, set the Value field to following formula:

dataUri(body('Get_file_content'))

More details about using expresson in flow actions, please check the following blog:

https://flow.microsoft.com/en-us/blog/use-expressions-in-actions/

 

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
twister
Post Patron
Post Patron

@v-xida-msft may i know how to use concat function in htmltext for this case?

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (34,516)