Skip to main content
hilukasz
Known Participant
June 10, 2012
Question

find position of text

  • June 10, 2012
  • 1 reply
  • 1103 views

I'm trying to get the position of point text from left anchor if left aligned, middle if center aligned and right if right aligned. is this even possible?

here are the keys of object I am trying to get at, if that helps

keys:

story : [Story]

contents : export me

textRange : [TextRange]

textSelection : [TextRange]

rowCount : 1

columnCount : 1

rowGutter : 0

columnGutter : 0

flowLinksHorizontally : true

spacing : 0

opticalAlignment : false

kind : TextType.POINTTEXT

contentVariable : undefined

orientation : TextOrientation.HORIZONTAL

this is what I am using to get at it:

app.activeDocument.textFrames[2].anchor[0]

am i confusing anchor point with baseline position?

This topic has been closed for replies.

1 reply

Inspiring
June 11, 2012

This looks right to me what makes you question it? Anchor is only valid for point text… If you have no baseline shift then I would expect it to be the same as baseline of the first para

hilukasz
hilukaszAuthor
Known Participant
June 12, 2012

I am not sure what was going on, I found another post where you mentioned outlining text. so did something like:

var temporaryText = currentTextItem.duplicate().createOutline(),

     // temporaryText is defined earlier

     left = Math.round(temporaryText.visibleBounds[0]),

     top = Math.abs(Math.round(temporaryText.visibleBounds[1])),

     right = Math.round(temporaryText.visibleBounds[2]),

     bottom = Math.abs(Math.round(temporaryText.visibleBounds[3]));

temporaryText.remove();

that way I can get all the bounding boxes exactly without wierd vector problems. Note I add the round and absolute math function so that I can get positive/even numbers, just easier for my brain to processes.

seems to work now though. very weird.

Inspiring
June 12, 2012

That I think is the only way to get bounds of type as here…

Anchor is the actual path point… As here for range left…