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 initial_transform(&self, invert_y: bool) -> Affine

Return the initial transform that should be applied when rendering. This accounts for a number of factors, such as the mismatch between PDF’s y-up and most renderers’ y-down coordinate system, the rotation of the page and the offset of the crop box.

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.

Examples found in repository?
examples/iterate.rs (line 24)
7fn main() {
8    // First load the data that constitutes the PDF file.
9    let data = std::fs::read(
10        PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../hayro-tests/pdfs/text_with_rise.pdf"),
11    )
12    .unwrap();
13
14    // Then create a new PDF file from it.
15    //
16    // Here we are just unwrapping in case reading the file failed, but you
17    // might instead want to apply proper error handling.
18    let pdf = Pdf::new(Arc::new(data)).unwrap();
19
20    // First access all pages, and then iterate over the operators of each page's
21    // content stream and print them.
22    let pages = pdf.pages();
23    for page in pages.iter() {
24        for op in page.typed_operations() {
25            println!("{op:?}");
26        }
27    }
28}

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> !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, 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.