docx_reader/documents/elements/
page_size.rs

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
use crate::types::*;

use serde::Serialize;

#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PageSize {
	w: u32,
	h: u32,
	orient: Option<PageOrientationType>,
}

// These values were based on microsoft office word2019 windows edition.
// <w:pgSz w:w="11906" w:h="16838"/>
impl Default for PageSize {
	fn default() -> PageSize {
		PageSize {
			w: 11906,
			h: 16838,
			orient: None,
		}
	}
}

impl PageSize {
	pub fn new() -> PageSize {
		Default::default()
	}

	pub fn size(self, w: u32, h: u32) -> PageSize {
		PageSize {
			w,
			h,
			orient: self.orient,
		}
	}

	pub fn width(mut self, w: u32) -> PageSize {
		self.w = w;
		self
	}

	pub fn height(mut self, h: u32) -> PageSize {
		self.h = h;
		self
	}

	pub fn orient(mut self, o: PageOrientationType) -> PageSize {
		self.orient = Some(o);
		self
	}
}