Docento.app Logo
Docento.app
Wide desk shot with documents
All Posts

How to Replace an Image in a PDF Cleanly

May 2, 2026·8 min read

Sometimes you need to swap an image inside a PDF rather than modify the surrounding text. The logo is out of date, the chart needs the latest numbers, the product photo is wrong. Replacing the image without touching anything else preserves all the surrounding content and layout. The mechanics are simple in good tools and painful in bad ones. This guide walks through how to do it cleanly.

When you would replace an image

  • Logo refresh. The company rebranded; every PDF template needs the new logo.
  • Chart update. Quarterly numbers changed; the chart image needs to reflect the current data.
  • Product photography. A product datasheet has the wrong color variant.
  • Personalization. Per-recipient PDFs need a swapped photo or signature.
  • Stock image swap. Replacing a generic placeholder with a real photograph after design.
  • Correcting a mistake. The original image is wrong, blurry, or has a typo.

Tools that replace images

Adobe Acrobat Pro. Tools → Edit PDF → click the image → Replace Image → choose new file. The cleanest GUI workflow.

Foxit PDF Editor. Right-click the image → Replace Image. Similar UX.

LibreOffice Draw. Open the PDF, right-click the image → Replace. Re-export as PDF.

Browser-based. Docento.app supports clicking an image and replacing it via upload, with the new image scaled to fit the original frame.

CLI tools (advanced):

  • pikepdf + Pillow. Identify the image object in the PDF, swap its bytes for a new image. Useful for batch jobs.
  • pdfrw. Similar Python library with object-level access.
  • PyMuPDF (fitz). page.insert_image(rect=image_bbox, filename="new.png") replaces an image at specific coordinates.

For one-off replacement, the GUI is easier. For "replace logo on every page of every PDF in this folder", scripting is the only sane option.

What "replace" preserves

A clean image replacement preserves:

  • The position of the image on the page
  • The size and aspect ratio of the original frame
  • Surrounding content layout (text reflows? no, surrounding content stays put)
  • The page count of the document
  • Bookmarks, links, and annotations elsewhere in the document
  • The original page boxes (MediaBox, CropBox)

What changes is just the image bytes inside the existing image object. The page references the same object index; the new bytes replace the old ones at that index.

Preparing the replacement image

Before you replace, prepare the new image to match expectations:

  • Same aspect ratio as the original. Otherwise it will either stretch or letterbox. Crop or pad the source image to match.
  • Same or higher resolution. A 1000×800 replacement for a 500×400 image renders fine; a 200×160 replacement will look pixelated.
  • Same color profile. If the original PDF uses CMYK and you replace with an RGB image, colors may shift. Convert to the right color space first.
  • Transparent background if needed. For a logo replacing a logo, transparency in the new image lets surrounding content show through. PNG with alpha channel is the right format.
  • Strip EXIF metadata if the source is a photograph, see how to strip metadata from PDF.

A 60-second prep pass beats a 60-minute "why does it look weird" debugging session.

Identifying the right image

A PDF page may have many images stacked. Identifying which to replace:

  • Visually. In Acrobat / Foxit, click the visible image. The editor highlights its bounding box.
  • By layer. Some tools show images grouped by layer.
  • Programmatically. Use pikepdf to list images per page; identify by index, position, or original filename.

For PDFs where multiple images are involved, name your replacements explicitly so you do not swap the wrong one.

Batch replacement

For "replace logo across 100 PDFs":

import pikepdf

def replace_image_at_index(pdf_path, page_index, image_index, new_image_path):
    with pikepdf.open(pdf_path, allow_overwriting_input=True) as pdf:
        page = pdf.pages[page_index]
        images = list(page.images.items())
        if image_index < len(images):
            name, img_obj = images[image_index]
            with open(new_image_path, 'rb') as f:
                new_bytes = f.read()
            img_obj.write(new_bytes, filter=pikepdf.Name('/DCTDecode'))
        pdf.save()

