4

I use javascript to create an inDesign file containing multiple textframes. During script runtime, the textframes are easily positioned at the right place.

The problem arises, when I change the text in a textframe afterwards, e.g., by deleting one line of text in a frame that has a second frame below it. Instead of having all text frames with absolute coordinates on the screen, I want to have them relative to each other, with automatic updates.

Simply said, I want to have an analogous concept to linking text frames (such that the text flows to the previous frame), but for moving frames.

How can this be achieved? I tried nesting and anchoring, but this wasn't helpful. Putting all frames in "automatically resize in height" + anchoring every frame to its predecessor would work, but I cannot anchor them to the previous textframe.

Example:

var doc = app.documents.item(0);
var page = doc.pages.item(0);
var x1 = 50, y1 = 50, x2 = 100, y2 = 100;
var firstFrame = page.textFrames.add({geometricBounds: [y1, x1, y2 x2]});

// Wrong, no absolute coordinates!
var secondFrame = page.textFrames.add({geometricBounds: [y2, x2, y2+50, x2+50]});

// "right":
var x3 = reference to firstFrame.geometricBounds[1], that is linked
var y3 = reference to firstFrame.geometricBounds[1], that is linked
var secondFrame = page.textFrames.add({geometricBounds: [y3, x3, y3+50, x3+50]});
  • Could I see the resulting document? I tried running your script but couldn't get past line 4. I'm not sure of a way to dynamically move objects relative to each other. But if I could see your document I may be able to suggest another solution. – jseymour186 Jan 15 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.