Copy link to clipboard
Copied
var myDoc = app.documents.everyItem()
var mySpread = myDoc.spreads.everyItem()
myDoc.sections[0].continueNumbering = true;
mySpread.allowPageShuffle = true;
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 refere
...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
Copy link to clipboard
Copied
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;
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
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.
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:
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)…
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.
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!
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.
Copy link to clipboard
Copied
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