Press "Enter" to skip to content

Convert SharePoint List Items to PDF

As a Microsoft community ‘Flownaught’ I spend (Jay Goodison) quite a lot of my working week helping users on the Microsoft Power Automate Community, it’s a fantastic resource for anyone how needs help building solutions with Microsoft Power Automate!

A topic which is raised often is ‘How to convert SharePoint list data to a PDF Document‘ and this post shows you how to do exactly that for both single and multiple items.

For both these example Flows the overall approach is pretty much the same:

  1. Obtain SharePoint List Item Data
  2. Create a HTML Template
  3. Interlace the HTML with SharePoint List Item Data
  4. Convert the HTML to PDF

For both of these examples I have created a SharePoint list containing ‘Orders’, configured as follows:

Convert a single SharePoint List Item to PDF

For this example, we’ll configure a Flow to automatically convert every new order (SharePoint List Item) to PDF upon creation.

1. Launch Power Automate – https://powerautomate.microsoft.com

2. Create a new ‘Automated flow

3. Provide the following information:

3.a. Flow name: Enter a relevant name/description for the Flow

3.b. Select the SharePoint ‘When an item is created‘ trigger action

3.c Click ‘Create

4. Configure the trigger action:

4.a. Site Address: Set to the target SharePoint site

4.b List Name: Set to the target SharePoint list

5. Add the Encodian ‘Convert HTML to PDF‘ action

5.a. Filename: Enter the name of the output file (pdf). You may wish to generate a unique filename by using the concat expression such as:

concat('NewOrder-',utcNow(),'.pdf')

5.b. HTML Data: Copy and paste the HTML data into the field. This demonstration uses this simple HTML snippet:

<html>
	<head>		
		<meta charset="UTF-8">
	</head>
	<body style="font-family:arial">
		<div style="padding-left: 12px;">
			<h2>Encodian - New Order</h2>
		</div>
		<div>
			<table style="width: 100%;"  cellpadding = "10">
				<tbody>
					<tr>
						<td><b>Submitted By<b></td>
						<td></td>
						<td><b>Submitted On<b></td>
						<td></td>
					</tr>
					<tr>
						<td><b>Customer Name<b></td>
						<td></td>
						<td><b>Customer Email<b></td>
						<td></td>
					<tr>
						<td><b>Customer Address<b></td>
						<td></td>
						<td>Order Status</td>
						<td></td>
					</tr>
					<tr>
						<td><b>Purchase Order<b></td>
						<td></td>
						<td><b>Order Details<b></td>
						<td></td>
					</tr>
					<tr>
						<td colspan="2"><b>Other Information<b></td>
						<td colspan="2"> </td>
					</tr>
				</tbody>
			</table>
		</div>		
	</body>
</html>

5.c. To interlace the list item data simply place your cursor in the target location within the HTML and select the required response field from dynamic data

6. Add a ‘Create File‘ SharePoint action

6.a. Site Address: Set to the target SharePoint site

6.b. Folder Path: Set to the target SharePoint library and folder

6.c. File Name: Select the ‘Filename‘ field from the ‘Convert HTML to PDF‘ action

6.d. File Content: Select the ‘File Content‘ field from the ‘Convert HTML to PDF‘ action

7. Test the Flow by submitting a new item into the list.

8. Validate the flow run has successfully executed

9. Check the PDF document has been created

We have used very simple HTML for this example, the Encodian ‘Convert HTML to PDF‘ provides full HTML5 / CSS3 support with many configuration options, so please configure your HTML as required to build visually appealing documents.

Convert a multiple SharePoint List Items to PDF

For this example, we’ll configure a Flow to automatically convert all orders into a PDF document. This could be executed on a schedule and perhaps query items in a specific state, however for this example we’ll focus on the conversion of multiple list items into a PDF document.

1. Launch Power Automate – https://powerautomate.microsoft.com

2. Create a new ‘Instant flow

3. Provide the following information:

3.a. Flow name: Enter a relevant name/description for the Flow

3.b. Select the SharePoint ‘Manually trigger a flow‘ trigger action

3.c Click ‘Create

4. Add a SharePoint ‘Get items‘ action and configure:

4.a. Site Address: Set to the target SharePoint site

4.b List Name: Set to the target SharePoint list

TIP: Add a filter query or selected a specific SharePoint list view to filter the data returned by the ‘Get items’ action.

5. Add a ‘Select‘ action

5.a. From: Select the ‘value‘ property from the SharePoint ‘Get items‘ action

5.b. Use the ‘Map’ fields to provide headings for each list item column you wish to display in the resulting document.

6. Add a ‘Create HTML Table‘ action

6.b. From: Select the ‘Output‘ property from the ‘Select‘ action

7. Add the Encodian ‘Convert HTML to PDF‘ action

7.a. Filename: Enter the name of the output file (pdf). You may wish to generate a unique filename by using the concat expression such as:

concat('Orders-',utcNow(),'.pdf')

7.b. HTML Data: Copy and paste the HTML data into the field. This demonstration uses this simple HTML snippet:

<html>
	<head>		
		<meta charset="UTF-8">
	</head>
	<body style="font-family:arial">
		<div style="padding-left: 12px;">
			<h2>Encodian - Orders</h2>
		</div>
		<div>
			
		</div>		
	</body>
</html>

7.c. To interlace the HTML table within the HTML data as follows:

8. Add a ‘Create File‘ SharePoint action

8.a. Site Address: Set to the target SharePoint site

8.b. Folder Path: Set to the target SharePoint library and folder

8.c. File Name: Select the ‘Filename‘ field from the ‘Convert HTML to PDF‘ action

8.d. File Content: Select the ‘File Content‘ field from the ‘Convert HTML to PDF‘ action

7. Test the Flow by manually starting

8. Validate the flow run has successfully executed

9. Check the PDF document has been created

We have used very simple HTML for this example, the Encodian ‘Convert HTML to PDF‘ provides full HTML5 / CSS3 support with many configuration options, so please configure your HTML as required to build visually appealing documents.

Finally…

For these examples, we’ve used Encodians ‘Convert HTML to PDF‘ action. You could use the OneDrive ‘Convert File‘ action, however, there is limited HTML support so you may run into unexpected issues.

We hope you’ve found this guide useful, and as ever, please share any feedback or comments – all are welcome!

Be First to Comment

Leave a Reply

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