Skip to main content

PDDocument

Struct PDDocument 

Source
pub struct PDDocument {
    pub cos_doc: COSDocument,
    pub catalog: PDDocumentCatalog,
    pub pages: Vec<PDPage>,
    pub info: PDDocumentInformation,
}
Expand description

High-level PDF document representing pages, metadata, catalog and content streams.

Fields§

§cos_doc: COSDocument§catalog: PDDocumentCatalog§pages: Vec<PDPage>§info: PDDocumentInformation

Implementations§

Source§

impl PDDocument

Source

pub fn new() -> Self

Creates a new, empty PDF document with catalog and info dictionaries.

Source

pub fn load_from_bytes(bytes: &[u8]) -> PdfResult<Self>

Loads a PDF document from raw byte slice.

Source

pub fn load_from_file(path: impl AsRef<Path>) -> PdfResult<Self>

Loads a PDF document from a file path.

Source

pub fn page_count(&self) -> usize

Number of pages in the document.

Source

pub fn pages(&self) -> &[PDPage]

Returns a slice of all pages.

Source

pub fn pages_mut(&mut self) -> &mut [PDPage]

Returns a mutable slice of all pages.

Source

pub fn get_page(&self, index: usize) -> PdfResult<&PDPage>

Gets a page reference by 0-based index.

Source

pub fn get_page_mut(&mut self, index: usize) -> PdfResult<&mut PDPage>

Gets a mutable page reference by 0-based index.

Source

pub fn add_page(&mut self, page: PDPage) -> ObjectId

Appends a new page to the document.

Source

pub fn insert_page(&mut self, index: usize, page: PDPage) -> ObjectId

Inserts a page at a given 0-based index.

Source

pub fn remove_page(&mut self, index: usize) -> PdfResult<()>

Removes a page by 0-based index.

Source

pub fn sync(&mut self)

Synchronizes all modified pages, resources, and info metadata back to the COSDocument.

Source

pub fn save_to_writer<W: Write>(&mut self, writer: W) -> PdfResult<()>

Saves the document to any writer implementing Write.

Source

pub fn save_to_file(&mut self, path: impl AsRef<Path>) -> PdfResult<()>

Saves the document to a file.

Source

pub fn save_incremental<W: Write>( &mut self, prev_bytes: &[u8], writer: W, ) -> PdfResult<()>

Appends an incremental update to original bytes and writes the result.

Source

pub fn stamp(&self) -> Stamper

Creates a fluent Stamper for watermarking, headers/footers, and rubber stamps.

Source

pub fn sign(&mut self, signer: Signer) -> PdfResult<Vec<u8>>

Digitally signs the document using the given Signer and returns the signed PDF bytes.

Trait Implementations§

Source§

impl Clone for PDDocument

Source§

fn clone(&self) -> PDDocument

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PDDocument

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PDDocument

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V