|
pdfRest PDF Forms Pro Self-Hosted API Reference Guide
REST APIs supporting PDF forms document processing capabilities through GET and POST HTTP requests
Welcome to the PDF Forms Pro Self-Hosted API Reference Guide! Below you will find all of the information you will need to use any of the PDF Forms Pro API Tools. This guide is organized by API endpoints, which express the output file types that can be generated from input files supplied with requests. For example, to flatten forms in a PDF file, you would send a PDF with forms to the /flattened-forms-pdf endpoint.
Note that the examples throughout are presented using cURL, but the APIs support any standard method for sending GET and POST HTTP requests.
Additional Resources
- Setup Instructions for AWS Self-Hosted Backend - learn how to launch and configure an EC2 and create a scalable stack
- API Lab - an intuitive interface to learn the tools and parameters, build code automatically, send API calls directly from the website, and download output files
- GitHub Repository - functional code examples available for several popular languages
- Postman Collection - preconfigured API calls ready to send using the Postman API Platform
Summary Retrieve a resource or its URL by ID. Resource IDs can be found in the JSON response of POST requests. Examples curl -X GET "YOUR_DOMAIN_HERE/resource/0950b9bdf-0465-4d3f-8ea3-d2894f1ae839?format=file" --output "@PATH_TO_FILE/output_file.pdf" curl -X GET "YOUR_DOMAIN_HERE/resource/112f7ea0d-0e56-44bc-a3d2-42fdff96d993?format=url"
Path Parameters
Name | Description | Default | Required |
id | Alphanumeric ID (UUID) of the resource to return
Accepts: Any valid resource ID returned by a POST request
Example: 0950b9bdf-0465-4d3f-8ea3-d2894f1ae839 | None | Yes |
format | Specify whether to return the file directly, URL to the file, or information about the file
Accepts:
- file - return the file itself
- url - return JSON containing the URL of the resource file
- info - return JSON containing detailed information about the file:
- resource ID
- file name
- url
- file type
- file size (bytes)
- last modified datetime
| None | Yes |
Responses
Response Status Code | Description | JSON Response Example |
200 | OK | {
"url": "YOUR_DOMAIN_HERE/resource/0950b9bdf-0465-4d3f-8ea3-d2894f1ae839?format=file" } |
200 | OK (format = info) | { "id":"2e523af74-7de9-492a-b7c6-c96eacd18a3a", "name":"smallword.doc", "url":"YOUR_DOMAIN_HERE/resource/2e523af74-7de9-492a-b7c6-c96eacd18a3a?format=file", "type":"application/msword", "size":22528, "modified":"2023-05-19T16:22:56.780Z" } |
400 | Bad Request | {
"error": "Invalid Request" } |
404 | Not Found | {
"error": "That file does not exist" } |
Summary
Import data from a file into an Acroform or XFA-based PDF form. This will find matching form fields in the PDF and fill those fields with the corresponding data from the data file.
Accepted data file formats vary, depending on the form type in the input PDF:
- Acroform: .fdf, .xfdf, .xml
- XFA: .xdp, .xfd, .xml
Examples curl -X POST "YOUR_DOMAIN_HERE/pdf-with-imported-form-data" -H "Accept: application/json" -H "Content-Type: multipart/form-data" -F "file=@/path/to/file" -F "output=example_out" -F "data_file=@/path/to/datafile" Required Headers Accept: application/json Content-Type: multipart/form-data
Body Parameters
Name | Description | Default | Required |
file | File to be uploaded and processed
Accepts: Any PDF file containing forms with edit permissions active
Example: @PATH_TO_FILE/example_file.pdf | None | One of: |
id | Alphanumeric ID (UUID) of existing file on server to be processed
Accepts: Any valid resource ID returned by a POST request
Example: 0950b9bdf-0465-4d3f-8ea3-d2894f1ae839 | None | One of: |
data_file | Data file to be uploaded in order to import its data to an input PDF file
Accepts: Accepted data file formats vary, depending on the form type in the input PDF: - Acroform: .fdf, .xfdf, .xml
- XFA: .xdp, .xfd, .xml
Example: @PATH_TO_FILE/example_file.xml | None | Yes |
output | Name of the generated output file, without extension
Accepts: Any valid file name
Example: example_out | [INPUT_FILE_NAME]_pdfrest_pdf-with-imported-form-data | No |
Responses
Response Status Code | Description | JSON Response Example |
200 | OK | {
"outputUrl": "YOUR_DOMAIN_HERE/resource/01240b25a-8936-4437-8652-8410130f1199?format=file"
"outputId": "01240b25a-8936-4437-8652-8410130f1199"
"inputId": "138aadb71-ee34-4621-9098-9686441e84e2" } |
400 | Bad Request | {
"error": "A data file is required to import data into a form. Use 'data_file' to upload a file." } |
Summary
Export form field data from an Acroform or XFA-based PDF form to an external data file.
Supported data file formats vary, depending on the form type in the input PDF:
- Acroform: .fdf, .xfdf, .xml
- XFA: .xdp, .xfd, .xml
Examples curl -X POST "YOUR_DOMAIN_HERE/exported-form-data" -H "Accept: application/json" -H "Content-Type: multipart/form-data" -H "Api-Key: xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -F "file=@/path/to/file" -F "data_format=xml" -F "output=example_out" Required Headers Accept: application/json Content-Type: multipart/form-data
Body Parameters
Name | Description | Default | Required |
file | File to be uploaded and processed
Accepts: Any PDF file containing forms
Example: @PATH_TO_FILE/example_file.pdf | None | One of: |
id | Alphanumeric ID (UUID) of existing file on server to be processed
Accepts: Any valid resource ID returned by a POST request
Example: 0950b9bdf-0465-4d3f-8ea3-d2894f1ae839 | None | One of: |
data_format | Data file format for the exported form data
Accepts: Supported data file formats vary, depending on the form type in the input PDF: - Acroform: fdf, xfdf, xml
- XFA: xdp, xfd, xml
Example: xml | None | Yes |
output | Name of the generated output data file, without extension
Accepts: Any valid file name
Example: example_out | [INPUT_FILE_NAME]_pdfrest_exported-form-data | No |
Responses
Response Status Code | Description | JSON Response Example |
200 | OK | {
"outputUrl": "YOUR_DOMAIN_HERE/resource/01240b25a-8936-4437-8652-8410130f1199?format=file"
"outputId": "01240b25a-8936-4437-8652-8410130f1199"
"inputId": "138aadb71-ee34-4621-9098-9686441e84e2" } |
400 | Bad Request | {
"error": "Input PDF contains XFA form fields. Valid options for data_format are: xfd, xdp, xml" } |
Summary Flatten all forms in a PDF, including both static and dynamic XFA and AcroForms. This makes form fields no longer editable while preserving form field data. It also ensures that PDFs with forms are compatible with all standard PDF viewers and processing tools. Examples curl -X POST "YOUR_DOMAIN_HERE/flattened-forms-pdf" -H "Accept: application/json" -H "Content-Type: multipart/form-data" -H "Api-Key: xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -F "file=@/path/to/file" -F "output=example_out" Required Headers Accept: application/json Content-Type: multipart/form-data
Body Parameters
Name | Description | Default | Required |
file | File to be uploaded and processed
Accepts: Any PDF file
Example: @PATH_TO_FILE/example_file.pdf | None | One of: |
id | Alphanumeric ID (UUID) of existing file on server to be processed
Accepts: Any valid resource ID returned by a POST request
Example: 0950b9bdf-0465-4d3f-8ea3-d2894f1ae839 | None | One of: |
output | Name of the generated output file, without extension
Accepts: Any valid file name
Example: example_out | [INPUT_FILE_NAME]_pdfrest_flattened-forms-pdf | No |
Responses
Response Status Code | Description | JSON Response Example |
200 | OK | {
"outputUrl": "YOUR_DOMAIN_HERE/resource/01240b25a-8936-4437-8652-8410130f1199?format=file"
"outputId": "01240b25a-8936-4437-8652-8410130f1199"
"inputId": "138aadb71-ee34-4621-9098-9686441e84e2" } |
400 | Bad Request | {
"error": "This route will only accept a File or an ID, not both." } |
Summary Convert XFA forms to Acroforms. This significantly improves compatibility, allowing forms to be accessed and edited across a wide range of PDF readers and applications.
Examples
curl -X POST "YOUR_DOMAIN_HERE/pdf-with-acroforms" -H "Accept: application/json" -H "Content-Type: multipart/form-data" -H "Api-Key: xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -F "file=@/path/to/file" -F "output=example_out" Required Headers Accept: application/json Content-Type: multipart/form-data
Body Parameters
Name | Description | Default | Required |
file | File to be uploaded and processed
Accepts: Any PDF file
Example: @PATH_TO_FILE/example_file.pdf | None | One of: |
id | Alphanumeric ID (UUID) of existing file on server to be processed
Accepts: Any valid resource ID returned by a POST request
Example: 0950b9bdf-0465-4d3f-8ea3-d2894f1ae839 | None | One of: |
output | Name of the generated output file, without extension
Accepts: Any valid file name
Example: example_out | [INPUT_FILE_NAME]_pdfrest_pdf-with-acroforms | No |
Responses
Response Status Code | Description | JSON Response Example |
200 | OK | {
"outputUrl": "YOUR_DOMAIN_HERE/resource/01240b25a-8936-4437-8652-8410130f1199?format=file"
"outputId": "01240b25a-8936-4437-8652-8410130f1199"
"inputId": "138aadb71-ee34-4621-9098-9686441e84e2" } |
200 | Warning | {
"warning": "No XFA forms were detected in the input PDF. No output was produced." } |
400 | Bad Request | {
"error": "This route will only accept a File or an ID, not both." } |
401 | Unauthorized | {
"error": "An Api-Key header is required to send this request." } |
© 2024 Datalogics, Inc. All rights reserved. |