• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

How do I get the x and y coordinates of a paragraph with ExtendScript?

Community Beginner ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

I've never done much with ExtendScript and am trying to get a little bit familiar with it. Assuming I have a paragraph object, how can I get the x, y location of the beginning of the paragraph?

 

Thanks,

Nick

TOPICS
Scripting

Views

95

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 25, 2024 Mar 25, 2024

Here is a way to do this with the beginning of the paragraph containing the text cursor. Note that the values are relative to the subcolumn containing the paragraph. And the top offset is to the baseline of the text in the paragraph.

 

var PT, doc, pgf, textLoc, prop, value;

PT = 65536; // Metric for a Postscript point.

doc = app.ActiveDoc;
// The paragraph object containing the cursor.
pgf = doc.TextSelection.beg.obj;
// Make a text location at the beginning of the paragraph.
textLoc = new Te
...

Votes

Translate

Translate
Community Expert ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

LATEST

Here is a way to do this with the beginning of the paragraph containing the text cursor. Note that the values are relative to the subcolumn containing the paragraph. And the top offset is to the baseline of the text in the paragraph.

 

var PT, doc, pgf, textLoc, prop, value;

PT = 65536; // Metric for a Postscript point.

doc = app.ActiveDoc;
// The paragraph object containing the cursor.
pgf = doc.TextSelection.beg.obj;
// Make a text location at the beginning of the paragraph.
textLoc = new TextLoc (pgf, 0);

// Left offset in points.
prop = doc.GetTextPropVal (textLoc, Constants.FP_LocX);
value = prop.propVal.ival / PT;
alert (value);

// Top offset in points.
prop = doc.GetTextPropVal (textLoc, Constants.FP_LocY);
value = prop.propVal.ival / PT;
alert (value);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines