Skip to main content
Participating Frequently
November 23, 2022
Answered

allowPageShuffle

  • November 23, 2022
  • 5 replies
  • 1319 views
Hello guys,
I'd like to process an entire InDesign Book (.indb) and switch ON autonumber AND AllowPageShuffle.
I use BatchProcessor, by Kasyan Servetsky the Great, that allows to run a script on every item of an .indb.
And the script I use (assembled snatching snippets here and there) is this:
 
var myDoc = app.documents.everyItem()
var mySpread = myDoc.spreads.everyItem()
myDoc.sections[0].continueNumbering = true;
mySpread.allowPageShuffle = true;
 
This works, BUT it switches on only "Allow Selected Spreads to Shuffle" and not "Allow Document Pages to Shuffle", that is what I'd need: if my single page has an even number, it has to shuffle to the left, and if it's odd to the right.
I work on a monthly magazine and in my indb book I have single pages with other single page documents or ADV on their right side, but I keep them as single to keep the workflow more "fluid", easier to reorder.
Can this be done? THX a lot
This topic has been closed for replies.
Correct answer Kasyan Servetsky

If I understood you correctly, you want something like this:

var section,
doc = app.activeDocument,
sections = doc.sections.everyItem().getElements();

for (var i = 0; i < sections.length; i++) {
	section = sections[i];
	
	if (!section.continueNumbering) {
		section.continueNumbering = true;
	}
}

doc.documentPreferences.allowPageShuffle = true;
doc.spreads.everyItem().allowPageShuffle = true;

 

You don't need to reference your documents like this:

var myDoc = app.documents.everyItem()

You can reference the current doc either

doc = app.activeDocument

or

doc = g.doc (the reference to the current doc sent from the batch processor via the global g variable).

Note: there is already a very similar script (I just added a couple of lines and removed an if statement).

Hope it helps!
— Kas

5 replies

Kasyan Servetsky
Kasyan ServetskyCorrect answer
Legend
November 28, 2022

If I understood you correctly, you want something like this:

var section,
doc = app.activeDocument,
sections = doc.sections.everyItem().getElements();

for (var i = 0; i < sections.length; i++) {
	section = sections[i];
	
	if (!section.continueNumbering) {
		section.continueNumbering = true;
	}
}

doc.documentPreferences.allowPageShuffle = true;
doc.spreads.everyItem().allowPageShuffle = true;

 

You don't need to reference your documents like this:

var myDoc = app.documents.everyItem()

You can reference the current doc either

doc = app.activeDocument

or

doc = g.doc (the reference to the current doc sent from the batch processor via the global g variable).

Note: there is already a very similar script (I just added a couple of lines and removed an if statement).

Hope it helps!
— Kas

Peter Kahrel
Community Expert
Community Expert
November 25, 2022

How strange. Did you try the script on a single document? Simply open a new document, disable the shuffle settings, then run the script. 

Add this line before those two lines:

myDoc = app.activeDocument;

If this works, then @4000965 might be able to tell you what goes wrong.

P.

Participating Frequently
November 25, 2022

I can confirm that on single document it works as it's supposed to!

Thus, the problem must be in how the script operates against the whole indb within Batch processor.

But I'm a bit doubtful to bother @kasyan, considering what is going on in Ukraine…

I'll try and figure it out by myself. Thank you Peter for your unvaluable support, as always!

Peter Kahrel
Community Expert
Community Expert
November 25, 2022

But I'm a bit doubtful to bother @Kasyan Servetsky considering what is going on in Ukraine…

That's very thoughtful of you, but he probably likes the diversion. We'll see.

Peter Kahrel
Community Expert
Community Expert
November 25, 2022

That code sample works for me. Not sure why it doesn't work at your end. Maybe try deleting ID's preferences (restart InDesign holding down Ctrl+Alt+Del), and if that doesn't fix it, delete the caches. On a Windows computer they're here:

 

C:\Users\[user]\AppData\Local\Adobe\InDesign\Version 18.0\en_GB\Caches

 

You need to change the version and the localisation, naturally.

Participating Frequently
November 25, 2022

I'm afraid none of these helped, Peter. 

Prefs deleted, Caches emptied, but no way…

Let me tell you what I do:

  1. Create a brand new dummy indb
  2. Populate it with a few single pages
  3. Run Batch processor, on active Book, telling it to run a Single script. In my case AutonumberANDshuffleON.jsx (the exact code you've tried successfully).

 

And again, Autonumbering is correctly ON on every page, but only the second shuffling option (Selected Spreads) is ON, not the first one (Document Pages)…

Peter Kahrel
Community Expert
Community Expert
November 24, 2022

As Brian mentioned, you need to set it on the document preferences (and on all sections):

 

myDoc.documentPreferences.allowPageShuffle = true;
myDoc.spreads.everyItem().allowPageShuffle = true;

 

Participating Frequently
November 25, 2022

Hi Peter, I've tried what you say:

var myDoc = app.documents.everyItem()
myDoc.sections[0].continueNumbering = true;
myDoc.documentPreferences.allowPageShuffle = true;
myDoc.spreads.everyItem().allowPageShuffle = true;

But again only Allow Selected Spreads to Shuffle is switched on, not Allow Document Pages to Shuffle.

What do you mean by "(and on all sections)?

Thank you again

brian_p_dts
Community Expert
Community Expert
November 23, 2022

You'd set what you need under myDoc.documentPreferences, I believe. Take a look at the allowPageShuffle and preserveLayoutWhenShuffling properties here: https://www.indesignjs.de/extendscriptAPI/indesign-latest/#DocumentPreference.html

Participating Frequently
November 23, 2022

Thank you Brianp, I've tried, but again it turns on only one of the two shuffling options, as you can see in the attachment (my version is in italian). I don't really understand…