This content has been marked as final. Show 4 replies
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 ...
// ... and index of found item
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.index, //first insertion point of paragraph
There's no need for parentParagraph and parentLine: myFoundSet[n].paragraphs returns an item's parent paragraph, myFoundSet[n].lines, the item's parent line.
Excellent! I have not tried it with the line number but the paragraph number works perfectly. It is rather convoluted how one has to arrive at the end, but I guess that is scripting.
You referred me to another discussion but that is about creating indexes. I had read it earlier but did not find it useful for this problem.
Here is a snippet of the code:
var paraNumber = myFoundSet[n].parentStory.characters.itemByRange(myFoundSet[n].parentTextFrames.insert ionPoints.index,myFoundSet[n].index).paragraphs.length;
> However, I would like to include the number of the paragraph where the found text resides as well as the line number in that paragraph.
it wasn't clear for me that you need pragraph's index in TextFrame ;)
but this thread was the answer to your question ;)