Page
Overview
Page is a class in Aspose.PDF FOSS for Python.
A page of a PDF document.
This class provides 10 methods for working with Page objects in Python programs.
Available methods include: __init__, accept, add_image, add_text, draw_line, draw_rectangle, redact_text, render, replace_text, save_as_image.
All public members are accessible to any Python application after installing the Aspose.PDF FOSS for Python package.
Properties: annotations, content, crop_box, index, media_box, rect, and 1 more.
Properties
| Name | Type | Access | Description |
|---|---|---|---|
index | int | Read/Write | The zero-based index of the page. |
rect | tuple[float, float, float, float] | Read | Get the page rectangle (MediaBox). |
annotations | AnnotationCollection | Read | Get the collection of annotations on the page. |
media_box | tuple[float, float, float, float] | Read | Alias for rect. |
rotation | int | Read/Write | The page rotation in degrees, clockwise (one of 0, 90, 180, 270). |
crop_box | tuple[float, float, float, float] | Read/Write | The page CropBox (x0, y0, x1, y1); falls back to the MediaBox when unset. |
content | bytes | Read | Get the page content stream. |
Methods
| Signature | Description |
|---|---|
__init__(document: Document, index: int) | Calls init(document, index) on this Page instance. |
add_text(text: str, x: float, y: float, font_size: float, font_name: str | None, font: FontDescriptor | bytes | bytearray | str | Path | None, color: Sequence[float], tag: str | None, actual_text: str | None, layout: TextLayoutOptions | None) → Page | Append positioned text to this page. |
add_image(image: bytes | bytearray | str | Path, x: float, y: float, width: float | None, height: float | None, pixel_width: int | None, pixel_height: int | None, color_space: str, bits_per_component: int, name: str | None, tag: str | None, alt: str | None, actual_text: str | None) → str | Place an image on this page and return its resource name. |
draw_rectangle(x: float, y: float, width: float, height: float, stroke_color: Sequence[float] | None, fill_color: Sequence[float] | None, line_width: float, tag: str | None, alt: str | None, actual_text: str | None) → Page | Append a stroked and/or filled rectangle to this page. |
draw_line(x1: float, y1: float, x2: float, y2: float, stroke_color: Sequence[float], line_width: float, tag: str | None, alt: str | None, actual_text: str | None) → Page | Append a stroked line segment to this page. |
accept(visitor: Any) | Dispatch this page to an object implementing visit(page). |
render(dpi: float, scale: float, background: tuple[int, int, int], antialias: bool | int) → RasterizedPage | Render this page to an RGB raster image. |
save_as_image(path: str | Path, dpi: float, scale: float, background: tuple[int, int, int], antialias: bool | int) → Path | Render this page and save it as .png or .tif/.tiff. |
replace_text(search: str, replacement: str, case_sensitive: bool, max_count: int) → int | Replace existing text in simple text-showing operands on this page. |
redact_text(search: str, case_sensitive: bool, max_count: int, overlay: bool, overlay_color: Sequence[float]) → int | Remove existing text from simple text-showing operands on this page. |