6 Replies Latest reply on Aug 14, 2017 12:33 AM by josephc13444680

    Applying a script to a defined page range

    josephc13444680

      Hi,

       

      I have a script that switches pages from the left to the right hand side of the spine. Very useful!

       

      But I'd like to define a range of pages to apply the script. Usually after page x, until the end of the document for example.

       

      Here's the script:

       

      app.documents[0].documentPreferences.pageBinding = app.documents[0].documentPreferences.pageBinding == PageBindingOptions.LEFT_TO_RIGHT ? PageBindingOptions.RIGHT_TO_LEFT : PageBindingOptions.LEFT_TO_RIGHT;

       

      Any thoughts on how this can be achieved would be greatly appreciated!

       

      Thanks,

      Joe

        • 1. Re: Applying a script to a defined page range
          [Jongware] Most Valuable Participant

          That seems unlikely to be possible. Binding direction is not a per-page setting, it's a document-wide setting. That's why it is in the Document Setup dialog, not in the per-page options. You can also see this reflected in your script – the setting is a documentPreferences thingy.

           

          Double-checking – after all, you never know – shows that the PageBinding options indeed only can be applied to documents: InDesign ExtendScript API (12.0): PageBindingOptions

          • 2. Re: Applying a script to a defined page range
            josephc13444680 Level 1

            Thanks for the informative answer!

             

            Maybe its solvable if I look at the problem a different way. Essentially what I'm doing is moving left hand pages to the right and right hand pages to the left within a specified page range.

            • 3. Re: Applying a script to a defined page range
              S Hopkins Adobe Community Professional

              Maybe I don't see this the way you do, but could this not be just a matter of swapping pages?

              Of course, if margins are not the same, you will have to add code to make adjustments.

               

               

              var sourceDoc = app.documents[0];

              var beginRange = 2;

              var endRange = 4;

              for (var i = beginRange; i <= endRange; i++) {

              var targetSpread = sourceDoc.spreads[i];

              targetSpread.pages[1].move(LocationOptions.BEFORE, targetSpread.pages[0]);

              }

              • 4. Re: Applying a script to a defined page range
                josephc13444680 Level 1

                Thanks for the answer!

                 

                I tried to run the script but got an error.

                 

                I suppose the crux of my problem is that I'm trying move page 3 (as shown in the image attached) from the left hand edge to the right and page 4 to the left and repeat that for all pages after page 2 in the document, so that my pagination is correct.

                 

                I have a master which is a 2 page spread as its handy to apply 1 master to all of the document instead of having one master for left and another for right hand pages (which would need to be manually reapplied if i add or remove a page)

                 

                I have the layout split like that because I produce spiral bound documents, so I need a bleed on the spine.

                 

                Any advise on how I can go about this is much appreciated, thanks for your time!Capture 20.PNG

                • 5. Re: Applying a script to a defined page range
                  S Hopkins Adobe Community Professional

                  So sorry I did not respond earlier.

                  The reason the script failed is that it assumed that all spreads had left and right-facing pages.

                  As you are having to swap page positions for margin considerations at some point in the workflow, and there can be some inconsistencies in how the page margins are arranged, my suggestion would be that you do have two master pages (A-Master and B-Master). A-Master would have the large margin on the left, and B-Master would have it on the right. You could set up some kind of dialog for easy entry, or just create a list similar to the one at the top of the following script. All you then have to do is change the order of the "A" and "B" designations as needed, and run the script to assign the appropriate master spreads.

                  If you delete a page, just run the script again to keep the left/right order as original.)

                  Note that the script works with the number of pages. Your pageList ("A" and "B" list) can be written to accommodate a maximum number of pages.

                  Just a suggestion.

                   

                  //assign master spreads to pages as designated by pageList

                  var pageList =["A", "B", "B", "A", "B", "A", "B", "A"];

                  var sourceDoc = app.documents[0];

                  var pageCount = sourceDoc.pages.count();

                  for (var i = 0; i < pageCount; i++) {

                  var targetPage= sourceDoc.pages[i];

                  var listItem = pageList[i];

                  var masterName = (listItem + "-Master");

                  targetPage.appliedMaster = sourceDoc.masterSpreads.itemByName(masterName);

                  }

                  • 6. Re: Applying a script to a defined page range
                    josephc13444680 Level 1

                    Thanks man it looks good - I'll have a play around with it.