Quick navigation:

1. Sign up and get your API key
2. Use IRS Form 1040
3. Use /pdf/info/fields endpoint to get the list of all fields in this PDF form
4. Copy and paste this code and add your API key
5. It will return all the form fields information like this
6. Now that we have a list of all fields. We can use /pdf/edit/add endpoint to fill them out
7. Copy and paste this code and add your API key
8. Copy and paste the resulting URL on your browser to see your filled-out PDF form
9. The filled-out IRS PDF Form will look like this

Useful resources:

Step by step guide:

1. Sign up and get your API key on https://app.pdf.co/signup

2. For this example, we will use IRS Form 1040

IRS Form 1040

3. Use /pdf/info/fields endpoint to get the list of all fields in this PDF form

4. Copy and paste this code and add your API key:

curl --location --request GET 'https://api.pdf.co/v1/pdf/info/fields?url=https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-form/f1040.pdf' \
--header 'x-api-key: YOUR_API_KEY_HERE'

5. It will return all the form fields information like this:

PDF Form Fields Result

6. Now that we have a list of all fields. We can use /pdf/edit/add endpoint to fill them out.

7. Copy and paste this code and add your API key:

curl --location --request POST 'https://api.pdf.co/v1/pdf/edit/add' \
--header 'Content-Type: application/json' \
--header 'x-api-key: YOUR_API_KEY_HERE' \
--data-raw '{
"async": false,
"encrypt": false,
"name": "f1040-filled",
"url": "https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-form/f1040.pdf",
"fields": [
{
"fieldName": "topmostSubform[0].Page1[0].FilingStatus[0].c1_01[1]",
"pages": "1",
"text": "True"
},
{
"fieldName": "topmostSubform[0].Page1[0].f1_02[0]",
"pages": "1",
"text": "John A."
},
{
"fieldName": "topmostSubform[0].Page1[0].f1_03[0]",
"pages": "1",
"text": "Doe"
},
{
"fieldName": "topmostSubform[0].Page1[0].YourSocial_ReadOrderControl[0].f1_04[0]",
"pages": "1",
"text": "123456789"
},
{
"fieldName": "topmostSubform[0].Page1[0].YourSocial_ReadOrderControl[0].f1_05[0]",
"pages": "1",
"text": "Joan B."
},
{
"fieldName": "topmostSubform[0].Page1[0].YourSocial_ReadOrderControl[0].f1_05[0]",
"pages": "1",
"text": "Joan B."
},
{
"fieldName": "topmostSubform[0].Page1[0].YourSocial_ReadOrderControl[0].f1_06[0]",
"pages": "1",
"text": "Doe"
},
{
"fieldName": "topmostSubform[0].Page1[0].YourSocial_ReadOrderControl[0].f1_07[0]",
"pages": "1",
"text": "987654321"
}

],
“annotations”:[
{
“text”:”Sample Filled with PDF.co API using /pdf/edit/add. Get fields from forms using /pdf/info/fields”,
“x”: 10,
“y”: 10,
“size”: 12,
“pages”: “0-“,
“color”: “FFCCCC”,
“link”: “https://pdf.co”
}
],
“images”: [
]
}’

8. Copy and paste the resulting URL on your browser to see your filled-out PDF form

cURL PDF Form 1040 resulting URL

9. The filled-out IRS PDF Form will look like this:

Filled-out PDF Form

Note: The output URL expires in 1 hour. You may need to generate a new URL once 1 hour has elapsed.

Related Samples: