rust_pdf_box/stamp/
options.rs1use std::ops::RangeInclusive;
2
3#[derive(Debug, Clone, PartialEq, Eq)]
5pub enum PageRange {
6 All,
7 Single(usize),
8 Range(RangeInclusive<usize>),
9 Odd,
10 Even,
11 Pages(Vec<usize>),
12}
13
14impl PageRange {
15 pub fn matches(&self, page_index_0_based: usize, _total_pages: usize) -> bool {
16 let page_1_based = page_index_0_based + 1;
17 match self {
18 Self::All => true,
19 Self::Single(p) => *p == page_1_based,
20 Self::Range(r) => r.contains(&page_1_based),
21 Self::Odd => page_1_based % 2 != 0,
22 Self::Even => page_1_based % 2 == 0,
23 Self::Pages(list) => list.contains(&page_1_based),
24 }
25 }
26}
27
28#[derive(Debug, Clone, Copy, PartialEq, Eq)]
30pub enum StampLayer {
31 UnderContent,
32 OverContent,
33}
34
35#[derive(Debug, Clone, Copy, PartialEq)]
37pub enum StampPosition {
38 Center,
39 TopLeft { margin_x: f64, margin_y: f64 },
40 TopCenter { margin_y: f64 },
41 TopRight { margin_x: f64, margin_y: f64 },
42 BottomLeft { margin_x: f64, margin_y: f64 },
43 BottomCenter { margin_y: f64 },
44 BottomRight { margin_x: f64, margin_y: f64 },
45 Custom { x: f64, y: f64 },
46}