Seb33300
Seb33300

Reputation: 7566

DomPDF table rows have incorrect height when setting a table height

I am trying to display a simple table with fixed height using dompdf:

#d {
  border-collapse: collapse;
  width: 100%;
  height: 500px;
}
#d td {
  vertical-align: top;
  padding: 10px;
  border-left: 1px solid #e8e8e8;
  border-right: 1px solid #e8e8e8;
}
<table id="d">
  <tbody>
    <tr>
      <td>aaa</td>
      <td>aaa</td>
    </tr>
    <tr>
      <td>bbb</td>
      <td>bbb</td>
    </tr>
    <tr>
      <td>ccc</td>
      <td>ccc</td>
    </tr>
    <tr>
      <td>ddd</td>
      <td>ddd</td>
    </tr>
  </tbody>
</table>
table bottom

But PDF render is not as I expect: dompdf result

What I want is that table rows height should be auto-adjusted to the table height like on pure html render: http://jsfiddle.net/qfw627an/

Is there a way to do that with dompdf?

Thanks

Upvotes: 0

Views: 3250

Answers (1)

Michael Cole
Michael Cole

Reputation: 16257

you may hate this answer, but you can't get there from here.

I had alot of trouble with DomPDF on a project. It doesn't look like it's gotten better in the last couple years.

Simulating a browser in PHP is a hard problem. Luckily, someone built a "headless" version of Webkit to print PDF's.

http://wkhtmltopdf.org/

We switched to this and were back to working on our application again, instead of endless fiddling with printing.

Good luck!

Upvotes: 3

Related Questions