Fill a PDF Form - Auto Populate Forms API
PDF4me Fill a PDF Form enables you to fill form fields in PDF documents with data. This API service processes PDF templates and populates form fields with structured data. The API receives PDF templates and form data through REST API calls, utilizing Base64 encoding for secure transmission. With support for dynamic data arrays and flexible output formats, this solution is ideal for document automation and form processing workflows.
Authenticating Your API Request
To access the PDF4me REST API, every request must include proper authentication credentials. Authentication ensures secure communication and validates your identity as an authorized user of the REST API.
Key Features
- Form Field Filling: Populate PDF form fields with structured data
- Template Processing: Use PDF templates with predefined form fields
- Data Array Support: Process form data as JSON arrays
- Flexible Output: Support for various output types
- Base64 Encoding: Secure file content transmission using Base64 encoding
- Simple API Integration: RESTful API designed for automated PDF form processing workflows
REST API Endpoint
The PDF4me REST API uses standard HTTP methods to interact with resources. All PDF form filling operations are performed through a single endpoint:
- Method: POST
- Endpoint:
/api/v2/FillPdfForm
REST API Parameters
Complete list of parameters for the Fill a PDF Form REST API. Parameters are organized by category for better understanding and implementation.
Important: Parameters marked with an asterisk (*) are required and must be provided for the API to function correctly.
Required Parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
| templateDocContent* | Base64 | The content of the PDF form template encoded in Base64 format | JVBERi... |
| templateDocName* | String | PDF form template file name with .pdf extension | form.pdf |
| dataArray* | String | JSON string with form field values | See Request Example below |
| outputType* | String | Output type (must be "pdf") | pdf |
| inputDataType* | String | Input data type (must be "json") | json |
| InputFormData* | Array | Array of form field objects with fieldName and fieldValue | See Request Example below |
Optional Parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
| metaData | String | Additional metadata (optional) | "" |
| metaDataJson | String | Additional JSON metadata (optional) | "" |
| async | Boolean | Enable asynchronous processing. When true, the API returns a 202 status and provides a polling URL in the Location header | true |
Output
The PDF4me Fill a PDF Form REST API returns different responses based on the processing mode. The API returns the PDF as binary data for synchronous processing or provides a polling URL for asynchronous processing.
- Success Response
- Asynchronous Processing
- Error Responses
- Response Format Details
Synchronous Processing (Default)
When async is not set or set to false, the API processes the request immediately:
Status Code: 200 OK
Content-Type: application/pdf or application/octet-stream
Response Body:
The API returns the PDF file directly as binary data (not JSON).
How to Use:
- The response body contains the binary PDF data
- Save the response content directly as a PDF file
- No Base64 decoding is needed for binary responses
Example (JavaScript):
const response = await fetch(url, options);
const pdfBlob = await response.blob();
// Save or process pdfBlob directly
Asynchronous Processing
When async: true is set, the API processes the request asynchronously:
Status Code: 202 Accepted
Response Headers:
Location: https://api.pdf4me.com/api/v2/FillPdfForm/poll/12345-abcde-67890
Polling Process:
- Extract the
Locationheader from the 202 response - Poll the URL using GET requests
- Continue polling until you receive a 200 OK status
- The final response contains the binary PDF data
Polling Example:
// Initial request returns 202 with Location header
const response = await fetch(url, options);
const location = response.headers.get('Location');
// Poll until complete
while (true) {
const pollResponse = await fetch(location, { headers: { 'Authorization': 'Basic ' + apiKey } });
if (pollResponse.status === 200) {
const pdfBlob = await pollResponse.blob();
// Process binary PDF
break;
}
await new Promise(resolve => setTimeout(resolve, 2000)); // Wait 2 seconds
}
Error Responses
| Status Code | Description | Example Response |
|---|---|---|
| 400 Bad Request | Invalid request parameters or missing required fields | {"error": "Missing required parameter: InputFormData"} |
| 401 Unauthorized | Invalid or missing API key | {"error": "Unauthorized"} |
| 500 Internal Server Error | Server error during processing | {"error": "Internal server error"} |
Understanding the Response
- Synchronous (200): Returns binary PDF data directly
- Asynchronous (202): Returns Location header for polling, final response is binary PDF
- No JSON Wrapper: The API returns PDF as binary, not wrapped in JSON with Base64 encoding
Request Example
Header
Content-Type: application/json
Authorization: Basic YOUR_BASE64_ENCODED_API_KEY
Note: The API key must be Base64 encoded. Get your API key from the PDF4me Dashboard
Payload
{
"templateDocName": "form.pdf",
"templateDocContent": "JVBERi...",
"dataArray": "{\"firstname\": \"John\", \"lastname\": \"Adams\", \"gender\": \"Male\"}",
"outputType": "pdf",
"inputDataType": "json",
"InputFormData": [
{"fieldName": "firstname", "fieldValue": "John"},
{"fieldName": "lastname", "fieldValue": "Adams"},
{"fieldName": "gender", "fieldValue": "Male"}
],
"metaData": "",
"metaDataJson": "",
"async": true
}
Code Samples
The PDF4me Fill a PDF Form REST API provides code samples in multiple programming languages. Choose the language that best fits your development environment:
- C#
- Java
- JavaScript
- Python
- Salesforce
- n8n
- Google Script
- AWS Lambda
Google Script Sample
Google Apps Script implementation for Google Workspace integration:
Form Filling Features
Dynamic Data Processing
- Data Array Support: Process multiple data sets for batch form generation
- Template Recognition: Intelligent recognition of form fields in PDF templates
- Data Mapping: Accurate mapping of data to corresponding form fields
- Professional Results: High-quality form filling with precise field population
- Advanced Processing: Support for complex form layouts and multiple field types
Template Management
- PDF Templates: Use predefined PDF templates with form fields for consistent document generation
- Field Recognition: Automatic recognition and mapping of form fields in templates
- Data Integration: Seamless integration of structured data with template fields
- Professional Generation: High-quality document generation with accurate form filling
- Flexible Templates: Support for various template formats and field types
Advanced Features
- Metadata Processing: Include custom metadata and JSON data for enhanced document processing
- Batch Operations: Generate multiple documents from single template with different data sets
- Custom Data Types: Support for various input data formats and structures
- Professional Processing: High-quality data processing with accurate field mapping
- Flexible Options: Customizable processing parameters for specific requirements
Industry Use Cases & Applications
- Legal & Professional Services
- Healthcare & Medical
- Finance & Banking
- Human Resources
- Business & Enterprise
Legal & Professional Services Use Cases
- Contract Generation: Fill contract templates with client and project data
- Legal Document Processing: Automatically fill legal forms with case data
- Client Documentation: Generate filled forms from client information databases
- Compliance Forms: Fill compliance and regulatory forms automatically
Healthcare & Medical Use Cases
- Patient Forms: Automatically fill patient intake forms from medical records
- Insurance Claims: Generate filled insurance claim forms from billing data
- Medical Documentation: Fill medical forms with patient data and history
- Lab Reports: Generate filled lab result forms from test data
Finance & Banking Use Cases
- Invoice Processing: Generate filled invoices from billing data and templates
- Loan Applications: Automatically fill loan application forms from applicant data
- Financial Reports: Create filled reports from data sources and templates
- Account Documentation: Fill account opening forms with customer data
Human Resources Use Cases
- Application Processing: Automate application form filling for job applications and registrations
- Employee Onboarding: Fill employee onboarding forms from HR systems
- Performance Reviews: Generate filled performance review forms from evaluation data
- Survey Processing: Process large volumes of survey forms with structured data
Business & Enterprise Use Cases
- Document Automation: Automatically fill forms with data from databases and systems
- Form Processing: Process large volumes of forms with structured data
- Data Collection: Generate filled forms from collected data and surveys
- Business Process Automation: Automate form filling workflows for enterprise operations