Edit images inside PDFs with a single line of code
PDFs are notoriously difficult to modify. Text editing is hard enough, but images? Most tools force you to extract the image, edit it externally, remove the old one, and carefully re-insert the new version - hoping the positioning doesn't break.
We think there's a better way.
Today we're releasing Image Transforms - a suite of in-place image manipulation capabilities that let you scale, rotate, crop, and transform images directly inside your PDFs. No extraction. No re-insertion headaches. Just clean, simple API calls.
What's included
The new Image Transform API includes seven operations, all designed to modify images in-place while preserving their position and context within the document:
Scale
Resize images by a factor or to specific dimensions. Optionally preserve aspect ratio to prevent distortion.
# Scale to 50% of original size
image.scale(0.5)
# Scale to specific dimensions, preserving aspect ratio
image.scale_to(width=200, height=150, preserve_aspect_ratio=True)Rotate
Rotate images by any angle. Perfect for fixing orientation issues or adjusting logos and signatures.
# Rotate 90 degrees clockwise
image.rotate(90)
# Rotate 180 degrees
image.rotate(180)Crop
Trim pixels from any edge. Useful for removing unwanted borders or focusing on specific parts of an image.
# Crop 10 pixels from all edges
image.crop(left=10, top=10, right=10, bottom=10)
# Crop only from the left
image.crop(left=50, top=0, right=0, bottom=0)Opacity
Adjust transparency from fully opaque (1.0) to fully transparent (0.0). Ideal for creating watermarks or subtle background images.
# Make image semi-transparent (50% opacity)
image.set_opacity(0.5)
# Create a subtle watermark (25% opacity)
image.set_opacity(0.25)Flip
Mirror images horizontally, vertically, or both. Useful for right-to-left layouts or creative effects.
from pdfdancer import ImageFlipDirection
# Mirror horizontally
image.flip(ImageFlipDirection.HORIZONTAL)
# Mirror vertically
image.flip(ImageFlipDirection.VERTICAL)
# Flip both directions
image.flip(ImageFlipDirection.BOTH)Replace
Swap an image with new content while keeping its position and bounding box. Perfect for template systems where placeholder images need to be replaced with real content.
from pdfdancer import Image
new_image = Image(
format="PNG",
width=100,
height=100,
data=image_data
)
image.replace(new_image)Move
Reposition images to new coordinates on the page.
# Move image to new position
image.move_to(x=200, y=350)All three SDKs, same capabilities
Image Transforms are available in Python, TypeScript, and Java with consistent APIs across all three:
Real-world use cases
Document templates
Create PDF templates with placeholder images that get replaced dynamically. A contract template might have a placeholder for a signature that gets swapped with the real thing at signing time.
Watermarking
Add your logo to a PDF and set its opacity to 20-30% for a professional watermark that doesn't obscure the content.
Batch processing
Process hundreds of PDFs at once - resize all logos to consistent dimensions, rotate scanned documents to the correct orientation, or crop whitespace from images.
Privacy and redaction
Crop sensitive areas from images or reduce their opacity before sharing documents externally.
Getting started
Update to the latest SDK version to access Image Transforms:
Check out the full documentation for detailed API references and more examples.