Skip to main content
BEGINNER_X
Legend
February 7, 2019
Answered

Is it possible document should be Shuffle?

  • February 7, 2019
  • 1 reply
  • 340 views

Hi All,

We have request to merge Indesign multiple files into one.

We have done this, but due to difference page height, the pages should not come one by one.

Please look at the below screenshot which having problem:

Need output to be like as below:

Below is the code Merge multiple Indesign file into one:

var destination_doc = app.activeDocument;

app.activeDocument.documentPreferences.allowPageShuffle = true;

var spread = destination_doc.spreads.everyItem() 

destination_doc.documentPreferences.allowPageShuffle = true; 

spread.allowPageShuffle = true; 

// select the source folder

var sourceFolder = Folder.selectDialog("Select a folder with source InDesign files.");

var fileList = sourceFolder.getFiles();

fileList.sort();

// run through each file

for ( var i = 0; i < fileList.length; i++ ) {

        var source_file = fileList;

        if ( source_file instanceof File && source_file.name.match(/\.indd$/i)) {

        app.open(source_file);

        var source_doc = app.documents.item(source_file.name);

        for ( var count = 0; count < source_doc.pages.length; count++ ) {

            var sourcePages = source_doc.pages.item(count);

            sourcePages.duplicate(LocationOptions.AFTER, source_doc.pages.item(0));

            sourcePages.move(LocationOptions.AFTER, destination_doc.pages.item(-1));

           

            var spread = destination_doc.spreads.everyItem() 

            destination_doc.documentPreferences.allowPageShuffle = true; 

            spread.allowPageShuffle = true; 

        }

        app.activeDocument.close(SaveOptions.NO);

        }

}

Thanks in Advance

This topic has been closed for replies.
Correct answer Manan Joshi

How about copying the whole spreads from the destination to the source. Something like below

var dest = app.activeDocument

var source = app.documents[1]

for(var i = 0; i < source.spreads.length; i++)

    source.spreads.duplicate(LocationOptions.AFTER, dest.spreads[-1])

-Manan

1 reply

Manan JoshiCommunity ExpertCorrect answer
Community Expert
February 7, 2019

How about copying the whole spreads from the destination to the source. Something like below

var dest = app.activeDocument

var source = app.documents[1]

for(var i = 0; i < source.spreads.length; i++)

    source.spreads.duplicate(LocationOptions.AFTER, dest.spreads[-1])

-Manan

-Manan