Xberg
High-performance document intelligence library for Rust. Extract text, metadata, transcripts, and structured information from PDFs, Office documents, images, audio/video, and 107 formats.
This is the core Rust library that powers the Python, TypeScript, and Ruby bindings.
Version 1.1.3
Installation
[]
= "1.1.3"
= { = "1", = ["rt", "macros"] }
Xberg uses a pure-Rust PDF backend (xberg-native-pdf) — no PDFium, no system libraries, and no
linking configuration required. For the full list of Cargo feature flags, see the
Xberg documentation.
System Requirements
ONNX Runtime (for embeddings)
If using embeddings functionality, ONNX Runtime must be installed:
# macOS
# Ubuntu/Debian
# Windows (MSVC)
# OR download from https://github.com/microsoft/onnxruntime/releases
Without ONNX Runtime, embeddings will raise MissingDependencyError with installation instructions.
Quick Start
use ;
async
Async Extraction
use ;
async
Batch Processing
use ;
async
MIME Detection Policy
ExtractionConfig::mime_detection_policy defaults to MimeDetectionPolicy::PreferContent. Use
TrustExtension to skip content sniffing when the filename has a supported extension, or ContentOnly to ignore
filename extensions. A specific explicit ExtractInput::mime_type remains authoritative; application/octet-stream
is treated as a generic placeholder and falls back to policy-based detection. A FileExtractionConfig override can
select a different policy for one batch item. Because uploaded and downloaded filenames are
attacker-controlled, use TrustExtension only for trusted sources; a misleading extension can otherwise route content
to the wrong extractor.
OCR with Table Extraction
use ;
async
Password-Protected PDFs
use ;
async
Extract from Bytes
use ;
use fs;
async
Code Intelligence
Xberg integrates tree-sitter-language-pack to parse and analyze source code files across 371 programming languages. When you extract a source code file, Xberg automatically detects the language and produces structured analysis including functions, classes, imports, exports, symbols, diagnostics, and semantic code chunks.
Code intelligence data is available via the metadata.format field as a FormatMetadata::Code variant containing a ProcessResult.
use ;
async
Requires the tree-sitter feature flag (included in full). See the Xberg docs for configuration details and examples in all languages.
Features
The crate uses feature flags for optional functionality:
[]
= { = "1.1.3", = ["pdf", "excel", "ocr"] }
Available Features
| Feature | Description | Binary Size |
|---|---|---|
pdf |
PDF extraction (pure Rust) | +2MB |
excel |
Excel/spreadsheet parsing | +3MB |
office |
DOCX, PPTX extraction | +1MB |
email |
EML, MSG extraction | +500KB |
html |
HTML to markdown | +1MB |
xml |
XML streaming parser | +500KB |
archives |
ZIP, TAR, 7Z extraction | +2MB |
ocr |
OCR with Tesseract | +5MB |
language-detection |
Language detection | +100KB |
chunking |
Text chunking | +200KB |
quality |
Text quality processing | +500KB |
Feature Bundles
= { = "1.1.3", = ["full"] }
= { = "1.1.3", = ["server"] }
= { = "1.1.3", = ["cli"] }
PDF Support
Xberg uses xberg-native-pdf — a pure-Rust PDF library with no system dependencies.
Enable PDF extraction with the pdf feature:
[]
= { = "1.1.3", = ["pdf"] }
No native libraries required. Works on all platforms including musl, Docker, and WASM.
Documentation
API Documentation – Complete API reference with examples
https://docs.xberg.io – User guide and tutorials
License
MIT License (MIT) - see LICENSE for details.