pub struct PdfDocument { /* private fields */ }Expand description
Parsed PDF document handle used for inspection, redaction, and save.
Implementations§
Source§impl PdfDocument
impl PdfDocument
Sourcepub fn open(bytes: &[u8]) -> PdfResult<Self>
pub fn open(bytes: &[u8]) -> PdfResult<Self>
Opens an unencrypted PDF from raw bytes, or an encrypted PDF
whose user password is empty. For encrypted PDFs that require a
user- or owner-supplied password, use
PdfDocument::open_with_password.
Sourcepub fn open_with_password(bytes: &[u8], password: &[u8]) -> PdfResult<Self>
pub fn open_with_password(bytes: &[u8], password: &[u8]) -> PdfResult<Self>
Opens an encrypted PDF from raw bytes using the supplied password.
The password is tried first as the user password, then as the
owner password; if neither authenticates, the function returns
pdf_objects::PdfError::InvalidPassword. For unencrypted
documents the password is ignored.
Sourcepub fn open_with_certificate(
bytes: &[u8],
cert_der: &[u8],
private_key_der: &[u8],
) -> PdfResult<Self>
pub fn open_with_certificate( bytes: &[u8], cert_der: &[u8], private_key_der: &[u8], ) -> PdfResult<Self>
Opens an Adobe.PubSec-encrypted PDF using the recipient’s X.509
certificate and matching RSA private key, both DER-encoded
(PKCS#8 for the private key, the standard form returned by most
browser key-management APIs). Returns
pdf_objects::PdfError::InvalidPassword when no recipient blob
in the PDF unwraps with the supplied private key. For
password-encrypted or unencrypted documents this returns
pdf_objects::PdfError::Unsupported — use
PdfDocument::open_with_password / PdfDocument::open
respectively.
Sourcepub fn page_count(&self) -> usize
pub fn page_count(&self) -> usize
Returns the number of pages in the parsed document.
Sourcepub fn page_size(&self, page_index: usize) -> PdfResult<PageSize>
pub fn page_size(&self, page_index: usize) -> PdfResult<PageSize>
Returns the normalized page size for a zero-based page index.
Sourcepub fn extract_text(&self, page_index: usize) -> PdfResult<PageText>
pub fn extract_text(&self, page_index: usize) -> PdfResult<PageText>
Extracts page text and geometry for the current supported subset.
Sourcepub fn search_text(
&self,
page_index: usize,
query: &str,
) -> PdfResult<Vec<TextMatch>>
pub fn search_text( &self, page_index: usize, query: &str, ) -> PdfResult<Vec<TextMatch>>
Searches page text in visual glyph order and returns page-space match geometry.
Sourcepub fn apply_redactions(
&mut self,
plan: RedactionPlan,
) -> PdfResult<ApplyReport>
pub fn apply_redactions( &mut self, plan: RedactionPlan, ) -> PdfResult<ApplyReport>
Applies a redaction plan in place to the opened document.
Auto Trait Implementations§
impl !Freeze for PdfDocument
impl RefUnwindSafe for PdfDocument
impl Send for PdfDocument
impl Sync for PdfDocument
impl Unpin for PdfDocument
impl UnsafeUnpin for PdfDocument
impl UnwindSafe for PdfDocument
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> 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