Skip to main content

pdfboss_write/
lib.rs

1//! PDF creation for pdfboss: the write-side twin of `pdfboss-core`.
2//!
3//! Three altitudes, each complete on its own and lowering into the one
4//! beneath:
5//!
6//! - **document** — [`Pdf`] and [`Page`]: plain structs whose fields are
7//!   the composition, saved with [`Pdf::save`].
8//! - **canvas** — [`Canvas`]: an imperative painter accumulating
9//!   `pdfboss_core::content::Op`, the same IR the reader parses, so every
10//!   generated content stream round-trips through `parse_content`.
11//! - **cos** — [`Writer`]: numbered objects in, finished file bytes out,
12//!   with stream compression, object streams, both cross-reference styles
13//!   and a deterministic `/ID`.
14//!
15//! Determinism is a feature: the same input produces byte-identical
16//! output, with one exception. The crate never reads clocks. Randomness is
17//! read only when encrypting: `encrypt_document` and `Writer::new_encrypted`
18//! draw key material and IVs from the operating system's random source by
19//! default (a caller can supply its own deterministic source through
20//! `Encryptor::aes256_with_rng`), so two encrypted runs need not match
21//! byte-for-byte. Otherwise, dates appear only when callers supply them.
22
23pub mod assemble;
24pub mod canvas;
25pub mod color;
26pub mod content;
27pub mod element;
28pub mod error;
29pub mod font;
30pub mod image;
31pub mod importer;
32pub mod pdf;
33pub mod ser;
34pub mod sink;
35pub mod update;
36pub mod writer;
37mod xmp;
38
39#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
40pub use assemble::encrypt_document;
41pub use assemble::{
42    decrypt_document, merge_documents, rewrite_document, rewrite_with_metadata, rotate_rewrite,
43    split_document,
44};
45pub use canvas::{BlendMode, Canvas, CanvasParts, GroupHandle, ImageHandle, LineCap, LineJoin};
46pub use color::Color;
47pub use content::serialize_ops;
48pub use element::{Content, Draw, Image, Link, Paragraph, ParagraphAlign, Text};
49pub use error::{Error, Result};
50pub use font::Standard14;
51pub use image::ImageData;
52pub use importer::Importer;
53pub use pdf::{
54    Attachment, Bookmark, Date, LabelStyle, LinkAnnotation, LinkTarget, Metadata, Outline, Page,
55    PageLabel, PageLayout, PageMode, PageSize, Pdf, Viewer,
56};
57pub use sink::{AsyncByteSink, Immediate};
58pub use update::{
59    rotate_pages, set_metadata_with, start_offset, watermark, watermark_under,
60    watermark_under_with, watermark_with, Overlay, OverlayBase, Update,
61};
62pub use writer::{WriteOptions, Writer, XrefStyle};