Skip to main content

PdfDocument

Struct PdfDocument 

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

A high-level representation of a PDF document.

This is the main entry point for creating and modifying PDF documents.

Implementations§

Source§

impl PdfDocument

Source

pub fn create() -> Self

Create a new, empty PDF document.

Source

pub fn load(bytes: &[u8]) -> Result<Self>

Load an existing PDF document from bytes.

Source

pub fn load_with_options(bytes: &[u8], options: LoadOptions) -> Result<Self>

Load an existing PDF document from bytes with options.

Source

pub fn save(&self) -> Vec<u8>

Save the document to PDF bytes.

Source

pub fn is_encrypted(&self) -> bool

Returns true if the document is encrypted.

Source

pub fn get_page_count(&self) -> usize

Get the number of pages in the document.

Source

pub fn get_page_indices(&self) -> Vec<usize>

Get the page indices (0-based).

Source

pub fn add_page(&mut self, size: [f64; 2]) -> PdfRef

Add a new blank page to the end of the document with the given size.

Source

pub fn insert_page(&mut self, index: usize, size: [f64; 2]) -> PdfRef

Insert a new blank page at the given index.

Source

pub fn remove_page(&mut self, index: usize)

Remove a page at the given index.

Source

pub fn copy_pages( &mut self, src_doc: &PdfDocument, indices: &[usize], ) -> Vec<PdfRef>

Copy pages from another document. Returns the new page refs.

Source

pub fn set_title(&mut self, title: &str)

Set the document title.

Source

pub fn set_author(&mut self, author: &str)

Set the document author.

Source

pub fn set_subject(&mut self, subject: &str)

Set the document subject.

Source

pub fn set_keywords(&mut self, keywords: &[&str])

Set the document keywords.

Source

pub fn set_creator(&mut self, creator: &str)

Set the document creator.

Source

pub fn set_producer(&mut self, producer: &str)

Set the document producer.

Source

pub fn get_title(&self) -> Option<String>

Get the document title, if any.

Source

pub fn get_author(&self) -> Option<String>

Get the document author, if any.

Source

pub fn context(&self) -> &PdfContext

Get direct access to the context (for advanced use).

Source

pub fn context_mut(&mut self) -> &mut PdfContext

Get mutable access to the context.

Source

pub fn get_page_refs(&self) -> Vec<PdfRef>

Get the refs for each page (public for inspection).

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.