How to Export PDF Form Data with cURL

Learn how to extract PDF form field values with pdfRest Export Form Data using cURL
Share this page

Why Export Form Data with cURL?

The pdfRest Export Form Data API Tool is a powerful utility that allows users to extract form data from PDF documents. By using cURL, a command-line tool for transferring data with URLs, you can automate and streamline the process of sending requests to this API endpoint. This tutorial will guide you through the process of making an API call to export form data using cURL, demonstrating how to set up and execute the request effectively.

You might have a large number of PDF forms that need to be processed to extract data for analysis or record-keeping. For example, a company might collect customer feedback through PDF forms and need to export this data into a structured format like XML for further processing. Using the Export Form Data API with cURL simplifies this task by allowing you to automate data extraction, saving time and reducing the potential for human error.

Export Form Data with cURL Code Example

curl -X POST "https://api.pdfrest.com/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"

Source: GitHub Repository

Breaking Down the Code

The provided cURL command sends a POST request to the https://api.pdfrest.com/exported-form-data endpoint. Let's break down each part of the command:

-X POST "https://api.pdfrest.com/exported-form-data"

This specifies that we are making a POST request to the Export Form Data endpoint.

-H "Accept: application/json"

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

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

This header indicates that the request body will contain multiple parts, such as files and form fields. This is necessary for uploading files.

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

The API key is a unique identifier used to authenticate the request. Replace the placeholder with your actual API key.

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

This option uploads the file specified by the path. The '@' symbol is used to denote that the content of the file should be uploaded.

-F "data_format=xml"

This form field specifies the format of the exported data. In this case, it is set to 'xml'.

-F "output=example_out"

This specifies the name of the output file where the exported data will be saved.

Beyond the Tutorial

In this tutorial, we successfully demonstrated how to use cURL to make an API call to pdfRest's Export Form Data endpoint. This allows you to automate the extraction of form data from PDF files, which can be particularly useful for processing large volumes of documents efficiently.

To further explore the capabilities of the pdfRest API, you can try out all of the available tools in the API Lab. For more detailed information, refer to the API Reference Guide.

Note: This example showcases a multipart API call. For code samples using JSON payloads, visit the GitHub Repository.

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