Skip to main content
Participating Frequently
February 29, 2012
Answered

How to request - Updating an embedded image in a PDF using Actions but not all actions are recorded

  • February 29, 2012
  • 1 reply
  • 2564 views

i am trying to create an Action in CS3 but some of my actions are not been recorded.

What i want to do is run the Batch option on a folder with a 1,000 PDFs in it. The PDFs

(which were created in Illustrator CS3) consist of a single page with a single embedded

image at the foot of the page. I am trying to update that embedded image.


The Actions i am trying to record are...


1) Select the single image in the Links palette.
2) Choose the "Relink.." option in the drop down menu of the Links palette.
3) Navigate to the new image and select "Place".
4) Save and close document.


But the first two actions are not been recorded.


How do i get around this problem ?


Note: From trying this manually the new image seems to take on the horizontal and

vertical scaling of the previous image which is what i want. But if i am going to have to

do a script then that is a factor that may have to be incorporated into the script.

Any help appreciated.

This topic has been closed for replies.
Correct answer Muppet Mark

If you are using a preset [Illustrator Default] then that should be all I need ( I will go check ) It's just a saved list of opions… much easier than setting all the properties out ( a long list )… I will rework it…


Give this a trial… It does a save as which is much safer than overwriting… At least you still have your originals should I get something wrong…? I did test but only with 3 files…

#target illustrator

function replaceImage() {

 

          var i, doc, fileList, inFolder, outFolder, opts, pic, rep, rip, saveFile, uIL;

          inFolder = Folder.selectDialog( 'Please choose your Folder of AI PDFs…' );

 

          outFolder = Folder.selectDialog( 'Please choose a Folder to save AI PDFs in…' );

 

          pic = File.openDialog( 'Please choose your replacement Image…' );

          if ( inFolder != null && outFolder  != null && pic != null ) {

                    fileList = inFolder.getFiles( /\.pdf$/i );

                    if ( fileList.length > 0 ) {

 

                              uIL = app.userInteractionLevel;

 

                              app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

 

                              for ( i = 0; i < fileList.length; i++ ) {

 

                                        doc = app.open( fileList );

 

                                        rip = doc.rasterItems[0].position;

 

                                        rep = doc.placedItems.add();

 

                                        rep.file = pic;

 

                                        rep.move( doc.rasterItems[0], ElementPlacement.PLACEBEFORE )

 

                                        rep.position = rip;

 

                                        rep.resize( 31.414, 31.414, true, true, true, true, 100, Transformation.TOPLEFT );

 

                                        doc.rasterItems[0].remove();

 

                                        rep.embed();

 

                                        opts = new PDFSaveOptions();

 

                                        opts.pDFPreset = '[Illustrator Default]';

 

                                        saveFile = File( outFolder + '/' + doc.name );

 

                                        doc.saveAs( saveFile, opts );

 

                                        doc.close( SaveOptions.DONOTSAVECHANGES );

 

                              };

 

                              app.userInteractionLevel = uIL;

 

                    } else {

 

                              alert( 'This Folder contained NO Illustrator PDF files?' );

 

                    };

          };

};

 

replaceImage();

1 reply

Inspiring
March 1, 2012

Bob, firstly yes script should be able to do this quite easy… Is the image to be replaced the same one in all cases or does each file have a new image?

Participating Frequently
March 1, 2012

It is the same image in all cases. It has the same dimensions as the embedded image.

Inspiring
March 1, 2012

Sounds reasonably straight forward then… The biggest issue would be the files that need procesing… Where are they on system? i.e. In one directory and just the files in question or mixed with other files in loads of directories…