Question: Is there any way to cutoff the maximum lines per page
Requirement: My documents need to present always the same amount of lines on each page.
Context: I have done a snippet to present the line numbers along with the document. Like this:
___________________
| 1. line p1 |
| 2. another line |
| 3. end of p1 |
| 4. |
| 5. line p2 |
| |
| |
|_________________|
But some pages don't render with the same amount of lines. So I am working on a snippet to check if the render exceeds a fixed amount of lines to force a page break.
renderNode(node, sourceNode) {
let lineNumber = calculateLineNumberFromBoundingClientRect()
if (lineNumber >= MAX_LINES) {
page.layoutMethod.forceBreak()
newBreakToken = {} // CREATES A NEW BREAK TOKEN
}
}
onBreakToken(breakToken, a, node, layout) {
// Ignore the breakToken and instead using mine.
RETURN newBreakToken
}
Any ideas, recommendations?