How to Convert PDF to PDF/A with cURL

Learn how to use pdfRest Convert to PDF/A API Tool with cURL to prepare documents for long term preservation
Share this page

Why Use Convert to PDF/A with cURL?

pdfRest offers a Convert to PDF/A API Tool that enables users to convert documents into the PDF/A format, which is an ISO-standardized version of the Portable Document Format (PDF) specialized for the digital preservation of electronic documents. This tutorial will guide you through the process of sending an API call to convert a document to PDF/A using cURL, a powerful and versatile command-line tool used for transferring data with URLs.

Converting to PDF/A is crucial for industries and organizations that require long-term archival of electronic documents. For instance, legal departments, government agencies, and libraries often need to store documents in a format that will remain readable and unchanged for extended periods. By converting documents to PDF/A, users ensure that their files are compliant with archival standards, preventing future compatibility issues and preserving the integrity of the document's content.

Convert to PDF/A with cURL Code Example

curl -X POST "" \
  -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" \
  -F "output_type=PDF/A-1b" \
  -F "rasterize_if_errors_encountered=off"

Reference to the code: pdf-rest-api-samples

Breaking Down the Code

This cURL command is structured to send a POST request to the pdfRest API endpoint for converting files to PDF/A. Let's break down the components of this command:

-X POST ""

This specifies that we are making a POST request to the pdfRest Convert to PDF/A API endpoint.

-H "Accept: application/json"

This header tells the server that the client expects a response in JSON format.

-H "Content-Type: multipart/form-data"

This header indicates that the data being sent in the request is in multipart form data format, which is suitable for file uploads.

-H "Api-Key: xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

This header is where you include your unique API key provided by pdfRest to authenticate your request.

-F "file=@/path/to/file"

This form field specifies the file to be converted. The '@' symbol indicates that a file is attached, followed by the path to the file on your local system.

-F "output=example_out"

This form field sets the prefix for the output file's name.

-F "output_type=PDF/A-1b"

This form field specifies the type of PDF/A to which the document should be converted. In this case, PDF/A-1b ensures that the document is visually preserved for long-term archiving.

-F "rasterize_if_errors_encountered=off"

This form field tells the API whether to rasterize the pages if errors are encountered during the conversion process. Setting it to 'off' means that rasterization will not occur.

Beyond the Tutorial

By following the steps outlined above, you have learned how to use cURL to make an API call to pdfRest's Convert to PDF/A endpoint. This allows you to convert documents to a standardized format suitable for long-term archiving, ensuring their preservation and accessibility in the future.

To explore and demo all of the pdfRest API Tools, visit the API Lab. For more detailed information about the API and its capabilities, refer to the API Reference Guide.

Note: This is an example of a multipart API call. Code samples using JSON payloads can be found at pdf-rest-api-samples.

Generate a self-service API Key now!

Create your FREE API Key to start processing PDFs in seconds, only possible with pdfRest.

Compare Plans
Contact Us