Parsing a clean, single-column PDF is easy. Most libraries can pull its text layer in a few lines. The trouble starts with the documents people actually send: scanned contracts, statements with ruled tables that span pages, two-column research papers, slides exported to PDF, and phone photos of receipts. This guide explains why those break naive extraction, what to check in any parser, and how to design an ingestion endpoint that stays reliable when the inputs are messy.
Digital PDFs vs scanned PDFs
The first question for any file is whether it has a text layer.
- Digital (born-digital) PDFs are exported from Word, a browser or a reporting tool. The characters are stored in the file, so extraction is a matter of reading them in the right order. Errors here are mostly about layout: reading order, tables and headers.
- Scanned PDFs are images of pages wrapped in a PDF. There is no text to read, so the parser has to run OCR. Quality depends on resolution, skew, stamps, handwriting and language.
- Hybrid files are common: a digital report with a scanned signature page, or a scan that a previous tool already ran OCR on, leaving a hidden and often poor text layer.
A quick test: try to select text in a PDF viewer. If you cannot, it is a scan. If you can but the copied text is garbled, the text layer is unreliable and OCR may do better than the embedded text.
A pipeline should not assume one kind. Either detect the type per file and route it, or use a parser that does this for you.
Why tables break
A PDF does not store tables. It stores text fragments at x/y positions and lines drawn between them. Rebuilding a table means inferring rows and columns from geometry, which fails in predictable ways:
- Borderless tables. Without ruling lines, columns are inferred from whitespace alone, and a long description can push text into the next column.
- Merged and multi-line cells. A wrapped cell looks like two rows unless the parser groups lines by cell.
- Tables across pages. The header row appears once, or repeats on every page, and the parser must not treat the repeat as data.
- Numbers. Thousands separators, parentheses for negatives, currency symbols and separate debit and credit columns all need consistent handling downstream.
For tabular data you will analyse, Markdown tables are a good intermediate format: readable by people and language models, and easy to convert to CSV. When cell merges or visual layout matter, HTML preserves more structure than Markdown can.
Multi-column layouts and reading order
Two-column papers, newsletters and brochures fail in a different way. A parser that reads strictly left to right across the page interleaves lines from both columns into nonsense. Footnotes, sidebars, figure captions and running headers add more noise. When you evaluate a parser, check:
- Does each column come out as continuous text?
- Are headers and footers either removed or clearly separated?
- Do figure captions stay next to their figures rather than in the middle of a paragraph?
- Are headings marked as headings, so you can split the document into sections later?
Choosing a model tier for the document
Running the most expensive engine on every page wastes money; running the cheapest on scans loses data. PDF Vector's Document Parse exposes this trade-off as model tiers:
| Tier | Best for (per the API reference) | Credits per page | Limits per file |
|---|---|---|---|
nano | Simple, plain-text documents | 1 | 30 pages, 40 MB |
mini | Documents with tables and structured content | 2 | 30 pages, 40 MB |
pro | Tables, handwritten text, figures, math, Arabic, images | 4 | 30 pages, 40 MB |
max | Everything in pro, plus enhanced multilingual support and HTML output | 8 | 2,000 pages, 500 MB |
auto (default) | Picks a tier for the document and bills the tier it selects | varies | 2,000 pages, 500 MB |
Some details that affect routing:
- Image files (PNG, JPG, TIFF, BMP, HEIF) need
pro,maxorauto. Images must be between 50 x 50 and 10,000 x 10,000 pixels. - With
auto, files a local engine can read without OCR (text PDFs, CSV, spreadsheets, Office and text files) are billed at most at the mini rate. Scans and images are billed at the tier that ran. - Only
maxreturns anhtmlfield alongside Markdown, which helps when tables have merged cells. - Pages are counted as you would expect for PDFs and TIFFs. For Word, HTML, EPUB and plain text, every 3,000 characters counts as one page; for slides, one page per slide.
A simple strategy is to start with auto, and only pin a tier when you know your documents. For example, use mini for a stream of digital statements under 30 pages, and max for long scanned archives.
Page-separated output
Whole-document Markdown is convenient, but many downstream jobs need page boundaries: citing a page in an answer, chunking for retrieval, re-processing one bad page, or showing a side-by-side review screen. Set includePages: true to get a pages array alongside the full markdown:
import requests
resp = requests.post(
"https://global.pdfvector.com/api/document/parse",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"x-pdfvector-document-id": "contract-2025-114",
},
json={
"url": "https://example.com/contract.pdf",
"model": "auto",
"includePages": True,
},
timeout=300,
)
resp.raise_for_status()
doc = resp.json()
print(doc["pageCount"], doc["model"], doc["credits"])
for page in doc["pages"]:
print(f"--- page {page['pageNumber']} ---")
print(page["markdown"][:300])
for warning in doc.get("warnings", []):
print("warning:", warning)
The response also reports the tier that ran (model), the credits charged, a requestId for support, and, when the parser supplies them, warnings about extraction limits and a pageUnit that says whether a "page" is a PDF page, a sheet, a slide or a text chunk.
Designing the ingestion endpoint
Parsing is one step. The endpoint that receives documents decides how reliable the whole system is. These are the decisions that matter most.
URL or file upload
PDF Vector accepts a document three ways: a public url, a multipart file upload, or a base64 string. Each has a place:
- URL keeps your request small and is the natural choice when files already sit in object storage. Use a signed URL with a reasonable expiry; an expired link fails as a user error.
- File upload avoids a second download and works for files that are not publicly reachable. Multipart is more efficient than base64.
- Base64 suits small files and environments where multipart is awkward. It inflates the payload by about a third, so avoid it for large scans.
If a URL points at a site that blocks or rate limits the download, the API reports UPSTREAM_FETCH_FAILED with retryable: true. The fix is to download the file yourself and send it as file or base64.
Synchronous vs callback
Long documents take time. Instead of holding an HTTP connection open, pass a callback object with a webhook URL. The API returns 202 immediately and later POSTs the full response to your webhook. On failure, the callback request carries an X-Pdfvector-Callback-Failed: true header with the error details in the body. Pass a documentId (or the x-pdfvector-document-id header) so you can match each callback to your own record.
Retries and idempotency
Retry only what can succeed on a retry:
- Network errors, timeouts,
429and5xx: retry with exponential backoff and jitter. - Errors flagged
retryable: retry later, or switch input method as above. - Errors flagged
retryableWithHigherModel: retry once with a stronger tier. - User errors (password-protected file, unsupported format, file over the tier's page or size limit): do not retry. Show the message to the user.
A request that ends in an error is not charged credits, but a request that succeeds twice is charged twice. So make your own pipeline idempotent: compute a SHA-256 of the file, store a job row keyed by that hash before calling the API, and return the stored result if the same file arrives again. Treat callbacks the same way: your webhook should accept the same payload twice without creating duplicates.
In TypeScript, the official SDK maps these cases to typed errors:
import {
createClient,
isPDFVectorError,
isPDFVectorUserError,
} from "@pdfvector/client";
const client = createClient({ apiKey: process.env.PDFVECTOR_API_KEY! });
async function parseWithEscalation(url: string, documentId: string) {
for (const model of ["mini", "max"] as const) {
try {
return await client.document.parse(
{ url, model, includePages: true },
{ context: { documentId } },
);
} catch (error) {
if (isPDFVectorUserError(error)) throw error; // show error.suggestion to the user
if (isPDFVectorError(error) && error.retryableWithHigherModel && model !== "max") {
continue; // escalate to a stronger tier
}
throw error; // let your job queue retry with backoff
}
}
throw new Error("unreachable");
}
Note that mini is limited to 30 pages; for longer files, start with auto or max.
Validate before you parse
Cheap checks at the edge save credits and support time: reject files over your size limit, check the page count of PDFs, and confirm the MIME type matches the extension. The API also rejects bytes that do not match the declared format, such as an HTML error page saved as .pdf.
A checklist for choosing a parsing provider
Test any provider, including this one, on a sample of your own documents. Twenty real files tell you more than any benchmark.
- Formats. Does it cover what you receive? PDF Vector reads PDF, Word, Excel, PowerPoint (including 97-2003 formats), CSV, text, HTML, RTF, OpenDocument, EPUB, bibliography files and, on pro and above, images.
- Scans and handwriting. Run your worst scans. Check numbers digit by digit.
- Tables. Compare row and column counts against the source, especially across page breaks.
- Reading order. Read the output of a two-column document from top to bottom.
- Output shape. Markdown for language models, HTML for layout fidelity, page arrays for citations, or structured JSON via an extract endpoint such as Document Extract.
- Limits. Maximum pages and file size per request, and what happens above them.
- Pricing model. Per page, per document or per request, and whether failed requests are billed.
- Data handling. Ask how long files are kept (including inputs from failed requests kept for debugging), whether they are used for training, and where they are processed. PDF Vector enterprise instances can run in a region you choose.
- Errors. Are they typed and actionable, or a generic 500?
- Integrations. SDKs, webhooks and no-code connectors such as n8n.
The free plan includes 100 credits per month, which is enough to run a small evaluation. Plan details are on the pricing section.
FAQ
How do I know if a PDF is scanned?
Try to select text in a PDF viewer. If nothing selects, the pages are images and need OCR. If text selects but copies as garbage, the embedded text layer is unreliable.
Which model tier should I use for scanned PDFs?
Use pro or max, or let auto choose. pro handles handwriting, figures and math; max adds enhanced multilingual support, HTML output and limits of 2,000 pages and 500 MB per file.
What is the page limit for parsing a PDF?
On PDF Vector, nano, mini and pro accept up to 30 pages and 40 MB per file. max and auto accept up to 2,000 pages and 500 MB.
Should I send a URL or upload the file?
Send a URL when the file is already in storage and publicly reachable, including via a signed link. Upload the file when it is private or when the source site blocks downloads.
How do I keep page numbers in the output?
Set includePages: true. The response then includes a pages array with a pageNumber and markdown for each page, in addition to the full markdown.
Am I charged when a parse fails?
No. A request that ends in an error is not charged. Successful duplicate requests are charged, so deduplicate files on your side.
Sources (checked 2026-11-11): https://www.pdfvector.com/document-parse, https://global.pdfvector.com/api/reference, https://www.npmjs.com/package/@pdfvector/client



