1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
//! # PDF-CLI Library
//!
//! A comprehensive Rust library for reading, writing, and manipulating PDF documents.
//! This library provides functionality for:
//!
//! - **PDF Generation**: Create PDFs from markdown or raw text content
//! - **PDF Parsing**: Extract text and structure from existing PDFs
//! - **PDF Manipulation**: Merge, split, rotate, and reorder pages
//! - **Image Support**: Embed JPEG, PNG, and BMP images in PDFs
//! - **Annotations**: Add text, link, and highlight annotations
//! - **Forms**: Create interactive PDF forms with text fields, checkboxes, radio buttons, and dropdowns
//! - **Watermarks**: Add text or image watermarks to PDFs
//! - **Metadata**: Manage document metadata including custom fields
//! - **Security**: Add password protection and permissions to PDFs
//!
//! ## Quick Start
//!
//! ```rust
//! use pdfrs::pdf_generator;
//! use pdfrs::elements;
//!
//! // Parse markdown content
//! let markdown = "# Hello World\n\nThis is a test document.";
//! let elements = elements::parse_markdown(markdown);
//!
//! // Generate PDF
//! let layout = pdf_generator::PageLayout::portrait();
//! pdf_generator::create_pdf_from_elements_with_layout(
//! "output.pdf",
//! &elements,
//! "Helvetica",
//! 12.0,
//! layout,
//! ).expect("Failed to create PDF");
//! ```
//!
//! ## Modules
//!
//! - [`pdf`]: PDF document parsing and text extraction
//! - [`pdf_generator`]: PDF generation from elements and content streams
//! - [`pdf_ops`]: High-level PDF operations (merge, split, watermark, etc.)
//! - [`elements`]: Markdown parsing and element representation
//! - [`markdown`]: Markdown to PDF conversion utilities
//! - [`image`]: Image loading, parsing, and PDF embedding
//! - [`compression`]: Data compression utilities
//! - [`security`]: PDF security, encryption, and permission management
//! - [`builder`]: Fluent builder API for ergonomic PDF creation
//! - [`streaming`]: Memory-efficient streaming PDF generation for large documents
//! - [`parallel`]: High-performance parallel PDF operations using Rayon
//! - [`optimization`]: PDF optimization profiles for different use cases (web, print, archive, ebook)
//!
//! ## Examples
//!
//! ### Creating a PDF from Markdown
//!
//! ```rust,no_run
//! use pdfrs::markdown;
//!
//! markdown::markdown_to_pdf_full(
//! "input.md",
//! "output.pdf",
//! "Helvetica",
//! 12.0,
//! pdfrs::pdf_generator::PageOrientation::Portrait,
//! ).expect("Failed to convert");
//! ```
//!
//! ### Merging PDFs
//!
//! ```rust,no_run
//! use pdfrs::pdf_ops;
//!
//! pdf_ops::merge_pdfs(
//! &["file1.pdf", "file2.pdf"],
//! "merged.pdf",
//! ).expect("Failed to merge");
//! ```
//!
//! ### Adding a Watermark
//!
//! ```rust,no_run
//! use pdfrs::pdf_ops;
//!
//! pdf_ops::watermark_pdf(
//! "input.pdf",
//! "output.pdf",
//! "CONFIDENTIAL",
//! 48.0,
//! 0.3,
//! ).expect("Failed to add watermark");
//! ```
//!
//! ### Parallel PDF Operations
//!
//! ```rust,no_run
//! use pdfrs::parallel;
//!
//! // Merge multiple PDFs in parallel (loads inputs concurrently)
//! parallel::merge_pdfs_parallel(
//! &["file1.pdf", "file2.pdf", "file3.pdf"],
//! "merged.pdf",
//! ).expect("Failed to merge");
//!
//! // Extract text from multiple PDFs in parallel
//! let results = parallel::extract_text_parallel(&["doc1.pdf", "doc2.pdf"])
//! .expect("Failed to extract text");
//! for (path, text) in results {
//! println!("{}: {} characters", path, text.len());
//! }
//! ```
//!
//! ### PDF Optimization Profiles
//!
//! ```rust
//! use pdfrs::optimization::{OptimizationProfile, OptimizedPdfGenerator};
//!
//! // Create a web-optimized PDF (smallest file size)
//! let _pdf_gen = OptimizedPdfGenerator::new(OptimizationProfile::web());
//!
//! // Or create a print-optimized PDF (highest quality)
//! let _pdf_gen = OptimizedPdfGenerator::new(OptimizationProfile::print());
//!
//! // Or create a custom optimization profile
//! use pdfrs::optimization::{OptimizationSettings, CompressionLevel};
//! let settings = OptimizationSettings::new()
//! .with_compression(CompressionLevel::High)
//! .with_image_dpi(200);
//! let _pdf_gen = OptimizedPdfGenerator::new(OptimizationProfile::custom(settings));
//! ```