6 Replies Latest reply on Dec 12, 2013 11:56 AM by Laubender

    Export selected items on each page in InDesign to JPEG

    Ramjivk Level 1

      Hi All,

       

      I have InDesign CS5.5. I have a document with more than 50 pages and each page has unique image and the description for image.

       

      I need to export each page as JPEG. but i don't want to export full page. i need only the items on each page. So i go to each page and select all the items and export. while exporting i use the same name of the image used in each page.

       

      I tried writing a script but it exports only the active page. i do not know how to navigate to the next page and export.

       

      is some one can help.

       

      below is my script.

       

      var myDoc = app.activeDocument;

      var myNumPages = myDoc.pages.length;  //get the number of pages

      var myFilePath = myDoc.filePath; //get the file path

      var myRectangle = app.activeWindow.activePage.allGraphics; //get the graphics of the active page

      var myPageName = app.activeWindow.activePage.name; //get the page name.

       

       

                 if(myRectangle.length >1)

                {

                          alert("the page has more than one image. Delete the other image to export");

                          exit();

                }

       

      var myImageName = myRectangle[0].itemLink.name; //get the name of the image

      app.select(NothingEnum.NOTHING);

       

      for(var i=0; i<myNumPages; i++)

      {

       

                app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.high;

                app.jpegExportPreferences.exportResolution = 300;

                app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;

                app.jpegExportPreferences.pageString = myPageName;

       

                mySelectedItems();

      }

       

       

      function mySelectedItems()

      {

                var myObj = new Array;

                myObj = app.activeWindow.activePage.pageItems; 

                try

                          {

                                    app.activeWindow.activePage.groups.add(myObj);

                          }

                                    catch(e)

                          {

       

                          }

                app.select(app.activeWindow.activePage.allPageItems);

                app.selection[0].exportFile(ExportFormat.JPG, File(myFilePath+"/"+myImageName+".JPEG"), false);

       

      }