pdfRest PDF Forms Pro Self-Hosted API Reference Guide
REST APIs supporting PDF forms document processing capabilities through GET and POST HTTP requests


Getting Started
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




API Endpoints
 GET  /resource/{id}

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
NameDescriptionDefaultRequired
idAlphanumeric ID (UUID) of the resource to return

Accepts:
Any valid resource ID returned by a POST request

Example:
0950b9bdf-0465-4d3f-8ea3-d2894f1ae839
NoneYes
formatSpecify 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
NoneYes


Responses
Response Status CodeDescriptionJSON Response Example
200OK
{
   "url": "YOUR_DOMAIN_HERE/resource/0950b9bdf-0465-4d3f-8ea3-d2894f1ae839?format=file"
}
200OK
(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"
}
400Bad Request
{
   "error": "Invalid Request"
}
404Not Found
{
   "error": "That file does not exist"
}



 POST  /pdf-with-imported-form-data

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
NameDescriptionDefaultRequired
fileFile to be uploaded and processed

Accepts:
Any PDF file containing forms with edit permissions active

Example:
@PATH_TO_FILE/example_file.pdf
NoneOne of:
  • file
  • id
idAlphanumeric 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
NoneOne of:
  • file
  • id
data_fileData 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
NoneYes
outputName of the generated output file, without extension

Accepts:
Any valid file name

Example:
example_out
[INPUT_FILE_NAME]_pdfrest_pdf-with-imported-form-dataNo


Responses
Response Status CodeDescriptionJSON Response Example
200OK
{
   "outputUrl": "YOUR_DOMAIN_HERE/resource/01240b25a-8936-4437-8652-8410130f1199?format=file"
"outputId": "01240b25a-8936-4437-8652-8410130f1199"
"inputId": "138aadb71-ee34-4621-9098-9686441e84e2"
}
400Bad Request
{
   "error": "A data file is required to import data into a form. Use 'data_file' to upload a file."
}



 POST  /exported-form-data

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
NameDescriptionDefaultRequired
fileFile to be uploaded and processed

Accepts:
Any PDF file containing forms

Example:
@PATH_TO_FILE/example_file.pdf
NoneOne of:
  • file
  • id
idAlphanumeric 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
NoneOne of:
  • file
  • id
data_formatData 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
NoneYes
outputName of the generated output data file, without extension

Accepts:
Any valid file name

Example:
example_out
[INPUT_FILE_NAME]_pdfrest_exported-form-dataNo


Responses
Response Status CodeDescriptionJSON Response Example
200OK
{
   "outputUrl": "YOUR_DOMAIN_HERE/resource/01240b25a-8936-4437-8652-8410130f1199?format=file"
"outputId": "01240b25a-8936-4437-8652-8410130f1199"
"inputId": "138aadb71-ee34-4621-9098-9686441e84e2"
}
400Bad Request
{
   "error": "Input PDF contains XFA form fields. Valid options for data_format are: xfd, xdp, xml"
}



 POST  /flattened-forms-pdf

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
NameDescriptionDefaultRequired
fileFile to be uploaded and processed

Accepts:
Any PDF file

Example:
@PATH_TO_FILE/example_file.pdf
NoneOne of:
  • file
  • id
idAlphanumeric 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
NoneOne of:
  • file
  • id
outputName of the generated output file, without extension

Accepts:
Any valid file name

Example:
example_out
[INPUT_FILE_NAME]_pdfrest_flattened-forms-pdfNo


Responses
Response Status CodeDescriptionJSON Response Example
200OK
{
   "outputUrl": "YOUR_DOMAIN_HERE/resource/01240b25a-8936-4437-8652-8410130f1199?format=file"
"outputId": "01240b25a-8936-4437-8652-8410130f1199"
"inputId": "138aadb71-ee34-4621-9098-9686441e84e2"
}
400Bad Request
{
   "error": "This route will only accept a File or an ID, not both."
}



 POST  /pdf-with-acroforms

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
NameDescriptionDefaultRequired
fileFile to be uploaded and processed

Accepts:
Any PDF file

Example:
@PATH_TO_FILE/example_file.pdf
NoneOne of:
  • file
  • id
idAlphanumeric 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
NoneOne of:
  • file
  • id
outputName of the generated output file, without extension

Accepts:
Any valid file name

Example:
example_out
[INPUT_FILE_NAME]_pdfrest_pdf-with-acroformsNo


Responses
Response Status CodeDescriptionJSON Response Example
200OK
{
   "outputUrl": "YOUR_DOMAIN_HERE/resource/01240b25a-8936-4437-8652-8410130f1199?format=file"
"outputId": "01240b25a-8936-4437-8652-8410130f1199"
"inputId": "138aadb71-ee34-4621-9098-9686441e84e2"
}
200Warning
{
   "warning": "No XFA forms were detected in the input PDF. No output was produced."
}
400Bad Request
{
   "error": "This route will only accept a File or an ID, not both."
}
401Unauthorized
{
   "error": "An Api-Key header is required to send this request."
}



© 2024 Datalogics, Inc. All rights reserved.