Hello community,
A user requested me for a multiline texbox (expandable) with a column next to it that would display the row number of each line.
Because every character type can have their own height i figured id convert the text to courrier as each character use the same height.
My problem now is when the textbox expands on multiple pages, I can't get the total height of the textbox, only the height of the textbox on the first page
Unfortunately i cannot upload the form from work for security reason but here is the code.
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 lblText = "";
p2_lbl_rowCount.rawValue = "";
for (var i = 1; i * 10 <= (xfa.layout.h(txt_CompteRendu, "pt")); i++) {
if (lblText != "") {
lblText = lblText + "\n";
}
lblText = lblText + i;
}
p2_lbl_rowCount.rawValue = lblText;
console.println(lblText);
xfa.layout.relayout(); // need to relayout so that if i remove lines it change the size of the row2 right away instead of having to put the focus on it again then out
the variable p2_lbl_rowCount is the text label use to display the line number.
Unfortunately if the textbox txt_CompteRendu is more than 72 lines it will expand to another page, at which point the counter will stop counting.
Solved! Go to Solution.
Views
Replies
Total Likes
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;
i managed to copy the file on a free hosting site.
http://s000.tinyupload.com/index.php?file_id=09992296537286432055
Views
Replies
Total Likes
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;
Views
Likes
Replies
Views
Likes
Replies