easyofd_core/model/
ofd_page.rs1use crate::model::content_object::ContentObject;
4use crate::model::image_object::ImageObject;
5use crate::model::path_object::PathObject;
6use crate::model::text_object::TextObject;
7
8#[derive(Debug, Clone)]
10pub struct OfdPage {
11 pub width: f64,
13 pub height: f64,
15 pub content: Vec<ContentObject>,
17 pub base_path: Option<String>,
22}
23
24impl OfdPage {
25 #[must_use]
27 pub fn new(width: f64, height: f64) -> Self {
28 Self {
29 width,
30 height,
31 content: Vec::new(),
32 base_path: None,
33 }
34 }
35
36 #[must_use]
38 pub fn with_base_path(mut self, path: impl Into<String>) -> Self {
39 self.base_path = Some(path.into());
40 self
41 }
42
43 pub fn add_text(&mut self, text: TextObject) {
45 self.content.push(ContentObject::Text(text));
46 }
47
48 pub fn add_image(&mut self, image: ImageObject) {
50 self.content.push(ContentObject::Image(image));
51 }
52
53 pub fn add_path(&mut self, path: PathObject) {
55 self.content.push(ContentObject::Path(path));
56 }
57}