Fill a PDF Form with Microsoft Power Automate

June 12th 2020
Back to all blogs

To complement our Get PDF Form Data action, we have just released the Fill a PDF Form action. It provides the ability to set data within a PDF form using Microsoft Power automate.

The Fill a PDF Form action supports both XFA and (Adobe) Acroforms, albeit the capabilities/support are enhanced or for (Adobe) Acroforms considering XFA form deprecation.

Populate a PDF Form Guide

The Fill a PDF Form action accepts two parameters, the file and a JSON payload containing the data which you would like to fill the form with, for example:

The JSON data schema is super simple; in essence, a key-value pair where the key refers to the name of the field within the PDF form, and the value is the actual value you would like to set:

{
    "fieldName":"value",
    "fieldName":"value",
}

Obtaining PDF Form Field Names

If you have PDF Form editing software, you can easily open the form and locate the relevant field names. Note that for an XFA form, you will need the full pathname of the form control.

However, we’d suggest using the Get PDF Form Data action to retrieve the data structure for your form, and here is how:

1. Create a new ‘Automated — from Blank‘ flow in Power Automate

2. Within your Flow, obtain the source PDF form using a ‘Get File Content‘ action appropriate to where the file is stored. This example uses the SharePoint action.

3. Add the Encodian Get PDF Form Data action

3. a File Content: Select the ‘File Content‘ property from the SharePoint ‘Get file content‘ action

4. Execute the flow and open the ‘Get PDF Form Data‘ action within the run history. The ‘Form Data‘ property contains the JSON schema, which we can use to fill the PDF form then later, and copy the value.

On occasion, Power Automate will return the ‘Form Data’ property value as escaped JSON, as it is in the screenshot above and in full below:

{
    \"Surname\":\"\",
    \"Forename\":\"\",
    \"DOB\":\"\",
    \"Gender\":\"Not Specified\",
    \"TermsAgreed\":\"\"
}

Before you can use this data to pass to the Fill a PDF Form action, we need to unescape it. There are lots of tools available, so be sure to check them out!

The unescaped JSON is shown below:

{
    "Surname":"",
    "Forename":"",
    "DOB":"",
    "Gender":"Not Specified",
    "TermsAgreed":""
}

Fill a PDF Form with Power Automate Step by Step

Now that we have a JSON schema specific to the form, we can start to build a flow to populate the form with data.

1. Create a new ‘Automated — from Blank‘ flow in Power Automate or an automated trigger relevant to your specific scenario.

2. Within your Flow, obtain the source PDF form using a ‘Get File Content‘ action appropriate to where the file is stored. This example uses the SharePoint action.

3. Add the Encodian Fill a PDF Form action

3.a. File Content: Select the ‘File Content‘ property from the SharePoint ‘Get file content‘ action

3.b. Form Data: Enter the JSON data which will be used to populate the form.

Please refer to the following article on our support portal. It details how to format JSON values about the control type within your PDF Form. Fill a PDF Form – Encodian Support Portal

4. Add a new action to your flow to store or share the completed PDF form as needed. For this example, I have added a ‘Send an email V2‘ effort. This sends the completed form for validation via email.

Execute your flow and check the PDF Form has been filled with the data you have provided to the Encodian. Fill a PDF Form action.

Finally…

We hope this post provides valuable guidance on using the Encodian Fill a PDF Form action to change data in a PDF Form using Power Automate. If you’re struggling, please raise a ticket with our support team, who’ll be delighted to help.

Author
Jay Goodison

Managing Director

Back to all blogs

You might also be interested in...