This content has been marked as final.
Show 16 replies
-
1. Re: Script to interleave two InDesign files of equal page counts
Loic_aigon Nov 1, 2008 9:31 AM (in response to Al Ferrari)Hi,
Maybe a smart way to get your goal without messing indesign files and dealing with document properties is to use your pdfs.
I mean,
1. either you wrote a javascript that you use into Acrobat for creating a new PDF file with the files that are opened or files that you may want to choose.
2. either you place the pdfs into a new indesign file (as all the page dimensions are the same) dealing with the disposition, then exporting to a new pdf. Obviously the safest way in my opinion.
Your pdf can be indesign generated pdf in the first part of the script or pdf that you call from a choos file dialog. Up to you.
3. You can of course create a mixed indesign file dealing with copy & paste but I think it's a lot of work for nothing.
Will try to write something for you.
Loic -
2. Re: Script to interleave two InDesign files of equal page counts
Al Ferrari Nov 1, 2008 9:59 AM (in response to Al Ferrari)Hi Loic,
Thanks for the response.
I have no scripting experience, so starting from scratch is not an option for me.
I agree that the copy/paste is out of the question. My two source files (either ID or pdf) have 200+ pages each. So, either a javascript for InDesign or for Acrobat would work. A choose files dialog would be a nice enhancement, but an Acrobat script that would work with two open files to produce the interleaved merged file would work. Let me know if you need more information.
Thanks,
Al -
3. Re: Script to interleave two InDesign files of equal page counts
Loic_aigon Nov 1, 2008 10:50 AM (in response to Al Ferrari)OK I think I have all I need.
I will have a look for the smartest approach, Acrobat or Indesign.
Right now, I would say Acrobat cause it doesn't take care of individual file formats and the native process may work faster. Will see.
Loic -
4. Re: Script to interleave two InDesign files of equal page counts
(Dave_Saunders) Nov 1, 2008 11:55 AM (in response to Al Ferrari)If we're talking CS3 or later, another approach would be to create a third document and then place pages from the other two alternatively.
Dave -
5. Re: Script to interleave two InDesign files of equal page counts
Al Ferrari Nov 1, 2008 12:59 PM (in response to Al Ferrari)Hi Dave,
Yes CS3. Is there already a script to alternatively place pages from two source IDCS3 files? I am aware of Olav Kvern 's script for placing pdf pages, and Scott Zanelli's for placing pdf or ID pages, but those deal with single file sources.
Thanks,
Al -
6. Re: Script to interleave two InDesign files of equal page counts
(Dave_Saunders) Nov 1, 2008 1:51 PM (in response to Al Ferrari)Al,
I doubt it. It's not really a common requirement.
What to do if the two documents are of different length? Leave the pages blank for the shorter one? Or should the script just stop in its tracks if the two documents don't match in this regard?
Dave -
7. Re: Script to interleave two InDesign files of equal page counts
Loic_aigon Nov 1, 2008 2:14 PM (in response to Al Ferrari)Of course Dave,
Completely forgot this one ;-)
Loic
In fact, this may be the quickest way to achieve the process although as you underline, it needs CS3. Well thought. -
8. Re: Script to interleave two InDesign files of equal page counts
Al Ferrari Nov 1, 2008 2:28 PM (in response to Al Ferrari)It may not be really common, but not that unusual either. As mentioned in my OP, it would be useful to users scanning long paper documents to pdf with a non duplexing scanner.
In my case the counts are equal. In the scanning case they would not differ by more than one page, in the case of an odd page count, assuming that any intermediate blank pages from the long paper document are either included in the scanning or inserted as needed in Acrobat as can be done with a blank page at the end to the shorter one to make them equal.
As for what to do with files of greater unequal length, the script could optionally stop at the shorter count, or insert alternating blank pages to complete the long count. But I agree that this would involve additional programing just to accommodate truly uncommon cases.
Al -
9. Re: Script to interleave two InDesign files of equal page counts
(Dave_Saunders) Nov 1, 2008 4:03 PM (in response to Al Ferrari)Al,
Here you go. I've only tested it with CS4, but I'm fairly sure it will work with CS3. It does, however, expose a bug in CS4. After the first placed page, the master items don't appear in the placed pages.
This is a very nasty bug. I trust that Adobe sits up and takes notice and issues a quick fix, although experience says we'll be lucky to see 4.01 inside of six months.//DESCRIPTION: Merge the two open documents
Dave
(function() {
if (app.documents.length != 2) {
alert("Please open two InDesign documents and try again."); return;
} else {
var doc1 = app.documents[0];
var doc2 = app.documents[1];
if (checkPageSizes(doc1, doc2)) {
// docs have same page sizes
var pHt = doc1.documentPreferences.pageHeight;
var pWd = doc1.documentPreferences.pageWidth;
if (!doc1.saved || !doc2.saved) {
if (!confirm("Both documents will be saved before closing. Continue?")) {
return;
}
}
var doc1Lim = doc1.pages.length;
var doc2Lim = doc2.pages.length;
var file1 = doc1.fullName;
var file2 = doc2.fullName;
doc2.close(SaveOptions.yes);
doc1.close(SaveOptions.yes);
app.documentPreferences.facingPages = false;
newDoc = app.documents.add();
newDoc.documentPreferences.properties = {
pagesPerDocument:Math.max(doc1Lim, doc2Lim)*2,
pageHeight:pHt,
pageWidth:pWd
}
app.importedPageAttributes.importedPageCrop = ImportedPageCropOptions.cropContent;
var j = 0;
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
while (true) {
app.importedPageAttributes.pageNumber = j + 1;
if (doc1Lim > j) {
newDoc.pages[j * 2].place(file1);
}
app.importedPageAttributes.pageNumber = j + 1;
if (doc2Lim > j) {
newDoc.pages[(j * 2) + 1].place(file2);
}
j++;
if (j > Math.max(doc1Lim,doc2Lim)) break;
}
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
} else {
alert("Two documents must have the same page size"); return;
}
}
function checkPageSizes(doc1, doc2) {
var d1ht = doc1.documentPreferences.pageHeight;
var d1wd = doc1.documentPreferences.pageWidth;
var d2ht = doc2.documentPreferences.pageHeight;
var d2wd = doc2.documentPreferences.pageWidth;
if (d1ht != d2ht) return false;
if (d1wd != d2wd) return false;
return true;
}
}())
-
10. Re: Script to interleave two InDesign files of equal page counts
Al Ferrari Nov 1, 2008 4:19 PM (in response to Al Ferrari)Hey Dave,
Thank you very much. I will not be able to test it till Monday, as my home machine is a G3, unable to run IDCS3.
Al -
11. Re: Script to interleave two InDesign files of equal page counts
Loic_aigon Nov 2, 2008 1:01 AM (in response to Al Ferrari)Impressive, Dave. Wish I could write scripts as quick as you one day. -
12. Re: Script to interleave two InDesign files of equal page counts
Al Ferrari Nov 2, 2008 7:05 AM (in response to Al Ferrari)Hi Loic,
Thank you also for any time you may have spent on this project. If by chance you have something partially worked up using the Acrobat approach, perhaps you could post that.
Al -
13. Re: Script to interleave two InDesign files of equal page counts
(Dave_Saunders) Nov 2, 2008 7:19 AM (in response to Al Ferrari)I'm getting feedback that the CS4 bug I mentioned doesn't always happen. I'll research that some more later today, when I get the chance.
Dave -
14. Re: Script to interleave two InDesign files of equal page counts
Al Ferrari Nov 2, 2008 12:21 PM (in response to Al Ferrari)I couldn't wait, so I came to the shop to test the script.
I made a two page non-spreads doc with numerals 2 and 4 on pages 1 and 2 respectively, and another similar doc with numerals 1 and 3 on corresponding pages. With the odd numbers doc front most I ran Dave's script and was rewarded in a flash with a new doc having pages numbered 1, 2, 3, 4. Way to go Dave!
It's worth noting that with the even numbers doc front most, the result is a new doc with pages numbered 2, 1, 4, 3, showing the importance of having the open files in the proper order before running the script.
Thanks again Dave.
Al -
15. Re: Script to interleave two InDesign files of equal page counts
skooges May 13, 2009 7:04 AM (in response to Al Ferrari)I'd like to thank you as well Dave, for a different reason. I'm kind of a newbie scripter, setting up some automated processes for my company and your script showed me how the correct syntax for changing placed page numbers. So I just wanted to say, thanks a ton!
-Tim Porath
-
16. Re: Script to interleave two InDesign files of equal page counts
bchavezgd Mar 19, 2014 2:25 PM (in response to (Dave_Saunders))tried this in CS5, on a mac.
froze the program, fyi.
edit: although it did freeze up, it was working in and generated about 1/3 of what i needed, i guess i'll have to let it run a while longer for the size of the file i'll be generating.

