I have a application made with Delphi 2006 which prints with QuickReport. Due to many bugs, I will rebuild this section of the software , generating the report in HTML and then send it to printer through some component. My question is, How/Can I tell when printer should break into a new page with HTML? Some tag or event on printing component for HTML?
Asked
Active
Viewed 4.2k times
16
-
1This answer might help https://stackoverflow.com/questions/1664049/can-i-force-a-page-jump-in-html-printing/1664058#answer-1664058 – Eduardo Pignatelli Sep 11 '18 at 14:24
1 Answers
41
You can add page breaks for printing with a little bit of CSS.
CSS:
@media all {
.page-break { display: none; }
}
@media print {
.page-break { display: block; page-break-before: always; }
}
HTML: Use a div element with the page-break class where you want insert your breaks
<div class="page-break"></div>
Example:
<div>Some content BEFORE the page break</div>
<div class="page-break"></div>
<div>Some content AFTER the page break</div>
<div class="page-break"></div>
<div> ... More content after another page break ... </div>
-
From https://developer.mozilla.org/en-US/docs/Web/CSS/page-break-after: "It won't apply on an emptythat won't generate a box."– vitaly Jan 07 '19 at 08:37
-
THANK YOU. I have tried ~10 similar solutions before this and nothing was working. – HFBrowning Jul 26 '19 at 18:22