PDF to JSON Extraction: Spatial Coordinates, Bounding Boxes & Document Parsing Architecture

Standardized under ISO 32000, the Portable Document Format (PDF) was engineered as a digital printing canvas rather than a semantic data structure. Inside a PDF stream, text does not exist as flowing paragraphs or tabular matrices; instead, it is stored as isolated, coordinate-positioned glyph instructions. When standard command-line tools or basic scripts extract raw text, they discard 2D coordinates—flattening multi-column financial statements and itemized invoices into scrambled strings.
x, y, width, and height attributes allows data engines to mathematically reconstruct rows, columns, and data key-value pairs.1. Inside ISO 32000: Digitally Born Character Streams vs. Scanned Raster PDFs
Before designing an automated document ingestion pipeline, developers must distinguish between the two fundamental types of PDF files encountered in production:
Generated programmatically by ERP software, billing engines, or headless browser rendering. These contain embedded font dictionaries, glyph mappings, and vector drawing operators. Character stream parsing extracts high-precision text and bounding boxes deterministically.
Created by physical office scanners or smartphone photography. The document contains only compressed pixel bitmaps (/DCTDecode or /CCITTFaxDecode). Extracting text requires Optical Character Recognition (OCR) rather than character stream parsing.
2. Font Encodings, Unicode Mappings & Ligature Decoding
Even digitally born PDFs can emit garbled text if the parser fails to interpret embedded /ToUnicode mapping CMaps. PDFs frequently use custom subset fonts where glyph index 0x01 represents the letter "e".
Furthermore, professional typographic documents replace letter pairs like fi, fl, and ffi with unified typographic ligatures. Robust extraction engines map these composite glyphs back to standard UTF-8 characters ("fi" → "f" + "i") so downstream search engines and database queries match expected strings.
3. Anatomy of a Coordinate-Aware PDF to JSON Schema (RFC 8259)
Rather than outputting an unstructured array of strings, a production-grade schema structures document data into metadata, page viewports, and bounded text fragments. The BrivTools PDF to JSON Converter produces compliant RFC 8259 output ready for database ingestion:
{
"metadata": {
"fileName": "enterprise-invoice-q3.pdf",
"fileSizeBytes": 148920,
"mimeType": "application/pdf",
"pageCount": 1,
"documentInfo": {
"title": "Invoice #INV-2026-089",
"producer": "BillingEngine v4.2"
}
},
"pages": [
{
"pageNumber": 1,
"viewport": { "width": 612, "height": 792 },
"textItems": [
{ "text": "Item Description", "x": 54.0, "y": 620.5, "width": 88.4, "height": 11.0, "fontSize": 11.0 },
{ "text": "Qty", "x": 380.0, "y": 620.5, "width": 19.2, "height": 11.0, "fontSize": 11.0 },
{ "text": "Line Total", "x": 495.0, "y": 620.5, "width": 52.1, "height": 11.0, "fontSize": 11.0 },
{ "text": "Dedicated Cloud Cluster", "x": 54.0, "y": 598.0, "width": 112.6, "height": 10.0, "fontSize": 10.0 },
{ "text": "2", "x": 380.0, "y": 598.0, "width": 6.1, "height": 10.0, "fontSize": 10.0 },
{ "text": "$2,400.00", "x": 495.0, "y": 598.0, "width": 48.3, "height": 10.0, "fontSize": 10.0 }
]
}
]
}4. Reconstructing Multi-Column Tables from Spatial Bounding Boxes
With individual bounding boxes captured, reconstructing table rows becomes a deterministic clustering problem. Because typographical baselines can drift slightly, items with matching y coordinates within a small vertical tolerance (±2 points) belong to the same row:
- Group by Y-Tolerance: Cluster fragments whose vertical positions fall within
|y1 - y2| ≤ 2.0 ptinto unified table rows. - Sort Horizontally: Order all elements within a clustered row by their
xcoordinate from left to right. - Assign Column Buckets: Match
xpositions against header coordinates to map each cell to its column header ("Qty", "Line Total").
5. Choosing the Right Output: PDF to JSON vs. Markdown vs. Plain Text
Selecting the right extraction format depends entirely on your downstream processing architecture:
| Extraction Target | Primary Use Case | Spatial Data Preserved | Ideal Processing Engine |
|---|---|---|---|
| PDF to JSON | ETL jobs, invoices, database JSONB storage | Yes (x, y, w, h, font size) | PostgreSQL, Python, Node.js ETL |
| PDF to Markdown | LLM embeddings, RAG ingestion pipelines | Semantic (#, ##, pipe tables) | Vector DBs, LangChain, LlamaIndex |
| PDF Plain Text | Full-text search indexing, word counts | None (linear stream) | Elasticsearch, Grep, Word Count |
For RAG vector pipelines requiring header chunking, explore our companion specification on PDF to Markdown for LLM RAG pipelines or use our raw PDF Text Extractor.
6. Frequently Asked Questions
How does PDF to JSON preserve table columns and spatial layouts?+
Standard text extractors discard the PDF coordinate matrix, reading characters in stream order. Because PDFs store text as positioned glyph commands rather than reading paragraphs, multi-column tables become jumbled strings. An RFC 8259 JSON schema records typographical points (where 1 pt = 1/72 inch) for each word, allowing post-processors to sort tokens into horizontal rows and vertical columns with strict mathematical tolerance.
Why does PDF text extraction return empty text on scanned documents?+
Unless a scanned document has undergone Optical Character Recognition (OCR) to inject an invisible 'hidden text layer', the PDF file contains only binary bitmap streams (DCTDecode JPEG or CCITTFaxDecode). PDF-to-JSON parsers inspect vector character operations; if no font glyph mappings exist in the page dictionary, the text payload is empty.
What is the key difference between PDF to JSON and PDF to Markdown?+
PDF to JSON is engineered for programmatic ETL pipelines, PostgreSQL JSONB storage, and deterministic data extraction from forms and invoices. PDF to Markdown translates visual layout into semantic hierarchy (#, ##, pipe tables) optimized for LLM token limits and Retrieval-Augmented Generation (RAG).
Can password-protected PDFs be converted to JSON in the browser?+
PDF security defines two password types: User Passwords (which prevent opening the document) and Owner Passwords (which restrict permissions like printing or text extraction). Modern client-side WebAssembly tools can decrypt files locally in browser RAM once the appropriate credential is provided.
Convert PDF Documents to Structured JSON Instantly
Extract coordinate-aware text items, bounding boxes, font sizes, and document metadata locally inside your browser with zero server uploads.