🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #2098

Re: How to find the paragraph and line numbers [CS3] [JS]

#2098
From: Peter Kahrel
Date: Sat, 03 Jan 2009 12:51
27 lines
1775 bytes
Assuming that you're looking for the number of the paragraph on the page, you'd need to count the number of paragraphs in the text frame that a found item occurs in. Since indexes are always counted from the beginning of the story, you isolate the text between the top of the page and the found item by starting at the index of the first insertion point of the found item's parent text frame and the found item itself. You capture that with this single long line:



 
// range over ... 
paragraph_number = myFoundSet[n].parentStory.characters.itemByRange ( 
   // ... index of first ins. point of found item's parent text frame ... 
   myFoundSet[n].parentTextFrames[0].insertionPoints[0].index, 
   // ... and index of found item 
   myFoundSet[n].index 
   ).paragraphs.length;



This includes any paragraph that started on the previous page. To find the found item's line number within its parent paragraph you do something similar:



line_number = myFoundSet[n].parentStory.characters.itemByRange ( 
   myFoundSet[n].paragraphs[0].index, //first insertion point of paragraph 
   myFoundSet[n].index 
   ).lines.length;



Peter
Technical Details
Message-ID: <59b76a0e.1@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newshub.sdsu.edu!webcrossing
References: <59b76a0e.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,c3c179ce83c93376
X-Google-Attributes: gidf939a,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Peter Kahrel" <kahrel@kahrel.plus.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Re: How to find the paragraph and line numbers [CS3] [JS]
Message-ID: <59b76a0e.1@webcrossing.la2eafNXanI>
Date: Sat, 3 Jan 2009 04:51:21 -0800
References: <59b76a0e.-1@webcrossing.la2eafNXanI>
Lines: 29
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit