3 Replies Latest reply on Jul 24, 2012 2:07 AM by ramkumar.vp

    Hyphenated Word


      Hi Friends,


      How to get the Before and After hyphenation words in indesign scripting.


      Example:AAAA-BBBBj(Automaticaly hyphenated)

      How to get AAA & BBBB and save in separate variables.


      Please give idea.

        • 1. Re: Hyphenated Word
          Laubender Adobe Community Professional & MVP

          @JesRoberts – you could test for the "lines.length" property of the word. If there is more than one line, the word is split. But that does not give you the parts (could be more than two). So you have to test for the lines index of every single character of the word.



          1 person found this helpful
          • 2. Re: Hyphenated Word
            Vamitul Level 4


            i did something like this a while ago, but i can't find the code.

            the problem is that the automated hypen does not apear in the text variable.

            so.. (assuming that AAAABBBB is stored in myVariable)


            myVariable.lines[0] will get the line, ending with the first part of the word,and

            myVariable.lines[1].. you get the ideea.


            unfortunatly using

            myVariable.lines[0].words[-1] will give you the entire word (AAAABBBB) so the trick i used was to insert a space at the end of the line like:

            myVariable.lines[0].insertionPoints[-1].contents=" "; then get the first and last part of the word using

            .lines[0].words[-1] and .lines[1].words[0] then remove the added space (.lines[0].characters[-1].remove())


            ps. it's just a guide to get you started, in the actual code you will have to be a bit more careful.

            1 person found this helpful
            • 3. Re: Hyphenated Word
              ramkumar.vp Level 3

              Hi Friend,


              Use the below code to select the first part and second part seperately.


              Javascript Code

              var myTxt = app.selection[0];
              var myChar1 = app.selection[0].lines[0].characters[-1];

              var myChar2 = app.selection[0].lines[1].characters[0];

              myChar1.select(1633969202); // SelectionOptions.ADDTO

              alert("First part selected");



              alert("Second part selected");


              Ramkumar .P