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

allowPageShuffle

New Here ,
Nov 23, 2022 Nov 23, 2022

Copy link to clipboard

Copied

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
TOPICS
How to , Scripting

Views

861

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

correct answers 1 Correct answer

Guru , Nov 28, 2022 Nov 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;

2022-11-28_20-22-23.png

2022-11-28_20-23-03.png

 

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

var myDoc = app.documents.everyItem()

You can refere

...

Votes

Translate

Translate
Community Expert ,
Nov 23, 2022 Nov 23, 2022

Copy link to clipboard

Copied

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

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 ,
Nov 23, 2022 Nov 23, 2022

Copy link to clipboard

Copied

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…

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
Community Expert ,
Nov 24, 2022 Nov 24, 2022

Copy link to clipboard

Copied

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;

 

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 ,
Nov 24, 2022 Nov 24, 2022

Copy link to clipboard

Copied

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

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
Community Expert ,
Nov 25, 2022 Nov 25, 2022

Copy link to clipboard

Copied

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.

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 ,
Nov 25, 2022 Nov 25, 2022

Copy link to clipboard

Copied

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)…

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
Community Expert ,
Nov 25, 2022 Nov 25, 2022

Copy link to clipboard

Copied

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 @Incredible_Miracle5DEE might be able to tell you what goes wrong.

P.

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 ,
Nov 25, 2022 Nov 25, 2022

Copy link to clipboard

Copied

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!

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
Community Expert ,
Nov 25, 2022 Nov 25, 2022

Copy link to clipboard

Copied

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.

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
Guru ,
Nov 28, 2022 Nov 28, 2022

Copy link to clipboard

Copied

LATEST

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;

2022-11-28_20-22-23.png

2022-11-28_20-23-03.png

 

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

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