in reply to page break at paragraph break
Watch out for paragraphs which are longer than one page; Your code will blank out the current page (even if there is nothing on the page yet), and then print over the page break and end up with $line > LPP.
After that, the $line will be inaccurate, and no longer match your actual position on the page.
Try using: $line %= LPP; which will set $line to zero in the typical case of $line == LPP, but will maintain your page position if you overflow.
Instead of printing a series of "\n", could you print a FormFeed character (0x0C) and then set $line to 0? It would work best on an actual printer or a fancy document viewer.
|
|---|