4 Replies Latest reply on May 14, 2013 1:16 AM by Laubender

    How to move floats to the next page?

    Learner Learner

      Hi All,

       

      Can anyone help me on this?

       

      How to move floats to the next page the same position?

       

      Thanks in advance

        • 1. Re: How to move floats to the next page?
          Laubender Adobe Community Professional & MVP

          @Learner – what do you mean exactly by "floats"?
          And how about the "same position"?

          Can you give us some screenshots to illustrate the problem?

           

          Uwe

          • 2. Re: How to move floats to the next page?
            Learner Learner Level 1

            Hi Laubender,

             

            Thanks for your reply.

             

            What i mean the same position is, say for example a figure placed on the top of the 2nd page of the active document it needs to be moved to the top of the 3rd page.

             

            Regards,

            Learner

            • 3. Re: How to move floats to the next page?
              Sajeev Sridharan Level 4

              Try this,

               

              for (var idx = 0; idx < app.activeDocument.allPageItems.length; idx++)

                  {

                      var pageItem = document.allPageItems[0];//first object

                      //var pageItem = document.allPageItems[idx];//all objects

                      pageItem.move(app.activeDocument.pages[0]);//this will place the first object in first page

                      pageItem.move([0,0]);//object position goes here

              }

               

               

              Vandy

              1 person found this helpful
              • 4. Re: How to move floats to the next page?
                Laubender Adobe Community Professional & MVP

                @Learner – you can duplicate the object to the next page and remove the original.
                If the original one is anchored you also have to account for its position, because duplicating an anchored object will move it.

                 

                Here an example for duplicating a selected object to the same page.

                 

                //DuplicateAnchoredObject_SELECTION_SNIPPET.jsx
                //Uwe Laubender
                
                /**
                * @@@BUILDINFO@@@ DuplicateAnchoredObject_SELECTION_SNIPPET.jsx !Version! Fri Apr 12 2013 07:53:31 GMT+0200
                */
                
                
                
                var sel = app.selection[0];
                
                var x = sel.geometricBounds[1];
                var y = sel.geometricBounds[0];
                
                //The duplicate() method without an optional argument:
                var dup = sel.duplicate();
                
                //NOW: the duplicated objects is at the inner border of the page
                //To move it to its original position we need the following:
                
                var xd = dup.geometricBounds[1];
                var yd = dup.geometricBounds[0];
                
                dup.move(undefined,[x-xd,y-yd]);
                


                That snippet can be enhanced for duplicating to a certain page, because the duplicate() methods can take arguments like "Page", "Layer", "Spread" etc. For details see the DOM documentation at:

                 

                http://www.jongware.com/idjshelp.html

                 

                One caution here: to make that work the way you want with facing pages, you have to take into account, that your coordinate system must be changed to "per page" by the property "RulerOrigin" of the ViewPreferences.

                 

                This said, here is a working example for duplicating a selected object to page 3 of the current document:

                 

                 

                //DuplicateAnchoredObject_TO-DIFFERENT-PAGE_SELECTION_SNIPPET.jsx
                //Uwe Laubender
                
                /**
                * @@@BUILDINFO@@@ DuplicateAnchoredObject_TO-DIFFERENT-PAGE_SELECTION_SNIPPET.jsx !Version! Tue May 14 2013 10:11:29 GMT+0200
                */
                
                
                
                var d=app.documents[0];
                var oldRulerOrigin = d.viewPreferences.rulerOrigin;
                var sel = app.selection[0];
                
                var x = sel.geometricBounds[1];
                var y = sel.geometricBounds[0];
                
                //In case of facing pages we change the ruler origin:
                d.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
                
                //Duplication of selected object:
                
                var dup = sel.duplicate(d.pages[2]);
                
                //NOW: the duplicated objects is at the inner border of the page
                //To move it to its original position we need the following:
                
                var xd = dup.geometricBounds[1];
                var yd = dup.geometricBounds[0];
                
                dup.move(undefined,[x-xd,y-yd]);
                
                //Restore the original ruler origin:
                d.viewPreferences.rulerOrigin = oldRulerOrigin;
                

                 

                Of course, thiese snippets are working also with not anchored objects…

                 

                Uwe

                1 person found this helpful