for Microsoft Power Automate and Azure logic apps

Fill a PDF Form with Power Automate and Encodian

By Jay Goodison

12th June 2020

Fill a PDF Form with Microsoft Power Automate

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.

7 Comments

  1. Alma Arce says:

    Is there a way to use a response from Microsoft Forms to Fill a PDF Form. I keep trying with now luck. I keep getting the error code “BadGateway”

    1. Jay Goodison says:

      It does not matter where the data comes from, it can come from anywhere. You are simply passing data into the PDF form. Please email support@encodian.com with further details, the team will be able to help

  2. John Turner says:

    I have gotten the flow to create and fill the pdf form, and email the completed form as an attachment but I can not figure out how to get it to store a copy

    1. Jay Goodison says:

      Hi John, you need to use another action to do something with the file (File Contents) returned by the Encodian action. IF you were storing in SharePoint, use the ‘Create File’ action. HTH Jay

  3. Apoorva Raina says:

    I have an excel file with all the details aligned to each employee. I want to share an email with pdf file with specific details of each employee extracted from the excel. Is this possible?

    1. Jay Goodison says:

      Yes, this is possible. You would need to get each row from the Excel file using the Excel Online (Business) connector, then for each row either create a new document via the ‘Convert HTML to PDF‘ action or the ‘Populate Word Document‘ action

Leave a comment

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