Docs/APIs/PDF to Text

PDF to Text

Extract the text from a PDF

OperationalCredits 10 per callp50 128msDocumentsStar

Overview

Text is read with Mozilla's pdf.js, in reading order with line breaks kept. Up to 100 pages are read per call; longer documents report their full page count with truncated set to true. Scanned PDFs have no text layer and return hasText false, as no OCR is performed.

Live Test PDF to Text API →

Endpoint

One host, one path per API. The block below shows this call in four languages; every one of them is the same HTTP request. Making requests covers the timeouts, retries and parameter rules that apply to all of them. The SDKs wrap the same call in a typed client.

POSThttps://api.apiverve.com/v1/pdftotext
curl -X POST https://api.apiverve.com/v1/pdftotext \
  -H "x-api-key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
  "pdf": "https://raw.githubusercontent.com/mozilla/pdf.js/master/test/pdfs/basicapi.pdf"
}'

Replace your_api_key_here with the key from your dashboard. When the inputs arrive as a list rather than one at a time, batch requests run up to 200 of them through this same API in a single call.

Authentication

Send your key in the x-api-key header. That is the only auth step — there is no token exchange and no per-endpoint scope to configure. Authentication covers creating, rotating and revoking keys.

401 is the only auth verdict

A 401 means the key is missing, invalid or expired. A 403 means the key is valid but not permitted here — blocked by a key restriction or an IP allow-list. Running out of credits is a 429.

Parameters

Sent as JSON in the request body. Premium parameters are accepted on every plan but only take effect on plans that include them.

ParameterTypeDescription
pdfOptionalstringThe PDF file to read (up to 10 MB), or a public PDF URL
url

Response

Every API returns the same three top-level keys, so one response handler covers your whole integration: status, error and data. Only data changes shape. Response format covers the envelope, the other output formats and how premium fields are withheld.

Sample response
{
  "status": "ok",
  "error": null,
  "data": {
    "text": "Table Of Content\nChapter 1 .......................................................... 2\nParagraph 1.1 ...................................................... 3\npage 1 / 3\n\nChapter 1\npage 2 / 3\n\nParagra…",
    "pageCount": 3,
    "pagesExtracted": 3,
    "truncated": false,
    "hasText": true,
    "wordCount": 31,
    "characterCount": 250,
    "pages": [
      {
        "page": 1,
        "text": "Table Of Content\nChapter 1 .......................................................... 2\nParagraph 1.1 ...................................................... 3\npage 1 / 3",
        "wordCount": 15
      },
      {
        "page": 2,
        "text": "Chapter 1\npage 2 / 3",
        "wordCount": 6
      },
      {
        "page": 3,
        "text": "Paragraph 1.1\nPowered by TCPDF (www.tcpdf.org)\npage 3 / 3",
        "wordCount": 10
      }
    ],
    "metadata": {
      "title": "Basic API Test",
      "author": "Brendan Dahl",
      "subject": null,
      "creator": "pdf.js",
      "producer": "TCPDF 5.9.133 (http://www.tcpdf.org)",
      "creationDate": "2012-04-10T21:30:26.000Z",
      "modificationDate": "2012-04-10T21:30:26.000Z",
      "pdfVersion": "1.7"
    }
  }
}

Response fields

Paths are relative to data. Premium fields are absent rather than zeroed on plans that do not include them, so check for presence instead of comparing to 0.

FieldTypeExampleDescription
textstring"Table Of Content Chapter 1 .......................................................... 2 Paragraph 1.…"The extracted text, pages separated by a blank line
pageCountnumber3Total pages in the PDF
pagesExtractednumber3Pages read (at most 100)
truncatedbooleanfalseTrue when the PDF has more pages than were read
hasTextbooleantrueFalse when no text layer was found, as in a scanned PDF
wordCountnumber31Words in the extracted text
characterCountnumber250Characters in the extracted text
pagesPremiumarray[3]The text of each page read
pagePremiumnumber1Page number
textPremiumstring"Table Of Content Chapter 1 .......................................................... 2 Paragraph 1.…"Text of the page
wordCountPremiumnumber15Words on the page
metadataPremiumobject{...}Document information from the PDF
titlePremiumstring"Basic API Test"Document title, or null
authorPremiumstring"Brendan Dahl"Author, or null
subjectPremiumobjectnullSubject, or null
creatorPremiumstring"pdf.js"Application that created the original document, or null
producerPremiumstring"TCPDF 5.9.133 (http://www.tcpdf.org)"Application that produced the PDF, or null
creationDatePremiumstring"2012-04-10T21:30:26.000Z"Creation date (ISO 8601), or null
modificationDatePremiumstring"2012-04-10T21:30:26.000Z"Last modification date (ISO 8601), or null
pdfVersionPremiumstring"1.7"PDF format version, such as 1.7

Errors

Read the HTTP status first, then error for the specific reason. The body names the parameter that has to change. Error handling covers the full status list and which of them are worth retrying.

StatusMeaningWhat to do
400Input was rejectedRead error; it names the parameter.
401Key missing or invalidCheck the header name and the key value.
403Key valid, but not permittedA key restriction or IP allow-list; see key scoping.
429Rate limited, or out of creditsRead error to tell them apart; see rate limits.

Use cases

Search Indexing
Index the text of uploaded PDFs so users can search inside documents, not just their titles.
AI and RAG Pipelines
Feed PDF text, page by page, into embeddings or a language model for question answering over documents.
Document Intake
Read invoices, statements and forms as text for downstream parsing and validation.
Content Moderation
Check the text of uploaded PDFs against your policies before they are published.

Other ways to use PDF to Text

Set up PDF to Text on APIVerve, or reach the same source a different way. Your APIVerve account and credits work on all of them — one key, one balance.

Give it to an AI agentConnect over MCP and your agent calls it as a native tool — Claude, Cursor, ChatGPT.VerveKit →Reference →

More in Documents:

Was this page helpful?