Skip to main content
Version: API v2 Preview

ImageObject

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

Represents an image object inside a PDF page.

Declaration

ImageObject(client: "'PDFDancer'", internal_id: 'str', object_type: 'ObjectType', position: 'Position')

Members

__init__

__init__(self, client: "'PDFDancer'", internal_id: 'str', object_type: 'ObjectType', position: 'Position')

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

clear_clipping

clear_clipping(self) -> 'bool'

Detach any active clipping path from this object.

crop

crop(self, left: 'int' = 0, top: 'int' = 0, right: 'int' = 0, bottom: 'int' = 0) -> "'CommandResult'"

Crop this image by removing pixels from edges.

Args: left: Pixels to crop from left edge top: Pixels to crop from top edge right: Pixels to crop from right edge bottom: Pixels to crop from bottom edge

Returns: CommandResult indicating success or failure

delete

delete(self) -> 'bool'

Delete this object from the PDF document.

fill_region

fill_region(self, x: 'int', y: 'int', width: 'int', height: 'int', color: "'Color'") -> "'CommandResult'"

Fill a rectangular region within this image with a solid color.

Args: x: X coordinate of the region (pixels from left edge of image) y: Y coordinate of the region (pixels from top edge of image) width: Width of the region in pixels height: Height of the region in pixels color: Fill color as a Color object (alpha channel is ignored)

Returns: CommandResult indicating success or failure

flip

flip(self, direction: "'ImageFlipDirection'") -> "'CommandResult'"

Flip this image in the specified direction.

Args: direction: Flip direction (HORIZONTAL, VERTICAL, or BOTH)

Returns: CommandResult indicating success or failure

flip_horizontal

flip_horizontal(self) -> "'CommandResult'"

flip_vertical

flip_vertical(self) -> "'CommandResult'"

move_to

move_to(self, x: 'float', y: 'float') -> 'bool'

Move this object to a new position.

object_ref

object_ref(self) -> 'ObjectRef'

replace

replace(self, new_image: "'Image'") -> "'CommandResult'"

Replace this image with a new image.

Args: new_image: The new Image object to replace this one with

Returns: CommandResult indicating success or failure

replace_from_file

replace_from_file(self, image_path: 'Path') -> "'CommandResult'"

rotate

rotate(self, angle: 'float') -> "'CommandResult'"

Rotate this image by a specified angle.

Args: angle: Rotation angle in degrees (positive = clockwise)

Returns: CommandResult indicating success or failure

scale

scale(self, factor: 'float') -> "'CommandResult'"

Scale this image by a factor.

Args: factor: Scale factor (e.g., 0.5 for half size, 2.0 for double size)

Returns: CommandResult indicating success or failure

scale_to

scale_to(self, width: 'float', height: 'float', preserve_aspect_ratio: 'bool' = True) -> "'CommandResult'"

Scale this image to a target size.

Args: width: Target width height: Target height preserve_aspect_ratio: If True, maintain proportions (default True)

Returns: CommandResult indicating success or failure

set_opacity

set_opacity(self, opacity: 'float') -> "'CommandResult'"

Set the opacity of this image.

Args: opacity: Opacity value from 0.0 (fully transparent) to 1.0 (fully opaque)

Returns: CommandResult indicating success or failure

aspect_ratio

aspect_ratio: 'Optional[float]'

height

height: 'Optional[float]'

page_number

page_number: 'int'

Page index where this object resides.

width

width: 'Optional[float]'

View source at af2a1171a1b9