Home > front end >  How to replace a specific image within a pdf?
How to replace a specific image within a pdf?

Time:12-08

I have a pdf with 3 images

enter image description here

I want to find each image and replace it with another image

I saw in the pdf the original paths under xmpMM:Ingredients:

enter image description here

I tried to change it via notepad but it looks like the images are already embedded and changing the path does nothing.

Is there any way to find each image and replace it with another image?

Thanks in advanced!

CodePudding user response:

The xmp stuff is information only. The actual images are embedded streams in the pdf file. Finding the correct streams to replace and replacing them isn't a simple problem, and can't be done with notepad. You'll need a library / toolkit that can modify PDFs, like https://pdf-lib.js.org/ or similar.

The PDF file looks like an Illustrator file, which adds another layer of weirdness - Illustrator can write PDFs that have both PDF and Illustrator versions of the content, and you see one in Acrobat and the other in Illustrator.

It's probably easier to recreate the PDF from whatever source produced it.

  • Related