- Compose HTML File - used to compose the HTML body. In it, you can see the HTML markup that points to an image (e.g. https://<YOUR TENANT>postmediacanoe.files.wordpress.com/2018/09/jackolanterns1000.jpg).
- Create file - this is where the HTML is converted into a temporary file, temp.html
- Convert file using path - here, the HTML file is converted into PDF. Note that this action doesn't actually save the PDF file; it just converts the content.
- Create file 2 - now, I use the content from action 3 to save the PDF content into a PDF file.
If you look at the temp.html file, you will see the image as expected:
However, if you try to open the corresponding PDF file, the image is missing.
The reason for this is that the Convert file using path action is expecting all the content to exist within the source document (the HTML file). So, the way to get around this is by extracting the content of the image and including it directly within the HTML body. Let's have a look at the updated Flow:
I added the Get file content using path to capture the content of the Halloween.png file. Next, I modified the Compose action to (specifically the <img ...> tag) to include the content of the image. For the image content itself, you need to include the following expression:
body('Get_file_content_using_path')?['$content']
Note that the name of the body object may be different in your case. Now, when you generate the PDF, you get the image included in it.
Final Thoughts
As you can see in the final image, the Halloween picture is larger in the PDF file than in the HTML file. Make sure to structure your HTML carefully to properly size the images and other content.
Thanks for sharing this useful tip/information!
ReplyDeleteI tried to resize my image but it did not work. May I know where did I go wrong?
[IMG SRC="data:image/png;base64, (the Dynamic Content)" width=150 height=80]
(Had to replace tags with square brackets as HTML tag was not allowed in the comments box).
Try using style="width:150px; height:80px" instead of the two tags.
DeleteIn terms of adding the brackets, you can try < and > instead of the less than/greater than brackets next time.
Thanks a lot.
ReplyDeleteAwesome, thanks! Was just wondering why my PDF didn't include the picture. :)
ReplyDeleteNot sure. Would you like to share your flow?
Delete