How to Fill a PDF Form Using Automation Anywhere and PDF.co

5 Minutes Read

Automation Anywhere is a technology company headquartered in San Jose, California, USA. It is a provider of an end-to-end Robotic Process Automation (RPA) and Artificial Intelligence (AI) platform for automating any business process. They offer Discovery Bot for fast-track automation, IQ Bot for transforming unstructured and hidden data with AI that can learn on its own, Bot Insight for real-time analytics, and a Bot Store to get pre-built automation solutions.

This tutorial shows how to create an Automation Anywhere Task Bot that sends form data to PDF.co and returns a filled PDF. The bot uses the PDF.co PDF Add API through Automation Anywhere’s REST Web Services action.

Prerequisites

  • An Automation Anywhere Community Edition or Enterprise account
  • A PDF.co account and API key
  • A fillable PDF available through a publicly accessible URL
  • The Automation Anywhere Bot Agent installed on the device that will run the bot

Access the Control Room

Register for Automation Anywhere and follow the activation instructions sent to your email.

Use the supplied Control Room URL to set your password and sign in.

Install the Bot Agent

The Bot Agent connects your local device to the Automation Anywhere Control Room and is required to run the bot.

From the Control Room:

  1. Select the option to connect a local device.
  2. Download and install the Bot Agent.
  3. Enable the requested browser extension.
  4. Complete the device registration process.

See the Automation Anywhere Bot Agent documentation for installation requirements.

Create a Task Bot

In the Control Room:

  1. Open Automation.
  2. Click Create.
  3. Select Task Bot.
  4. Enter a name such as PDF.co Fill Form.
  5. Create the bot.

A Task Bot provides the step-by-step action editor needed for this workflow.

Add the REST Web Services Action

In the bot’s Flow view:

  1. Click Quick add between Start and End.
  2. Search for REST Web Services.
  3. Select Post method.

Configure the Request

Enter the following URI:

https://api.pdf.co/v1/pdf/edit/add

Leave the Authentication setting as No Authentication. The PDF.co API key will be supplied through a custom request header.

Set the content type to:

JSON (application/json)

Add the API Key Header

Under Custom headers, add a header with these values:

  • Name: x-api-key
  • Value type: Insecure string
  • Value: Your PDF.co API key

The value field may initially use Credential mode. Change it to Insecure string before entering the API key directly.

Add the Request Body

Under Custom parameters, enter the following JSON:

{
  "name": "f1040-form-filled",
  "url": "https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-form/f1040.pdf",
  "fieldsString": "1;topmostSubform[0].Page1[0].f1_02[0];John A. Doe|1;topmostSubform[0].Page1[0].FilingStatus[0].c1_01[1];true|1;topmostSubform[0].Page1[0].YourSocial_ReadOrderControl[0].f1_04[0];123456789"
}

The fieldsString property uses this structure:

page;fieldName;value

Separate multiple fields with a pipe character:

page;fieldName;value|page;fieldName;value

Page numbering starts at 0. The sample uses page 1 because the PDF contains a cover page before the form.

Replace the sample field names and values when using your own PDF template. You can use the PDF.co PDF Inspector to inspect the template and identify its form field names.

Capture the API Response

Under Assign the output to a variable:

  1. Select Multiple variables.
  2. Click Add variable mapping.
  3. Enter Body as the key.
  4. Create a new String variable named Body.
  5. Map the response body to that variable.

The variable will contain the JSON response returned by PDF.co.

Display the Response

Add a Message Box action after the REST Web Services action.

In the message field, enter:

$Body$

This displays the complete PDF.co response when the bot finishes.

Save and Run the Bot

Save the Task Bot and click Run. Select the registered device if prompted.

After a successful request, the message box displays a JSON response containing the URL of the filled PDF. Open that URL to review the result.

PDF.co output URLs are temporary. Download the file or send it to permanent storage if it must be retained.

Conclusion

You have created an Automation Anywhere Task Bot that sends form values to the PDF.co PDF Add API, fills the corresponding fields, and returns a downloadable PDF.

Related Tutorials

See Related Tutorials