Skip to main content

Convert PDF to Excel

PDF4me Convert PDF to Excel is a REST endpoint that extracts tables and text from a PDF and returns an editable Excel workbook. POST a Base64 PDF to /api/v2/ConvertPdfToExcel, pick Draft or High quality, enable OCR for scanned pages, and save the returned .xlsx bytes. One call, no manual retyping.

What this endpoint does

Sends one PDF in, gets one Excel workbook out. The engine detects table structures on each page and rebuilds them as spreadsheet cells, extracting the surrounding text alongside. qualityType switches between fast text-layer extraction (Draft) and per-page recognition for scans (High), and ocrWhenNeeded runs OCR automatically when a page has no text layer. The response is the raw .xlsx binary (200) or a Location poll URL (202).

Related Blog Posts
No blog post yet for this feature — coming soon.
In the meantime, browse the PDF4me blog for tutorials and workflows across every platform.
Visit the blog

Authenticating Your API Request

Every PDF4me REST call must include your API key in the Authorization header as Basic auth. Get or rotate your key from the developer dashboard.

Endpoint

POST/api/v2/ConvertPdfToExcel

Important Facts You Should Not Miss

Draft and High are billed differently
Draft costs 1 API call per file and reads the existing text layer. High costs 2 API calls per page and reprocesses every page, which is what makes scanned PDFs work. Do not run High on clean digital PDFs; you pay per page for nothing.
outputFormat and ocrWhenNeeded are booleans
The official code samples send true / false JSON booleans for both fields. Older copies of this page showed string values like "yes"; use booleans as in the samples below.
Async returns 202 + Location header
With async: true the API may respond 202 with a Location header. GET that URL (same Authorization) until it returns 200 with the workbook binary. The official samples poll every 10 seconds, up to 10 retries.

HTTP setup

Method: POST
URL: https://api.pdf4me.com/api/v2/ConvertPdfToExcel
Content-Type: application/json
Authorization: Basic <your PDF4me API key>

Send async: true in the body. 200 returns the converted .xlsx workbook as binary bytes. 202 returns a Location header with a poll URL; GET that URL with the same Authorization header until it returns 200 with the workbook binary.

Which quality mode should I choose: Draft vs High?

Draft reads the text layer that already exists inside a digitally created PDF. High re-renders and recognizes every page, which is slower and costs more but is the only mode that works on scans, photos of documents, and image-only pages.

Draft vs HighDraftHigh
Best forDigitally created PDFs with selectable textScanned or image-based PDFs
Cost1 API call per file2 API calls per page
OCRNot appliedApplied per page (pair with ocrWhenNeeded: true)
SpeedFast, single passSlower, per-page recognition
When tables come back emptyRetry with HighCheck language if text is garbled

API body fields

ParameterRequiredTypeWhat it doesExample
docContentRequiredstringBase64-encoded bytes of the source PDF. Strip any data:application/pdf;base64, prefix before posting.JVBERi0xLjcK...
docNameRequiredstringSource filename including the .pdf extension. Used to derive the output filename.invoice-report.pdf
qualityTypeRequiredstringDraft for text-based PDFs (1 API call per file). High for scanned or image-based PDFs (2 API calls per page).Draft
languageConditionalstringLanguage of the text in the source file. Set only when the converted output is not recognizable; otherwise let the engine detect it.English
mergeAllSheetsOptionalbooleantrue combines all extracted content into a single worksheet. false keeps content on separate worksheets.true
outputFormatOptionalbooleanOutput format flag sent as a JSON boolean in the official samples.true
ocrWhenNeededOptionalbooleanRuns OCR automatically on pages without a text layer. Keep true unless you explicitly want recognition skipped.true
asyncOptionalbooleantrue enables the 202 + Location polling pattern, recommended for large or scanned files.true

Sample payloads

Draft mode. digital PDF with selectable text

