Fill PDF Forms using Power Automate

In this guide you’ll learn how to fill a PDF form using Power Automate.

Muhimbi’s ‘Import PDF Form data’ action, allows you to Import XML, FDF, and XFDF data in the PDF Forms. In this example, you will retrieve data from an MS SharePoint List and fill out a PDF form with Power Automate.

Prerequisites

Before we start building the workflow, ensure all prerequisites are in place. It is also assumed that the reader has some knowledge of building Workflow using Power Automate.

  • Muhimbi PDF Converter for SharePoint full or free trial subscription.
  • Appropriate privileges to create Power Automate(Flow).
  • Working knowledge of Power Automate.
  • MS SharePoint List with data ready for import.

Note: With Muhimbi’s ‘Import PDF Form data’ action, you can Import XML, FDF, and XFDF data in the PDF Forms. For the scenario covered in this article, we will Import XML data into a PDF Form.

Filling a PDF Form with Microsoft Power Automate

In this scenario, there is an MS SharePoint List with data, and you can loop through all the list items and Import the data in a PDF Form Template. The form will be editable after the data is imported.

We will use the form sample which can be downloaded here.

Creating the Form Structure as XML

  1. You have two options to get the form structure:

  2. You can export the Form to XML using Adobe DC by using the ‘Export Form Data’ option.

  3. Create a Power Automate Flow to Export the PDF Form Data as XML:

    create power automate flow
    Note: Muhimbi ‘Processed file content’ returns a Base64 value and we need to use the formula below to Convert it to a String.

    *base64ToString(outputs(‘Export_PDF_Forms_Data’)?[‘body/processed_file_content’]).

    *The XML will look as follows:

Now that we have the Template as an XML let’s create a Power Automate Flow to import the SharePoint List item in a PDF Template.

Creating the Power Automate Flow

From a high level, our Flow will look like the screenshot below:

fill pdf form flow

  1. Create a new Flow using the ‘Instant cloud flow’ option and use the ‘Manually trigger a flow’ Trigger.

    create flow

  2. Add the SharePoint ‘Get items’ action to the Flow canvas and configure it as per the details below:

    Site Address: Specify the path to the SharePoint Online site-collection which holds the file.
    List Name: Select the SharePoint list you want to get the items from.

    get items action

Note: If you have a large list you might need to configure the action ‘Settings’ and turn on the Pagination option and set the threshold to a site collection.

  1. Add the SharePoint ‘Get file content using path’ action to the Flow canvas and configure it as per the details below:

Site Address: Specify the path to the SharePoint Online site-collection which holds the Form Template.
File Path: Select the File Path to your PDF Form Template.

get file content using path

  1. Insert an ‘Apply to each’ condition and configure it as per details below:

    Select an output from previous steps: Select the ‘value’ output from ‘Get items’ action.

    apply to each

  2. Add the ‘Compose action’ inside the ‘Apply to each’ action on the Flow canvas and paste in the XML template we exported as per section Creating the Form Structure as XML in the inputs section.

    compose action

    Note: Ensure you insert the various list fields from the ‘Get items’ action in the appropriate places between >< element in the XML pasted here.

  3. Inside the ‘Apply to Each’ loop, add the Muhimbi ‘Import PDF Form data’ action to the Flow canvas and configure it as per the details below:

    Source File name: ‘Title’.xml the output from the ‘Get items’ action.
    Source file content: ‘Outputs’ of the ‘Compose’ action.
    PDF Form file Content: ‘File Content’ is the output of the ‘Get file content using path’ action.
    Flatten: No (We need the form to be editable).
    Read-Only: No

    source file settings

  4. Inside the ‘Apply to each loop’ add the ‘Create file’ SharePoint action to create the PDF document in the SharePoint document library. Configure this action as per the details below:

    Folder Path: Specify the output path to write the PDF file to.
    File Name: ‘Base File Name’.pdf is the output variable of the ‘Import PDF Form data’ action.
    File Content: ‘Processed file content’ is the output variable of the ‘Import PDF Form data’ action.

    create file

  5. You can start your Flow manually and you will notice that after a few seconds, each list item from the SharePoint List will be imported into a template, and PDF documents will be created in the destination library.

Have a Question?
We’re Always Happy to Help.

© Muhimbi Ltd. 2008 - 2023
This website uses cookies to ensure you get the best experience. Learn more