Avatar

Correct answer by
Level 2

Finally figured it out.

It seems like the textbox "txt_CompteRendu" is actually divided into multiple boxes when changing lines.

xfa.layout.h actually has an option to specify the textbox index

It the following code textHeight will take the height of the textbox if the text expand on 3 pages, it will also work  if the text expand on 2 pages or is only one one page.

var txt_CompteRendu = xfa.resolveNode("formulaire1.page2.sf7.table7.row7_1.Tableau22.row2.txt71_CompteRendu");
var p2_lbl_rowCount = xfa.resolveNode("formulaire1.page2.sf7.table7.row7_1.Tableau22.row2.lbl7_LineNum");
var textHeight = xfa.layout.h(txt_CompteRendu, "pt", 0) + xfa.layout.h(txt_CompteRendu, "pt",1) + xfa.layout.h(txt_CompteRendu, "pt",2);
var lblText = "";
console.println( textHeight );

p2_lbl_rowCount.rawValue = "";

for (var i = 1; i * 10 <= textHeight ; i++) {
    if (lblText != "") {
     lblText = lblText + "\n";
}
    lblText = lblText + i;
}
p2_lbl_rowCount.rawValue = lblText;

View solution in original post