1 person found this helpful
You could let this piece of code run over all pages:
doc1 = app.documents; doc2 = app.documents; doc1.pages.pageItems.everyItem().select(SelectionOptions.ADD_TO); app.copy (); app.activeDocument = doc2; app.pasteInPlace ();
-- this will do what you asked, but will it do what you intended?
You cannot select objects across spreads. (The other day someone suggested using an XML tagged file, and apparently you can with that. I wouldn't know if it's applicable for your situation.)
So this code does what one can do manually: select all, copy, activate document 2, paste. However, as you will find out, threaded text frames will not thread anymore to the next.
It would be easier to duplicate each spread (not "page" -- it's not an option [**]) to your other document -- then you would not have to worry about the number of pages. It does add other responsibilies, though (styles, swatches, document size; all of these should match across the docs). [*]
An other option could be to place the document's pages as images into the other.
[* Post-Edit] That wouldn't preserve your text threads either, by the way.
[** Post-Edit #2] Well, whaddoyouknow? You can duplicate pages as well from one document to another, as long as you reference a page in the other doc:
doc1 = app.documents; doc2 = app.documents; doc1.pages.duplicate (LocationOptions.AFTER, doc2.pages);
The oblique Help confused things a bit: you can duplicate a Spread to another document immediately (I didn't try that), but for a Page it sez "another page or Spread" -- without mentioning that that one can be in another doc.
thank you Jongware.
I would prefer not using copy and paste methods as this is a procedure most people suggest to avoid, I would like to stick to the duplicate method you suggested.
My problem with page duplicate is that my second doc is not empty, though it has the same number of pages as the source doc, but it has some existing frames I need to preserve. So my purpose is to copy every object of the source doc into the destination preserving its position on the page: this way I want to get a destination page where original frames and the duplicated (from the source doc) ones are "merged".
I will test some of your directions,