AgKit AgKit Fill PDF

Fill PDF forms from the command line

Send a fillable PDF, or a link to one. /fields returns its fields as JSON, with a readable label for each. /fill takes your values and returns the filled PDF. Nothing is stored.

POST/fields

List the fields of a form. Send the PDF as file, or its link as url.

curl -s -X POST https://fillpdf.agkit.io/fields \
  -F url=https://www.irs.gov/pub/irs-pdf/fss4.pdf
{
  "xfa": true,
  "fields": [
    {
      "name": "topmostSubform[0].Page1[0].f1_2[0]",
      "label": "1 Legal name of entity (or individual) for whom the EIN is being requested",
      "description": "Type or print clearly. 1. Legal name of entity (or individual) ...",
      "page": 1,
      "type": "text",
      "required": false,
      "readOnly": false,
      "value": null,
      "maxLength": null,
      "multiline": false
    },
    {
      "name": "topmostSubform[0].Page1[0].c1_1[0]",
      "label": "Yes",
      "description": "8a. Is this application for a limited liability company (L L C) (or a foreign equivalent)? Yes.",
      "page": 1,
      "type": "checkbox",
      "required": false,
      "readOnly": false,
      "value": false
    }
  ]
}

label is the text printed with the field. description is the longer screen-reader text, when the form has it. Use name as the key in /fill.

POST/fill

Write values into the form and get the filled PDF back. Pass data as a JSON object of name to value.

curl -s -X POST https://fillpdf.agkit.io/fill -o filled.pdf \
  -F file=@fss4.pdf \
  -F 'data={"topmostSubform[0].Page1[0].f1_2[0]": "Jane Doe",
          "topmostSubform[0].Page1[0].c1_1[1]": true}'

Or send JSON with a link:

curl -s -X POST https://fillpdf.agkit.io/fill -o filled.pdf \
  -H 'content-type: application/json' \
  -d '{"url": "https://www.irs.gov/pub/irs-pdf/fss4.pdf",
       "data": {"topmostSubform[0].Page1[0].f1_2[0]": "Jane Doe"}}'
TypeValue
textA string, number or boolean
checkboxtrue or false
radioOne string from options
dropdown, optionlistA string from options, or an array when multiselect is true

null clears a field of any type.

The Worker checks every value before it writes any. If one fails, it writes nothing and returns 400 with a details object that names each bad field:

{"error": "Some fields cannot be filled",
 "details": {"topmostSubform[0].Page1[0].c1_1[0]": "Checkbox takes true or false"}}

Work with the output

Build a data template from the field list with jq, edit it, then fill:

curl -s -X POST https://fillpdf.agkit.io/fields -F file=@fss4.pdf \
  | jq '.fields | map({(.name): .value}) | add' > data.json

curl -s -X POST https://fillpdf.agkit.io/fill -o filled.pdf \
  -F file=@fss4.pdf -F 'data=<data.json'

See the labels next to the names:

curl -s -X POST https://fillpdf.agkit.io/fields -F file=@fss4.pdf \
  | jq -r '.fields[] | [.type, .name, .label] | @tsv'

Limits