I'm using a CSS property,
If I use page-break-after: always;
=> It prints an extra blank page before
If I use page-break-before: always;
=> It prints an extra blank page after. How to avoid this?
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <style type="text/css"> .print{ page-break-after: always; } </style> <script type="text/javascript"> window.print(); </script> </head> <body> <div class="print">fd</div> <div class="print">fdfd</div> </body> </html>
There are numerous possible causes for a printer that's randomly producing blanks. The most common ones are empty ink cartridges, improper cartridge installation, and congested nozzles. Driver and software issues can sometimes cause this problem as well.
If you have a landscape section in amongst your portrait pages, and there's only enough content to fit on a single landscape page, then the back of that page will print as a blank page. Again, if you're printing double-sided, this is what you want to happen, but it's disconcerting when you're printing single-sided.
Have you tried this?
@media print { html, body { height: 99%; } }
You could maybe add
.print:last-child { page-break-after: auto; }
so the last print
element will not get the extra page break.
Do note that the :last-child selector is not supported in IE8, if you're targetting that wretch of a browser.
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