Copying and Relinking Page Items While Maintaining Position and Rotation in InDesign
The following function is supposed to copy the items on page src to page dst. That works on simple items.
function copyPageContent(src, dst) {
itemsOnPage = src.pageItems;
for (var e = 0; e < itemsOnPage.length; e++) {
gb = itemsOnPage[e].geometricBounds;
pos = [gb[1], gb[0]];
duped = itemsOnPage[e].duplicate(dst);
duped.move(pos);
}
}
But if i have 2 Items on the page src that are linked (being src.Item-A the original and src.Item-B the link to src.Item-A), on the copied page, the newly copy dst.Item-B is still linked to the original src.Item-A on page src. I want it to be linked to the dst.Item-A on the page dst.
Also, if the src.Item-B is rotated by 180° and put below the src-Item-A, its copy dst.Item-B is also rotated but put left of dst.Item-A. In other words: its right-down corner is put where its upper-left corner should be.
How can I unlink dst.Item-B from src.Item-A, link it to dst.Item-A and how can I correctly position it?
<Title renamed by MOD>
