Pregunta

I'm looking for a way in Adobe InDesign CS5+ to make one element a child element of another (similar to what you can do with Edit -> Paste Into).

I can't use the app.pasteInto option unfortunately because in my script, the window is not visible.

Is there any other way of doing this?

Regards,

pieter

¿Fue útil?

Solución

If an object is a PageItem and supports the contentPlace() method, you can place another object inside of it (documentation). For example, if there are two rectangles on a page and you want to place one rectangle inside the other, you could use something like this:

var doc = app.activeDocument;

var page = doc.pages[0];

var rect = page.rectangles[0];
var rect2 = page.rectangles[1];

rect.contentPlace([rect2]);     // Content place duplicates the item,
rect2.remove();                 // so it needs to be removed after moving it.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top