pivot_pdf/lib.rs
1//! PDF creation library for Rust.
2//!
3//! `pivot-pdf` provides a high-level API for building PDF documents
4//! programmatically. It is designed for low memory usage, making it suitable
5//! for SaaS applications that generate many documents (invoices, reports,
6//! contracts, bills of material, etc.).
7//!
8//! # Quick Start
9//!
10//! ```no_run
11//! use pivot_pdf::{DocumentOptions, PdfDocument, BuiltinFont, Rect, TextFlow, TextStyle};
12//!
13//! let mut doc = PdfDocument::new(Vec::<u8>::new(), DocumentOptions::default()).unwrap();
14//! doc.set_info("Title", "Hello World");
15//! doc.begin_page(612.0, 792.0);
16//! doc.place_text("Hello, world!", 72.0, 720.0);
17//! doc.end_page().unwrap();
18//! let pdf_bytes = doc.end_document().unwrap();
19//! ```
20//!
21//! # Key Types
22//!
23//! - [`PdfDocument`] — the main entry point for building documents
24//! - [`TextFlow`] — flowing styled text across multiple pages
25//! - [`Table`] — rendering tabular data with flexible styling
26//! - [`BuiltinFont`] — the 14 standard PDF fonts (no embedding required)
27//!
28//! # Feature Highlights
29//!
30//! - **Incremental page writing**: each page is flushed to the writer as it
31//! completes, keeping memory constant regardless of document size.
32//! - **TrueType fonts**: embed custom fonts from `.ttf` files.
33//! - **JPEG and PNG images**: embed with automatic fit/fill/stretch modes.
34//! - **FlateDecode compression**: enable with [`PdfDocument::set_compression`].
35//! - **PDF merge**: combine existing PDFs with [`merge_pdfs`].
36
37#![warn(missing_docs)]
38
39/// High-level PDF document builder.
40pub mod document;
41/// Font types and metrics.
42pub mod fonts;
43/// Color types for PDF graphics.
44pub mod graphics;
45/// Image loading and placement.
46pub mod images;
47/// PDF merge operations.
48pub mod merger;
49/// PDF object types (ISO 32000-1:2008 §7.3).
50pub mod objects;
51/// PDF reader for parsing existing PDF files.
52pub mod reader;
53/// Table rendering for tabular data.
54pub mod tables;
55/// Flowing text layout across bounding boxes.
56pub mod textflow;
57/// TrueType font parsing and embedding.
58pub mod truetype;
59/// Low-level PDF binary writer.
60pub mod writer;
61
62pub use document::{DocumentOptions, FormFieldError, Origin, PdfDocument};
63pub use fonts::{BuiltinFont, FontRef, TrueTypeFontId};
64pub use graphics::{Angle, Color};
65pub use images::{ImageFit, ImageId};
66pub use merger::{merge_pdfs, MergeOptions, PdfMergeError};
67pub use reader::{PdfReadError, PdfReader};
68pub use tables::{Cell, CellOverflow, CellStyle, Row, Table, TableCursor, TextAlign};
69pub use textflow::{FitResult, Rect, TextFlow, TextStyle, WordBreak};