Skip to content Skip to sidebar Skip to footer

Dompdf Generating Pdf In With Many Blank Pages Between Content

I'm using DOMPDF to generate pdf files from html. PDF file is getting generated but there are many blank pages are appearing in between content. Following is my php code.

Solution 1:

This looks to be due to a bug in how dompdf handles paging of table cells. If you remove the outer table, which appears to only exist to supply a border, the page will render better. You may still need to tweak the structure/styling, however, to get exactly what you want.

For example, instead of this:

<tablewidth="100%"border="0"cellpadding="0"cellspacing="0"id=""style="border:1px solid #ccc;color: #000;font-family: Arial,Helvetica,sans-serif;font-size:14px;"><tr><td><tablewidth="100%"cellspacing="0"cellpadding="0"border="0"style="border-bottom:1px solid #ccc"><tr><tdwidth="15%"align="left"valign="top"style="border-right:1px solid #ccc;padding:10px;line-height:20px">Form
                        <imgsrc="/var/www/html/pm5/bodytechniques/working/development/version5/therapist/images/w9-form.JPG"width="83"height="37"style="margin-left:15px" /><br>(Rev. August 2013)
                        <br>Department of the Treasury
                        <br>Internal Revenue Service</td><tdwidth="69%"align="left"valign="top"style="border-right:1px solid #ccc;padding:10px;text-align:center;line-height:45px"><h1align="center">Request for Taxpayer Identification Number and Certification</h1></td><tdwidth="16%"align="left"valign="top"><h3style="line-height:25px;padding:10px">Give Form to the requester. Do not send to the IRS</h3></td></tr></table></td></tr></table>

Do this:

<divstyle="border:1px solid #ccc;color: #000;font-family: Arial,Helvetica,sans-serif;font-size:14px;"><tablewidth="100%"cellspacing="0"cellpadding="0"border="0"style="border-bottom:1px solid #ccc"><tr><tdwidth="15%"align="left"valign="top"style="border-right:1px solid #ccc;padding:10px;line-height:20px">Form
                <imgsrc="/var/www/html/pm5/bodytechniques/working/development/version5/therapist/images/w9-form.JPG"width="83"height="37"style="margin-left:15px" /><br>(Rev. August 2013)
                <br>Department of the Treasury
                <br>Internal Revenue Service</td><tdwidth="69%"align="left"valign="top"style="border-right:1px solid #ccc;padding:10px;text-align:center;line-height:45px"><h1align="center">Request for Taxpayer Identification Number and Certification</h1></td><tdwidth="16%"align="left"valign="top"><h3style="line-height:25px;padding:10px">Give Form to the requester. Do not send to the IRS</h3></td></tr></table></div>

Solution 2:

I have problem when multiple tables doesn't fit to one page. Solution for this is easy, add <div style="clear: both;"> after table.

Post a Comment for "Dompdf Generating Pdf In With Many Blank Pages Between Content"