for f in glob.glob("*.pdf"):
    replace_image_at_index(f, 0, 0, "new_logo.png")

(Simplified, production code needs filter detection for JPEG vs PNG, transparency handling, and error checking.)

Replacing the image at a different size

If the new image is a different aspect ratio than the original, you have choices:

  1. Stretch to fill, the new image distorts. Usually wrong.
  2. Fit inside, letterbox or pillarbox with whitespace. Safe but may look odd.
  3. Crop to fit, center the new image, crop edges. Good for photos.
  4. Replace and resize the image frame, change the frame to match the new image's aspect. Tools like Acrobat let you click and drag the frame to a new size.

For controlled use cases (a logo replacing a logo of the same aspect), this is not a concern. For ad-hoc replacements, decide before clicking.

Replacing scanned signatures

A common workflow: replace a scanned signature image with a fresh signature. See how to create an electronic signature.

Mechanically the same as any image replacement. Prepare the new signature image (transparent background, suitable resolution), open the PDF, replace.

For legally-binding workflows, consider whether you need an actual digital signature instead. See digital signatures vs electronic signatures.

Common gotchas

Image quality drops. The PDF tool re-encodes the image during replacement. Use lossless or high-quality settings to avoid degradation. Acrobat Pro lets you specify image compression in advanced settings.

Color shifts. RGB→CMYK conversions, or ICC profile mismatches, can produce visible color changes. Verify with a printed test if color matters.

Position changes slightly. Some tools snap the replacement image to the corner or center of the frame, depending on its aspect ratio. Verify the position after replacement.

The replacement is bigger than the page. A 4000×3000 image replacing a small thumbnail balloons file size. Resize before replacing.

Multiple images on the same page. Easy to swap the wrong one if they look similar. Always confirm the bounding box highlight before clicking Replace.

Linked images. Some PDFs reference external images rather than embedding them. Replacing requires changing the reference, not the image bytes. Rare in modern PDFs but possible.

Tagged PDF alt text. A tagged PDF has alt text associated with each image. When replacing, update the alt text to reflect the new content. Forgetting this is one of the easiest accessibility regressions. See tagged PDF vs untagged PDF.

Hyperlinks attached to the image. If the original image was a clickable link, the link may or may not survive replacement depending on the tool. Test after replacing.

Encrypted PDF. Replacing an image in a password-protected PDF requires the password and may invalidate signatures. See how to remove a password from a PDF for permissions and how to password protect a PDF to re-protect afterward.

Signature invalidation. A digitally-signed PDF cannot be modified. Replace before signing, or accept signature invalidation.

A practical recipe

For a single logo replacement:

  1. Prepare the new logo: same aspect ratio as old, transparent background, 300 DPI minimum, no EXIF.
  2. Open the PDF in Acrobat / Foxit / Docento.app.
  3. Tools → Edit PDF.
  4. Click the existing logo.
  5. Right-click → Replace Image → select the new logo.
  6. Verify position and size.
  7. Save as a new file.
  8. Open in a different viewer to confirm.

For batch:

  1. Prepare the new logo.
  2. Write a script that opens each PDF, finds the image at the expected location, and swaps it.
  3. Run on a test folder of 5 files first; verify visually.
  4. Run on the full set.
  5. Verify a random sample of the output.

Alternative: redact and add a new image

If the original image cannot be reliably identified or replaced, an alternative is to redact (cover with a white box) the area and add a new image on top. The visual result is the same; the file structure is different.

This is sometimes the only path for stubborn PDFs whose original images cannot be cleanly replaced.

Takeaway

Replacing an image in a PDF is a clean operation in any decent editor. The mechanics are simple; the preparation is what produces a good result. Match aspect ratio, resolution, and color profile to the original before replacing. For batch jobs, scripted replacement via pikepdf or PyMuPDF is reliable. For browser-based workflows that combine image replacement with adding text or annotations, Docento.app handles the whole pipeline. Always verify the result in a separate viewer, image-replacement bugs are easy to miss in the same tool that created them.

Related Posts