2 Replies Latest reply on Sep 8, 2015 2:48 AM by [Jongware]

    How to distribute objects evenly with a top and bottom margin?

    calebs58827315 Level 1

      I have a page with two images.  I would like them distributed vertically with the top whitespace, space between the images and the bottom whites pace are all the same.  Instead one image gets put at the top, the other at the bottom:




      I would instead like it to like this, which I did manually:




      Any help or suggestions would be great, so I don't have to manually arrange every time.



        • 1. Re: How to distribute objects evenly with a top and bottom margin?
          vladan saveljic Level 4

          you could add two temporary object (for example two lines): the one at the top and the other at the bottom.

          Then select all objects and click the "Distribute Spacing" button to distribute the objects along their vertical axes.

          Then you can delete two lines


          Schermata 2015-09-08 alle 10.24.10.png


          after clic:


          Schermata 2015-09-08 alle 10.24.23.png

          • 2. Re: How to distribute objects evenly with a top and bottom margin?
            [Jongware] Most Valuable Participant

            Well that was a bit of fun scripting! Save the following as "alignOnPage.jsx" in your local Scripting folder (and in case that's a first, please read


            http://indesignsecrets.com/how-to-install-a-script-in-indesign-that-you-found-in-a-forum-o r-blog-post.php). Select your objects, then run the script. Other than InDesign's own Distribute, it divides the free vertical space including the top and bottom margin, and then moves the objects vertically into position.


            Written using CS4 but I'm pretty sure it ought to work for newer versions as well.


            if (app.selection.length > 0)
            if (app.selection.length == 1)
              app.activeDocument.align (app.selection, AlignOptions.VERTICAL_CENTERS, AlignDistributeBounds.PAGE_BOUNDS);
            } else
              page = app.selection[0].parent;
              while (!(page instanceof Page || page instanceof Spread) )
              if (page instanceof Application)
                alert ("okay I give up");
              page = page.parent;
              if (page instanceof Spread)
              page = page.pages[0];
              // how high is the page in total?
              pageheight = Math.abs(page.bounds[0] - page.bounds[2]);
              dividerspace = pageheight;
              // subtract the object's individual heights
              for (i=0; i<app.selection.length; i++)
              objheight = Math.abs(app.selection[i].geometricBounds[0]-app.selection[i].geometricBounds[2]);
              dividerspace -= objheight;
              // divide by # of objects PLUS 1 (2 objects needs 3 spaces)
              dividerspace /= (app.selection.length+1);
              // redistribute objects from top to bottom
              app.activeDocument.distribute (app.selection, DistributeOptions.VERTICAL_SPACE, undefined, true, dividerspace);
              // make a group to center vertically
              g = app.activeDocument.groups.add(app.selection);
              app.activeDocument.align (g, AlignOptions.VERTICAL_CENTERS, AlignDistributeBounds.PAGE_BOUNDS);
              // restore group
            } else
            alert ("please make sure you selected something!");