Dompdf: First table cell misalignment

Created on 10 Feb 2016  路  4Comments  路  Source: dompdf/dompdf

If I apply one or more css styles to "*:after" rule, then the first cell in any table on that page will be aligned to the left of any other cells in the first column. I am using v0.6.2 to perform the conversion to PDF.

bug

Most helpful comment

This is awesome news, thankyou so much for updating this issue and this project!

All 4 comments

Can you post some sample HTML?

I just ran into this. The following html creates the problem. The *, *:before, *:after portion is commonly used for a global box sizing border box.


<!doctype html>
<html>
  <head>
    <title>Test Title</title>
    <style>
    *, *:before, *:after {
      color: red;
    }
    </style>
  </head>
  <body>
    <table>
      <tbody>
        <tr>
          <th>Misaligned</th>
          <td>Also Misaligned</td>
        </tr>
        <tr>
          <th>Fine Alignment</th>
          <td>Fine Alignment</td>
        </tr>
      </tbody>
    </table>
  </body>
</html>

Options used:

setIsHtml5ParserEnabled(true);
setDefaultMediaType('print');
setDefaultFont('sans-serif');
setDpi(72);
setPaper('letter', 'portrait');

@webspecnick that certainly causes it. Similar issue reported in #1107, though ultimately this ties back to #758.

To work around the issue for now you can add the following to your stylesheet:

thead:before, thead:after,
tbody:before, tbody:after,
tfoot:before, tfoot:after {
  display: none;
}

This is awesome news, thankyou so much for updating this issue and this project!

Was this page helpful?
0 / 5 - 0 ratings