Document
Overview
Document is a class in Aspose.PDF FOSS for Python.
Pythonic wrapper for PDF document lifecycle and core operations.
This class provides 16 methods for working with Document objects in Python programs.
Available methods include: __init__, change_passwords, check, close, decrypt, dispose, encrypt, flatten, free_memory, load_from, merge, optimize, and 4 additional methods.
All public members are accessible to any Python application after installing the Aspose.PDF FOSS for Python package.
Properties: file_name, form, id, info, is_disposed, is_encrypted, and 10 more.
Properties
| Name | Type | Access | Description |
|---|---|---|---|
load_limits | PdfLoadLimits | Read | Return the resource limits used for loading this document. |
is_disposed | bool | Read | Expose the disposal state of the document. |
page_count | int | Read | Number of pages currently in the document. |
file_name | Any | Read | Gets the file name. |
info | Any | Read | Gets the info. |
metadata | Any | Read | Gets the metadata. |
id | Any | Read | Gets the id. |
version | Any | Read | Gets the version. |
pages | Any | Read | Gets the pages. |
outlines | Any | Read | Gets the outlines. |
named_destinations | Any | Read | Gets the named destinations. |
form | Any | Read | Gets the form. |
is_encrypted | Any | Read | Gets the is encrypted. |
permissions | Any | Read | Gets the permissions. |
is_pdfa_compliant | Any | Read | Gets the is pdfa compliant. |
is_pdfua_compliant | Any | Read | Gets the is pdfua compliant. |
Methods
| Signature | Description |
|---|---|
__init__(source: str | Path | bytes | bytearray | BinaryIO | None, options: Any, password: str | None, limits: PdfLoadLimits | None) | Create a new :class:Document instance. |
load_from(source: str | bytes | bytearray | Path | BinaryIO, password: str | None, limits: PdfLoadLimits | None) → Document | Load a document from source using native engine. |
save(destination: Any, save_format: Any, overwrite: bool) → Document | Save the document to destination using native engine. |
close() | Alias of :meth:dispose. |
dispose() | Release resources associated with this document. |
merge() → Document | Merge the supplied documents into the current one. |
optimize(compress_images: bool) → Document | Perform generic optimizations on the document. |
optimize_resources(remove_unused: bool) → Document | Optimize shared resources such as fonts and images. |
repair() → Document | Attempt to repair the document’s structure via the engine. |
flatten() → Document | Flatten form fields and annotations via the engine. |
free_memory() | Clear any cached data that might hold onto memory. |
encrypt(password: str) → Document | Encrypt the document with the given password. |
decrypt(password: str) → Document | Decrypt the document if password matches the stored one. |
change_passwords(old_password: str, new_password: str) → Document | Change the document’s password from old_password to new_password. |
validate() → bool | Return True if the document is structurally valid. |
check() → bool | Alias for :meth:validate kept for API compatibility. |