oxidize_pdf/lib.rs
1//! # oxidize-pdf
2//!
3//! A pure Rust PDF generation and manipulation library with zero external PDF dependencies.
4//!
5//! ## Features
6//!
7//! - **PDF Generation**: Create multi-page documents with text, graphics, and images
8//! - **PDF Parsing**: Read and extract content from existing PDFs
9//! - **PDF Operations**: Split, merge, and rotate PDFs
10//! - **Pure Rust**: No C dependencies or external libraries
11//!
12//! ## Quick Start
13//!
14//! ```rust
15//! use oxidize_pdf::{Document, Page, Font, Color, Result};
16//!
17//! # fn main() -> Result<()> {
18//! // Create a new document
19//! let mut doc = Document::new();
20//! doc.set_title("My PDF");
21//!
22//! // Create a page
23//! let mut page = Page::a4();
24//!
25//! // Add text
26//! page.text()
27//! .set_font(Font::Helvetica, 24.0)
28//! .at(50.0, 700.0)
29//! .write("Hello, PDF!")?;
30//!
31//! // Add graphics
32//! page.graphics()
33//! .set_fill_color(Color::rgb(0.0, 0.5, 1.0))
34//! .circle(300.0, 400.0, 50.0)
35//! .fill();
36//!
37//! // Save the document
38//! doc.add_page(page);
39//! doc.save("output.pdf")?;
40//! # Ok(())
41//! # }
42//! ```
43//!
44//! ## Modules
45//!
46//! - [`document`] - PDF document creation and management
47//! - [`page`] - Page creation and layout
48//! - [`graphics`] - Vector graphics and images
49//! - [`text`] - Text rendering and flow
50//! - [`parser`] - PDF parsing and reading
51//! - [`operations`] - PDF manipulation (split, merge, rotate)
52
53pub mod document;
54pub mod error;
55pub mod graphics;
56pub mod objects;
57pub mod operations;
58pub mod page;
59pub mod parser;
60pub mod text;
61pub mod writer;
62
63#[cfg(feature = "semantic")]
64pub mod semantic;
65
66pub use document::{Document, DocumentMetadata};
67pub use error::{PdfError, Result};
68pub use graphics::{Color, GraphicsContext, Image, ImageFormat, ImageColorSpace};
69pub use page::{Page, Margins};
70pub use parser::PdfReader;
71pub use text::{Font, FontFamily, TextContext, TextAlign, TextFlowContext, measure_text, split_into_words};
72
73#[cfg(test)]
74mod tests {
75 use super::*;
76
77 #[test]
78 fn test_create_empty_document() {
79 let doc = Document::new();
80 assert_eq!(doc.pages.len(), 0);
81 }
82
83 #[test]
84 fn test_create_page() {
85 let page = Page::new(595.0, 842.0);
86 assert_eq!(page.width(), 595.0);
87 assert_eq!(page.height(), 842.0);
88 }
89}