6 Replies Latest reply on Apr 28, 2014 2:19 AM by Arivusudar

    exportFile for multiple selection

    Arivusudar Level 1

      CS5.5 - Javascript, I would like to know the exportFile method for multiple selection, for example if i have selected 4 rectangles and want to export these four objects as single jpg without grouping it. Thanks in advance.

        • 1. Re: exportFile for multiple selection
          Kai Rübsamen Level 4

          Try the following one. This will set no preferences and has no controls about naming conventions or if files or folders exists already.

          It will simply export your 4 elements to the desktop.

           

           

          var allSel = app.selection;
          for ( var i =0; i < allSel.length; i++ ) {
              var curSel = allSel[i];
              var myFile = File( Folder.desktop + "/myTest" + ( i+1 ) + ".jpg" );
              curSel.exportFile( ExportFormat.JPG, myFile, false );
          }
          
          • 2. Re: exportFile for multiple selection
            Arivusudar Level 1

            Thanks for your replay Kai, I dont want to export it as element by element, i want to convert 4 elements as single jpg file, means if i select 4 rectangles then it has to produce one jpg with all 4 elements. I can do it via InDesign UI but i'm looking for script to do that... even i tried

            rectangles.everyItem().exportFile

            • 3. Re: exportFile for multiple selection
              Kai Rübsamen Level 4

              Ah, sorry!

               

              It seems, that is not possible, without grouping. The trick is to undo the grouping after export, see: http://indisnip.wordpress.com/2010/08/09/export-selection-to-jpeg/

               

              var myFile = File("~/Desktop/myTest.jpg");
              var myObj = app.activeWindow.activePage.groups.add( app.selection );
              myObj.exportFile(ExportFormat.JPG, myFile, false);
              app.activeDocument.undo();
              
              • 4. Re: exportFile for multiple selection
                Arivusudar Level 1

                Thanks for your effort, i'm in a different situation, means my InDesign having a group with few rectangles and one textframe, now i would like to take a snap of rectangles as a single jpg, i cant group it again, because indesign wont allow to group, i tried that. Is there any other solution possible?

                • 5. Re: exportFile for multiple selection
                  Jump_Over Level 5

                  Hi,

                   

                  If your recs are inside a group already a possible solution is to:

                  duplicate them - group - export - remove.

                   

                  Assuming recs are selected:

                  var
                            mDoc = app.activeDocument,
                            mFile = File("~/Desktop/test1.jpg"),
                            len = app.selection.length,
                            tempGroup = [], mTarget;
                  
                  while (len-->0) {
                            tempGroup.push( app.selection[len].duplicate() );
                            }
                  
                  mTarget = mDoc.groups.add( tempGroup );
                  mTarget.exportFile(ExportFormat.JPG, mFile);
                  mTarget.remove();
                  

                   

                  Assuming a group is selected and each rec child is a target:

                  var
                      mDoc = app.activeDocument,
                      mFile = File("~/Desktop/test2.jpg"),
                      mTarget = mDoc.groups.add(app.selection[0].rectangles.everyItem().duplicate());
                  
                  mTarget.exportFile(ExportFormat.JPG, mFile);
                  mTarget.remove();
                  

                   

                  Jarek

                  • 6. Re: exportFile for multiple selection
                    Arivusudar Level 1

                    Thanks Jarek, this is what i'm expecting...