Skip to main content

graphitepdf_kit/
lib.rs

1//! # GraphitePDF Kit
2//!
3//! A pure Rust PDF generation library with no external PDF dependencies.
4//!
5//! ## Features
6//! - Document construction with `DocumentBuilder`
7//! - Page sizing (A0-A6, Letter, Legal, Tabloid, custom sizes)
8//! - Text rendering with `TextBuilder`
9//! - Vector graphics with `Canvas`
10//! - Flate compression
11//! - Metadata support
12//! - Optional tracing support
13//!
14//! ## Quick Start
15//! ```rust,no_run
16//! use graphitepdf_kit::{DocumentBuilder, PageSize, TextBuilder, Canvas, Color, Metadata};
17//!
18//! // Create text content
19//! let text = TextBuilder::new()
20//!     .font("F1", 24.0)
21//!     .position(100.0, 700.0)
22//!     .text("Hello, World!")
23//!     .finish();
24//!
25//! // Create vector graphics
26//! let graphics = Canvas::new()
27//!     .fill_color(Color::RED)
28//!     .rect(100.0, 650.0, 200.0, 50.0)
29//!     .fill()
30//!     .finish();
31//!
32//! // Combine and build the document
33//! let content = [text, graphics].concat();
34//! let doc = DocumentBuilder::new()
35//!     .metadata(Metadata::new()
36//!         .title("My Document")
37//!         .author("Me"))
38//!     .with_page(PageSize::A4, content);
39//!
40//! // Save to file
41//! doc.save("output.pdf").unwrap();
42//! ```
43
44#[path = "font.rs"]
45mod backend_font;
46mod compress;
47mod document;
48mod error;
49mod image_render;
50mod metadata;
51mod objects;
52mod outline;
53mod page;
54mod pattern;
55mod security;
56mod svg_render;
57#[cfg(test)]
58mod tests;
59mod text;
60mod vector;
61mod writer;
62
63#[cfg(feature = "tables")]
64mod table;
65#[cfg(feature = "tables")]
66pub use table::{BorderStyle, TableBuilder, TableCell, TableRow};
67
68pub use self::image_render::{
69    ImageRenderOptions, render_image_to_page_content, render_image_to_page_content_with_options,
70};
71pub use self::svg_render::{
72    SvgRenderOptions, ToPdfPageContent, render_math_to_page_content,
73    render_math_to_page_content_with_options, render_svg_node_to_page_content,
74    render_svg_node_to_page_content_with_options,
75};
76pub use backend_font::{Font, FontRegistry};
77pub use compress::flate_encode;
78pub use document::{DocumentBuilder, Page};
79pub use error::{GraphitePdfKitError, Result};
80pub use font::StandardFont;
81pub use graphitepdf_errors as errors;
82pub use graphitepdf_font as font;
83pub use graphitepdf_image as image;
84pub use graphitepdf_math as math;
85pub use graphitepdf_svg as svg;
86pub use metadata::Metadata;
87pub use objects::Object;
88pub use outline::{Outline, OutlineItem};
89pub use page::{PageMargins, PageOrientation, PageSize};
90pub use pattern::{GradientStop, LinearGradient, Pattern, RadialGradient, TilingPattern};
91pub use security::{Permissions, SecurityOptions};
92pub use text::{FontWeight, TextAlignment, TextBuilder, TextRenderingMode};
93pub use vector::{Canvas, Color, LineCap, LineJoin};
94pub use writer::PdfWriter;