4

I'm looking for a method to replace an image in an existing PDF file (setup as a template).

In a perfect world I could just run a command (linux or windows will work, I'm not picky) at the command line, however, if need be, I could also implement something using a scripting language or even a full blown program at this point (I have visual studio).

I honestly can't believe how hard it has been to find an example of this being done somewhere.

We're running Windows w/ Cygwin and have Acrobat Pro XI as well as Illustrator CS6 from which the PDF file is originally created.

Essentially what we're looking for is an efficient way to replace images for PDF files that we're sending to the printing house.

Tom Stromar
  • 41
  • 1
  • 2
  • Are all of the images the same size? And do they have to be put in the same location? Does your template PDF also need to contain an image or could it just have empty space? Are the size / location of the image always the same? – David van Driessche Jan 22 '16 at 15:05
  • We have a number of pieces that we produce. The simplest is just a postcard that will have a single image to replace. The most complicated is a brochure that was about 15. Right now the process is to open a piece in illustrator and then change the link of each placed image and save as PDF. the size and location of a given image is always the same. The finished piece has to have a image but the template can or cannot have one. – Tom Stromar Jan 23 '16 at 18:39
  • Wouldn't it be simpler than to create templates without images in them and simply insert the images once you have them? The problem with replacing images is that you have find them and remove them from the PDF stream. If all you need to do is insert new images, that task may be much easier (certainly so if those images are always at the very top or the very bottom of the Z-order of objects on the page. You could create a PDF file with the images and simply superimpose it in front or back of your template PDF and you'd be done, no? – David van Driessche Jan 25 '16 at 21:44
  • Ok - hadn't considered that would be easier. Do you have any suggestions for the easiest way to add those images? – Tom Stromar Jan 31 '16 at 07:14
  • 1
    I'm pretty sure you could accomplish that by scripting either Acrobat or Illustrator, but there are also lots of command-line utilities that feature similar functionality; an example here would be the "stamp" functionality from PDFtk (https://www.pdflabs.com/docs/pdftk-man-page/#dest-op-stamp) – David van Driessche Jan 31 '16 at 17:28
  • Thanks David - that looks like exactly the type of thing I'm looking for. I'm going to play around a bit with this and see if I can make it work :) – Tom Stromar Feb 06 '16 at 22:17
  • Glad I could point you in the right direction (hopefully :)) - if it works, let me know and I'll write this comment stream up as a real answer you can approve. – David van Driessche Feb 07 '16 at 12:07
  • duplicate of [Replace an image in a PDF using command line](https://unix.stackexchange.com/questions/208232/replace-an-image-in-a-pdf-using-command-line) – milahu Jun 28 '23 at 12:20

0 Answers0