Overview
The form filling API lets you programmatically fill forms in PDFs and images. It works with both:- Native PDF forms - Forms with actual form fields
- Image-based forms - Scanned forms or images with visual form layouts
Basic Usage
Form Filling Options
| Option | Type | Default | Description |
|---|---|---|---|
field_data | dict | Required | Field names mapped to values and descriptions |
context | str | None | Additional context to help match fields |
confidence_threshold | float | 0.5 | Minimum confidence for field matching (0.0-1.0) |
max_pages | int | None | Maximum pages to process |
page_range | str | None | Specific pages to process (e.g., "0-2"). For spreadsheets, filters by sheet index. |
skip_cache | bool | False | Skip cached results |
Field Data Format
Each field infield_data is a dictionary with:
description helps the API match your field key to the actual form field, especially when field names in the PDF don’t match your data structure.
Example with Multiple Field Types
Using Context
Thecontext parameter provides additional information to improve field matching:
Confidence Threshold
Adjustconfidence_threshold to control field matching strictness:
- Lower values (0.3-0.5): More fields matched, but may have incorrect matches
- Higher values (0.7-0.9): Fewer fields matched, but more accurate
Form Filling Result
Result Fields
| Field | Type | Description |
|---|---|---|
success | bool | Whether form filling succeeded |
status | str | Processing status |
output_format | str | Output type: "pdf" or "png" |
output_base64 | str | Base64-encoded filled form |
fields_filled | list | Field names that were successfully filled |
fields_not_found | list | Field names that couldn’t be matched |
page_count | int | Number of pages processed |
runtime | float | Processing time in seconds |
cost_breakdown | dict | Cost details |
Saving the Filled Form
Filling Image Forms
The API also works with image-based forms (PNG, JPG, etc.):From URL
Fill a form from a URL:Async Usage
Handling Unmatched Fields
Check which fields couldn’t be matched:Example: Tax Form
Next Steps
Form Filling Recipe
Detailed guide on form filling with field matching and templates.
File Management
Upload, list, and manage files in Datalab storage.
Conversion SDK
Convert documents to Markdown, HTML, JSON, or chunks.
Pipelines
Chain processors into versioned, reusable pipelines.