Skip to main content

PDF Forms

Endpoints for working with interactive form fields in PDF documents.

Fill Form Fields

POST https://api.getdocuforge.dev/v1/pdf/forms/fill Fill existing form fields in a PDF with provided values.

Request Body

ParameterTypeRequiredDescription
pdfstringYesBase64-encoded PDF document
fieldsobject[]YesArray of field name/value pairs (see below)
flattenbooleanNoIf true, flatten form fields after filling (makes them non-editable). Default: false
outputstringNo"url" (default) or "base64"

Field Object

ParameterTypeRequiredDescription
namestringYesForm field name
valuestring or booleanYesValue to set. Use string for text fields, boolean for checkboxes

Example

curl -X POST https://api.getdocuforge.dev/v1/pdf/forms/fill \
  -H "Authorization: Bearer df_live_sk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "pdf": "<base64-encoded-pdf>",
    "fields": [
      { "name": "full_name", "value": "Jane Doe" },
      { "name": "email", "value": "jane@example.com" },
      { "name": "agree_terms", "value": true }
    ],
    "flatten": true
  }'

Response

{
  "url": "https://cdn.getdocuforge.dev/gen_abc123.pdf",
  "file_size": 55200
}

Add Form Fields

POST https://api.getdocuforge.dev/v1/pdf/forms/add-fields Add new interactive form fields to an existing PDF.

Request Body

ParameterTypeRequiredDescription
pdfstringYesBase64-encoded PDF document
fieldsobject[]YesArray of field definitions (see below)
outputstringNo"url" (default) or "base64"

Field Definition

ParameterTypeRequiredDescription
namestringYesUnique field name
typestringYes"text", "checkbox", or "dropdown"
pageintegerYesPage index (0-based)
xnumberYesX coordinate
ynumberYesY coordinate
widthnumberNoField width in points
heightnumberNoField height in points
optionsstring[]NoDropdown options (required for "dropdown" type)
defaultValuestring or booleanNoDefault value for the field

Example

curl -X POST https://api.getdocuforge.dev/v1/pdf/forms/add-fields \
  -H "Authorization: Bearer df_live_sk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "pdf": "<base64-encoded-pdf>",
    "fields": [
      {
        "name": "full_name",
        "type": "text",
        "page": 0,
        "x": 100,
        "y": 700,
        "width": 200,
        "height": 20
      },
      {
        "name": "country",
        "type": "dropdown",
        "page": 0,
        "x": 100,
        "y": 650,
        "width": 200,
        "height": 20,
        "options": ["United States", "Canada", "United Kingdom"]
      },
      {
        "name": "agree_terms",
        "type": "checkbox",
        "page": 0,
        "x": 100,
        "y": 600
      }
    ]
  }'

Response

{
  "url": "https://cdn.getdocuforge.dev/gen_abc123.pdf",
  "file_size": 61500
}

List Form Fields

POST https://api.getdocuforge.dev/v1/pdf/forms/list-fields List all form fields in a PDF document.

Request Body

ParameterTypeRequiredDescription
pdfstringYesBase64-encoded PDF document

Example

curl -X POST https://api.getdocuforge.dev/v1/pdf/forms/list-fields \
  -H "Authorization: Bearer df_live_sk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "pdf": "<base64-encoded-pdf>"
  }'

Response

{
  "fields": [
    { "name": "full_name", "type": "text", "value": "" },
    { "name": "email", "type": "text", "value": "" },
    { "name": "agree_terms", "type": "checkbox", "value": false }
  ],
  "total": 3
}

Errors

All form endpoints return the same error codes:
StatusCodeDescription
400VALIDATION_ERRORInvalid request body or PDF exceeds size limit
401UNAUTHORIZEDInvalid or missing API key
429RATE_LIMITEDToo many requests
500INTERNAL_ERRORServer error processing form fields