Page
Page
概述
Page 是 Aspose.PDF FOSS 中用于 Python 的类。
PDF 文档的一页。
此类提供了 10 个方法,用于在 Python 程序中处理 Page 对象。可用的方法包括:__init__、accept、add_image、add_text、draw_line、draw_rectangle、redact_text、render、replace_text、save_as_image。在安装了 Aspose.PDF FOSS for Python 包后,所有公共成员对任何 Python 应用程序均可访问。属性:annotations、content、crop_box、index、media_box、rect,以及另 1 项。
属性
| 名称 | 类型 | 访问 | 描述 |
|---|---|---|---|
index | int | 读写 | 页面的零基索引。 |
rect | tuple[float, float, float, float] | 读取 | 获取页面矩形(MediaBox)。 |
annotations | AnnotationCollection | 读取 | 获取页面上的注释集合。 |
media_box | tuple[float, float, float, float] | 读取 | rect 的别名。 |
rotation | int | 读写 | 页面顺时针旋转的角度(0、90、180、270 之一)。 |
crop_box | tuple[float, float, float, float] | 读写 | 页面 CropBox (x0, y0, x1, y1);未设置时回退到 MediaBox。 |
content | bytes | 读取 | 获取页面内容流。 |
方法
| 签名 | 描述 |
|---|---|
__init__(document: Document, index: int) | Calls init(document, index) 在此 Page 实例上。 |
| `add_text(text: str, x: float, y: float, font_size: float, font_name: str | None, font: FontDescriptor |
| `add_image(image: bytes | bytearray |
| `draw_rectangle(x: float, y: float, width: float, height: float, stroke_color: Sequence[float] | None, fill_color: Sequence[float] |
| `draw_line(x1: float, y1: float, x2: float, y2: float, stroke_color: Sequence[float], line_width: float, tag: str | None, alt: str |
accept(visitor: Any) | 将此页面分派给实现 visit(page) 的对象。 |
| `render(dpi: float, scale: float, background: tuple[int, int, int], antialias: bool | int)→RasterizedPage` |
| `save_as_image(path: str | Path, dpi: float, scale: float, background: tuple[int, int, int], antialias: bool |
replace_text(search: str, replacement: str, case_sensitive: bool, max_count: int) → int | 替换此页面上简单文本显示操作数中的现有文本。 |
redact_text(search: str, case_sensitive: bool, max_count: int, overlay: bool, overlay_color: Sequence[float]) → int | 删除此页面上简单文本显示操作数中的现有文本。 |