Expand description
PDF creation for pdfboss: the write-side twin of pdfboss-core.
Three altitudes, each complete on its own and lowering into the one beneath:
- document —
PdfandPage: plain structs whose fields are the composition, saved withPdf::save. - canvas —
Canvas: an imperative painter accumulatingpdfboss_core::content::Op, the same IR the reader parses, so every generated content stream round-trips throughparse_content. - cos —
Writer: numbered objects in, finished file bytes out, with stream compression, object streams, both cross-reference styles and a deterministic/ID.
Determinism is a feature: the same input produces byte-identical output. The crate never reads clocks or randomness — dates appear only when callers supply them.
Re-exports§
pub use canvas::Canvas;pub use canvas::CanvasParts;pub use canvas::ImageHandle;pub use canvas::LineCap;pub use canvas::LineJoin;pub use color::Color;pub use content::serialize_ops;pub use error::Error;pub use error::Result;pub use font::Standard14;pub use image::ImageData;pub use pdf::Date;pub use pdf::LinkAnnotation;pub use pdf::Metadata;pub use pdf::Page;pub use pdf::PageSize;pub use pdf::Pdf;pub use sink::AsyncByteSink;pub use sink::Immediate;pub use writer::WriteOptions;pub use writer::Writer;pub use writer::XrefStyle;
Modules§
- canvas
- The imperative painting surface. A
Canvasaccumulatespdfboss_core::content::Opvalues — the exact IR the reader parses — plus the fonts and images those operators reference. Nothing here serializes;finishhands the parts to document assembly. - color
- Device color values for content generation. The first public color
vocabulary in the workspace — the render crate keeps its own private
read-side
ColorSpace. - content
- Content-stream serialization:
pdfboss_core::content::Opvalues back to operator syntax. The writer emits from the same IR the reader parses into, soparse_content(serialize_ops(ops)) == opsis the module’s defining property — every variant ofOpmust round-trip. - error
- Error type for PDF creation. Writing is strict where reading is lenient: a writer that silently drops or corrupts content is worse than one that refuses, so every lossy situation is an error, never a skip.
- font
- The fourteen standard fonts (ISO 32000 §9.6.2.2), with WinAnsi text
encoding and AFM metrics from
pdfboss-encoding. Text in these faces needs no embedded font program — every conforming reader carries them. - image
- Image import for document creation. JPEG passes through untouched as
/DCTDecode(dimensions sniffed from its SOF marker); PNG is decoded to a raster with its alpha split into an/SMask; raw rasters cover generated content. No encode-side JPX/JBIG2/CCITT — by design. - Document assembly: pages of canvas content, document metadata, and the
save path.
Pdfis a plain struct — the fields are the composition, andDefaultfills everything optional. - ser
- COS object serialization:
Objectvalues to PDF syntax bytes (ISO 32000 §7.3). Output is deterministic — dictionary keys are emitted in sorted order regardless of insertion order. - sink
- The byte-sink abstraction shared by the synchronous and asynchronous write APIs.
- writer
- The object-level PDF writer: numbered objects in, finished file bytes
out. Handles the header, stream
/Lengthbookkeeping, optional Flate compression, object streams, both cross-reference styles, the trailer and a deterministic/ID.