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.

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.

Share this:

Like Loading.

Related

Published by Steve

Steve Knutson is a Microsoft Regional Director, Microsoft MVP for Office Apps and Services (Office 365 and SharePoint) and Technology Consultant focused on SharePoint and related technologies. Steve has a B.Sc in Computer Science from Massey University. In 2011 Steve co-founded Stratos Technology Partners, a Software Engineering and Technology Consulting firm based in Christchurch, New Zealand. View all posts by Steve

28 comments

LauraAnn says:

Looks good, but what if the pdf file is already created, with “fields” to fill in, which are stored in the Sharepoint List?

Steve says:

Hi LauraAnn, Power Automate doesn’t support completing forms, but you can get an addon from Plumsail that adds the features needed https://plumsail.com/docs/documents/v1.x/flow/how-tos/documents/fill-pdf-form.html

sandra_nz says:

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.

Steve says: Thanks Sandra, I am glad it helped 🙂 Ken Martinez says:

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.

Steve says:

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.

sandramcgechan says:

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.

Steve says:

Hi Sandra, have you tried creating an HTML table in the muliple line text field? You can insert additonal HTML inside the HTML template I use in my example (just the table elements e.g no header tags).

sandramcgechan says: I don’t know how to go from that weird code in that column to an html table. Steve says:

If the column contains XML then you can use this approach in Power Automate to convert the XML to HTML.
I hope this helps 🙂 https://powerusers.microsoft.com/t5/Building-Flows/Parsing-an-XML-file-and-creating-a-table-fields-that-can-be/td-p/495127

sandramcgechan says: Thank you very much, I’ll give that a go tomorrow! William says:

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.

Steve says:

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?

Kat says:

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”>,,] Any help would be greatly appreciated, I’m incredibly new to this and it’s my first journey into the world of HTML code.

Steve says:

Hi Kat, when you have multiple answers the you need to think of the item as an Array. The trick is to use a loop to extract each result and add it to a variable (multiple line of text) where each line in the variable is a row in the HTML table. This article explains the steps https://powerusers.microsoft.com/t5/Building-Flows/Create-HTML-table-from-Sharepoint-List-with-multi-selection/td-p/407296 I hope this helps

Becca Lopez says:

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?

Daniel Schell says:

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?

Mike S says:

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.

CJ L says:

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?

Mark Saffell says:

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?

Mark Saffell says:

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.

nchiliza says:

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.

Isis de Oliveira Bortoluzzi says:

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! 🙂

Steve says:

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.

Arthur Santos says:

Thanks for the great content. Would it be possible to create this pdf so that it can be attached to an Outlook email?

Steve says:

Hi Arthur, you can use the “Send an Email (V2)” action in Power Automate to send the file as an attachment. Here are the steps https://community.powerplatform.com/forums/thread/details/?threadid=85b17da2-85db-4a0c-b359-3a49dd0c259b

Arthur Santos says: Steve Your blog has been very good for my learning, but I’m stuck with one detail. When the PDF is created, the file comes with several pages precisely because there is an option in my list that can be 1 or more values. Ideally, the PDF would come on just one page with all the options on the same line. I marked in bold the step I’m stuck at

Novo Item Criado Micro Marketing – PULSE

Confidential – file copy

ID:

Nome do Representante:

Gerente Distrital:

Data da emissão:

Local realizado o Mini Meeting:

Outro:

Utilizado na reuniao: @

HCPs Presentes:

Nome Médico/CRM:

Nome Médico/CRM:

Nome Médico/CRM:

Nome Médico/CRM:

Nome Médico/CRM:

Nome Médico/CRM:

Nome Médico/CRM:

Nome Médico/CRM:

Nome Médico/CRM:

Steve says:

Hi Arthur, you could try using a Compose before the HTML. Make the Compose the value of the multi-line text field. You may need to use the TRIM function to remove any extra characters at the end. In the HTML replace the field with the Output from the compose.

Leave a comment Cancel reply

Instagram

Thanks for visiting my blog. All content is copywrite 2008-2024 Steve Knutson.