16 Replies Latest reply on Jun 21, 2015 10:38 AM by rob day

    "Drifting" page numbers - like a dictionary/thesaurus

    shmu72 Level 1

      I have a 150 page document in which I would like the page numbers to drift downwards as you go further into the document. Working in the same way as an old fashioned dictionary or thesaurus works with the different sections (A, B, C, D, etc). Is there a way to program InDesign to do this automatically, as opposed to manually nudging the page number down on each page?

       

      Attached is an image. My goal is not to the page numbers grouped in sections, but for each individual page have the page number slightly lower than the last, until it reaches the bottom on the very last page. as such....

       

      closed-dictionary-EDHCF4.jpg

        • 1. Re: "Drifting" page numbers - like a dictionary/thesaurus
          Eugene Tyson Adobe Community Professional & MVP

          Page numbers would be attached to a master page, meaning that the page number is in a fixed position on each page.

           

          To have it move down the page you'd need a different master page for each time you wanted to shift.

           

          Old style dictionaries weren't done on computers, it was a very manual and mechanical process which probably made it easier.

           

           

          I don't know of a way for InDesign to do it automatically - perhaps it can be scripted?

          • 2. Re: "Drifting" page numbers - like a dictionary/thesaurus
            shmu72 Level 1

            Yes indeed, the number is on the master. How would i go about scripting this?

            • 3. Re: "Drifting" page numbers - like a dictionary/thesaurus
              Peter Spier Most Valuable Participant (Moderator)

              Unless you have a different master page for each document page, you will not be able to drift the numbers, even by script, and that more or less defeats the purpose of having the master page.

               

              Here's a link to the scripting forum: InDesign Scripting

              • 4. Re: "Drifting" page numbers - like a dictionary/thesaurus
                rob day Adobe Community Professional & MVP

                even by script, and that more or less defeats the purpose of having the master page.

                 

                Peter, a script could find all instances of a selected master page item, release it on the pages with the applied master, then adjust the y position. The page numbers would still be linked to the master and they would respond to changes.

                 

                The curious thing about this is when I was playing around with a script I realized when the MP item is overridden via scripting, the positioning behavior is different. If I manually change the x,y of the master page item after running the script the page items respond—their positions change relative to the master page move!

                 

                The script releases all of the page numbers and makes a y percentage move based on the number of spreads:

                Screen Shot 2015-06-20 at 10.40.38 AM.png

                 

                Here I've moved the page number on the master and the numbers on the pages move relative to my MP move. Not sure whether this is a bug or a feature:

                 

                Screen Shot 2015-06-20 at 10.48.29 AM.png

                • 5. Re: "Drifting" page numbers - like a dictionary/thesaurus
                  Peter Spier Most Valuable Participant (Moderator)

                  I guess my prejudice against overriding master objects is showing...

                   

                  Rob, what happens if you shuffle or adjust the number of pages after running the script? Does re-running fix things, or move a new copy of the number frame?

                   

                  For the benefit of the OP, I presume the strategy for the script here is to divide the page number by the number of steps you want to allow for the drift, then multiply the remainder by the stepping factor to to adjust the y-coordinate.

                  • 6. Re: "Drifting" page numbers - like a dictionary/thesaurus
                    Peter Spier Most Valuable Participant (Moderator)

                    Which makes me think that maybe having the correct number of stepped frame master pages isn't that bad an idea, then use a script with that strategy to apply the correct master. With nothing overridden, there should be no problem running the script multiple times if the page positions change.

                    • 7. Re: "Drifting" page numbers - like a dictionary/thesaurus
                      rob day Adobe Community Professional & MVP

                      For the benefit of the OP, I presume the strategy for the script here is to divide the page number by the number of steps you want to allow for the drift, then multiply the remainder by the stepping factor to to adjust the y-coordinate.

                       

                      It's just calculating the move as a percentage of spreads in the document. So a 10 page doc has 4 facing page spreads. In that case the move would be 25%, a 12 page doc would be 20%, etc.

                       

                      what happens if you shuffle or adjust the number of pages after running the script?

                       

                      I put a reset in so any overrides would get removed before the reposition, so shuffled pages shouldn't matter, but I haven't tested much.

                      • 8. Re: "Drifting" page numbers - like a dictionary/thesaurus
                        rob day Adobe Community Professional & MVP

                        Sorry, I thought I had posted the script.

                         

                        It's Applescript so OSX only. I've assumed the document is a typical book with facing pages with 2 pages per spread. Select the page number you want to adjust on its master page before running the script. If nothing is selected you'll get an error. The positioning is centered on the master's top and bottom margins:

                         

                         

                         

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

                        tell application "Adobe InDesign CC 2014"

                            --the selected page number on the master page

                            set s to object reference of selection

                            set p to every page of active document

                            repeat with x in p

                                set pi to all page items of x

                                repeat with j in pi

                                    if overridden master page item of j is equal to s then

                                        --resets number if it's been overridden

                                        remove override of j

                                    end if

                                end repeat

                                -- the page master page items

                                set ms to master page items of x

                                repeat with i in ms

                                    if object reference of i is equal to s then

                                        set pn to override i destination page x

                                        my positionNumber(x, pn)

                                    end if

                                end repeat

                            end repeat

                        end tell

                         

                         

                        on positionNumber(p, pn)

                            tell application "Adobe InDesign CC 2014"

                                --gets the percentage amount to move based on number of pages

                                set c to (count (every spread of active document)) - 3

                                set i to (index of parent of p) - 2

                                set pct to i / c

                               

                                --get the live text area

                                set tm to top of (margin preferences of p)

                                set bm to bottom of (margin preferences of p)

                                set ph to page height of document preferences of active document

                                set mh to ph - (tm + bm)

                               

                                --get the page number bounds and its height

                                set {a, b, c, d} to geometric bounds of pn

                                set nh to (c - a)

                               

                                --the amount to offset the y

                                set yoff to tm - (nh / 2)

                               

                                --the new y based on percentage

                                set y to (mh * pct) + yoff

                                set geometric bounds of pn to {y, b, y + nh, d}

                               

                            end tell

                        end positionNumber

                        • 9. Re: "Drifting" page numbers - like a dictionary/thesaurus
                          rob day Adobe Community Professional & MVP

                          With nothing overridden, there should be no problem running the script multiple times if the page positions change.

                          Obviously it would be most useful if the document has lots of pages. I've tried shuffling, changing page counts, manually moving the page numbers, and re-running the script doesn't seem to be a problem. Here's 128 pages:

                           

                          Screen Shot 2015-06-20 at 11.38.45 AM.png

                          • 10. Re: "Drifting" page numbers - like a dictionary/thesaurus
                            Obi-wan Kenobi Adobe Community Professional

                            Hi Rob,

                             

                            Very nice!

                            It seems to have a problem if we add pages in the middle of the pages (delete not tested).

                            I we want make it work on odd/even pages, it works cool! but a problem on page 1 (page number on the left, instead of on the right) and on the last page, too low!

                             

                            Anyway a great and very clever script! 

                            • 11. Re: "Drifting" page numbers - like a dictionary/thesaurus
                              rob day Adobe Community Professional & MVP

                              In order to limit the size of the script (and the time to write it), I made some assumptions about the document. It's "typical" book setup as Facing pages, 2 pages per spread, no page number on the front or back. A bigger script could handle exceptions.

                               

                              It seems to have a problem if we add pages in the middle of the pages (delete not tested).

                              If you add, delete or shuffle pages, the script has to be rerun. So here I have 8 pages with 3 spreads

                               

                              Screen Shot 2015-06-20 at 2.03.22 PM.png

                               

                              If I add a new spread and manually or move a number, the number positions are now wrong, but re-running the script realigns the positions:

                              Screen Shot 2015-06-20 at 2.04.12 PM.png

                               

                              run again:

                               

                              Screen Shot 2015-06-20 at 2.04.32 PM.png

                              • 12. Re: "Drifting" page numbers - like a dictionary/thesaurus
                                rob day Adobe Community Professional & MVP

                                but a problem on page 1 (page number on the left, instead of on the right) and on the last page, too low!

                                 

                                If the page numbers are on first and last pages and either side of the spread, then this should work

                                 

                                 

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

                                tell application "Adobe InDesign CC 2014"

                                    --the selected page number on the master page

                                    set s to object reference of selection

                                    repeat with thePage in (every page of active document)

                                        set pi to all page items of thePage

                                        repeat with j in pi

                                            if overridden master page item of j is equal to s then

                                                --resets number if it's been overridden

                                                remove override of j

                                            end if

                                        end repeat

                                        set ms to master page items of thePage

                                      

                                        repeat with i in ms

                                            if object reference of i is equal to s then

                                                set pageNumber to override i destination page thePage

                                                my positionNumber(thePage, pageNumber)

                                            end if

                                        end repeat

                                    end repeat

                                end tell

                                 

                                --(page, masterpage number object to move)

                                on positionNumber(thePage, pageNumber)

                                    tell application "Adobe InDesign CC 2014"

                                        --gets the percentage amount to move based on number of pages

                                        set c to (count (every spread of active document))

                                        set i to (index of parent of thePage) - 1

                                        set pct to i / c

                                      

                                        --get the live text area

                                        set tm to top of (margin preferences of thePage)

                                        set bm to bottom of (margin preferences of thePage)

                                        set ph to page height of document preferences of active document

                                        set mh to ph - bm

                                      

                                        --get the page number bounds and its height

                                        set {a, b, c, d} to geometric bounds of pageNumber

                                        set nh to (c - a)

                                      

                                        --the amount to offset the y

                                        set yoff to tm - (nh / 2)

                                      

                                        --the new y based on percentage

                                        set y to (mh * pct) + yoff

                                        set geometric bounds of pageNumber to {y, b, y + nh, d}

                                      

                                    end tell

                                end positionNumber

                                • 13. Re: "Drifting" page numbers - like a dictionary/thesaurus
                                  rob day Adobe Community Professional & MVP

                                  Peter, In case you are interested, here's a link to a file where I've overridden and changed the position of MP items on the page via scripting and I can still move them via the master. I've never seen this before.

                                   

                                  http://www.zenodesign.com/forum/CuriousMaster.zip

                                   

                                  The orange frames were released and repositioned via scripting and the blue frame was released by hand. You can see the orange frames still move with the master even though they all have different positions.

                                   

                                  Screen Shot 2015-06-20 at 3.19.20 PM.png

                                   

                                  master move

                                   

                                  Screen Shot 2015-06-20 at 3.19.52 PM.png

                                  • 14. Re: "Drifting" page numbers - like a dictionary/thesaurus
                                    Obi-wan Kenobi Adobe Community Professional

                                    Rob,

                                     

                                    About the script last version, almost perfect! 

                                    I still have a problem with the last page: tested after 0-generation, adding and deleting pages, and master page modifications, it appears that the vertical position of the number page block on the last page is not stable: I've got 3 different Y-offset!

                                    • 15. Re: "Drifting" page numbers - like a dictionary/thesaurus
                                      rob day Adobe Community Professional & MVP

                                      I see the problem I'm using the variable c for two different things. Should be able fix when I get a minute.

                                      • 16. Re: "Drifting" page numbers - like a dictionary/thesaurus
                                        rob day Adobe Community Professional & MVP

                                        Here's a compiled version with the fixed variable—seems to work now.

                                         

                                        http://www.zenodesign.com/forum/DictionaryNumbers.zip