2 Replies Latest reply on Mar 8, 2012 5:11 AM by natdeamer

    Script - Paste a Group into a TextFrame

    natdeamer

      Very similar to my last question here - http://forums.adobe.com/message/4167532

       

      In Indesign desktop I can copy and paste a group inside a text frame - obviously this can't be done in Indesign server.

       

      I have tried looking at the duplicate and move methods - but these don't take a page item as the 'to' parameter.

       

       

      var textFrame = myPage.pageItems.item("TextFrame");

      var group1 = myPage.pageItems.item("group1");

      var group2 = myPage.pageItems.item("group1");

      .....

       

      I can remove items once they are already in the text frame with

      textFrame.pageItems.item(0).remove();

       

      PageItems is read only - so I can't add items to it.

       

      Suggestions?

        • 1. Re: Script - Paste a Group into a TextFrame
          [Jongware] Most Valuable Participant

          Alas -- the following did not work, although it does with another kind of item (try with "rectangles.add", that works). It may give you some fresh ideas, so I'm showing it anyway:

           

          textFrame = app.selection[0].parentTextFrames[0];
          group1 = app.layoutWindows[0].activePage.parent.groups[0];
          group1elements = group1.ungroup();
          textFrame.insertionPoints[1].groups.add(group1elements); <-- fail!
          

           

          You can test this in the UI version with (1) some group, and (2) a text frame with the text cursor inside it.

           

          The "fail" line errors out with

           

          JavaScript Error!

          Error Number: 24
          Error String: textFrame.insertionPoints[1].groups.add is not a function

          File: zzztry.js
          Line: 5
          Source: textFrame.insertionPoints[1].groups.add(group1elements);

          which is kind of a bummer.

          • 2. Re: Script - Paste a Group into a TextFrame
            natdeamer Level 1

            Hi Jongware

             

            I tried with textFrame.insertionPoints[0].groups.add(...) - but obviously like you found doesn't work.  Will look into rectangles.