Creating PDF documents with images using Flow

One of the nice document generation features of Flow is to create PDF documents from structured data, such as HTML.  However, if you want to integrate images, you may not see the expected result.  For demonstration purposes, suppose you want to have a PDF image that only includes.  The flow may look something like the image below:

The Flow is broken down into 4 actions:

  1. 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>
  2. Create file - this is where the HTML is converted into a temporary file, temp.html
  3. 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.
  4. 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:


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.


  1. Thanks for sharing this useful tip/information!

    I 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).

    1. Try using style="width:150px; height:80px" instead of the two tags.

      In terms of adding the brackets, you can try &lt; and &gt; instead of the less than/greater than brackets next time.

  2. Awesome, thanks! Was just wondering why my PDF didn't include the picture. :)


Employee Check-in Simplified using Power Automate

Company employees who move between offices are often faced with a tedious process of having to check-in at the security desk to get a tempor...