Extracting an Image field from SharePoint onto a PDF file

Posted by

SharePoint List columns of type ‘Image’ or ‘Thumbnail’ are not readily available in Power Automate’s in built SharePoint Connector. The way is to utilize the content we have from the list item and then add a few additional actions to pull the image from SharePoint itself via its API.

SharePoint

Power Automate

The Get items action will not return reference to the image, we need to use an additional action to do that. Here, the name of my column is Image

The above action will return JSON data, which can be parsed by creating the schema from the output of the action above. The field we are interested is Image.

The Image field too returns a JSON which looks something like this

{"type":"thumbnail","fileName":"360_F_579485255_hzHox0stuQmBx5QViwnQqQjk7RD2AJza.jpg","nativeFile":{},"fieldName":"Image","serverUrl":"https://Yourdomain.sharepoint.com","fieldId":"66b34763-66eb-4866-9b47-11674358e995","serverRelativeUrl":"/sites/Sudeep/SiteAssets/Lists/5980f4e9-7f7b-4394-a401-b461e5757394/360_F_579485255_hzHox0stuQmBx5QViwnQqQjk7RD2AJza.jpg","id":"d63484f5-564c-48ab-a9f4-bd5b34899dae"}

So we use another Parse JSON action to extract the serverRelativeUrl and then append it to the Tenant url variable to form the Absolute url to the image.

We need the Absolute Url to get the binary contents of the image file. This can be done using the Get file content using path action

Once we obtain the Binary data, we create the Image HTML tag as shown below. The expression been used is:

dataUri(body('Get_file_content_using_path'))

Finally, we create an HTML file and then subsequently a PDF.

Output

One comment

  1. Hi,

    The “ID” column is automatically created in all sharepoint lists or is it a column that must be created, or can another column be used to replace this “ID”?.

    Regards,

Leave a Reply

Your email address will not be published. Required fields are marked *