2 Replies Latest reply on Nov 4, 2009 6:23 AM by sotospeak2009

    duplicate all objects in a multi page doc in another doc

    sotospeak2009

      Come back to Indesign scripting after some break so forgive my ingenuos questions.

       

      I need to open one doc, select every object in all pages (what you have from the menu with CTRL+A but just for the active page) and duplicate them in another doc which has the same number of pages (paste in same place). Could you please guide me through the best way to get this by Javascript?

       

      carlo

        • 1. Re: duplicate all objects in a multi page doc in another doc
          [Jongware] Most Valuable Participant

          You could let this piece of code run over all pages:

           

          doc1 = app.documents[0];
          doc2 = app.documents[1];
          doc1.pages[0].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[0];
          doc2 = app.documents[1];
          doc1.pages[2].duplicate (LocationOptions.AFTER, doc2.pages[0]);
          

           

          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.

          1 person found this helpful
          • 2. Re: duplicate all objects in a multi page doc in another doc
            sotospeak2009 Level 1

            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,

             

            carlo