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

Get the line number of selected text

New Here ,
Mar 30, 2010 Mar 30, 2010

Hi All,

Please tell me how to get the line number of the selected text in a page.

for example

Consider, below is the page with some text, in that i want to get the line number of that selected(marked in red) text

|-------------------------|

|xxxxxxxxxxxxxx|

|xxxxxxxxxx       |
|xxxxxxxxxxxxxx|

|xxxxxxxxxxxxxx|

|xxxxxxxxxx       |

|xxxxxxxxxxxxxx|

|xxxxxxxxxxxxxx|

---------------------------

Thanks in Advance

Shiv

TOPICS
Scripting
1.2K
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

Engaged , Mar 30, 2010 Mar 30, 2010

Hi Shiv,

Checkout this thread. This will give you idea.

Always search in forum first before creating new one.

Shonky

Translate
Engaged ,
Mar 30, 2010 Mar 30, 2010

Hi Shiv,

Checkout this thread. This will give you idea.

Always search in forum first before creating new one.

Shonky

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
New Here ,
Mar 30, 2010 Mar 30, 2010

Hi Shonky,

First, thanks for your reply and its woking fine for me but, the only thing is, its not counting empty line.

Is there any way to do that?

below is my try

app.findTextPreferences = app.changeTextPreferences = null;
app.findTextPreferences.findWhat = "XXX";
var arrFoundItems = new Array;
myFoundSet =app.activeDocument.findText (true);
if(myFoundSet.length != 0)
{        
    for(var n = 0; n < myFoundSet.length; n ++)
    {   
        linecnt = myFoundSet.parentStory.characters.itemByRange (myFoundSet.paragraphs[0].index,  myFoundSet.index).lines.length;
        alert(paragraph_index);
   }
}

Thanks

Shiv

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
Community Expert ,
Mar 30, 2010 Mar 30, 2010

Here is an easier method (it counts empty lines):

myText = // whatever
myTF = myText.parentTextFrames[0];
line_number = myTF.characters.itemByRange (myTF.characters[0], myText).lines.length;

Peter

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
New Here ,
Mar 30, 2010 Mar 30, 2010

Hi Peter,

Great!!!!

Thanks a lot.....

Shiv

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
Contributor ,
Apr 16, 2013 Apr 16, 2013
LATEST

Hi,

Its returning page number of selected text but its throwing error for selected text in footnote. 

How can i get the line number of text in Foot Note?? help me...

Thanks,

Sudha K

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