1use serde::Deserialize;
2
3#[derive(Debug, Clone, Copy, PartialEq, Deserialize)]
4pub struct PdfRect {
5 pub x: f64,
6 pub y: f64,
7 pub width: f64,
8 pub height: f64,
9}
10
11#[derive(Debug, Clone, Copy, PartialEq, Deserialize)]
12pub struct PdfPoint {
13 pub x: f64,
14 pub y: f64,
15}
16
17#[derive(Debug, Clone, Copy, PartialEq, Deserialize)]
18pub struct PdfSize {
19 pub width: f64,
20 pub height: f64,
21}
22
23#[derive(Debug, Clone, Copy, PartialEq, Deserialize)]
24pub struct PdfEdgeInsets {
25 pub top: f64,
26 pub left: f64,
27 pub bottom: f64,
28 pub right: f64,
29}
30
31#[derive(Debug, Clone, Copy, PartialEq, Deserialize)]
32pub struct PdfColor {
33 pub red: f64,
34 pub green: f64,
35 pub blue: f64,
36 pub alpha: f64,
37}
38
39#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
40pub struct PdfTextRange {
41 pub location: usize,
42 pub length: usize,
43}
44
45#[derive(Debug, Clone, Copy, PartialEq, Eq)]
46#[repr(i32)]
47pub enum DisplayBox {
48 MediaBox = 0,
49 CropBox = 1,
50 BleedBox = 2,
51 TrimBox = 3,
52 ArtBox = 4,
53}
54
55impl DisplayBox {
56 #[must_use]
57 pub const fn as_raw(self) -> i32 {
58 self as i32
59 }
60}
61
62#[derive(Debug, Clone, Copy, PartialEq, Eq)]
63#[repr(i32)]
64pub enum PdfBorderStyle {
65 Solid = 0,
66 Dashed = 1,
67 Beveled = 2,
68 Inset = 3,
69 Underline = 4,
70}
71
72impl PdfBorderStyle {
73 #[must_use]
74 pub const fn from_raw(raw: i32) -> Option<Self> {
75 match raw {
76 0 => Some(Self::Solid),
77 1 => Some(Self::Dashed),
78 2 => Some(Self::Beveled),
79 3 => Some(Self::Inset),
80 4 => Some(Self::Underline),
81 _ => None,
82 }
83 }
84}
85
86#[derive(Debug, Clone, Copy, PartialEq, Eq)]
87#[repr(i32)]
88pub enum PdfDisplayMode {
89 SinglePage = 0,
90 SinglePageContinuous = 1,
91 TwoUp = 2,
92 TwoUpContinuous = 3,
93}
94
95impl PdfDisplayMode {
96 #[must_use]
97 pub const fn from_raw(raw: i32) -> Option<Self> {
98 match raw {
99 0 => Some(Self::SinglePage),
100 1 => Some(Self::SinglePageContinuous),
101 2 => Some(Self::TwoUp),
102 3 => Some(Self::TwoUpContinuous),
103 _ => None,
104 }
105 }
106}
107
108#[derive(Debug, Clone, Copy, PartialEq, Eq)]
109#[repr(i32)]
110pub enum PdfDisplayDirection {
111 Vertical = 0,
112 Horizontal = 1,
113}
114
115impl PdfDisplayDirection {
116 #[must_use]
117 pub const fn from_raw(raw: i32) -> Option<Self> {
118 match raw {
119 0 => Some(Self::Vertical),
120 1 => Some(Self::Horizontal),
121 _ => None,
122 }
123 }
124}
125
126#[derive(Debug, Clone, Copy, PartialEq, Eq)]
127#[repr(i32)]
128pub enum PdfInterpolationQuality {
129 None = 0,
130 Low = 1,
131 High = 2,
132}
133
134impl PdfInterpolationQuality {
135 #[must_use]
136 pub const fn from_raw(raw: i32) -> Option<Self> {
137 match raw {
138 0 => Some(Self::None),
139 1 => Some(Self::Low),
140 2 => Some(Self::High),
141 _ => None,
142 }
143 }
144}
145
146#[derive(Debug, Clone, Copy, PartialEq, Eq)]
147#[repr(i32)]
148pub enum PdfWidgetControlType {
149 Unknown = -1,
150 PushButton = 0,
151 RadioButton = 1,
152 CheckBox = 2,
153}
154
155impl PdfWidgetControlType {
156 #[must_use]
157 pub const fn from_raw(raw: i32) -> Option<Self> {
158 match raw {
159 -1 => Some(Self::Unknown),
160 0 => Some(Self::PushButton),
161 1 => Some(Self::RadioButton),
162 2 => Some(Self::CheckBox),
163 _ => None,
164 }
165 }
166}
167
168#[derive(Debug, Clone, Copy, PartialEq, Eq)]
169#[repr(i32)]
170pub enum PdfDocumentPermissions {
171 None = 0,
172 User = 1,
173 Owner = 2,
174}
175
176impl PdfDocumentPermissions {
177 #[must_use]
178 pub const fn from_raw(raw: i32) -> Option<Self> {
179 match raw {
180 0 => Some(Self::None),
181 1 => Some(Self::User),
182 2 => Some(Self::Owner),
183 _ => None,
184 }
185 }
186}
187
188#[derive(Debug, Clone, Deserialize)]
189pub struct PdfDocumentInfo {
190 pub document_url: Option<String>,
191 pub major_version: i32,
192 pub minor_version: i32,
193 pub is_encrypted: bool,
194 pub is_locked: bool,
195 pub permissions_status: i32,
196 pub access_permissions: u64,
197 pub allows_printing: bool,
198 pub allows_copying: bool,
199 pub allows_document_changes: bool,
200 pub allows_document_assembly: bool,
201 pub allows_content_accessibility: bool,
202 pub allows_commenting: bool,
203 pub allows_form_field_entry: bool,
204 pub page_class: String,
205}
206
207impl PdfDocumentInfo {
208 #[must_use]
209 pub fn permissions_status_enum(&self) -> Option<PdfDocumentPermissions> {
210 PdfDocumentPermissions::from_raw(self.permissions_status)
211 }
212}
213
214#[derive(Debug, Clone, Deserialize)]
215pub struct PdfDocumentAttributes {
216 pub title: Option<String>,
217 pub author: Option<String>,
218 pub subject: Option<String>,
219 pub creator: Option<String>,
220 pub producer: Option<String>,
221 pub creation_date: Option<String>,
222 pub modification_date: Option<String>,
223 pub keywords: Option<Vec<String>>,
224}
225
226#[derive(Debug, Clone, Deserialize)]
227pub struct PdfBorderInfo {
228 pub style: i32,
229 pub line_width: f64,
230 pub dash_pattern: Option<Vec<f64>>,
231}
232
233impl PdfBorderInfo {
234 #[must_use]
235 pub fn style_enum(&self) -> Option<PdfBorderStyle> {
236 PdfBorderStyle::from_raw(self.style)
237 }
238}
239
240#[derive(Debug, Clone, Deserialize)]
241pub struct PdfAnnotationInfo {
242 pub annotation_type: Option<String>,
243 pub bounds: PdfRect,
244 pub contents: Option<String>,
245 pub should_display: bool,
246 pub should_print: bool,
247 pub has_appearance_stream: bool,
248 pub user_name: Option<String>,
249 pub modification_date: Option<String>,
250 pub color: Option<PdfColor>,
251 pub highlighted: bool,
252 pub action_type: Option<String>,
253 pub border: Option<PdfBorderInfo>,
254}
255
256#[derive(Debug, Clone, Deserialize)]
257pub struct PdfDestinationInfo {
258 pub page_label: Option<String>,
259 pub page_index: Option<usize>,
260 pub point: PdfPoint,
261 pub zoom: f64,
262}
263
264#[derive(Debug, Clone, Deserialize)]
265pub struct PdfAppearanceCharacteristicsInfo {
266 pub control_type: i32,
267 pub background_color: Option<PdfColor>,
268 pub border_color: Option<PdfColor>,
269 pub rotation: i32,
270 pub caption: Option<String>,
271 pub rollover_caption: Option<String>,
272 pub down_caption: Option<String>,
273}
274
275impl PdfAppearanceCharacteristicsInfo {
276 #[must_use]
277 pub fn control_type_enum(&self) -> Option<PdfWidgetControlType> {
278 PdfWidgetControlType::from_raw(self.control_type)
279 }
280}
281
282#[derive(Debug, Clone, Deserialize)]
283pub struct PdfViewInfo {
284 pub display_mode: i32,
285 pub display_direction: i32,
286 pub displays_page_breaks: bool,
287 pub page_break_margins: PdfEdgeInsets,
288 pub display_box: i32,
289 pub displays_as_book: bool,
290 pub displays_rtl: bool,
291 pub background_color: Option<PdfColor>,
292 pub interpolation_quality: i32,
293 pub page_shadows_enabled: bool,
294 pub scale_factor: f64,
295 pub min_scale_factor: f64,
296 pub max_scale_factor: f64,
297 pub auto_scales: bool,
298 pub scale_factor_for_size_to_fit: f64,
299 pub in_markup_mode: bool,
300 pub has_document_view: bool,
301 pub visible_page_count: usize,
302 pub current_page_label: Option<String>,
303}
304
305impl PdfViewInfo {
306 #[must_use]
307 pub fn display_mode_enum(&self) -> Option<PdfDisplayMode> {
308 PdfDisplayMode::from_raw(self.display_mode)
309 }
310
311 #[must_use]
312 pub fn display_direction_enum(&self) -> Option<PdfDisplayDirection> {
313 PdfDisplayDirection::from_raw(self.display_direction)
314 }
315
316 #[must_use]
317 pub fn interpolation_quality_enum(&self) -> Option<PdfInterpolationQuality> {
318 PdfInterpolationQuality::from_raw(self.interpolation_quality)
319 }
320
321 #[must_use]
322 pub fn display_box_enum(&self) -> Option<DisplayBox> {
323 match self.display_box {
324 0 => Some(DisplayBox::MediaBox),
325 1 => Some(DisplayBox::CropBox),
326 2 => Some(DisplayBox::BleedBox),
327 3 => Some(DisplayBox::TrimBox),
328 4 => Some(DisplayBox::ArtBox),
329 _ => None,
330 }
331 }
332}
333
334#[derive(Debug, Clone, Deserialize)]
335pub struct PdfThumbnailViewInfo {
336 pub has_pdf_view: bool,
337 pub background_color: Option<PdfColor>,
338 pub selected_pages_count: usize,
339 pub thumbnail_size: PdfSize,
340 pub maximum_number_of_columns: usize,
341 pub allows_dragging: bool,
342 pub allows_multiple_selection: bool,
343}