在 Python 中使用 PDF 工件
Contents
[
Hide
]
PDF 工件标记页面元素,例如装饰性背景、连续页眉和页脚以及水印。在标记的 PDF 中,辅助技术可以跳过工件,专注于文档的有意义内容。
选择指南
添加工件
检查工件
删除工件
工件 API
artifacts 属性返回页面的 ArtifactCollection 集合。Artifact 类提供 BackgroundArtifact、WatermarkArtifact、HeaderArtifact、FooterArtifact 和 BatesNArtifact 等专用类共有的属性。
| 任务 | 属性 |
|---|---|
| 识别工件 | 使用 type 和 subtype 用于标准分类和 custom_type 和 custom_subtype 用于自定义名称。 |
| 检查其内容 | 使用 text, image, 和 lines 对于文本和图像,或 contents 和 form 用于 PDF 操作符和相关的 XForm。 |
| 在页面上定位它 | 使用 rectangle 检查其边界。设置 position 用于显式放置或使用 left_margin, right_margin, top_margin, bottom_margin, artifact_horizontal_alignment, 和 artifact_vertical_alignment. 显式位置会覆盖边距和对齐。 |
| 控制其外观 | 使用 rotation, opacity (从 0 到 1),以及 text_state. 设置 is_background 将工件放置在页面内容后面。 |