Article View: adobe.scripting.indesign
Article #19143Re: how to place box round text
From: Olav Kvern
Date: Mon, 13 Jan 2003 21:03
Date: Mon, 13 Jan 2003 21:03
29 lines
2238 bytes
2238 bytes
Reinhardt--
Sure, it's (relatively<g>) easy.
The way to get page location information from text is to use the baseline, ascent, descent, and horizontal offset properties of the text objects.
If you're looking to put a box around a word, and all of the word appears on a single line, then it's very easy:
--Given a reference to a word "myWord" and a rectangle "myRectangle"...
set myX1 to horizontal offset of character 1 of myWord
set myY1 to baseline of character 1 of myWord - ascent of character 1 of myWord
set myX2 to horizontal offset of insertion point -1 of myWord
set myY2 to baseline of insertion point -1 of myWord - descent of insertion point -1 of myWord
set geometric bounds of myRectangle to {y1, x1, y2, x2}
Take a look at the BoxCharacters example script for more on positioning rectangles relative to text objects.
If you're trying to place a box around an arbitrary range of text, you'll have to find the baseline and ascent of the first line of the range and the baseline and descent of the last line in the range, then find the farthest-left horizontal offset and farthest-right horizontal offset to set the values for the bounds of the rectangle.
If you want the box to move with the text as the text moves, and the text is a paragraph or series of paragraphs, consider making the text into a table.
Thanks,
Ole
Technical Details
Message-ID:
<1de75bfc.0@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!news.webusenet.com!wn11feed!wn12feed!worldnet.att.net!169.207.30.132!newsengine.sol.net!skynet.be!skynet.be!newsfeed.tpinternet.pl!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<371A133AF2F1132546947E22CDF01A70@in.WebX.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,19ed4f3d573ae8c9 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-01-13 13:08:07 PST From: "Olav Kvern" <okvern@adobe.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!news.webusenet.com!wn11feed!wn12feed!worldnet.att.net!169.207.30.132!newsengine.sol.net!skynet.be!skynet.be!newsfeed.tpinternet.pl!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: how to place box round text Message-ID: <1de75bfc.0@WebX.la2eafNXanI> Date: Mon, 13 Jan 2003 13:03:15 -0800 References: <371A133AF2F1132546947E22CDF01A70@in.WebX.la2eafNXanI> Lines: 38 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit