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
PageItems is read only - so I can't add items to it.
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.parentTextFrames; group1 = app.layoutWindows.activePage.parent.groups; group1elements = group1.ungroup(); textFrame.insertionPoints.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
Error Number: 24
Error String: textFrame.insertionPoints.groups.add is not a function
which is kind of a bummer.
I tried with textFrame.insertionPoints.groups.add(...) - but obviously like you found doesn't work. Will look into rectangles.