pub struct PdfDocument { /* private fields */ }Expand description
An open PDF document.
The document owns the PDF bytes for its whole lifetime (PDFium requires the backing buffer to stay valid while the document is open). Dropping the document releases the PDFium handle and, if forms were enabled, the form-fill environment first (in the order PDFium requires).
§Thread safety
PdfDocument is Send + Sync: every method serializes through the
process-wide FFI lock. Sharing one document across threads is safe;
calls will not run in parallel.
Implementations§
Source§impl PdfDocument
impl PdfDocument
Sourcepub fn page_count(&self) -> usize
pub fn page_count(&self) -> usize
Number of pages.
Sourcepub fn pages(&self) -> impl Iterator<Item = Result<PdfPage<'_>>>
pub fn pages(&self) -> impl Iterator<Item = Result<PdfPage<'_>>>
Iterates over all pages, opening each lazily.
Sourcepub fn page_size(&self, index: usize) -> Result<PageSize>
pub fn page_size(&self, index: usize) -> Result<PageSize>
Page size in points without loading the page — cheap for dimension surveys of large documents.
Sourcepub fn form_type(&self) -> FormType
pub fn form_type(&self) -> FormType
The document’s interactive form type (cheap; does not initialize form rendering).
Sourcepub fn enable_form_rendering(&self) -> Result<()>
pub fn enable_form_rendering(&self) -> Result<()>
Initializes PDFium’s form-fill environment so
RenderConfig::form_fields
can draw AcroForm field appearances.
Idempotent. Pages opened after this call participate in form rendering; enable forms before opening pages you intend to render.
Sourcepub fn forms_enabled(&self) -> bool
pub fn forms_enabled(&self) -> bool
Whether enable_form_rendering has
been called successfully.
Sourcepub fn permissions(&self) -> Permissions
pub fn permissions(&self) -> Permissions
Document permissions from the encryption dictionary. Unencrypted documents report all permissions granted.
Sourcepub fn security_handler_revision(&self) -> Option<i32>
pub fn security_handler_revision(&self) -> Option<i32>
Security handler revision (2/3/4/5/6), or None for unencrypted
documents.
Sourcepub fn pdf_version(&self) -> Option<i32>
pub fn pdf_version(&self) -> Option<i32>
PDF file version as reported by the header, times ten
(14 = PDF 1.4, 17 = PDF 1.7, 20 = PDF 2.0). None if unavailable.
Sourcepub fn metadata(&self, tag: MetadataTag) -> Option<String>
pub fn metadata(&self, tag: MetadataTag) -> Option<String>
A standard metadata field, or None when absent/empty.
Sourcepub fn page_label(&self, index: usize) -> Option<String>
pub fn page_label(&self, index: usize) -> Option<String>
The page label for index (e.g. “iv”, “A-2”), or None when the
document defines no label for it.