Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DOMPDF table border issue

Tags:

border

dompdf

I've come across a very strange issue with the latest version of DOMPDF (0.6.0 Beta 3). I'm using it to create invoices for customers on my site. The design calls for 1px borders between the table cells. If I use either black or #000 for the border color, the tables are rendered nicely. However, when I change the color, to say #CCC for example, instead of a 1px border, the borders become 2px. I'm using border-collapse:collapse and I've been pulling my hair out over this for 2 days. I'm not changing anything else except the color, yet the border thickness is changing. Has anyone else run across this issue and know what the solution is or have any suggestions? Why does black render a 1px border but other colors are rendered as 2px borders? Help!

Edit: I also have empty cells filled with   as I read that that may cause issues with tables, but still no luck.

like image 368
user2389431 Avatar asked Dec 02 '22 19:12

user2389431


2 Answers

This might help. I have not tried to reproduce your problem, but I know it helped with some issues I was having with tables. try adding this to your css for the table:

table {
    border-collapse: collapse;
}

Obviously you can use the appropriate selector in the css and not define the entire table class.

like image 148
john Avatar answered Dec 23 '22 12:12

john


I was having the exact same problem. It's caused from the table having its own border and the cells having their own borders. Here's how I fixed it:

table {
    border-left: 0.01em solid #ccc;
    border-right: 0;
    border-top: 0.01em solid #ccc;
    border-bottom: 0;
    border-collapse: collapse;
}
table td,
table th {
    border-left: 0;
    border-right: 0.01em solid #ccc;
    border-top: 0;
    border-bottom: 0.01em solid #ccc;
}
like image 42
Gavin Avatar answered Dec 23 '22 10:12

Gavin