How To Fill PDF Form Using Power Automate FLOW

Problem

Consider you have an agreement or contract template as PDF form with fields in it, and you want to generate hundreds of contracts every month by filling actual data in it. Now your colleagues are doing it manually. Can that be automated?

If you have a SharePoint list, where you store required metadata, get the approvals done; then can we automatically read this data and fill in the PDF form?

Solution

Yes, we can fill PDF forms automatically and generate PDF files from them. With an on-premises version of SharePoint and custom development, many of us have used iTextSharp DLLs to read and generate PDF files.

There are multiple options available in office 365 as well. You can write the Azure function, call the function from Logic Apps, trigger logic apps on list item event. OR if you don’t want to get into the complexity of development you can make use of Encodian connector.

Encodian is third-party connector, mostly offers actions/functions related to PDF files. It comes with various plans which includes lifetime free plan as well. It comes with 50 monthly calls. Very good option to start with.

Create a test FLOW, look for Encodian connector and its action to understand more about it. We will be making use of below two actions from it

Before moving ahead, here is my sample PDF form with fields in it. Its Power of attorney template. I would like to automate the process of generating POA. My organization needs to generate hundreds of POA every month.

I have a SharePoint list with required metadata, which has its own approval FLOW running. Once the record is approved, I want to push this metadata into a PDF form template and generate the PDF file. Below is a sample PowerApps screen for it.

I have stored the template PDF file in a separate folder in the SharePoint document library. We will need this so that we can get the file content of this template.

Now let’s get back to main FLOW actions. My FLOW runs on SharePoint list, there is an approval process in it. Once status changes to Approved below actions would run.

You need to get the file content of the PDF form file template. You can call Get PDF Form Data action – to understand the schema of fields in it. It will return JSON data as shown below

Depending on how PDF forms are generated by the author, you will get the JSON DATA. My sample PDF template had fields as shown below.

{
	"Text269": "",
	"Text270": "",
	"Text271": "",
	"Text272": "",
	"Text273": "",
	"Text274": "",
	"Text275": "",
	"Text276": "",
	"Text277": "",
	"Text278": "",
	"Text279": "",
	"Text280": "",
	"Text281": "",
	"Text282": "",
	"Text283": "",
	"Text284": "",
	"Text285": "",
	"Text286": "",
	"Text287": ""
}

We must generate our input data in the same format. We must pass this data to Fill a PDF Form data action. Once done use the output of this action to the next “Create file” action. It will generate the PDF file with the filled form.

Now you can send the link to the newly generated file to the requestor or send it as an email attachment as per your need.

Do check out the above configuration in detail from this YouTube video.

Summary

This will reduce the workload of the administrative team, contracts or agreements can be generated automatically and sent to requestor or event clients through email. As I mentioned you can go with a free subscription to Encodian or make use of the Azure function with Logic apps.

Hope this helps. Thanks for reading.