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
//! PDF editing module for modifying existing PDF documents.
//!
//! This module provides a high-level API for editing PDF documents:
//! - Metadata editing (title, author, subject, keywords)
//! - Page operations (add, remove, reorder, extract)
//! - Content manipulation
//! - PDF merging
//!
//! ## Architecture
//!
//! ```text
//! PdfDocument (read-only source)
//! ↓
//! [DocumentEditor] (tracks modifications)
//! ↓
//! Save Options:
//! - Incremental update (append to original)
//! - Full rewrite (new PDF structure)
//! ```
//!
//! ## Encryption Handling
//!
//! When opening encrypted PDFs:
//!
//! - **Reading**: Encrypted PDFs are decrypted transparently when opened.
//! The user/owner password can be provided via `PdfDocument::open_with_password()`.
//! Once opened, all content is accessible in decrypted form.
//!
//! - **Writing**: Saved PDFs are written **unencrypted** by default.
//! The original encryption is **not preserved** during save operations.
//! This is intentional as encryption requires separate configuration.
//!
//! ### Current Limitations
//!
//! Re-encryption on save is not yet supported. If you need to preserve encryption:
//!
//! 1. Save the modified PDF without encryption
//! 2. Use an external tool to re-encrypt:
//! ```bash
//! qpdf --encrypt user-pass owner-pass 256 -- unencrypted.pdf encrypted.pdf
//! ```
//!
//! ### Planned for v0.4.0
//!
//! `SaveOptions::with_encryption()` will allow specifying encryption on save:
//!
//! ```ignore
//! // Future API (v0.4.0)
//! editor.save_with_options("output.pdf", SaveOptions::full_rewrite()
//! .with_encryption(EncryptionConfig {
//! user_password: "user123".to_string(),
//! owner_password: "owner456".to_string(),
//! algorithm: EncryptionAlgorithm::Aes256,
//! permissions: Permissions::default(),
//! })
//! )?;
//! ```
//!
//! ## Example
//!
//! ```ignore
//! use pdf_oxide::editor::DocumentEditor;
//!
//! // Open an existing PDF for editing
//! let mut editor = DocumentEditor::open("input.pdf")?;
//!
//! // Edit metadata
//! editor.set_title("Updated Title");
//! editor.set_author("John Doe");
//!
//! // Modify pages
//! editor.remove_page(5)?;
//! editor.move_page(2, 0)?; // Move page 2 to front
//!
//! // Save changes
//! editor.save("output.pdf")?; // Full rewrite
//! // or
//! editor.save_incremental("output.pdf")?; // Append changes
//! ```
pub use ;
pub use ;
pub use ;
pub use ResourceManager;