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?
We can add a page break tag with style "page-break-after: always" at the point where we want to introduce the pagebreak in the html page.
To fix this just change it to page-break-after:auto. It will break correctly and not create an extra blank page. Save this answer.
Note: The page-break-after property cannot be used on absolutely positioned elements or an empty <div> element. Syntax: page-break-after: auto|always|avoid|left|right|initial|inherit; Default Value : Its default value is auto.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With