dais_document/page.rs
1/// Dimensions of a document page.
2#[derive(Debug, Clone, Copy)]
3pub struct PageDimensions {
4 /// Width in PDF points (1 point = 1/72 inch).
5 pub width_pts: f32,
6 /// Height in PDF points.
7 pub height_pts: f32,
8}
9
10impl PageDimensions {
11 /// Aspect ratio (width / height).
12 pub fn aspect_ratio(&self) -> f32 {
13 self.width_pts / self.height_pts
14 }
15
16 /// Whether this is approximately 16:9 (within tolerance).
17 pub fn is_widescreen(&self) -> bool {
18 (self.aspect_ratio() - 16.0 / 9.0).abs() < 0.05
19 }
20
21 /// Whether this is approximately 4:3 (within tolerance).
22 pub fn is_standard(&self) -> bool {
23 (self.aspect_ratio() - 4.0 / 3.0).abs() < 0.05
24 }
25}
26
27/// Target size for rendering a page.
28///
29/// Each window requests rasterization at its own appropriate resolution.
30/// This is a runtime parameter, not a global constant — the architectural
31/// prerequisite for zoom/magnification features.
32#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
33pub struct RenderSize {
34 /// Target width in pixels.
35 pub width: u32,
36 /// Target height in pixels.
37 pub height: u32,
38}
39
40/// A rendered page as an RGBA bitmap.
41#[derive(Debug, Clone)]
42pub struct RenderedPage {
43 /// RGBA pixel data (4 bytes per pixel, row-major).
44 pub data: Vec<u8>,
45 /// Width in pixels.
46 pub width: u32,
47 /// Height in pixels.
48 pub height: u32,
49}