• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Applying a script to a defined page range

New Here ,
Aug 01, 2017 Aug 01, 2017

Copy link to clipboard

Copied

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

TOPICS
Scripting

Views

2.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 01, 2017 Aug 01, 2017

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 01, 2017 Aug 01, 2017

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 01, 2017 Aug 01, 2017

Copy link to clipboard

Copied

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;

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

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 01, 2017 Aug 01, 2017

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 12, 2017 Aug 12, 2017

Copy link to clipboard

Copied

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;

var listItem = pageList;

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

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

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 14, 2017 Aug 14, 2017

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines