css - DOMPDF page-break-inside:avoid; property is leaving a blank at start of the pdf -
in code trying add external border frame pdf, when so, content of pdf breaks in between , continue in second page. overcome issue used page-break-inside:avoid; property on parent div. resulted in new strange issue, keeping first page blank (without border) , adding whole content second page (with border) of pdf.
no way me understand doing wrong.
i detailing dummy code snippet below -
<style type="text/css"> @page { margin: 0px; } body { margin: 0px; } html { margin: 0px;} .back-img { background: url('imageurl'); background-position: top left; background-repeat: no-repeat; background-size: 100%; padding-top: 100px; padding-left: 100px; padding-right: 100px; width:100%; height:100%; } </style> <div style="page-break-inside:avoid;" class="back-img"> <div style="text-align: center;"> <h1>heading text</h1> <br> <img src="imgurl" height="100"> <br><br> text here <br> text here.. text here.. <br> text here <br><br> text here <br><br> 3-4 lines of paragraph here <br><br> <img src="imgurl" height="50"> <br> text here <br> text here <br> text here </div> </div>
dompdf version 0.7.0 php version 7.0.18
your appreciated.
this because set width , height of container div 100%. dompdf doesn't best job flowing elements bumping against margins of page. have few options try address issuue:
- set height , width of container bit less containing page. easier if know page dimensions in pt , can specify specific lengths container dimensions.
- style container fixed-position element. won't affect document flow , apply generated pages. put margins on page , apply negative values border element.
for latter try like:
<style type="text/css"> @page { margin: 100px; } .back-img { position: fixed; background: url('imageurl'); background-position: top left; background-repeat: no-repeat; background-size: 100%; top: -50px; right: -50px; bottom: -50px left: -50px; } </style> <div class="back-img"></div> <div style="text-align: center;">...</div>
Comments
Post a Comment