Skip to main content

Page

Struct Page 

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

A PDF page.

Implementations§

Source§

impl<'a> Page<'a>

Source

pub fn page_stream(&self) -> Option<&[u8]>

Return the decoded content stream of the page.

Source

pub fn resources(&self) -> &Resources<'a>

Get the resources of the page.

Source

pub fn media_box(&self) -> Rect

Get the media box of the page.

Source

pub fn rotation(&self) -> Rotation

Get the rotation of the page.

Source

pub fn crop_box(&self) -> Rect

Get the crop box of the page.

Source

pub fn intersected_crop_box(&self) -> Rect

Return the intersection of crop box and media box.

Source

pub fn base_dimensions(&self) -> (f32, f32)

Return the base dimensions of the page used for the canvas size.

When the CropBox origin is within the MediaBox (i.e. CropBox.x0 >= MediaBox.x0 and CropBox.y0 >= MediaBox.y0), the canvas is sized to intersect(CropBox, MediaBox). This matches MuPDF’s behaviour for spec-violating PDFs where CropBox.y1 > MediaBox.y1 (e.g. gen-271: CropBox=[0,0,595,793.7] vs MediaBox=[0,0,612,792] — using raw CropBox gives 1654px height, a 4px vertical content offset, and SSIM 0.49; intersecting gives 1650px matching MuPDF exactly).

When CropBox extends below the MediaBox origin (gen-802 style: CropBox=[0,0,684,864] vs MediaBox=[36,36,648,828]), MuPDF still uses the full CropBox dimensions, so we do too. (#544, #558, gen-271)

Source

pub fn render_dimensions(&self) -> (f32, f32)

Return the with and height of the page that should be assumed when rendering the page.

Depending on the document, it is either based on the media box or the crop box of the page. In addition to that, it also takes the rotation of the page into account.

Source

pub fn operations(&self) -> UntypedIter<'_>

Return an untyped iterator over the operators of the page’s content stream.

Source

pub fn raw(&self) -> &Dict<'a>

Get the raw dictionary of the page.

Source

pub fn xref(&self) -> &'a XRef

Get the xref table (of the document the page belongs to).

Source

pub fn typed_operations(&self) -> TypedIter<'_>

Return a typed iterator over the operators of the page’s content stream.

Source

pub fn annots(&self) -> Vec<Dict<'a>>

Return the annotation dictionaries for this page, if any.

Auto Trait Implementations§

§

impl<'a> !Freeze for Page<'a>

§

impl<'a> !RefUnwindSafe for Page<'a>

§

impl<'a> Send for Page<'a>

§

impl<'a> Sync for Page<'a>

§

impl<'a> Unpin for Page<'a>

§

impl<'a> UnsafeUnpin for Page<'a>

§

impl<'a> !UnwindSafe for Page<'a>

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, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(value: T, _simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

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.