Skip to main content
Participating Frequently
September 28, 2021
Question

Insert Blank Page - every other page with Autoflow

  • September 28, 2021
  • 1 reply
  • 4696 views

Hoping someone can help... I saw another post where a script can be used to insert a blank page every other page, however when I tried it, a single blank page was only added to the bottom of my document. I have a hunch its because I am using Autoflow on my content but am not sure... 

Is there a way of overcoming this using scripting I wonder?

Alternatively what I am ultimatly trying to achieve is that my printing would occur on odd pages only while being ran through a batch job on a server. (Not locally using the print dialogue box where I can see the option for this)

Any help greatly appreciated!

This topic has been closed for replies.

1 reply

brian_p_dts
Community Expert
Community Expert
September 28, 2021

Does this not work? 

var doc = app.activeDocument;
var pages = doc.pages.everyItem().getElements();
for (var i = 0; i < pages.length; i+=2) {
    doc.pages.add(LocationOptions.AFTER, pages[i], {appliedMaster : null});
}
Participating Frequently
September 28, 2021

Unfortunatly not ... do you think it is because I have Autoflow on my content item? The finished document could be hundreds of pages long and its all contained in content items with Autoflow... Thanks very much for the help....

Peter Kahrel
Community Expert
Community Expert
September 28, 2021

Autoflow doesn't play a role. In Brian's script, remove 

.everyItem().getElements()

from the second line and it works as expected. The reason is that the Pages object must be rebuilt every time you add one, so you can't work with the collection converted to an array.