Struct PdfiumPageBoundaries

Source
pub struct PdfiumPageBoundaries<'a> { /* private fields */ }
Expand description

Rust interface to the boundary boxes of a page

PDF pages define multiple nested boundary boxes that serve different purposes in the document lifecycle, from creation to final output.

MediaBox The MediaBox represents the full physical size of a PDF page. It includes every possible part of the layout—bleed area, crop marks, and artwork. It’s essentially the outermost boundary and acts like the canvas that all other boxes sit on. Every PDF must have a MediaBox, and it’s the largest of the five.

CropBox The CropBox defines the visible area of the page when viewed on a screen or printed by default. It acts as a “window” through which the page content is displayed in most PDF viewers. This box doesn’t usually affect professional printing, but it’s important for digital previews and general display.

BleedBox The BleedBox extends slightly beyond the final trim size to include artwork that “bleeds” off the edge of the page. This is especially important in printing, as it prevents unwanted white margins if the paper is cut slightly off-target. Designers typically allow 3 to 5 mm of bleed outside the TrimBox.

TrimBox The TrimBox defines the finished size of the printed page after it’s been trimmed. In professional printing workflows, this box is the most critical—it determines how the page will be cut and positioned. For example, if you’re printing a business card or a poster, the TrimBox sets the final dimensions.

ArtBox The ArtBox outlines the area that contains the meaningful content—like text, logos, or illustrations. It’s useful in cases where you want to mark a “safe zone” so that nothing important sits too close to the edge. While not used as often, it’s handy for laying out advertisements or design elements within a page.

Implementations§

Source§

impl<'a> PdfiumPageBoundaries<'a>

Source

pub fn new(page: &'a PdfiumPage) -> PdfiumPageBoundaries<'a>

Source

pub fn art(&self) -> PdfiumResult<PdfiumRect>

Gets the “ArtBox” entry from the page dictionary.

The ArtBox defines the extent of the page’s meaningful content (including potential white space) as intended by the page’s creator. This is typically used by print production software and represents the “artistic” boundary of the page content. It should be contained within or equal to the CropBox.

Source

pub fn bleed(&self) -> PdfiumResult<PdfiumRect>

Gets the “BleedBox” entry from the page dictionary.

The BleedBox defines the region to which the contents of the page should be clipped when output in a production environment. This may include any extra bleed area needed to accommodate the physical limitations of cutting, folding, and trimming equipment. The bleed box should be larger than or equal to the TrimBox.

Source

pub fn crop(&self) -> PdfiumResult<PdfiumRect>

Gets the “CropBox” entry from the page dictionary.

The CropBox defines the visible region of default user space. When the page is displayed or printed, its contents should be clipped to this rectangle and then imposed on the output medium. This is what viewers typically show as the “page” and defaults to the MediaBox if not specified. The CropBox should be contained within the MediaBox.

Source

pub fn media(&self) -> PdfiumResult<PdfiumRect>

Gets the “MediaBox” entry from the page dictionary.

The MediaBox defines the boundaries of the physical medium on which the page is to be printed. This represents the largest possible page size and is required for every page. All other page boundary boxes should be contained within or equal to the MediaBox. This is typically the paper size (e.g., A4, Letter, etc.).

Source

pub fn trim(&self) -> PdfiumResult<PdfiumRect>

Gets the “TrimBox” entry from the page dictionary.

The TrimBox defines the intended dimensions of the finished page after trimming. This represents the final size of the page as it will appear to the end user after any production cutting/trimming processes. It should be contained within or equal to the BleedBox and is commonly used in professional printing workflows.

Source

pub fn default(&self) -> PdfiumResult<PdfiumRect>

Gets the default boundary for use by PDF viewers

Returns the most appropriate boundary box for displaying the page in a PDF viewer or similar application. This method implements a fallback hierarchy to determine the best viewing area:

  1. CropBox - The primary choice, as it defines the visible region intended for display and is what most PDF viewers show by default
  2. TrimBox - Used if CropBox is not available, representing the final page dimensions after trimming
  3. MediaBox - The fallback option, representing the full physical page size

This method ensures that viewer applications always have a valid boundary to work with, since MediaBox is required to exist in every PDF page. The returned rectangle represents the area that should be visible to end users when viewing the document.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.