apyhub
Back
▣ INGESTION KIT · DOCUMENT INTELLIGENCE KIT

Convert PDF to XLSX, DOCX & TXT API

What it does

Convert PDF to XLSX, DOCX & TXT API is a scanned PDF to Excel API. Send a PDF and get back an XLSX workbook, a DOCX document or TXT text in one JSON response. It reads text PDFs directly and runs OCR on scanned pages.

Send the file as base64 in fileContent with its fileName, or send up to 10 PDFs in files. Choose the output with format: xlsx (default), docx or txt. Set language to match the text on scanned pages: eng (default), deu, bul or eng+deu+bul. In Excel output each page gets its own sheet. Set onOneSheet to true to put all pages on one sheet.

The response holds the converted file as base64, a preview of the extracted rows, and a page count. Teams use this scanned PDF to Excel API to move invoice and report tables into spreadsheets, turn scanned letters into editable Word files, and pull PDF text into search indexes.

Each call takes up to 10 files, 10 pages and 20 MB, counted across all files. Calls over these limits return a 400 error. OCR reads up to 5 scanned pages per call. For longer files, cut them into parts with the Split PDF by Page Range API first. Shrink heavy scans with the Compress PDF File API, or combine photos into one PDF with the Merge Files to PDF API before you convert.

POST
PDF to Excel / Word API - tables and text out of PDFs
https://api.eu.apyhub.com/martin10291/convert-pdf-to-excel-word-txt

QUICKSTART

GUIDE

Quickstart

Convert a local PDF to an Excel workbook (the default output).

curl -X POST "https://api.eu.apyhub.com/martin10291/convert-pdf-to-excel-word-txt" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"fileName": "sample.pdf", "fileContent": "'"$(base64 -w0 sample.pdf)"'"}'

What you'll get back

Returns a JSON object with count and items. For one PDF, the item holds the converted file as base64 in fileBase64, a preview of the extracted rows, and the number of pages converted in stats. For two or more PDFs, the item holds a files array with one output file per converted PDF.

{
  "count": 1,
  "items": [
    {
      "columns": [],
      "fileBase64": "UEsDBBQAAAAIAPdBgV1Gx01IlQAAAM0AAAAQAAAA...",
      "fileName": "sample.xlsx",
      "mime": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
      "rows": [
        ["Invoice 2026-001 Example Ltd"],
        ["Total 120.00 EUR"]
      ],
      "stats": { "Pages done": 1 },
      "title": "sample.pdf converted to Excel"
    }
  ]
}
TRY ITLIVE · 100 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
files
Use instead of fileContent to convert several PDFs in one call. Max 10 items, with 10 pages and 20 MB in total. If fileContent is also sent, all PDFs are converted.
Output format: xlsx (Excel), docx (Word) or txt (text returned in the JSON).
Name of the PDF, e.g. report.pdf. Used to name the output file. Default: file.

About this endpoint

What it does

Converts one PDF, or up to 10 PDFs, into an Excel, Word or plain text result. Text pages are read directly and scanned pages are read with OCR. The response returns the converted file as base64 together with a preview of the extracted rows.

Request Body

ParameterTypeDescription
fileContentStringRequired unless files is sent. The PDF as base64. A data URI (data:application/pdf;base64,...) is also accepted.
fileNameStringName of the PDF, e.g. report.pdf. Used to name the output file (report.xlsx). Default: file.
filesObject ArrayUse instead of fileContent to convert several PDFs in one call. Max 10 items, with 10 pages and 20 MB in total.
files[].fileNameStringName of this PDF, e.g. a.pdf.
files[].fileContentStringRequired. This PDF as base64 or a data URI.
formatENUMOutput format. Allowed values: xlsx, docx, txt. Default: xlsx.
languageENUMLanguage of the text on scanned pages, used by OCR. Allowed values: eng, deu, bul, eng+deu+bul. Default: eng.
onOneSheetBooleanExcel only. false puts each page on its own sheet (Page 1, Page 2, ...). true puts all pages on one sheet named All pages. Default: false.

Response

Returns a JSON object with count and an items array. items always holds one object. For one PDF in xlsx or docx, it holds the file in fileBase64. For one PDF in txt, it holds the text in text and has no file. For two or more PDFs, it holds one output file per converted PDF in files, for all formats.

ParameterTypeDescription
countIntegerNumber of objects in items. 1 even when several PDFs are sent.
itemsObject ArrayConversion results.
items[].titleStringShort summary, e.g. sales.pdf converted to Excel.
items[].fileNameStringOutput file name, e.g. sales.xlsx. Only present for one PDF in xlsx or docx.
items[].mimeStringMIME type of the output file. Only present for one PDF in xlsx or docx.
items[].fileBase64StringThe output file as base64. Only present for one PDF in xlsx or docx.
items[].textStringExtracted text, pages separated by --- Page N --- lines. Only present for one PDF in txt.
items[].filesObject ArrayOne output file per converted PDF. Only present when two or more PDFs are sent.
items[].files[].fileNameStringOutput file name, e.g. a.xlsx.
items[].files[].fileBase64StringThe output file as base64.
items[].rowsArrayPreview of the extracted rows of the first page (or of the first file). Each row is an array of cell values.
items[].columnsArrayColumn headers. Currently always empty.
items[].statsObjectProcessing stats.
items[].stats.Pages doneIntegerNumber of pages converted, across all files.
items[].stats.Scanned pages readIntegerNumber of pages read with OCR. Only present when OCR was used.
items[].stats.Files convertedIntegerNumber of PDFs converted. Only present when two or more PDFs are sent.
items[].notesString ArrayWarnings, e.g. that some pages were read with OCR or skipped, or that a file could not be read. Only present when there is something to note.
items[].cachedBooleantrue when the result of an identical earlier call is returned. Only present on cached results.
items[].cacheAgeSecondsIntegerAge of the cached result in seconds. Only present on cached results.

Errors return HTTP 400 with a JSON object holding code (invalid_input), error (the full error text) and message (the same text without the invalid input: prefix). Some messages end with an example request that contains a base64 PDF.

Notes

  • Limits per call, counted across all files: 10 files, 10 pages and 20 MB of decoded data. A call over any of these returns 400 and nothing is converted.
  • OCR reads up to 5 scanned pages per call, counted across all files. Extra scanned pages are skipped and the call still returns 200. Compare stats.Pages done with the number of pages you sent, and check notes.
  • Skipped scans may be listed in notes as No text found in this file, even when the page is readable. Send those pages in a new call.
  • If both fileContent and files are sent, all of the PDFs are converted.
  • When several PDFs are sent and one cannot be read, the others are still converted and notes names the one that failed.
  • A single PDF with no text and no readable image returns 400 with No text found in this file.
  • A single PDF that is damaged or password-protected returns 400 with This PDF cannot be opened.
  • OCR keeps tables as one cell per line. Text PDFs keep their table columns.
  • File names are cleaned: characters outside letters, digits, ., - and _ become _.
▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.