rpdfium_parser/lib.rs
1#![forbid(unsafe_code)]
2#![doc = "PDF file structure parser for rpdfium — a faithful Rust port of PDFium."]
3//!
4//! This crate implements the PDF file format parser, including:
5//!
6//! - **Object model**: PDF objects (null, boolean, integer, real, string, name,
7//! array, dictionary, stream, reference) with lazy resolution.
8//! - **Tokenizer**: Low-level byte-to-token conversion.
9//! - **Header parsing**: `%PDF-X.Y` version detection.
10//! - **Cross-reference tables**: Traditional `xref` and PDF 1.5+ xref streams.
11//! - **Trailer parsing**: `startxref` location, `/Prev` chain following.
12//! - **Object streams**: ObjStm (PDF 1.5+) decompression and extraction.
13//! - **ObjectStore**: Central thread-safe lazy-parsing object repository.
14//! - **Linearization detection**: Checks for linearized PDF markers.
15//! - **Content stream tokenization**: Parses PostScript-like operator sequences.
16//!
17//! # Design Principles
18//!
19//! - `#![forbid(unsafe_code)]`
20//! - All deep operations are **iterative** (explicit `Vec` stacks), never recursive.
21//! - `OnceLock`-based lazy parsing: each object is parsed at most once.
22//! - Stream `/Length` uses direct-object-only + endstream scan fallback.
23//! - Security limits enforced: `MAX_OBJECT_NUMBER`, `MAX_RECURSION_DEPTH`, etc.
24
25pub mod content_stream;
26pub mod crypto;
27pub mod filter;
28pub mod header;
29pub mod hint_tables;
30pub mod linearized_header;
31pub mod object;
32pub mod object_parser;
33pub mod object_stream;
34pub mod object_walker;
35pub mod security;
36pub mod store;
37pub mod tokenizer;
38pub mod trailer;
39pub mod xref;
40pub mod xref_stream;
41
42// Re-export primary types for convenience.
43pub use content_stream::{Operand, Operator, TextArrayElement, tokenize_content_stream};
44pub use crypto::CryptoError;
45pub use filter::resolve_filter_chain;
46pub use header::PdfVersion;
47pub use hint_tables::{HintTables, PageOffsetHintTable};
48pub use linearized_header::{LinearizedInfo, detect_linearized};
49pub use object::{Object, ObjectId, StreamData};
50pub use object_walker::{ObjectStats, ObjectVisitor, ObjectWalker};
51pub use security::{Permissions, SecurityError, SecurityHandler};
52pub use store::ObjectStore;
53pub use trailer::TrailerInfo;
54pub use xref::{XrefEntry, XrefEntryType, XrefSection, XrefTable};