I have a page that prints tickets in 3 ways. Each ticket path is within a div
with class ticket
.
After each route, I need to generate a page break. However, by using page-break-after: always;
in Google Chrome, sometimes (depending on content), Google Chrome breaks the page out of the desired location, unconfiguring the whole impression. (see in the image below the image that would be the logo cut).
MicrosoftEdgeworksperfectly.
Tomakeiteasiertoreproducetheerror,belowismyHTMLcodewith%cssCSS.
<!DOCTYPEhtml><html><head><metacharset="UTF-8">
<style>
*{font-family: arial;}
@media print {
.ticket{
page-break-after: always;
page-break-inside: avoid;
position: relative;
}
body{
position: relative;
background-color:red;
}
}
</style>
</head>
<body>
<div class="ticket">
<img src="http://lorempixel.com/output/animals-q-g-198-44-7.jpg"alt="LOGO" /><br/>
RAZAO SOCIAL DA EMPRESA LTDA.<br/>
Endereço: Av. QUALQUER LUGAR, NÚMERO 000. NOME DO BAIRRO.<br/>
CNPJ: 11.111.111-1111-11<br/>
TF: 11.111.111 FP<br/>
Isento de ISS (lei número 1.111)<br/>
Telefones: 0800 111 1111 <br/>
(00)00000-0000<br/>
(00)00000-0000<br/>
<br/>
<strong>Via 1</strong>
<DIV style="border:1px solid #000; padding:10px;font-size:20px;font-weight:bold;width:100%;text-align:center;">Por favor, entregue <br/>esta via ao xxxxxxx</DIV><br/>
<DIV style="font-size:18px;font-weight:bold;width:100%;text-align:center;">TICKET: <span style="font-weight:bold;">00000000000000</span></DIV>
Tipo: XYZ<br/>
<strong>OBS: </strong>Mauris placerat euismod blandit. Donec vel nisl at odio sodales gravida.<br/>
<strong>Info Complementar: </strong>Etiam luctus urna nec metus scelerisque, sed laoreet magna volutpat. Sed ac lacus vitae augue vestibulum condimentum ut et arcu.<br/>
<strong>More: </strong>Mauris placerat euismod blandit. Donec vel nisl at odio sodales gravida.<br/>
<strong>OBS: </strong>Mauris placerat euismod blandit. Donec vel nisl at odio sodales gravida.<br/>
<strong>Info Complementar: </strong>Etiam luctus urna nec metus scelerisque, sed laoreet magna volutpat. Sed ac lacus vitae augue vestibulum condimentum ut et arcu.<br/>
<strong>More: </strong>Mauris placerat euismod blandit. Donec vel nisl at odio sodales gravida.<br/>
</div>
<div class="ticket">
<img src="http://lorempixel.com/output/animals-q-g-198-44-7.jpg"alt="LOGO" /><br/>
RAZAO SOCIAL DA EMPRESA LTDA.<br/>
Endereço: Av. QUALQUER LUGAR, NÚMERO 000. NOME DO BAIRRO.<br/>
CNPJ: 11.111.111-1111-11<br/>
TF: 11.111.111 FP<br/>
Isento de ISS (lei número 1.111)<br/>
Telefones: 0800 111 1111 <br/>
(00)00000-0000<br/>
(00)00000-0000<br/>
<br/>
<strong>Via 2</strong>
<DIV style="border:1px solid #000; padding:10px;font-size:20px;font-weight:bold;width:100%;text-align:center;">Por favor, entregue <br/>esta via ao xxxxxxx</DIV><br/>
<DIV style="font-size:18px;font-weight:bold;width:100%;text-align:center;">TICKET: <span style="font-weight:bold;">00000000000000</span></DIV>
Tipo: XYZ<br/>
<strong>OBS: </strong>Mauris placerat euismod blandit. Donec vel nisl at odio sodales gravida.<br/>
<strong>Info Complementar: </strong>Etiam luctus urna nec metus scelerisque, sed laoreet magna volutpat. Sed ac lacus vitae augue vestibulum condimentum ut et arcu.<br/>
<strong>More: </strong>Mauris placerat euismod blandit. Donec vel nisl at odio sodales gravida.<br/>
<strong>OBS: </strong>Mauris placerat euismod blandit. Donec vel nisl at odio sodales gravida.<br/>
<strong>Info Complementar: </strong>Etiam luctus urna nec metus scelerisque, sed laoreet magna volutpat. Sed ac lacus vitae augue vestibulum condimentum ut et arcu.<br/>
<strong>More: </strong>Mauris placerat euismod blandit. Donec vel nisl at odio sodales gravida.<br/>
</div>
<div class="ticket">
<img src="http://lorempixel.com/output/animals-q-g-198-44-7.jpg"alt="LOGO" /><br/>
RAZAO SOCIAL DA EMPRESA LTDA.<br/>
Endereço: Av. QUALQUER LUGAR, NÚMERO 000. NOME DO BAIRRO.<br/>
CNPJ: 11.111.111-1111-11<br/>
TF: 11.111.111 FP<br/>
Isento de ISS (lei número 1.111)<br/>
Telefones: 0800 111 1111 <br/>
(00)00000-0000<br/>
(00)00000-0000<br/>
<br/>
<strong>Via 3</strong>
<DIV style="border:1px solid #000; padding:10px;font-size:20px;font-weight:bold;width:100%;text-align:center;">Por favor, entregue <br/>esta via ao xxxxxxx</DIV><br/>
<DIV style="font-size:18px;font-weight:bold;width:100%;text-align:center;">TICKET: <span style="font-weight:bold;">00000000000000</span></DIV>
Tipo: XYZ<br/>
<strong>OBS: </strong>Mauris placerat euismod blandit. Donec vel nisl at odio sodales gravida.<br/>
<strong>Info Complementar: </strong>Etiam luctus urna nec metus scelerisque, sed laoreet magna volutpat. Sed ac lacus vitae augue vestibulum condimentum ut et arcu.<br/>
<strong>More: </strong>Mauris placerat euismod blandit. Donec vel nisl at odio sodales gravida.<br/>
<strong>OBS: </strong>Mauris placerat euismod blandit. Donec vel nisl at odio sodales gravida.<br/>
<strong>Info Complementar: </strong>Etiam luctus urna nec metus scelerisque, sed laoreet magna volutpat. Sed ac lacus vitae augue vestibulum condimentum ut et arcu.<br/>
<strong>More: </strong>Mauris placerat euismod blandit. Donec vel nisl at odio sodales gravida.<br/>
</div>
</body>
</html>
How to make the page break occur in the correct location using Google Chrome?