Copy link to clipboard
Copied
Hello
I have two InDesign documents.
A first (A) of 300 different pages and a second (B) of 1 page.
I want to insert the second document (B) after each of the 300 pages, for a total of 600 pages.
That is: A1-B-A2-B-A3-B-A4-B…. Up to….A299-B-A300-B
What would be the quickest method?
THANKS
<Title renamed by MOD>
Copy link to clipboard
Copied
Write a script, or get someone to write a script. There is no built-in feature in InDesign to do it.
Copy link to clipboard
Copied
Create PDFs of each file. Check out PDFsam Basic, a free open-source program. It can do an alternative mix of the pages.
Copy link to clipboard
Copied
Put all INDD files into a book INDB and export from there all you need.
Copy link to clipboard
Copied
Put all INDD files into a book INDB and export from there all you need.
By @Willi Adelberger
How this will mix pages from both files?
Copy link to clipboard
Copied
Hi @Eugene Tyson , Think you need pages[i] not pages[0]
insertDoc.pages[i].duplicate(LocationOptions.AFTER, mainDoc.pages[addPageLocation]);
Also if the docs are facing pages the allow shuffle prefs will matter, and you might need to consider the masterspreads contents.
Copy link to clipboard
Copied
But doc "B" is the one page document, and this single page should be inserted after every page in the doc "A"?
Copy link to clipboard
Copied
Thanks missed that.
If the doc is facing the shuffle prefs still need to be checked, and does B have masterpage items?
Copy link to clipboard
Copied
With a facing page document without setting shuffle prefs I get this before and after:
With this:
var mainDoc = app.activeDocument; // Assuming this is Document A
//make sure to allow shuffling
mainDoc.spreads.everyItem().allowPageShuffle = true;
mainDoc.documentPreferences.properties = {allowPageShuffle:true};
var insertDoc = app.documents.itemByName("B.indd"); // Open Document B separately
//bring any masterpageitems?
var mpi = insertDoc.pages[0].masterPageItems;
for (var i = 0; i < mpi.length; i++){
mpi[i].override(insertDoc.pages[0])
};
var addPageLocation = 0;
var docLength = mainDoc.pages.length; // Start with the original length of Document A
var p
for (var i = 0; i < docLength; i++) {
// Duplicate the page from Document B to Document A after each page
p = insertDoc.pages[0].duplicate(LocationOptions.AFTER, mainDoc.pages[addPageLocation]);
//remove the insert page’s section?
p.appliedSection.remove()
// Update the page location to skip over the newly added page from Document B
addPageLocation += 2;
}
Copy link to clipboard
Copied
Sometimes I think that scripters only know script-based solutions. 😁 I was able to combine two 1000-page documents with an alternative mix using PDFsam Basic in less than a minute.
Copy link to clipboard
Copied
Yeah. But it depends on what you need - just print - or edit something afterwards...
Copy link to clipboard
Copied
True enough!
Copy link to clipboard
Copied
Great you mentioned this.
And I've done something similar in the past but not sure how or remember when or what I used.
I think someone have me a script up use in acrobat.
Since you have this option I thought I'd try offer the way I may have approached it before.
It's a good suggestion, along with the book file.
I think there is many ways to do it. And great we all come together to share experience
Copy link to clipboard
Copied
Try it out on a duplicate set of files - I'm not the best scripter
Found a script here that looks like what you want
https://stackoverflow.com/questions/57545582/indesign-script-to-add-a-page-to-every-given-page
Haven't tested it properly but I suspect this might work better with a tweak
var mainDoc = app.activeDocument; // Assuming this is Document A
var insertDoc = app.documents.itemByName("B.indd"); // Open Document B separately
var addPageLocation = 0;
var docLength = mainDoc.pages.length; // Start with the original length of Document A
for (var i = 0; i < docLength; i++) {
// Duplicate the page from Document B to Document A after each page
insertDoc.pages[0].duplicate(LocationOptions.AFTER, mainDoc.pages[addPageLocation]);
// Update the page location to skip over the newly added page from Document B
addPageLocation += 2;
}
Copy link to clipboard
Copied
It should work - I'm on my phone so can't test your code.
But just in case, in situations like this - it's better to iterate backward.
Copy link to clipboard
Copied
Correction:
var myPage = insertDoc.pages[0].duplicate(LocationOptions.AFTER, mainDoc.pages[addPageLocation]);
myPage.appliedSection.remove();
(^/) The Jedi