Expand description
§xberg-native-pdf
A PDF parsing, extraction and rendering library — the PDF engine behind
xberg.
This crate began as a fork. The upstream project it derives from ships bindings for
19 languages, a CLI and an MCP server; this crate strips all of that down to the single
Rust library xberg consumes, and is not endorsed by or affiliated with upstream. The
upstream project, its authors and its licence are named in the repository’s
ATTRIBUTIONS.md, which is the single place that record is kept.
§Core Features
§Reading & Extraction
- Text Extraction: Character, span, and page-level with font metadata and bounding boxes
- Reading Order: 4 pluggable strategies (XY-Cut, Structure Tree, Geometric, Simple)
- Complex Scripts: RTL (Arabic/Hebrew), CJK (Japanese/Korean/Chinese), Devanagari, Thai
- Image Extraction: Content streams, Form XObjects, inline images
- Forms & Annotations: Read form fields, all annotation types, bookmarks
- Text Search: Regex and case-insensitive search with page-level results
§Quick Start
use xberg_native_pdf::PdfDocument;
use xberg_native_pdf::pipeline::{TextPipeline, TextPipelineConfig};
// Open a PDF
let mut doc = PdfDocument::open("paper.pdf")?;
// Plain text, in reading order
let text = doc.extract_text(0)?;
// Or drive the reading-order pipeline yourself (multi-column support)
let spans = doc.extract_spans(0)?;
let config = TextPipelineConfig::default();
let pipeline = TextPipeline::with_config(config.clone());
let ordered_spans = pipeline.process(spans, Default::default())?;§License
MIT (LICENSE or https://opensource.org/licenses/MIT).
The upstream project is offered as MIT OR Apache-2.0; this crate is distributed under the MIT arm alone. Copyright in the bulk of the code is held by Yury Fedoseev and the upstream contributors — see LICENSE, which carries both notices, and ATTRIBUTIONS.md.
Re-exports§
pub use pipeline::XYCutStrategy;pub use annotation_types::AnnotationBorderStyle;pub use annotation_types::AnnotationColor;pub use annotation_types::AnnotationFlags;pub use annotation_types::AnnotationSubtype;pub use annotation_types::BorderEffectStyle;pub use annotation_types::BorderStyleType;pub use annotation_types::CaretSymbol;pub use annotation_types::FileAttachmentIcon;pub use annotation_types::FreeTextIntent;pub use annotation_types::HighlightMode;pub use annotation_types::LineEndingStyle;pub use annotation_types::QuadPoint;pub use annotation_types::ReplyType;pub use annotation_types::StampType;pub use annotation_types::TextAlignment;pub use annotation_types::TextAnnotationIcon;pub use annotation_types::TextMarkupType;pub use annotation_types::WidgetFieldType;pub use annotations::Annotation;pub use annotations::LinkAction;pub use annotations::LinkDestination;pub use config::DocumentType;pub use config::ExtractionProfile;pub use document::ExtractedImageRef;pub use document::ImageFormat;pub use document::PageRotation;pub use document::PdfDocument;pub use document::ReadingOrder;pub use error::Error;pub use error::Result;pub use extractors::images::PdfFilter;pub use extractors::images::PdfImageHandle;pub use layout::PageText;pub use outline::Destination;pub use outline::OutlineItem;pub use redaction::FontInfoMetrics;pub use redaction::OcgPolicy;pub use redaction::RedactionOptions;pub use redaction::RedactionRegion;pub use redaction::RedactionReport;pub use redaction::RegionSet;pub use redaction::redact_content_stream;pub use structured::ColumnMode;pub use structured::RegionRole;pub use structured::StructuredPage;pub use structured::StructuredRegion;pub use fonts::global_cache::clear_global_font_cache;pub use fonts::global_cache::global_font_cache_stats;pub use fonts::global_cache::set_global_font_cache_capacity;pub use fonts::cmap::clear_cmap_cache;pub use fonts::cmap::cmap_cache_size;
Modules§
- annotation_
types - Core annotation types and enums per PDF spec Core annotation types and enums per PDF spec ISO 32000-1:2008, Section 12.5.
- annotations
- PDF annotations support.
- api
- Convenience re-exports for read-path PDF operations.
- color
- Colour management for PDF rendering and image extraction.
- config
- Configuration module for PDF text extraction.
- content
- PDF content stream parsing and execution.
- converters
- Shared text-shaping helpers for the extraction pipeline.
- crypto
- Cryptographic provider abstraction.
- decoders
- Stream decoder implementations for PDF filters.
- document
- PDF document model.
- elements
- Content elements for PDF generation Unified content elements for read/write operations.
- encryption
- PDF encryption support.
- error
- Error types for the PDF library.
- extractors
- Text and content extraction from PDF documents.
- fdf
- Forms Data Format (FDF) support for exporting/importing form field values.
- fonts
- Font handling and encoding.
- functions
- PostScript Type 4 (calculator) function evaluator.
- geometry
- Geometric primitives for layout analysis.
- layout
- Layout analysis algorithms for PDF documents.
- object
- PDF object types.
- objstm
- Object stream parsing (PDF 1.5+).
- optional_
content - Shared Optional Content (OCG / OCMD) helpers.
- outline
- PDF document outline (bookmarks) support.
- parser_
config - Parser configuration options
- pipeline
- PDF text extraction pipeline with clean abstraction layers.
- redaction
- True/destructive redaction + document sanitization (#231). True / destructive redaction and document sanitization.
- rendering
- Page rendering module for converting PDF pages to images.
- search
- Text search functionality for PDF documents.
- structure
- PDF logical structure (Tagged PDFs) PDF Logical Structure (Tagged PDF) support.
- structured
- Structured per-page extraction (
extract_structured, #536) Structured per-page extraction (extract_structured). - text
- Text processing and analysis module.
- xfa
- XFA (XML Forms Architecture) support.
- xref
- Cross-reference table parser.
- xref_
reconstruction - Cross-reference table reconstruction for damaged PDFs.
Macros§
- extract_
log_ debug - Log a DEBUG level event. Forwards to
tracing::debug!. - extract_
log_ error - Log an ERROR level event. Forwards to
tracing::error!. - extract_
log_ info - Log an INFO level event. Forwards to
tracing::info!. - extract_
log_ trace - Log a TRACE level event. Forwards to
tracing::trace!. - extract_
log_ warn - Log a WARN level event. Forwards to
tracing::warn!.
Constants§
- LOG_
TARGET_ ROOT - The root of every
tracingtarget this crate emits. - NAME
- Library name
- VERSION
- Library version