Skip to main content
Inspiring
December 3, 2010
Question

Bridge talk for InDesign CS4/CS5 js

  • December 3, 2010
  • 1 reply
  • 24361 views

Hi,

Have this code that opens file in Ph and resaves it in different format. In this case I need to adjust it to open pdf file in photoshop and set crop to media box. It works with pdf files as is, but if there is white space around artwork, it gets removed. How can I set it to open with media box:

function ResaveInPS(myImagePath, myNewPath) {
     try {
           var myPsDoc = app.open(new File(myImagePath));
             if (myPsDoc.mode == DocumentMode.CMYK) {
                    myPsDoc.changeMode(ChangeMode.RGB);
               }
           var docName = myPsDoc.name;

          var myPNGSaveOptions = new PNGSaveOptions();
          myPNGSaveOptions.interlaced = false; // or true
          myPsDoc.saveAs(new File(myNewPath), myPNGSaveOptions, true);
          myPsDoc.close(SaveOptions.DONOTSAVECHANGES);     
     }
     catch (err) {
          try {
               app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
          }
          catch (err) {}
     }
}

Thank you for your help.

Yulia

This topic has been closed for replies.

1 reply

Muppet_Mark-QAl63s
Inspiring
December 3, 2010

In the same manner as you have made PNG save options object for saving. You need to have Photoshop make a PDF open options object to open the file in the required way else you will get default using just File and open. Color Space is one of the properties so you could then remove your mode check too by doing this…

YuliaartAuthor
Inspiring
December 3, 2010

I am trying the following quite blindly, to be honest, because there is no properties and methods for PDFOpenOptions in OMV, and so far not getting any result, so I am not sure how to specify MediaBox:

function ResaveInPS(myImagePath, myNewPath){
     try{
           var myPDFOpenOptions  = new PDFOpenOptions(MediaBox);
           myPDFOpenOptions.interlaced = true; // or true
           var myPsDoc = app.open(new File(myImagePath), myPDFOpenOptions, true);
          
             if (myPsDoc.mode != DocumentMode.CMYK){
                    myPsDoc.changeMode(ChangeMode.CMYK);
               }
           var docName = myPsDoc.name;

          var myTiffSaveOptions  = new TiffSaveOptions();
          myTiffSaveOptions.interlaced = false; // or true
          myPsDoc.saveAs(new File(myNewPath), myTiffSaveOptions, true);
          myPsDoc.close(SaveOptions.DONOTSAVECHANGES);
     }
     catch(err){
          try{
               app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
          }
          catch(err){}
     }
}

Do I need 'interlaced' line for PDFOpenOptions, or it's not related to it.

Thank you very much for your help.

Yulia

Larry G. Schneider
Community Expert
Community Expert
December 3, 2010

Mark was probably thinking about Illustrator. Indesign has a PDFPlacePreferences which addresses the pdfCrop which can be set to a number of options. Look in Jongware's html version of the OMV.

http://www.jongware.com/idjshelp.html