Summary
In previous blog, we discussed Generating the PDF from Microsoft Flow with two approaches. The First one with an HTML Template can be accessed from here –link—
Let’s start with the Second approach,
Part-2
Generate a PDF of SharePoint List Data with Word Template from Microsoft Flow
This is the second approach for generating the PDF from SharePoint List data that is using the predefined format as Template in SharePoint Document Library, then updated the file properties and created a template in OneDrive then converting that template to PDF and saving in SharePoint Document Library.
The approach is described below:
Step-1
Create a SharePoint Custom List named Conversion-to-PDF-from-Flow with necessary fields to enter the data, required to move to predefined PDF Format. Here I have taken the following fields.
Create another SharePoint Document Library with name Test-PDF-Documents to store the generated PDF’s.
Please note, while creating multi-line columns, make sure that plain text is selected.
Step-2
The Word Template
Create a SharePoint Document Library named Test-PDF-Doc-Template. Create the same data fields created in the SharePoint List – Conversion-to-PDF-from-Flow.
We would create a Document Template in the Library. We would also create the same data fields in the Library as we had created in the List named Conversion-to-PDF-from-Flow. Once we have created the same data fields, we would go to Library Settings > go to Advanced Setting > Edit Template.
In previous approach, we used tokens. In this approach we would be using the Quick Parts from Insert tab. We can access or add them like Insert > Quick Parts > Document Property > Use the data column which would be used to replace the data inserted in it.
One created the template would look like this,
Once created, save it in .docx format.
So the next time when you would try to edit the template it would have to be saved in .docx format.
Step-3
Creating the Flow
- Create the Flow with a trigger – When an item is created of SharePoint connector. Select the Site collection address and List’s name.
- Add an action – Get File Content of SharePoint connector. Select the Site collection address and the File from which the template would be taken and used to create the file.
- Add an action – Create File of SharePoint connector. Select the Site collection address, folder path to the template saved, Create a File name as required and select the file content from the dynamic content window from the previous action.
- Add an action – Update File Properties, select the Site collection address, Library name, Select the ID as ItemID from previous action Create File action and select the data fields linked to each other.
Additional Read
How to Migrate File Server to SharePoint Online [Expert Guide]
- Add an action – Get File Content of SharePoint connector. Select the Site Collection address, and the file identifier, set the file identifier as file identifier from the previous action.
- Add an action – Create File for the OneDrive connector. Select the Folder path to save the file, name of the file and the file content as file content from previous action from dynamic content.
- Add an action – Convert File for the SharePoint connector. Select the File as ID from the precious action.
- Add an action – Create File for the SharePoint connector. Select the Site collection address, folder path to save the file, name of the file with an extension .pdf and file content as File Content from previous action of Convert File.
Once the Flow is created, it would look like this:
Let’s enter data in our SharePoint Custom List Conversion to PDF from the Flow:
The document that gets created in the Library named Test-PDF-Doc-Template while the Flow runs would appear like this:
The document that would be created inside the Library Test-PDF-Documents after the Flow runs would appear as:
The file content would look like this:
Are you in need of assistance? We can help!
Book a live 1-on-1 call with the experts of Reality Tech to find out how we will help you to achieve your goal. You’ll find our solutions robust, scalable, and dependable. Let’s talk!
Please post your question, if you will find while implementing this process. Thank you.
Want to talk?
Drop us a line. We are here to answer your questions 24*7.