I recently created a well-designed HTML page that can be transformed into a PDF format. The HTML page displays correctly in the web browser.
https://i.sstatic.net/D0DE8.png
However, when I execute window.print()
, the structure appears distorted.
https://i.sstatic.net/1EtRJ.jpg
This is how my HTML code looks:
<div class="main"> <!-- PDF Page 1 --> </div>
<div class="pagebreak"></div>
<div class="main"> <!-- PDF Page 2 --> </div>
<div class="pagebreak"></div>
<!-- more ... -->
I've spent hours trying to troubleshoot this issue without success. The red boxes located at the corners of the PDF pages have the CSS property position: absolute;
. The overflowing content seems to be causing the problem. How can I prevent this from happening?