1use std::path::Path;
8
9pub use crate::api_error::Error;
10
11pub enum PdfSource<'a> {
13 Path(&'a Path),
14 Bytes(&'a [u8]),
15}
16
17impl<'a> From<&'a str> for PdfSource<'a> {
18 fn from(s: &'a str) -> Self {
19 PdfSource::Path(Path::new(s))
20 }
21}
22
23impl<'a> From<&'a Path> for PdfSource<'a> {
24 fn from(p: &'a Path) -> Self {
25 PdfSource::Path(p)
26 }
27}
28
29impl<'a> From<&'a [u8]> for PdfSource<'a> {
30 fn from(b: &'a [u8]) -> Self {
31 PdfSource::Bytes(b)
32 }
33}
34
35#[derive(Default, Debug, Clone)]
37pub struct ReadOptions {
38 pub(crate) password: Option<String>,
39 pub(crate) repair: bool,
40}
41
42impl ReadOptions {
43 pub fn new() -> Self {
44 Self::default()
45 }
46
47 pub fn password(&mut self, pw: impl Into<String>) -> &mut Self {
48 self.password = Some(pw.into());
49 self
50 }
51
52 pub fn repair(&mut self, repair: bool) -> &mut Self {
53 self.repair = repair;
54 self
55 }
56}
57
58#[derive(Default, Debug, Clone)]
60pub struct SaveOptions {
61 pub(crate) format: Option<PdfFormat>,
62 pub(crate) linearize: bool,
63}
64
65impl SaveOptions {
66 pub fn new() -> Self {
67 Self::default()
68 }
69
70 pub fn format(&mut self, format: PdfFormat) -> &mut Self {
71 self.format = Some(format);
72 self
73 }
74
75 pub fn linearize(&mut self, linearize: bool) -> &mut Self {
76 self.linearize = linearize;
77 self
78 }
79}
80
81#[derive(Debug, Clone, Copy, PartialEq, Eq)]
82pub enum PdfFormat {
83 Pdf1_4,
84 Pdf1_7,
85 Pdf2_0,
86 PdfA1b,
87 PdfA2b,
88 PdfA3b,
89}
90
91#[derive(Default, Debug, Clone)]
92pub struct WatermarkOptions {
93 pub opacity: f64,
94 pub rotation: f64,
95}
96
97#[derive(Debug, Clone, Copy, PartialEq, Eq)]
98pub enum ImageFormat {
99 Png,
100 Jpeg,
101}
102
103pub struct TextBlock {
105 pub text: String,
106 pub bbox: [f64; 4],
107}
108
109pub struct Metadata {
111 pub title: Option<String>,
112 pub author: Option<String>,
113 pub creation_date: Option<String>,
114}
115
116pub struct FormField {
118 pub name: String,
119 pub value: String,
120 pub field_type: String,
121}
122
123pub struct Signature {
125 pub signer_name: String,
126 pub date: String,
127 pub is_valid: bool,
128}
129
130pub struct Document {
132 }
134
135impl Document {
136 pub fn text(&self) -> String {
140 unimplemented!("facade")
141 }
142
143 pub fn page(&self, page_number: usize) -> Page {
145 let _ = page_number;
146 unimplemented!("facade")
147 }
148
149 pub fn structured_text(&self) -> Vec<TextBlock> {
151 unimplemented!("facade")
152 }
153
154 pub fn page_count(&self) -> usize {
158 unimplemented!("facade")
159 }
160
161 pub fn metadata(&self) -> Metadata {
163 unimplemented!("facade")
164 }
165
166 pub fn save(&self, path: impl AsRef<Path>) -> Result<(), Error> {
170 let _ = path;
171 unimplemented!("facade")
172 }
173
174 pub fn save_with<F>(&self, path: impl AsRef<Path>, build_opts: F) -> Result<(), Error>
176 where
177 F: FnOnce(&mut SaveOptions) -> &mut SaveOptions,
178 {
179 let _ = path;
180 let _ = build_opts;
181 unimplemented!("facade")
182 }
183
184 pub fn form_fields(&self) -> Vec<FormField> {
188 unimplemented!("facade")
189 }
190
191 pub fn fill_form(&self, fields: &[(&str, &str)]) -> Result<(), Error> {
193 let _ = fields;
194 unimplemented!("facade")
195 }
196
197 pub fn flatten_forms(&self) -> Result<(), Error> {
199 unimplemented!("facade")
200 }
201
202 pub fn sign(&self, certificate: &[u8], private_key: &[u8]) -> Result<(), Error> {
206 let _ = certificate;
207 let _ = private_key;
208 unimplemented!("facade")
209 }
210
211 pub fn signatures(&self) -> Vec<Signature> {
213 unimplemented!("facade")
214 }
215
216 pub fn verify_signatures(&self) -> Result<bool, Error> {
218 unimplemented!("facade")
219 }
220
221 pub fn redact(&self, text: &str) -> Result<(), Error> {
225 let _ = text;
226 unimplemented!("facade")
227 }
228
229 pub fn redact_region(&self, page: usize, rect: [f64; 4]) -> Result<(), Error> {
231 let _ = page;
232 let _ = rect;
233 unimplemented!("facade")
234 }
235
236 pub fn to_docx(&self, path: impl AsRef<Path>) -> Result<(), Error> {
240 let _ = path;
241 unimplemented!("facade")
242 }
243
244 pub fn to_images(&self, pattern: &str, format: ImageFormat) -> Result<(), Error> {
246 let _ = pattern;
247 let _ = format;
248 unimplemented!("facade")
249 }
250
251 pub fn is_pdfa_compliant(&self) -> Result<bool, Error> {
253 unimplemented!("facade")
254 }
255
256 pub fn merge(&self, other_doc: &Document) -> Result<(), Error> {
260 let _ = other_doc;
261 unimplemented!("facade")
262 }
263
264 pub fn split_pages(&self) -> Result<Vec<Document>, Error> {
266 unimplemented!("facade")
267 }
268
269 pub fn rotate_page(&self, page: usize, angle: i32) -> Result<(), Error> {
271 let _ = page;
272 let _ = angle;
273 unimplemented!("facade")
274 }
275
276 pub fn add_watermark(&self, text: &str, options: WatermarkOptions) -> Result<(), Error> {
278 let _ = text;
279 let _ = options;
280 unimplemented!("facade")
281 }
282}
283
284pub struct Page {
286 }
288
289impl Page {
290 pub fn text(&self) -> String {
292 unimplemented!("facade")
293 }
294}
295
296pub fn read<'a, S: Into<PdfSource<'a>>>(input: S) -> Result<Document, Error> {
300 let _ = input;
301 unimplemented!("facade")
302}
303
304pub fn read_with<'a, S, F>(input: S, build_opts: F) -> Result<Document, Error>
306where
307 S: Into<PdfSource<'a>>,
308 F: FnOnce(&mut ReadOptions) -> &mut ReadOptions,
309{
310 let _ = input;
311 let _ = build_opts;
312 unimplemented!("facade")
313}