PDF to Text API

Extract the text layer of a PDF page by page (Vietnamese Unicode kept), with document metadata, word counts and a warning for scanned files.

POSThttps://apibox.io.vn/v1/pdf-text

The PDF text API reads the text layer of a PDF with the PDF.js engine and returns it page by page (pages: [{ page, text }]) or as one string with merge=true. Vietnamese text produced by Word, LibreOffice, invoicing software or our own PDF APIs is returned as proper Unicode. pages=2-4 restricts the output to some pages.

The answer also contains the document information (title, author, creator, producer), the total page count and character and word counts. When pages have no text at all, a note warns that the file looks scanned: such PDFs are images and need OCR, which this API does not do.

Up to 500 pages are read per call by default (max_pages, at most 2,000), within the file size of your plan. Password-protected PDFs are refused. Layout (columns, tables) is flattened to lines of text.

Parameters

NameInTypeRequiredDefault
filebodyfileyesThe PDF (multipart, raw body or file_base64).
pagesquery|bodystringnoPages to return, e.g. 1-3,5.
mergequery|bodybooleannofalsetrue: one text string instead of pages.
max_pagesquery|bodynumberno500Refuse longer documents unless pages is given (1–2000).

Example

curl -X POST "https://apibox.io.vn/v1/pdf-text" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "0=@./my-file"

Response

{
  "pages_total": 1,
  "pages_returned": 1,
  "info": {
    "title": "Báo giá",
    "author": null,
    "creator": "apibox.io.vn",
    "producer": "APIBox md-pdf"
  },
  "characters": 137,
  "words": 32,
  "pages": [
    {
      "page": 1,
      "text": "Báo giá dịch vụ\nKính gửi Quý khách,\nCông ty xin gửi báo giá gói API Pro: 15 USD / tháng.\nĐiều khoản\nThanh toán trong 7 ngày.\n1 / 1Báo giá"
    }
  ]
}

Use cases

  • Index uploaded PDF documents for search
  • Read amounts and references from PDF invoices
  • Feed contracts and reports to an AI pipeline
  • Check that a generated PDF contains the expected text

FAQ

Does it work on scanned documents?

No. A scanned PDF only contains images; the API detects it and says so in note. OCR is needed for those files.

Is the table layout kept?

No, the text comes line by line in reading order. Tables become lines with their cell values.

What is the page limit?

500 pages by default, up to 2,000 with max_pages, and the file size of your plan.

Related APIs

Start with 1,000 free requests every month. Get free API key →