How to Convert PDF to Excel with cURL

Learn how to use pdfRest PDF to Excel API Tool to convert PDF files to Excel spreadsheets with cURL
Share this page

Why Use PDF to Excel with cURL?

The pdfRest PDF to Excel API Tool is a powerful resource for converting PDF documents into editable Excel files. This tool is particularly useful for automating the process of extracting data from PDFs and making it available for analysis or reporting in a more flexible format like Excel. This tutorial will demonstrate how to make an API call to the PDF to Excel endpoint using cURL, a widely used command-line tool for transferring data with URLs.

You might need to convert financial reports, invoices, or data tables from PDF to Excel to perform calculations, sort data, or integrate it with other datasets. For instance, an accountant could use this API to convert batches of financial statements into Excel, enabling efficient data manipulation and analysis without the need for manual data entry.

PDF to Excel with cURL Code Example

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

Reference to the provided code: pdf-rest-api-samples on GitHub.

Breaking Down the Code

This cURL command is used to send a POST request to the PDF to Excel API endpoint:

-X POST "https://api.pdfrest.com/excel"

The -X POST specifies that this is a POST request, which is required to send data to the server to create or update resources.

Headers are set to specify the expected response format and the content type of the request:

-H "Accept: application/json"
-H "Content-Type: multipart/form-data"

The Accept: application/json header tells the server that the client expects a JSON response. The Content-Type: multipart/form-data header indicates that the request body contains form data.

The API key is included as a header for authentication:

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

Replace xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx with your actual API key provided by pdfRest.

The file to be converted is included in the form data:

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

The -F flag denotes form data. The file=@/path/to/file specifies the path to the PDF file that needs to be converted. The @ symbol is used to upload a file with the given path.

Optionally, you can specify the output filename:

-F "output=example_out"

The output=example_out form field sets the base name for the output file. The server will append the appropriate file extension.

Beyond the Tutorial

By following this tutorial, you have learned how to use cURL to call the pdfRest PDF to Excel API to convert a PDF document into an Excel file. This is just one example of the capabilities of pdfRest's API tools. You can explore and demo all of the pdfRest API Tools in the API Lab and refer to the API Reference Guide for more detailed information on the available endpoints and their functionalities.

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

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