Skip to main content
Inspiring
September 26, 2011
Question

Precisely aligning anchored frames

  • September 26, 2011
  • 2 replies
  • 1489 views

Using FM10 in TCS3 on Windows XP

Just finished watching Rick Quatro's webinar on ExtendScript.  One of the sample scripts changes the alignment of anchored frames to left, center, or right.  Is there any way to more precisely align the anchored frames using inches or pixels or whtaever?

As always, thanks in advance.

This topic has been closed for replies.

2 replies

Ian Proudfoot
Legend
September 27, 2011

Setting the positioning of an anchored frame is one of the easier procedures with ExtendScript, but there are limitations...

Assign the anchored frame to a variable named anchoredFrame, I won't go into the method of selection here.

To select the Anchoring Position use the following:

anchoredFrame.AnchorType = Constants.FV_ANCHOR_INLINE;

The other possible anchoring poitions are:

Constants.FV_ANCHOR_TOP

Constants.FV_ANCHOR_BELOW

Constants.FV_ANCHOR_BOTTOM

Constants.FV_ANCHOR_SUBCOL_LEFT

Constants.FV_ANCHOR_SUBCOL_RIGHT

Constants.FV_ANCHOR_SUBCOL_NEAREST

Constants.FV_ANCHOR_SUBCOL_FARTHEST

Constants.FV_ANCHOR_SUBCOL_INSIDE

Constants.FV_ANCHOR_SUBCOL_OUTSIDE

Constants.FV_ANCHOR_TEXTFRAME_LEFT

Constants.FV_ANCHOR_TEXTFRAME_RIGHT

Constants.FV_ANCHOR_TEXTFRAME_NEAREST

Constants.FV_ANCHOR_TEXTFRAME_FARTHEST

Constants.FV_ANCHOR_TEXTFRAME_INSIDE

Constants.FV_ANCHOR_TEXTFRAME_OUTSIDE

Constants.FV_ANCHOR_RUN_INTO_PARAGRAPH

Now that the anchoring position has been set, you can adjust the relevant positions just as you would with the user interface. The relevant properties are:

anchoredFrame.BaselineOffset

anchoredFrame.SideOffset

These two properties look useful, but they seem to be read only for anchored frames:

anchoredFrame.LocX

anchoredFrame.LocY

So, if you want to have more control over the horizontal positioning with the anchoring position set to Below Current Line (Constants.FV_ANCHOR_BELOW) you are probably out of luck - it can't be done using the user interface. In this case the best way would perhaps be to adjust the Anchored frame to match the column width then shift its entire contents to the required position. Perhaps someone knows a better way?

Ian

cvgsAuthor
Inspiring
September 27, 2011

Wow, Ian, that was fast. I’ll give it a try.

Ian Proudfoot
Legend
September 26, 2011

Everything that can be done to align an anchored frame using Frame's user interface can also be done via ExtendScript.

Open the ExtendScript ToolKit and take a look at the AFrame class in the Object Model Viewer. You will see the Properties and Methods that are available. It's getting late here but I may be able to write a small example script tomorrow.

Ian

cvgsAuthor
Inspiring
September 27, 2011

Thanks so much, Ian.