Expand description
Core PDF machinery: syntax, objects, filters, cross-references, the document model, and lazy element iteration (physical file structure with byte spans plus logical document structure), implemented from the PDF specification (ISO 32000).
Re-exports§
pub use cmap::cid_to_unicode;pub use cmap::type0_encoding;pub use cmap::CidCmap;pub use cmap::CidToUnicode;pub use cmap::Type0Encoding;pub use crypt::crypt_filter_refs;pub use crypt::direct_crypt_filters;pub use crypt::Decryptor;pub use crypt::Encryptor;pub use crypt::Permissions;pub use crypt::PERMISSION_NAMES;pub use date::Date;pub use destination::destination_value_with;pub use destination::destination_with;pub use destination::named_destination_with;pub use destination::named_destinations_with;pub use destination::Destination;pub use destination::DestinationPage;pub use destination::Fit;pub use document::content_stream_data_with;pub use document::decoded_stream_data_with;pub use document::map_pages;pub use document::page_content_with;pub use document::Document;pub use document::DocumentSeed;pub use document::Metadata;pub use document::Page;pub use elements::Element;pub use elements::ElementOpts;pub use elements::Span;pub use elements::XrefKind;pub use embedded_file::embedded_file_data_with;pub use embedded_file::embedded_files_with;pub use embedded_file::file_spec_with;pub use embedded_file::spec_components;pub use embedded_file::EmbeddedFile;pub use embedded_file::FileSpec;pub use error::Error;pub use error::Result;pub use extension::extensions_with;pub use extension::DeveloperExtension;pub use geom::Matrix;pub use geom::Point;pub use geom::Rect;pub use hash::FastMap;pub use hash::FastSet;pub use hash::FxHasher;pub use language::language_with;pub use language::LanguageTag;pub use names::name_tree_root_with;pub use names::named_with;pub use names::names_with;pub use names::NameTree;pub use object::Dict;pub use object::Name;pub use object::ObjRef;pub use object::Object;pub use object::Stream;pub use oc::OcState;pub use outline::outline_with;pub use outline::OutlineItem;pub use page_label::page_label;pub use page_label::page_labels_with;pub use page_label::LabelStyle;pub use page_label::PageLabel;pub use source::block_on;pub use source::resolve_sync_with;pub use source::resolve_with;pub use source::AsyncObjectSource;pub use source::BoxFuture;pub use source::Immediate;pub use source::ObjectSource;pub use source::MAX_RESOLVE_DEPTH;pub use structure::AttributeObject;pub use structure::MarkedContentId;pub use structure::Placement;pub use structure::StandardKind;pub use structure::StandardOwner;pub use structure::StandardType;pub use structure::StructureElement;pub use structure::StructureTree;pub use viewer_preferences::viewer_preferences_with;pub use viewer_preferences::Direction;pub use viewer_preferences::Duplex;pub use viewer_preferences::NonFullScreenPageMode;pub use viewer_preferences::PageBoundary;pub use viewer_preferences::PrintScaling;pub use viewer_preferences::ViewerPreferences;
Modules§
- cmap
- CID CMap parsing and code splitting for composite (Type0) fonts
(ISO 32000-1 §9.7.5-9.7.6):
begincodespacerangedrives variable-width code splitting,begincidrange/begincidcharmap codes to CIDs,usecmaplayers a CMap over another, and/WModeselects the writing mode. The value domain is codes to CID integers — distinct from the ToUnicode CMaps parsed inpdfboss-text, whose destinations are text. - content
- Content-stream operator parsing (ISO 32000 §8/§9), including inline images. Lenient: unknown operators and arity mismatches are skipped (the operand stack is cleared), never an error.
- crypt
- Decryption for the Standard security handler (ISO 32000 §7.6), opened with the user or the owner password (the empty user password opens transparently).
- date
- Date strings (ISO 32000-1 §7.9.4):
D:YYYYMMDDHHmmSSOHH'mm', read leniently intoDateand written back, or formatted as ISO 8601 for XMP and display. - destination
- Destinations (ISO 32000-1 §12.3.2): the page a link, outline item or action shows and how that page is fitted in the window, given explicitly as an array (§12.3.2.2) or by name (§12.3.2.3).
- document
- The document model: loading, object resolution with caching, the lazily-flattened page tree with attribute inheritance, and document metadata.
- elements
- Lazy iteration over a document’s elements: the physical file structure (header, indirect objects, cross-reference sections, trailer, startxref, eof) with byte spans, and the logical document structure (pages, fonts, images, annotations, content operators). ISO 32000 §7.5 (file structure) and §7.7 (document structure).
- embedded_
file - File specifications and embedded files (ISO 32000-1 §7.11.2 to §7.11.4):
the strings and dictionaries that name a file, and the streams that
carry a file’s bytes inside the document, listed through the catalog’s
/EmbeddedFilesname tree. - error
- Error and result types shared across all pdfboss crates.
- extension
- The developer extensions the catalog declares (ISO 32000-1 §7.12): the
/Extensionsdictionary, one developer extensions dictionary per registered developer prefix, each naming the PDF version it extends and the developer’s extension level. - filters
- Stream filters (ISO 32000 §7.4): FlateDecode, LZWDecode, ASCIIHexDecode,
ASCII85Decode, RunLengthDecode, CCITTFaxDecode, JBIG2Decode, plus PNG/TIFF
predictors.
DCTDecodeandJPXDecodeare passthrough (decoded at the image layer),Cryptis a no-op (the document’s decryptor applied it when the object was loaded), and unknown names are unsupported. - geom
- Planar geometry shared by text extraction and rendering: points,
axis-aligned rectangles, and 2-D affine transformation matrices using the
PDF row-vector convention
[x y 1] · M. - hash
- A fast, non-cryptographic hasher for the small keys PDF machinery hashes
in bulk: dictionary names (
/Type,/Font, …), object ids(num, gen), and glyph indices. The standard library’s defaultHashMapuses SipHash-1-3, which is DoS-resistant but far slower than necessary for this data — the keys are short, the maps are in-process, and the input has already been parsed, so hash-flooding is not a concern here. - language
- The document’s natural language (ISO 32000-1 §14.9.2): the catalog’s
/Lang, the default for every piece of text a structure element or a marked-content sequence does not tag with a language of its own. - lexer
- Byte-level tokenizer for PDF syntax (ISO 32000 §7.2/§7.3), zero-copy where possible.
- names
- The document’s name dictionary (ISO 32000-1 §7.7.4): the catalog’s
/Namesentry, whose entries are the roots of name trees, one per category of object that can be referred to by name. - object
- The PDF object model: the nine basic object types plus indirect references (ISO 32000 §7.3).
- objstm
- Object streams (ISO 32000 §7.5.7): compressed objects stored inside a
/Type/ObjStmstream. - oc
- Optional-content visibility (ISO 32000-1 §8.11): which optional content
groups the document’s default configuration turns off, and whether
content gated by an
/OCentry or aBDC /OCspan is visible. - outline
- The document outline (ISO 32000-1 §12.3.3): the tree of items a viewer shows as a table of contents, each with a title, an open or closed state, a destination or action, and its children.
- page_
label - Page labels (ISO 32000-1 §12.4.2): the labelling ranges of the catalog’s
/PageLabelsnumber tree, and the label each page shows. - parser
- Object parser built on the
Lexer, including indirect objects and streams (ISO 32000 §7.3.8/§7.3.10). - pretty
- Human-readable, indented pretty-printing of PDF objects.
- source
- The object-source abstraction shared by the synchronous and asynchronous APIs.
- structure
- Structure-tree reading order (ISO 32000-1 §14.7): where a page’s marked-content sequences sit in the document’s logical structure, so a tagged page can be read in the order its author declared, and which structure type the element holding each sequence declares (§14.7.3).
- tree
- Name trees and number trees (ISO 32000-1 §7.9.6 and §7.9.7): sorted
key-value maps spread over
/Kidsnodes, each labelled with the/Limitsits keys fall in, so one key can be found without reading the whole tree, or every pair listed leaf by leaf. - viewer_
preferences - The viewer preferences the catalog declares (ISO 32000-1 §12.2): how a
reader should present the document on the screen and in print, read
from the catalog’s
/ViewerPreferencesdictionary (Table 150). - xref
- Cross-reference loading (ISO 32000 §7.5): classic tables, xref streams,
hybrid files (
/XRefStm),/Prevchains, and a whole-file recovery scan when everything else fails.