pub struct Document {}Expand description
The main entry point for a PDF Document.
Implementations§
Source§impl Document
impl Document
Sourcepub fn page(&self, page_number: usize) -> Page
pub fn page(&self, page_number: usize) -> Page
Accesses a specific page for text extraction and other operations (1-based index).
Sourcepub fn structured_text(&self) -> Vec<TextBlock>
pub fn structured_text(&self) -> Vec<TextBlock>
Extracts structured text blocks with coordinates.
Sourcepub fn page_count(&self) -> usize
pub fn page_count(&self) -> usize
Returns the total number of pages in the document.
Sourcepub fn save_with<F>(
&self,
path: impl AsRef<Path>,
build_opts: F,
) -> Result<(), Error>
pub fn save_with<F>( &self, path: impl AsRef<Path>, build_opts: F, ) -> Result<(), Error>
Saves the document with specific options.
Sourcepub fn form_fields(&self) -> Vec<FormField>
pub fn form_fields(&self) -> Vec<FormField>
Gets all form fields in the document.
Sourcepub fn fill_form(&self, fields: &[(&str, &str)]) -> Result<(), Error>
pub fn fill_form(&self, fields: &[(&str, &str)]) -> Result<(), Error>
Fills form fields matching the provided name-value pairs.
Sourcepub fn flatten_forms(&self) -> Result<(), Error>
pub fn flatten_forms(&self) -> Result<(), Error>
Flattens all forms, converting them to static content.
Sourcepub fn sign(&self, certificate: &[u8], private_key: &[u8]) -> Result<(), Error>
pub fn sign(&self, certificate: &[u8], private_key: &[u8]) -> Result<(), Error>
Signs the document using the provided certificate and private key.
Sourcepub fn signatures(&self) -> Vec<Signature>
pub fn signatures(&self) -> Vec<Signature>
Retrieves all signatures from the document.
Sourcepub fn verify_signatures(&self) -> Result<bool, Error>
pub fn verify_signatures(&self) -> Result<bool, Error>
Verifies the cryptographic validity of all signatures.
Sourcepub fn redact(&self, text: &str) -> Result<(), Error>
pub fn redact(&self, text: &str) -> Result<(), Error>
Redacts all occurrences of the specified text.
Sourcepub fn redact_region(&self, page: usize, rect: [f64; 4]) -> Result<(), Error>
pub fn redact_region(&self, page: usize, rect: [f64; 4]) -> Result<(), Error>
Redacts a specific rectangular region on the specified page.
Sourcepub fn to_docx(&self, path: impl AsRef<Path>) -> Result<(), Error>
pub fn to_docx(&self, path: impl AsRef<Path>) -> Result<(), Error>
Converts the document to a DOCX file.
Sourcepub fn to_images(&self, pattern: &str, format: ImageFormat) -> Result<(), Error>
pub fn to_images(&self, pattern: &str, format: ImageFormat) -> Result<(), Error>
Renders the document’s pages to images based on a filename pattern.
Sourcepub fn is_pdfa_compliant(&self) -> Result<bool, Error>
pub fn is_pdfa_compliant(&self) -> Result<bool, Error>
Checks if the document is PDF/A compliant.
Sourcepub fn merge(&self, other_doc: &Document) -> Result<(), Error>
pub fn merge(&self, other_doc: &Document) -> Result<(), Error>
Merges another document into this one.
Sourcepub fn split_pages(&self) -> Result<Vec<Document>, Error>
pub fn split_pages(&self) -> Result<Vec<Document>, Error>
Splits the document into individual 1-page documents.
Sourcepub fn rotate_page(&self, page: usize, angle: i32) -> Result<(), Error>
pub fn rotate_page(&self, page: usize, angle: i32) -> Result<(), Error>
Rotates a specific page by the given angle (in degrees).
Sourcepub fn add_watermark(
&self,
text: &str,
options: WatermarkOptions,
) -> Result<(), Error>
pub fn add_watermark( &self, text: &str, options: WatermarkOptions, ) -> Result<(), Error>
Adds a watermark to all pages of the document.
Auto Trait Implementations§
impl Freeze for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnsafeUnpin for Document
impl UnwindSafe for Document
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more