How to count lines in TextField?

mr__broccoli

11-05-2016

I have TextField designed like “multi line”, with “auto-fit” height.

Content (text) is filled by external data (via interface) in print scenario. Please help me how to read number of really utilized lines in JavaScript?

Accepted Solutions (0)

Answers (4)

Answers (4)

yanip

19-05-2016

I actually had to do something similar to what your looking for a couple of weeks again.

For it to work tho you must use courrier character ( from what i understand they are the only for which each character has the same height but im not sure)

finding height of multiLine textbox when it expands on multiple pages

for (var i = 0; xfa.layout.h(txt_CompteRendu, "pt", i) > 0; i++) {

  totLine = totLine + (xfa.layout.h(txt_CompteRendu, "pt", i) / 10);

}

Basically i take the height of the textbox "in pt but you could use mm / cm" and divide it by the height of  my characters (in my case 10).

THe reason i put it in a for loop is because my  textbox can grow on many pages, to access the textbox on each page you need to specify its index

Magus069

MVP

11-05-2016

This works if lines are created using enter, but it is not working if lines are created with excessive characters on one line... Sorry it is not working perfectly

Magus069

MVP

11-05-2016

Hi there,

if you want to verify how many lines there is text, and skip lines which are blank, you can use the following script to achieve what you need

If you want to verify how many line, counting the empty lines, use the following code

Hope this will help!