Skip to main content
Version: API v2 Preview

Image

Kind: class
Module/package: models
SDK: pdfdancer-client-python 2.0.0

Raster image to be placed on a page.

Parameters:

  • position: Where to place the image. Use Position.at_page_coordinates(page, x, y).
  • format: Image format hint for the server (e.g. "PNG", "JPEG"). Optional.
  • width: Target width in points. Optional; server may infer from data.
  • height: Target height in points. Optional; server may infer from data.
  • data: Raw image bytes. If provided, it will be base64-encoded in AddRequest.to_dict().

Example:

from pdfdancer.models import Image, Position, AddRequest

img = Image(
position=Position.at_page_coordinates(0, 72, 600),
format="PNG",
width=128,
height=64,
data=open("/path/logo.png", "rb").read(),
)
payload = AddRequest(img).to_dict()

Declaration

Image(position: pdfdancer.models.Position | None = None, format: str | None = None, width: float | None = None, height: float | None = None, data: bytes | None = None) -> None

Members

__init__

__init__(self, position: pdfdancer.models.Position | None = None, format: str | None = None, width: float | None = None, height: float | None = None, data: bytes | None = None) -> None

Initialize self. See help(type(self)) for accurate signature.

get_position

get_position(self) -> pdfdancer.models.Position | None

Returns the position of this image.

set_position

set_position(self, position: pdfdancer.models.Position) -> None

Sets the position of this image.

View source at af2a1171a1b9