{
"docContent": "JVBERi0xLjcKJcfsj6IKNSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZw...",
"docName": "invoice-report.pdf",
"qualityType": "Draft",
"mergeAllSheets": true,
"outputFormat": true,
"ocrWhenNeeded": true,
"async": true
}

High mode. scanned PDF with OCR

{
"docContent": "JVBERi0xLjcKJcfsj6IKNSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZw...",
"docName": "scanned-statement.pdf",
"qualityType": "High",
"mergeAllSheets": false,
"language": "English",
"outputFormat": true,
"ocrWhenNeeded": true,
"async": true
}

Postman collection tips

Headers
Content-Type: application/json + Authorization: Basic <apiKey>.
Body
raw JSON. Copy one of the payloads above and replace docContent with your Base64.
Response
Use Send and Download so Postman saves the binary body as a .xlsx file when status is 200. If 202, GET the Location URL with the same Authorization until 200.
Quality
Start with Draft. Only switch to High when tables come back empty, and expect 2 API calls per page in that mode.

curl example

curl -X POST https://api.pdf4me.com/api/v2/ConvertPdfToExcel \
-H "Content-Type: application/json" \
-H "Authorization: Basic YOUR_API_KEY" \
-d '{
"docContent": "'"$(base64 -w 0 invoice-report.pdf)"'",
"docName": "invoice-report.pdf",
"qualityType": "Draft",
"mergeAllSheets": true,
"outputFormat": true,
"ocrWhenNeeded": true,
"async": true
}' \
--output converted.xlsx

What does the API return?

A successful conversion returns the Excel workbook itself, not a JSON wrapper. The output is a modern Office Open XML workbook (.xlsx), the default XML-based format supported by every current version of Excel. Handle the three cases below.

FieldTypeWhat it contains
Response body (HTTP 200)BinaryThe converted .xlsx workbook bytes. Write them straight to a file with an .xlsx extension.
Location header (HTTP 202)String (URL)Poll URL for an async job that is still running. GET it with the same Authorization header.
Poll response (HTTP 200)BinaryThe finished workbook, returned once processing completes. The official samples poll every 10 seconds, up to 10 retries.
Poll response (HTTP 202)EmptyJob still processing. Wait and poll the same Location URL again.

Code samples

Working end-to-end implementations, each with a sample PDF and the exact payload from this page:

FAQ

Which quality mode should I choose, Draft or High?+
Draft is for digitally created PDFs with a real text layer and costs 1 API call per file. High is for scanned or image-based PDFs and costs 2 API calls per page. Start with Draft; switch to High only when tables come back empty or garbled.
Can the API extract tables from a scanned PDF?+
Yes. Set qualityType to High and ocrWhenNeeded to true. The engine runs OCR on pages without a text layer and reconstructs detected tables as spreadsheet cells in the output workbook.
What does mergeAllSheets do?+
With mergeAllSheets true the extracted content is combined into a single worksheet. With false, content is kept on separate worksheets, so a multi-page PDF maps to multiple sheets in the workbook.
When do I need the language field?+
Only when the converted output is not recognizable. The engine detects the document language automatically; set language explicitly when recognition returns garbled text for your source language.
Is the response JSON or the file itself?+
The file itself. A 200 response body is the raw .xlsx binary. Do not JSON-parse it; write the bytes to disk. Only the 202 case involves reading a header (Location) instead of the body.
My tables came back as plain text without cell structure. What now?+
Rerun with qualityType High so each page goes through recognition, and keep ocrWhenNeeded true. If the text itself is garbled rather than misplaced, set the language field to match the document.
How large can the PDF be?+
Large and scanned files are exactly what the async pattern is for. Send async true and be prepared to poll the Location URL; the official samples poll every 10 seconds, up to 10 retries, before timing out.
Can I get XLS instead of XLSX?+
No. The endpoint returns a modern Open XML workbook (.xlsx). Legacy .xls output is not offered; every current version of Excel, LibreOffice, and Google Sheets opens .xlsx.

Same task on other platforms

Get Help