language:
- en
- pt license: agpl-3.0 tags:
- pdf-parser
- spatial
- spatial-pdf
- parser
- rust
- python
- nodejs
- layout-analysis
- document-parsing
- bounding-box
- table-extraction
- rag
- llm
- pdf-to-json
- document-ai pipeline_tag: document-question-answering
⚡ RasgaPDF
The Blazing-Fast 2D Spatial PDF Parser powered by Pure Rust.
Extract exact physical coordinates (Raw X/Y) or structured blocks & tables at native hardware speeds.
GitHub Repo • Web Visualizer • HF Space Demo • Two Modes • CLI Tool • Architecture • Spatial Schema • llms.txt
🎯 The Philosophy: Pure Spatial Parsing
Most PDF extraction tools make fragile guesses: they flatten multi-column layouts into corrupted text streams, mangle tables, and strip away 2D positional geometry.
RasgaPDF does one thing with uncompromising precision:
It returns the exact 2D physical spatial geometry of the PDF.
- Bounding Boxes Everywhere: Every character, word span, line, block, and table has exact coordinates
[x0, y0, x1, y1]. - Zero Lossy Heuristics: No broken markdown assumptions. Downstream LLMs, RAG pipelines, or vision-language models receive the true physical layout.
- Microsecond Rayon Parallelism: Multi-threaded page processing in pure Rust utilizing AVX2/AVX-512 SIMD.
- Polyglot First: Native C-ABI FFI bindings for Python, Node.js, Go, and C# (.NET).
⚡ Two Extraction Modes
RasgaPDF offers two distinct modes for different engineering needs:
⚡ Mode 1: Flat Physical Coordinates (Raw X/Y)
The fastest, most direct extraction possible. Returns an unnested list of physical 2D coordinates for every text span on the page, with zero block or table overhead:
- Latency: ~3 to 8 ms per page
- Supported Formats: Flat JSON, Formatted Text, TSV, or CSV
- Best For: Spatial RAG, 2D visualizers, vector indexing, OCR alignment, Unix pipelines with
awk/grep.
[Page 1] (X0: 50.00, Y0: 67.00, X1: 244.00, Y1: 83.00) [12.0pt] The Revolution of Artificial Intelligence
[Page 1] (X0: 50.00, Y0: 103.00, X1: 478.00, Y1: 119.00) [12.0pt] Artificial Intelligence (AI) has transformed...
🎯 Mode 2: Hierarchical Structured Document
Reconstructs the visual hierarchy into visual paragraphs (text_blocks), text lines (lines), spans, and auto-detects matrix tables via horizontal column projection:
- Latency: ~8 to 15 ms per page
- Output: Hierarchical tree
SpatialDocument->pages->text_blocks->lines->tables.
⚡ Performance Benchmark
Measured on Intel Core i7-1365U (10 Cores / 12 Threads, AVX2):
| Library / Tool | Language | Single Page | 50 Pages | Memory Footprint | Output Type |
|---|---|---|---|---|---|
| ⚡ RasgaPDF (Raw X/Y) | Rust (Native) | 7.7 ms | 95 ms | ~14 MB | Flat Raw Coordinates |
| 🚀 RasgaPDF (Structured) | Rust (Native) | 8.5 ms | 142 ms | ~18 MB | Spatial Blocks & Tables |
PyMuPDF (fitz) |
C / Python | 28.0 ms | 620 ms | ~45 MB | Text / Pixmap |
pdfplumber |
Python | 410.0 ms | 9,800 ms | ~140 MB | Python dicts |
pypdf |
Python | 95.0 ms | 2,100 ms | ~85 MB | Flat text string |
| Apache Tika | Java | 650.0 ms | 12,400 ms | ~320 MB | XHTML |
💻 Standalone CLI Tool
Install or build the standalone CLI binary:
# ⚡ MODE 1: Raw Physical Coordinates (Raw X/Y)
|
# 🎯 MODE 2: Hierarchical Structured Document
# 🖼️ GRAPHICS (opt-in): embedded images and vector paths
🚀 Rust Quickstart
Add rasgapdf to your Cargo.toml:
[]
= "0.3.1"
⚡ Mode 1: Raw Physical Coordinates (Raw X/Y)
Extract exact 2D bounding boxes [x0, y0, x1, y1] for every text span on the page with zero block overhead (~3 to 8 ms):
use parse_raw_file;
🎯 Mode 2: Hierarchical Structured Document
Reconstruct the visual hierarchy into visual paragraphs (text_blocks), text lines (lines), and auto-detect matrix tables:
use ;
🖼️ Embedded Images & Vector Graphics (opt-in)
Both extras are off by default, so the JSON shape is byte-for-byte unchanged unless you ask for them. Image bytes are never embedded in the JSON: metadata (dimensions, colour space, filter, SHA-256) stays in the tree, while the original encoded stream can be written to disk.
use ;
Equivalent CLI flags: --images, --drawings, --extract-images DIR, and --keep-backgrounds (keeps full-page background fills, which are dropped by default). See docs/SCHEMA.md for the full field reference.
📦 Native Bindings for Other Ecosystems
RasgaPDF provides native C-ABI bindings for other languages, each published with its own language-specific package and documentation:
| Language | Registry | Package / Installation | Total Downloads | Documentation |
|---|---|---|---|---|
| 🐍 Python | PyPI | pip install rasgapdf |
Python Guide & Examples | |
| 📦 Node.js | npm | npm install rasgapdf |
Node.js Guide & Examples | |
| 🦀 Rust | crates.io | cargo add rasgapdf |
docs.rs Reference | |
| 🔷 C# / .NET | NuGet | dotnet add package RasgaPdf |
C# Guide & Examples | |
| 🐹 Go | Go Module | go get github.com/MartinsMessias/rasgapdf/bindings/go |
(via Go Proxy) | Go Guide & Examples |
🦜️🔗 Official AI & RAG Integrations (LangChain & LlamaIndex)
RasgaPDF provides out-of-the-box loaders for LangChain and LlamaIndex with zero external setup:
🦜️ LangChain Document Loader (RasgaPDFLoader)
Preserves reading flow, exact 2D coordinates [x0, y0, x1, y1], and turns tables into structured Markdown matrices for LLM prompting:
# Mode 1: "pages" (Default — 1 LangChain Document per PDF page with markdown tables)
=
=
# Mode 2: "elements" (Spatial RAG — 1 Document per text block/table with exact bounding box!)
=
=
# Each chunk carries its true physical coordinates [x0, y0, x1, y1]
🦙 LlamaIndex Reader (RasgaPDFReader)
Native high-throughput reader for LlamaIndex vector indices and query engines:
=
=
# Build lightning-fast vector index with exact spatial context
=
=
=
🎨 Interactive Web Visualizer
🌐 Live Hugging Face Space (Zero Server Quota / Client-Side)
Test RasgaPDF instantly without installing anything:
- Live Demo: https://huggingface.co/spaces/martinsmessias/rasgapdf
- Zero Server Costs: Runs directly in your browser using pure client-side Rust WebAssembly.
- Run on Your Personal Quota: Click
to clone into your own Hugging Face account with your personal compute quota.
🤖 AI Agents, Spatial RAG & LLM Grounding (llms.txt)
RasgaPDF provides first-class machine-readable documentation following the llms.txt standard so coding agents (Cursor, Claude Code, GitHub Copilot, Windsurf, Perplexity, ChatGPT) can index and integrate the full API in a single pass:
- Concise LLM Index:
llms.txt - Complete Technical Reference (
llms-full.txt):llms-full.txt - Coding Agent Instructions:
AGENTS.md
❓ Frequently Asked Questions (FAQ)
🇬🇧 English
- When should I choose RasgaPDF over PyMuPDF (
fitz),pdfplumber, orpypdf?
Choose RasgaPDF when you need exact 2D bounding-box coordinates[x0, y0, x1, y1], automatic matrix table reconstruction, opt-in embedded image/vector extraction, or high-throughput multi-threaded Rust speed (~3–8 ms/page — up to 50x faster thanpdfplumberand 4x faster thanPyMuPDF) with an identical JSON schema across Rust, Python, Node.js, Go, and C#. - Does RasgaPDF require external C dependencies or PDF.js?
No. RasgaPDF is 100% pure Rust with zero external C dependencies. The browser visualizer runs on pure client-side WebAssembly compiled from the same Rust codebase.
🇧🇷 Português (Brasil)
- Como extrair texto, tabelas e coordenadas X/Y (
bounding boxes) de PDF rápido em Python, Rust, Node.js ou C#?
Instale o RasgaPDF viapip install rasgapdf,npm install rasgapdf,dotnet add package RasgaPdfoucargo add rasgapdf. Useparse_raw("arquivo.pdf")para obter coordenadas físicas[x0, y0, x1, y1]em ~3–8 ms por página, ouparse_pdf("arquivo.pdf", detect_tables=True, extract_images=True, extract_drawings=True)para reconstruir blocos de texto, tabelas, imagens embutidas e gráficos vetoriais. - O RasgaPDF funciona no navegador em WebAssembly sem servidor?
Sim. Todo o core em Rust compila diretamente parawasm32-unknown-unknown, permitindo processamento 100% local no navegador com segurança e privacidade total (Zero Data Transmission).
🤝 Contributing & Community
Contributions are what make the open-source community thrive!
- Read our Contributing Guide to get started.
- Adhere to our Code of Conduct.
📄 License
RasgaPDF is licensed under the GNU Affero General Public License v3.0 or later.
Copyright (c) 2026 Messias Martins.
RasgaPDF is an independent, 100% pure Rust implementation of the ISO 32000-1 PDF specification. It contains zero external C library dependencies and zero MuPDF bindings. All lexical analysis, cross-reference table/stream decoding, Flate decompression, Type 1/TrueType/Type0 CID font decoding, and 2D spatial coordinate tracking are natively executed in pure Rust.
💼 Commercial & Enterprise Licensing (AGPL-3.0 Waiver)
Need to use RasgaPDF in closed-source commercial software, proprietary SaaS platforms, private cloud environments, or corporate applications without releasing your source code under the AGPL-3.0?
A Commercial / Enterprise License is available directly from the author:
- Complete AGPL-3.0 Exemption: Keep your intellectual property, backend code, and SaaS infrastructure 100% closed-source and proprietary.
- Enterprise SLA & Support: Direct architecture advisory, guaranteed response times, and priority bug resolution.
- On-Premise & Air-Gapped Appliances: Ready-to-deploy private Docker containers for confidential banking, healthcare, and legal compliance (LGPD / GDPR).
- Custom Spatial Features: Tailored table extractors for bank statements, invoices, and court proceedings.
📬 Inquiries & Licensing:
👉 Click here to Request a Commercial License & Pricing with details about your organization, use case, and estimated volume.