Create a PDF from a SharePoint List Item with Power Automate

Do you need to create a PDF file using data from a SharePoint List? In this video I demonstrate how to create a PDF file with Power Automate in less than 5 minutes. This is great for all sorts of things, from generating a certificates for completing a course, receipts from a business process and much more.

To create this workflow I started with a “For the Selected Item” trigger, allowing the Flow to be run manual on the selected SharePoint List item.

The Get Item action is used to get all of the values from the selected List Item.

Use a Compose or Create HTML Table action to define your template using HTML

Next use the Create a File using OneDrive, convert the file to PDF and then generate the PDF and save it to OneDrive. The initial Create File action uses the Outputs from the HTML template.

In my example I have created a folder in OneDrive call DEMO where I save the HTML template and final PDF file.

That’s it! Now you have a Flow that generates a PDF file from a List Item.

One thing to note is the Flow saves the files into the OneDrive of the person who publised the Flow. If you are storing sensitive information you should consider using a service account and moving the files to a secure location.

24 comments

  1. This is so helpful, thank you! For my last step, I used the SharePoint Create file action to put the PDF into a SharePoint folder connected to a Team.

  2. Steve – Very helpful. Thank you. Some of my data does & some doesn’t come across from my list. The data that isn’t coming across seems to be large blocks of data as opposed to short descriptions. Not even making it to the HTML file. Any ideas. I’m getting ready to research but figured I’d ask.

    • Hi Ken, it could be due to special characters in the multi-line text field. Try making that field a Plan Text format rather than Rich Text. Another possible cause could be quotes that may break the HTML generated.

  3. Hello again, I was wondering if you’ve done any videos that might help me with my current challenge?
    I’ve been able to get most of what I need from this video, but my SharePoint list has a Nintex form that includes a repeating table. I have connected that repeating table to a multiple lines of text column in my SharePoint list. I have an inkling that it’s a xml something, but as a self-taught user, I don’t fully understand what that is.
    I want that repeating table to be added into the middle of the PDF, but I don’t know how to achieve that.

  4. Steve,

    Thank you for the helpful video. When I try to use the html table function instead of compose, I receive the following error message: The ‘from’ property value in the ‘table’ action inputs is of type ‘Integer’. The value must be of type ‘Array’.

    I am using “ID” as the input.

    • Hi William, do you mean you are using ID in the HTML template? e.g. a mix of HTML plus the “ID” value from a List item?

  5. Thank you so much for this, it’s exactly the answer I was looking for. However I’m having an issue with dynamic content that contains more than one response.

    I’m using this to create a pdf document based on an entry in a SharePoint list. The responses are for an incident report that it is completed through a Power Apps form.

    Some of the responses allow for multiple answers. I have a text field for a list of witnesses, separated by commas, as well as a list of injury types and locations where the staff member can select all that apply to them.

    How can I get the items in these fields separated into bullet points?

    I can bullet the line, but not separate the contents to provide multiple bullets.

    Also, for the fields where more than one option can be selected, I’m not getting the responses at all, more of an error code.

    [{“@odata.type”:”#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference”,”Id”:10,”Value”:”Sprain/strain”},{“@odata.type”:”#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference”,”Id”:13,”Value”:”Other”},{“@odata.type”:”#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference”,”Id”:-1,”Value”:”possiblybroken- awaiting xray”}]

    Any help would be greatly appreciated, I’m incredibly new to this and it’s my first journey into the world of HTML code.

  6. Steve, this is great. However, one of the fields I want to pull is a people picker, where I allow multiple people to be added to that field. How can I pull the details for the display name for each and add that in the table? I know this is kind of goofy with Sharepoint people picker fields, any help would be appreciated. Also how can I add grid lines to the table?

  7. Hi Steve,
    Thanks for this, it’s very helpful! I’m having one issue though where the table that is created seems to be too big for the pdf, as the right side of it ends up getting cut off. Any suggestions?

  8. Got this to work 99%. Thank you. The one last hurdle is to show a picture that comes from an image field in my list. When I go to insert it in my HTML, this field does not show in my content selection. All other fields are showing.

    • Hi Mike. I’m attempting to work through this same problem right now. May I ask if you were able to find a good solution for exporting the image field?

  9. This was awesome! I was able to use this as part of a fairly complex Flow and it worked perfectly. I would have preferred it to work on a SharePoint folder instead of OneDrive for Business, but it doesn’t. I have a question about attaching this .pdf now inside a Flow. After the .pdf is created, is the path to it captured somewhere where I could then use that to attach the .pdf into an email?

  10. I should also say that I used Dynamic Content to create a file name that was relevant to the actual flow. This lets me automatically create a unique file name every time the flow runs including the person’s name and date.

  11. Hi There

    I am struggling with getting double spacing right on my Compose script.

    I see your example has sectioned the pdf doc nicely but it I apply your concept, it doesn’t work.

    Please help.

  12. Hello Steve! Good day!

    How can I create multiples files (more than 2000 files) using this method?

    Example:

    I have a sharepoint list, the data in the PDF file it’s from there with HTML format.
    I did this with the trigger “When an item or a file is modified” and it’s perfectly.

    But I have to create more than 2000 files in a short time, and this flow it’s not helping it. So I need create PDF file for all items in the list once (effectively). Can you help me with this, do you know any article that has this?

    Thank you so much! 🙂

    • Hi Isis, you may need to run this in batches. There are some limitations on the number of Flows that can run at once. I would start with 50 and once those flows complete, run the next batch.

Leave a comment