Document
Document
概述
Document 是 Aspose.PDF FOSS 中用于 Python 的类。
针对 PDF 文档生命周期和核心操作的 Pythonic 包装器。
此类提供 16 个用于在 Python 程序中处理 Document 对象的方法。可用的方法包括:__init__、change_passwords、check、close、decrypt、dispose、encrypt、flatten、free_memory、load_from、merge、optimize,以及另外 4 个方法。安装 Aspose.PDF FOSS for Python 包后,所有公共成员对任何 Python 应用程序均可访问。属性:file_name、form、id、info、is_disposed、is_encrypted,以及另外 10 项。
属性
| 名称 | 类型 | 访问 | 描述 |
|---|---|---|---|
load_limits | PdfLoadLimits | 读取 | 返回用于加载此文档的资源限制。 |
is_disposed | bool | 读取 | 暴露文档的处置状态。 |
page_count | int | 读取 | 当前文档中的页数。 |
file_name | Any | 读取 | 获取文件名。 |
info | Any | 读取 | 获取信息。 |
metadata | Any | 读取 | 获取元数据。 |
id | Any | 读取 | 获取 id。 |
version | Any | 读取 | 获取版本。 |
pages | Any | 读取 | 获取页面。 |
outlines | Any | 读取 | 获取大纲。 |
named_destinations | Any | 读取 | 获取已命名的目标。 |
form | Any | 读取 | 获取表单。 |
is_encrypted | Any | 读取 | 获取是否已加密。 |
permissions | Any | 读取 | 获取权限。 |
is_pdfa_compliant | Any | 读取 | 获取是否符合 PDF/A 标准。 |
is_pdfua_compliant | Any | 读取 | 获取是否符合 pdfua 标准。 |
方法
| 签名 | 描述 |
|---|---|
| `init(source: str | Path |
| `load_from(source: str | bytes |
save(destination: Any, save_format: Any, overwrite: bool) → Document | 将文档保存到 destination 使用本机引擎。 |
close() | :meth:dispose 的别名。 |
dispose() | 释放与此文档关联的资源。 |
merge() → Document | 合并提供的 documents 到当前的. |
optimize(compress_images: bool) → Document | 对文档进行通用优化。 |
optimize_resources(remove_unused: bool) → Document | 优化共享资源,如字体和图像。 |
repair() → Document | 尝试通过引擎修复文档结构。 |
flatten() → Document | 通过引擎将表单字段和注释展平。 |
free_memory() | 清除任何可能占用内存的缓存数据。 |
encrypt(password: str) → Document | 使用给定的方式加密文档 password. |
decrypt(password: str) → Document | 如果满足条件则解密文档 password 与已存储的匹配。 |
change_passwords(old_password: str, new_password: str) → Document | 将文档密码从 old_password to new_password. |
validate() → bool | 如果文档结构有效,返回 True。 |
check() → bool | 别名 :meth:validate 为了保持 API 兼容性而保留。 |