PDFDocument

Struct PDFDocument 

Source
pub struct PDFDocument { /* private fields */ }
Expand description

Represents a PDF document with all its components and functionality.

This struct encapsulates a parsed PDF document, providing access to its cross-reference table, version information, tokenizer, and page structure.

Implementations§

Source§

impl PDFDocument

Source

pub fn open(path: PathBuf) -> Result<PDFDocument>

Opens a PDF document from a file path.

This function opens a PDF file, reads its content, and parses it into a PDFDocument.

§Arguments
  • path - The path to the PDF file to open
§Returns

A Result containing the parsed PDFDocument or an error if the file cannot be opened or parsed correctly

Source

pub fn new(sequence: impl Sequence + 'static) -> Result<PDFDocument>

Creates a PDF document from a sequence of bytes.

This function parses a sequence of bytes representing a PDF document and constructs a PDFDocument instance with all its components.

§Arguments
  • sequence - A sequence implementation providing access to the PDF bytes
§Returns

A Result containing the parsed PDFDocument or an error if parsing fails

Source

pub fn get_xref_slice(&self) -> &[XEntry]

Gets a reference to the cross-reference table slice.

§Returns

A slice reference to the vector of cross-reference entries

Source

pub fn find_xref_index<F>(&self, visit: F) -> Option<usize>
where F: Fn(&XEntry) -> bool,

Finds the index of a cross-reference entry that matches a condition.

§Arguments
  • visit - A closure that takes a reference to an XEntry and returns a boolean
§Returns

An optional index of the first matching entry, or None if no entry matches

Source

pub fn get_version(&self) -> &PDFVersion

Gets the PDF version information.

§Returns

A reference to the PDFVersion struct containing version information

Source

pub fn read_object(&mut self, index: usize) -> Result<Option<PDFObject>>

Reads an object from the PDF document by its index.

§Arguments
  • index - The index of the object to read from the cross-reference table
§Returns

A Result containing an optional PDFObject (None if the index is out of bounds or the object is freed) or an error if reading/parsing fails

Source

pub fn read_object_with_ref( &mut self, tuple: ObjRefTuple, ) -> Result<Option<PDFObject>>

Source

pub fn get_page_num(&self) -> usize

Source

pub fn get_page_ids(&self) -> Vec<u64>

Source

pub fn get_page(&self, node_id: u64) -> Option<&PageNode>

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