How to Extract PDF to CSV with PDF.co API and Postman
This tutorial explains how to convert a PDF document into CSV using the PDF.co Web API and Postman. The PDF-to-CSV endpoint extracts rows, columns, and tables from regular or scanned PDFs.
Requirements
Before starting, make sure you have:
- A PDF.co account
- Your PDF.co API key
- The Postman desktop application
- A PDF with tabular or column-based data
Step 1: Download the PDF.co Postman Collection JSON
Download the actual JSON collection file:
Download the PDF.co Postman Collection JSON
The downloaded file should be named similarly to:
PDF.co+API+v.1.00.postman_collection.jsonDo not save the documentation page itself. Postman needs the .json collection file.
Step 2: Import the Collection into Postman
Open the Postman desktop application.
From the application menu, select:
File → Import
Select the downloaded JSON file or drag it into the import window. Review the import summary and complete the import.
After the import finishes, open Collections in the Postman sidebar. The imported PDF.co API v.1 collection should appear there.
Step 3: Configure the PDF.co API Key
The collection uses your PDF.co API key to authenticate requests.
Create or select a Postman environment and add the following variable:
- Variable:
x-api-key - Value: Your PDF.co API key
Save the environment and select it as the active environment.
Confirm that the request contains this header:
x-api-key: {{x-api-key}}It should also contain:
Content-Type: application/jsonKeep API keys in a private Postman environment or another protected variable scope. Do not place a real key in documentation, screenshots, shared collections, or source control.
Step 4: Open the PDF-to-CSV Request
In the Postman sidebar:
- Open Collections.
- Expand PDF.co API v.1.
- Expand the top-level PDF to CSV folder.
- Select the request for:
POST /pdf/convert/to/csvPDF to CSV is its own folder in the current collection.
The complete endpoint URL is:
https://api.pdf.co/v1/pdf/convert/to/csvThe request method must be POST.
Step 5: Configure the Request Body
Open the request’s Body tab.
Select raw and choose JSON as the body format. Use a request body such as:
{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-to-csv/sample.pdf",
"lang": "eng",
"inline": false,
"pages": "0-",
"async": false,
"name": "result.csv"
}Replace the sample URL with a direct, publicly accessible URL to your PDF when you are ready to process your own document.
The primary parameters are:
url: Direct URL to the source PDF.lang: OCR language used for scanned pages. The default is English (eng).inline: Whenfalse, PDF.co returns a temporary URL for the generated CSV.pages: Pages to process.0-selects every page.async: Whenfalse, the request waits for the conversion result.name: Filename for the generated CSV.
The supported parameters are listed in the PDF.co PDF-to-CSV API documentation.
Step 6: Choose the Pages to Convert
PDF.co uses zero-based page numbering:
0means the first page.1means the second page.0-means the first page through the final page.0,2,4selects the first, third, and fifth pages.2-5selects the third through sixth pages.2-selects the third page through the final page.
Leave pages empty if you want the endpoint’s default behavior of processing all pages.
Step 7: Configure Optional Extraction Settings
You can add optional parameters when the source document requires them.
Password-Protected PDFs
Add the password property:
{
"password": "document-password"
}Do not include a password for an unprotected PDF.
Scanned PDFs
Set lang to the document’s OCR language:
{
"lang": "eng"
}Two languages can be combined when necessary:
{
"lang": "eng+deu"
}Multiline Table Cells
The lineGrouping option controls how extracted lines are combined:
1: Group by rows2: Group by columns3: Join orphaned rows
When using unwrap, set lineGrouping to 1.
For example:
{
"lineGrouping": "1",
"unwrap": true
}Extract a Specific Area
Use rect to restrict extraction to a region of each selected page:
x y width heightFor example:
{
"rect": "50 100 500 600"
}Step 8: Send the Request
Select Send.
Postman will display the HTTP response below the request. Confirm that:
- The HTTP status is
200 OK. errorisfalse.statusis200.- The response includes a
urlfor the generated CSV.
A successful response may resemble:
{
"url": "https://pdf-temp-files.s3.amazonaws.com/.../result.csv",
"pageCount": 2,
"error": false,
"status": 200,
"name": "result.csv",
"remainingCredits": 1000,
"credits": 20
}The exact URL, credit values, and page count will vary.
Step 9: Download the CSV File
Copy the returned url value and open it in a browser, or send a GET request to that URL from Postman.
Download the CSV and open it in Excel, Google Sheets, or another spreadsheet application. Confirm that the rows and columns match the source PDF.
PDF.co output URLs are temporary. Download the CSV or move it into permanent storage before the link expires.
Return CSV Directly in the Response
To receive the extracted CSV content inside the API response, set:
{
"inline": true
}With inline output enabled, the response contains a body property holding the CSV text. This is useful when another application will process the CSV immediately and no downloadable file is required.
For example:
{
"body": "\"Product\",\"Quantity\",\"Price\"\r\n\"Item 1\",\"2\",\"50.00\"\r\n",
"pageCount": 1,
"error": false,
"status": 200,
"name": "result.csv"
}Equivalent cURL Request
The following cURL request performs the same synchronous conversion and returns a downloadable CSV URL:
curl --location 'https://api.pdf.co/v1/pdf/convert/to/csv' \
--header 'Content-Type: application/json' \
--header 'x-api-key: INSERT_YOUR_API_KEY_HERE' \
--data '{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-to-csv/sample.pdf",
"lang": "eng",
"inline": false,
"pages": "0-",
"async": false,
"name": "result.csv"
}'Replace INSERT_YOUR_API_KEY_HERE with your PDF.co API key before running the command.
Troubleshooting
Postman Imports a Web Page Instead of a Collection
Use the direct JSON download link:
PDF.co Postman Collection JSON
Confirm that the downloaded file ends in .json.
The PDF-to-CSV Request Cannot Be Found
Open the top-level PDF to CSV folder inside the PDF.co API v.1 collection.
The Request Returns 401 Unauthorized
Confirm that:
- The
x-api-keyenvironment variable contains a valid PDF.co API key. - The intended environment is active.
- The request header uses
{{x-api-key}}. - There are no extra spaces in the variable value.
PDF.co Cannot Access the Source PDF
The url value must point directly to a downloadable PDF. A private file-sharing or browser-preview page may not give PDF.co access to the document.
Upload the file to PDF.co storage or use an accessible direct-download URL.
The Response Does Not Contain a Download URL
Check the inline setting. When inline is true, the CSV is returned in the response’s body property. Set it to false when you need a temporary download URL.
The CSV Columns Are Incorrect
Try a different column-detection profile or line-grouping mode. PDFs store visual content rather than true spreadsheet cells, so irregular spacing, borderless tables, and overlapping text can affect extraction.
The PDF Contains Scanned Pages
Set the appropriate OCR language in lang. You can also use PDF.co profiles to adjust OCR mode, resolution, and preprocessing.
Conclusion
You have imported the PDF.co Postman collection from its JSON file, configured authentication, located the top-level PDF to CSV folder, and converted a PDF through the POST /v1/pdf/convert/to/csv endpoint.
You can now reuse the request with other documents, page ranges, OCR languages, passwords, and extraction settings.
Related Tutorials
