pub struct BoundingBox {
pub page_number: Option<u32>,
pub last_page_number: Option<u32>,
pub left_x: f64,
pub bottom_y: f64,
pub right_x: f64,
pub top_y: f64,
}Expand description
A rectangular bounding box in PDF coordinate space.
PDF coordinates: origin at bottom-left, Y increases upward. 72 points = 1 inch.
(leftX, topY) ──────── (rightX, topY)
│ │
│ Element │
│ │
(leftX, bottomY) ──── (rightX, bottomY)Fields§
§page_number: Option<u32>Page number (1-based)
last_page_number: Option<u32>Last page number (for cross-page elements)
left_x: f64Left X coordinate
bottom_y: f64Bottom Y coordinate
right_x: f64Right X coordinate
top_y: f64Top Y coordinate
Implementations§
Source§impl BoundingBox
impl BoundingBox
Sourcepub fn new(
page: Option<u32>,
left_x: f64,
bottom_y: f64,
right_x: f64,
top_y: f64,
) -> Self
pub fn new( page: Option<u32>, left_x: f64, bottom_y: f64, right_x: f64, top_y: f64, ) -> Self
Create a new BoundingBox.
Sourcepub fn is_one_page(&self) -> bool
pub fn is_one_page(&self) -> bool
Whether this element is on a single page.
Sourcepub fn is_multi_page(&self) -> bool
pub fn is_multi_page(&self) -> bool
Whether this element spans multiple pages.
Sourcepub fn union(&self, other: &BoundingBox) -> BoundingBox
pub fn union(&self, other: &BoundingBox) -> BoundingBox
Compute the union of two bounding boxes.
Sourcepub fn overlaps(&self, other: &BoundingBox) -> bool
pub fn overlaps(&self, other: &BoundingBox) -> bool
Whether this bounding box overlaps with another.
Sourcepub fn contains(&self, other: &BoundingBox) -> bool
pub fn contains(&self, other: &BoundingBox) -> bool
Whether this bounding box fully contains another.
Sourcepub fn weakly_contains(&self, other: &BoundingBox) -> bool
pub fn weakly_contains(&self, other: &BoundingBox) -> bool
Weakly contains: allows small margin of error.
Sourcepub fn intersection_percent(&self, other: &BoundingBox) -> f64
pub fn intersection_percent(&self, other: &BoundingBox) -> f64
Compute intersection area percentage relative to other.
Sourcepub fn vertical_intersection_percent(&self, other: &BoundingBox) -> f64
pub fn vertical_intersection_percent(&self, other: &BoundingBox) -> f64
Vertical intersection percentage.
Sourcepub fn vertical_gap(&self, other: &BoundingBox) -> f64
pub fn vertical_gap(&self, other: &BoundingBox) -> f64
Vertical gap between two bounding boxes.
Sourcepub fn horizontal_gap(&self, other: &BoundingBox) -> f64
pub fn horizontal_gap(&self, other: &BoundingBox) -> f64
Horizontal gap between two bounding boxes.
Sourcepub fn are_horizontal_overlapping(&self, other: &BoundingBox) -> bool
pub fn are_horizontal_overlapping(&self, other: &BoundingBox) -> bool
Whether two bounding boxes horizontally overlap.
Sourcepub fn are_vertical_overlapping(&self, other: &BoundingBox) -> bool
pub fn are_vertical_overlapping(&self, other: &BoundingBox) -> bool
Whether two bounding boxes vertically overlap.
Sourcepub fn to_json_array(&self) -> [f64; 4]
pub fn to_json_array(&self) -> [f64; 4]
Serialize to JSON array format: [leftX, bottomY, rightX, topY]
Trait Implementations§
Source§impl Clone for BoundingBox
impl Clone for BoundingBox
Source§fn clone(&self) -> BoundingBox
fn clone(&self) -> BoundingBox
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BoundingBox
impl Debug for BoundingBox
Source§impl<'de> Deserialize<'de> for BoundingBox
impl<'de> Deserialize<'de> for BoundingBox
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for BoundingBox
impl PartialEq for BoundingBox
Auto Trait Implementations§
impl Freeze for BoundingBox
impl RefUnwindSafe for BoundingBox
impl Send for BoundingBox
impl Sync for BoundingBox
impl Unpin for BoundingBox
impl UnsafeUnpin for BoundingBox
impl UnwindSafe for BoundingBox
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more