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: PDDocumentInformationImplementations§
Source§impl PDDocument
impl PDDocument
Sourcepub fn load_from_bytes(bytes: &[u8]) -> PdfResult<Self>
pub fn load_from_bytes(bytes: &[u8]) -> PdfResult<Self>
Loads a PDF document from raw byte slice.
Sourcepub fn load_from_file(path: impl AsRef<Path>) -> PdfResult<Self>
pub fn load_from_file(path: impl AsRef<Path>) -> PdfResult<Self>
Loads a PDF document from a file path.
Sourcepub fn page_count(&self) -> usize
pub fn page_count(&self) -> usize
Number of pages in the document.
Sourcepub fn get_page(&self, index: usize) -> PdfResult<&PDPage>
pub fn get_page(&self, index: usize) -> PdfResult<&PDPage>
Gets a page reference by 0-based index.
Sourcepub fn get_page_mut(&mut self, index: usize) -> PdfResult<&mut PDPage>
pub fn get_page_mut(&mut self, index: usize) -> PdfResult<&mut PDPage>
Gets a mutable page reference by 0-based index.
Sourcepub fn insert_page(&mut self, index: usize, page: PDPage) -> ObjectId
pub fn insert_page(&mut self, index: usize, page: PDPage) -> ObjectId
Inserts a page at a given 0-based index.
Sourcepub fn remove_page(&mut self, index: usize) -> PdfResult<()>
pub fn remove_page(&mut self, index: usize) -> PdfResult<()>
Removes a page by 0-based index.
Sourcepub fn sync(&mut self)
pub fn sync(&mut self)
Synchronizes all modified pages, resources, and info metadata back to the COSDocument.
Sourcepub fn save_to_writer<W: Write>(&mut self, writer: W) -> PdfResult<()>
pub fn save_to_writer<W: Write>(&mut self, writer: W) -> PdfResult<()>
Saves the document to any writer implementing Write.
Sourcepub fn save_to_file(&mut self, path: impl AsRef<Path>) -> PdfResult<()>
pub fn save_to_file(&mut self, path: impl AsRef<Path>) -> PdfResult<()>
Saves the document to a file.
Sourcepub fn save_incremental<W: Write>(
&mut self,
prev_bytes: &[u8],
writer: W,
) -> PdfResult<()>
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.
Trait Implementations§
Source§impl Clone for PDDocument
impl Clone for PDDocument
Source§fn clone(&self) -> PDDocument
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PDDocument
impl Debug for PDDocument
Auto Trait Implementations§
impl Freeze for PDDocument
impl RefUnwindSafe for PDDocument
impl Send for PDDocument
impl Sync for PDDocument
impl Unpin for PDDocument
impl UnsafeUnpin for PDDocument
impl UnwindSafe for PDDocument
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more