3 Replies Latest reply on Mar 16, 2014 3:26 AM by Kasyan Servetsky

    Bridge Talk to Save Masked Document as Web PNG

    Melchiar

      Hi everyone,

       

      I'll start off by saying that I am by no definition an experienced programmer, however I have been able to hack together a few scripts to help eliminate some repetitive tasks from my workflow (using CS 5.5). One of these tasks requires me to save a web-ready png thumbnail of an indesign file that is clipped to a specific die line path. In the past, how I've manually done this is to group all objects in the document and paste them into the die line object so that it masks the outside areas. I would then export this as a pdf, import it into photoshop, resize it to my necessary diminsions (167px wide), and save it as a web ready transparent PNG.

       

      In an attempt to automate this lengthy process, I've been able to create this script which I've included below, that groups all objects in the document and pastes them into the currently selected die line object, and then exports the document as a PDF. From this point on however I'm still stuck with having to open that PDF in photoshop manually, resize it, and save a transparent PNG back to the same folder.

       

      I know that you can have Indesign give commands to Photoshop using Bridge Talk, but I'm unsure of the best way to try to achieve my goal. Is it possible to use scripting to export a pdf, and then use bridgetalk to open that same pdf in photoshop for processing? Or would I be better off just doing the Photoshop part manually as I have been?

       

      Here is my Export Masked PDF script:

       

       if (app.activeDocument.selection.length > 0) {
      var myDocument = app.activeDocument;
      var myDieline = app.selection[0];
      
      //select all objects
      app.select(app.documents.item(0).pages.item(0).pageItems);
      
      //group all objects except die line
      myDieline.visible = false;
      var myObj = new Array;
      myObj = app.selection;
      app.activeWindow.activePage.groups.add(myObj);
      app.activeWindow.activePage.groups.item(-1).select();
      var myGroup = app.selection[0];
      myDieline.visible = true;
      
      //cut group and paste into die line
      app.cut();
      app.select(myDieline);
      app.pasteInto();
      
      //define pdf export preferences and save PDF
      var preset = null;
      with(app.pdfExportPreferences){
          useDocumentBleedWithPDF = false;
          includeSlugWithPDF = false;
          cropMarks = false;
          bleedMarks = false;
          pageInformationMarks = false;
          registrationMarks = false;
          colorBars = false;
          }
      if (myDocument.saved) preset = myDocument.filePath;
      var f = Folder.selectDialog('Choose a folder',preset);
      
      for (var count = 0; count < myDocument.pages.length;count++)
      {    
          app.pdfExportPreferences.pageRange=String(count+1);
          $.writeln(app.pdfExportPreferences.pageRange);
          if (f != null)
          {
              var file = File(f+'/'+String(myDocument.name).replace(/.indd$/,'-PROOF'+'.pdf'));
              $.writeln(file);
              myDocument.exportFile(ExportFormat.pdfType,file,false);
          }
      }
      }
      else{
      alert("You must select the die line first!");
      }
      

       

      Thanks! Any help is greatly appreciated!