Xberg
High-performance document intelligence library for Rust. Extract text, metadata, transcripts, and structured information from PDFs, Office documents, images, audio/video, and 98 formats.
This is the core Rust library that powers the Python, TypeScript, and Ruby bindings.
Version 5.0.0-rc.17 Release This is a pre-release version. We invite you to test the library and report any issues you encounter.
Note: The Rust crate is not currently published to crates.io for this RC. Use git dependencies or language bindings (Python, TypeScript, Ruby) instead.
Installation
[]
= "5.0.0-rc.17"
= { = "1", = ["rt", "macros"] }
PDFium Linking Options
Xberg offers flexible PDFium linking strategies for different deployment scenarios. Note: Language bindings (Python, TypeScript, Ruby, Java, Go, C#, PHP, Elixir) automatically bundle PDFium—no configuration needed. This section applies only to the Rust crate.
| Strategy | Feature Flag | Description | Use Case |
|---|---|---|---|
| Default (Dynamic) | None | Links to system PDFium at runtime | Development, system package users |
| Static | pdf-static |
Statically links PDFium into binary | Single binary distribution, no runtime dependencies |
| Bundled | pdf-bundled |
Downloads and embeds PDFium in binary | CI/CD, hermetic builds, largest binary size |
| System | pdf-system |
Uses system PDFium via pkg-config | Linux distributions with PDFium package |
Example Cargo.toml configurations:
# Default (dynamic linking)
[]
= "5.0.0-rc.17"
# Static linking
[]
= { = "5.0.0-rc.17", = ["pdf-static"] }
# Bundled in binary
[]
= { = "5.0.0-rc.17", = ["pdf-bundled"] }
# System library (requires PDFium installed)
[]
= { = "5.0.0-rc.17", = ["pdf-system"] }
For more details on feature flags and configuration options, 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
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 306 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:
[]
= { = "5.0.0-rc.17", = ["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
= { = "5.0.0-rc.17", = ["full"] }
= { = "5.0.0-rc.17", = ["server"] }
= { = "5.0.0-rc.17", = ["cli"] }
PDF Support
Xberg uses pdf_oxide — a pure-Rust PDF library with no system dependencies.
Enable PDF extraction with the pdf feature:
[]
= { = "5.0", = ["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.