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
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
...
Copy link to clipboard
Copied
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);