Skip to main content
lfcorullon13651490
Brainiac
July 9, 2024
Answered

[SCRIPT] Split spread of 2 pages into 2 spreads of 1 page

  • July 9, 2024
  • 4 replies
  • 2667 views

Hello, how can I accomplish the same I'm doing mnually (in the link below), using javascript?

https://youtu.be/afsloq5D_RU


I tried the following code, but the right pages doesn't move.

var doc = app.activeDocument;
var sp = app.activeWindow.activeSpread;
var p1 = sp.pages[0];
var p2 = sp.pages[1];
sp.allowPageShuffle = false;
p2.move(LocationOptions.AFTER , sp , BindingOptions.RIGHT_ALIGN);

Thanks in advance.

This topic has been closed for replies.
Correct answer m1b

Hi @lfcorullon13651490, yes it could definitely be easier. But here is some code that works, at least in the basic case. Let me know if it is what you were thinking.

- Mark

/**
 * @file Split Spread.js
 * Split a double facing-page spread into two spreads, preserving sided-ness.
 * 
 * CAUTION: not tested beyond the basic case!
 * 
 * @author m1b
 * @discussion https://community.adobe.com/t5/indesign-discussions/script-split-spread-of-2-pages-into-2-spreads-of-1-page/m-p/14729224
 */
function main() {

    splitDoublePageSpread(app.activeDocument.layoutWindows[0].activeSpread);

};
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Split Spread');

/**
 * Split a double facing-page spread
 * into two spreads, preserving sided-ness.
 * @author m1b
 * @version 2024-07-10
 * @param {Spread} spread - an Indesign Spread.
 */
function splitDoublePageSpread(spread) {

    if (
        'Spread' !== spread.constructor.name
        || !spread.isValid
    )
        throw Error('splitDoublePageSpread: bad `spread` supplied.');

    if (2 !== spread.pages.length)
        throw Error('splitDoublePageSpread: expected 2 pages per spread.');

    // the right-hand page
    var page = spread.pages.lastItem();

    spread.allowPageShuffle = false;

    // add the new spread (note: it will also add two unwanted pages)
    var newSpread = spread.parent.spreads.add(LocationOptions.AFTER, spread, { allowPageShuffle: false });

    // slot the page in between the two unwanted pages
    page.move(LocationOptions.AFTER, newSpread.pages.firstItem());

    // remove the unwanted pages
    newSpread.pages.lastItem().remove();
    newSpread.pages.firstItem().remove();

};

 

 

4 replies

rob day
Community Expert
July 10, 2024

Hi @lfcorullon13651490 , Also, this works for me:

 

var doc = app.activeDocument;
var sp = app.activeWindow.activeSpread;
var np = doc.spreads[sp.index+1].pages[0]
var p1 = sp.pages[1];
sp.allowPageShuffle = false;
p1.move(LocationOptions.BEFORE , np);

 

 

m1b
Community Expert
July 10, 2024

Very nice @rob day! I really tried to do a simpler way, but didn't quite manage it. 🙂

- Mark

Robert at ID-Tasker
Brainiac
July 10, 2024

@lfcorullon13651490

 

Why? 

 

rob day
Community Expert
July 10, 2024

Why?

 

If you are doing it from the UI, it would usually be to add an extended inside bleed for binding methods where the inside edge is trimmed and visible, not folded. Something like Wire-o.

rob day
Community Expert
July 10, 2024
quote

Yes, I helped @lfcorullon13651490 with the code, but I wouldn’t use it.


By @rob day

 

And that's why I've asked "why" - what is his reason to move pages to separate spreads. 

 


And that's why I've asked "why" - what is his reason to move pages to separate spreads.

 

If, for some reason, the document was created as Facing Pages, it might be easier to split the pages that need an inside bleed to individual spreads, rather than change a complex existing document to non facing pages.

Community Expert
July 10, 2024

Hi @lfcorullon13651490 ,

in case you need this for adding bleed to the spine I have another suggestion:

 

[1] Make sure that the pasteboard below and above the pages is at least double the height of the page plus some extra space.

[2] Move one of the pages plus its contents down so that the right edge of the left page does not touch the left edge of the right page in the spread.

 

Both pages still share the same spread.

 

To accomplish this without scripting is relatively easy by using the Page tool to select a page and the Transform panel to move the selection.

 

From my German InDesign, where I checked the option "Move objects with page" from the Control panel.

The page is selected with the Page tool, the Transform panel's Y value is set to 305 mm (page height in my case is 297 mm):

 

 

After the transformation there is plenty of space on all sides of the pages to apply bleed:

 

In case you need to do this for more pages in a document, simply select the Page tool first, then open the Pages panel and cmd select (Ctrl select on Windows) all pages you want to move before using the Transform panel.

 

Regards,
Uwe Laubender
( Adobe Community Expert )

m1b
Community Expert
July 10, 2024

Hi @Laubender, I never would have thought of that! What is a case where it would be worth having the pages offset like this on the same spread versus on separate spreads? It seems a bit awkward.

- Mark

Community Expert
July 10, 2024

@m1b said: "What is a case where it would be worth having the pages offset like this on the same spread versus on separate spreads? It seems a bit awkward."

 

Not awkward at all, I think. It's a matter of personal workflow if you like to see both pages in one spread or in two different ones when doing changes in the layout.

 

Regards,
Uwe Laubender
( Adobe Community Expert )

 

 

m1b
m1bCorrect answer
Community Expert
July 10, 2024

Hi @lfcorullon13651490, yes it could definitely be easier. But here is some code that works, at least in the basic case. Let me know if it is what you were thinking.

- Mark

/**
 * @file Split Spread.js
 * Split a double facing-page spread into two spreads, preserving sided-ness.
 * 
 * CAUTION: not tested beyond the basic case!
 * 
 * @author m1b
 * @discussion https://community.adobe.com/t5/indesign-discussions/script-split-spread-of-2-pages-into-2-spreads-of-1-page/m-p/14729224
 */
function main() {

    splitDoublePageSpread(app.activeDocument.layoutWindows[0].activeSpread);

};
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Split Spread');

/**
 * Split a double facing-page spread
 * into two spreads, preserving sided-ness.
 * @author m1b
 * @version 2024-07-10
 * @param {Spread} spread - an Indesign Spread.
 */
function splitDoublePageSpread(spread) {

    if (
        'Spread' !== spread.constructor.name
        || !spread.isValid
    )
        throw Error('splitDoublePageSpread: bad `spread` supplied.');

    if (2 !== spread.pages.length)
        throw Error('splitDoublePageSpread: expected 2 pages per spread.');

    // the right-hand page
    var page = spread.pages.lastItem();

    spread.allowPageShuffle = false;

    // add the new spread (note: it will also add two unwanted pages)
    var newSpread = spread.parent.spreads.add(LocationOptions.AFTER, spread, { allowPageShuffle: false });

    // slot the page in between the two unwanted pages
    page.move(LocationOptions.AFTER, newSpread.pages.firstItem());

    // remove the unwanted pages
    newSpread.pages.lastItem().remove();
    newSpread.pages.firstItem().remove();

};