2 Replies Latest reply on Nov 2, 2015 9:46 AM by macian2

    How to add new pages to a document on the left-hand side.

    macian2 Level 1

      How is it possible to add a specified number of pages, to an existing document, where the new pages will fall on a “left-hand” side (even-numbered pages)?

      My example: I have a four-page document; I want to add an additional 4 pages, using a specific master page, to the document. But, I require the new pages to be placed as left-handed pages (even-number pages).

      I currently have a applescript, that I built & use, to add the four (4) new pages. Unfortunately, the new pages fall at the end of the current document. I cannot figure out how to get them to place properly. I currently do the manual move of the pages.

      Please be nice … my applescritping skill level is just below intermediate. Any suggestions would be greatly appreciated.

       

      * * * * * * * * * *

      (* INSERT • Display Ad pages.applescript *)

       

      set myFirst_Pagenumber to 1

       

      --LIST FOR MY COMMON USE

      --set myMasterChoice to "ADs-Display ad pages"

      --set myMasterChoice to "ADs-Display Ad pages"

      --set myMasterChoice to "ADs-Display Ad Pages"

      --set myMasterChoice to "ADs-Display ads"

      --set myMasterChoice to "ADs-Display Ads"

      --set myMasterChoice to "Ads-Display ads"

       

      tell application "Adobe InDesign CC 2014"

          activate

          set theDoc to document 1

          set originalPgCount to get count of pages of theDoc

         

          tell theDoc

              --DETERMINE WHAT THE DISPLAY AD MASTER NAME IS

              try

                  if master spread "ADs-Display ad pages" exists then

                      set myMasterChoice to "ADs-Display ad pages"

                  else if master spread "ADs-Display Ad pages" exists then

                      set myMasterChoice to "ADs-Display Ad pages"

                  else if master spread "ADs-Display Ad Pages" exists then

                      set myMasterChoice to "ADs-Display Ad Pages"

                  else if master spread "ADs-Display ads" exists then

                      set myMasterChoice to "ADs-Display ads"

                  else if master spread "ADs-Display Ads" exists then

                      set myMasterChoice to "ADs-Display Ads"

                  else if master spread "Ads-Display ads" exists then

                      set myMasterChoice to "Ads-Display ads"

                  end if

              on error

                  tell current application to beep 3

                  display dialog "Your \"display ad\" master page was not found !" buttons {"Gee Thanks!"} default button 1 with icon 1 giving up after 2

                  return

              end try

          end tell --theDoc

         

          -- SET PAGE NUMBERING TO START AT 1

          tell theDoc

              set continue numbering of section 1 to false

              set page number start of section 1 to myFirst_Pagenumber

              set continue numbering of section 1 to true

          end tell

         

          -- INSERT NEW "DISPLAY AD" PAGES

          tell theDoc

              repeat originalPgCount times

                  --make new page at end of theDoc --okay this works

                  try

                      make new page at end of theDoc with properties {applied master:master spread myMasterChoice, allow page shuffle:true}

                  on error

                      tell current application to beep 3

                      display dialog "Your \"display ad\" master page was not found !" buttons {"Gee Thanks!"} default button 1 with icon 1 giving up after 2

                      return

                  end try

              end repeat

             

              --SET GUIDES TO TOP

              set properties of the guide preferences to {guides in back:false, guides locked:false, guides shown:true, guides snapto:true, ruler guides color:cyan, ruler guides view threshold:5.0}

          end tell --theDoc

      end tell --application

       

      tell current application to beep 2

        • 1. Re: How to add new pages to a document on the left-hand side.
          Peter Kahrel Adobe Community Professional & MVP

          When you add a page you can specify where the page is added. Without specification, new pages go to the end of the document. I don't know AppleScript, but in JavaScript you'd do something like

           

          app.activeDocument.pages.add (LocationOptions.BEFORE, app.activeDocument.pages[-1])
          

           

          to add a page before the document's last page. Try and find the AppleScript equivalent of LocationOptions.before.

           

          Peter

          • 2. Re: How to add new pages to a document on the left-hand side.
            macian2 Level 1

            Thank you pkahrel. Though your suggestion was not exactly what I needed, it was the catalyst to my solution. By identifying the page ID of each existing page of the active document, I could then place my new page exactly where I wanted it. I have attached below the New and Revised applescript that solved my dilemma.

             

            * * * * * * * *

             

            (* INSERT • Display Ad pages.applescript *)

             

            set myFirst_Pagenumber to 1

             

            tell application "Adobe InDesign CC 2014"

                activate

                set theDoc to document 1

                set originalPgCount to get count of pages of theDoc

               

                tell theDoc

                    --DETERMINE WHAT THE DISPLAY AD MASTER PAGE NAME IS

                    repeat with eachItem in {"ADs-Display ad pages", "ADs-Display Ad pages", "ADs-Display Ad Pages", "ADs-Display ads", "ADs-Display Ads", "Ads-Display ads"}

                        if master spread eachItem exists then

                            set myMasterChoice to eachItem

                        end if

                    end repeat

                end tell --theDoc

               

                -- SET PAGE NUMBERING TO START AT 1

                tell theDoc

                    set continue numbering of section 1 to false

                    set page number start of section 1 to myFirst_Pagenumber

                    set continue numbering of section 1 to true

                end tell --theDoc

               

                -- INSERT NEW "DISPLAY AD" PAGES

                tell theDoc

                    set originalPgCount to count of pages

                    set myPageNames to get id of every page as list

                    repeat with eachItem in myPageNames

                        make new page at after page id eachItem with properties {applied master:master spread myMasterChoice, allow page shuffle:true}

                    end repeat

                   

                    --SET GUIDES TO TOP

                    set properties of the guide preferences to {guides in back:false, guides locked:false, guides shown:true, guides snapto:true, ruler guides color:cyan, ruler guides view threshold:5.0}

                   

                end tell --theDoc

            end tell --application

            tell current application to beep 2