5 Replies Latest reply on Jun 5, 2012 3:38 AM by bgfrhlp

    Exporting all groups to jpgs

    bgfrhlp

      I am trying to figure out how to export all groups from a document to separate jpgs. To export a selection might do the trick, but how to use it? Here is the script (CS5.5):

       

      doc = app.activeDocument;

      with(app.jpegExportPreferences){

          exportRangeOrAllPages = ExportRangeOrAllPages.exportRange;

          jpegOptionsQuality = JPEGOptionsQuality.maximum;

          exportResolution = 300;

          pageString = "1"; // This is the problem. It doesn't take a variable.

          JPEGColorSpace = JpegColorSpaceEnum.rgb;

          jpegOptionsFormat = JPEGOptionsFormat.baselineEncoding;

      }

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

      // ************** Center each group to the page***************

          doc.documentPreferences.pageSize = "A3";

          arrLocation = doc.groups[i].geometricBounds;

          y1 = arrLocation[0];

          x1 = arrLocation[1];

          y2 = arrLocation[2];

          x2 = arrLocation[3];

          groupHeight = y2 - y1;

          groupWidth = x2 - x1;

          currentPageWidth = doc.documentPreferences.pageWidth;

          currentPageHeight = doc.documentPreferences.pageHeight;

          centerY = currentPageWidth/2 - groupWidth/2;

          centerX = currentPageHeight/2 - groupHeight/2;

          doc.groups[i].move([centerY, centerX]);

       

      // ************** Resize page to the size of the group***************

          doc.documentPreferences.pageWidth = groupWidth;

          doc.documentPreferences.pageHeight = groupHeight;

       

          groupNumber = i + 1;

          jpgFilename = "groupedPicture_" + groupNumber + ".jpg";

          var newJPG = new File("/d/eXport/" + jpgFilename);

          doc.exportFile(ExportFormat.jpg, newJPG);

      }

       

      Many thanks in advance!

      bgfrhlp