1 Reply Latest reply on Jun 22, 2014 8:46 AM by liquid_blues

    Export images from indesign file with actual page name not working

    liquid_blues

      Hi,

       

      I've the following script with export's all images from an indesign file as a jpeg in an export folder.

       

      The only problem i have is, I would like to have the page number in the file name of the image.

       

      But at the moment this isn't working, the page number isn't correct. Does anybody know how to fix this?

       

      Thanks so much,

       

      ---------------

       

      var myDoc = app.activeDocument;
      
      var docName = myDoc.name;
      var docShortName = docName.replace(/.indd/, '');
      var docPath = '' + myDoc.fullName;
      var docContainerPath = docPath.replace(docName, '');
      var destPath = docContainerPath + '/' + docShortName + '_jpgExport/';
      
      if(Folder(destPath).create() != true){
           alert('Could not create targetfolder.');
           exit();
      }
      
      var myImage = myDoc.allGraphics;
      
      for (var i=0; myImage.length>i; i++){
      
           app.select(myImage[i]);
      
           var page = myDoc.pageItems[i].parentPage.name;
           var MyImageName  = myImage[i].itemLink.name;
           app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.high;
           app.jpegExportPreferences.exportResolution = 300;
           app.selection[0].exportFile(ExportFormat.JPG, File(destPath +"page_" + page + "_" + MyImageName + ".JPEG"), false);
      }