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

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

Community Beginner ,
Mar 25, 2024 Mar 25, 2024

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
118
Translate
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
...
Translate
Community Expert ,
Mar 25, 2024 Mar 25, 2024
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);
Translate
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