Elitmiar
Elitmiar

Reputation: 36829

Css border lines not showing when assigned to td tags in PDF file generated by DOMPDF

I'm rendering a table using DomPDF 0.6, now I need to have borders throughout each cell. If I use then the cellpadding and cellspacing affects the width of the border so I can't use it.

Now I have my table

$html = '<table border="0" cellspacing="0" cellpadding="4" width="100%" style="border:1px solid #000;">
                <tr>
                    <td class="borderOk">&nbsp;</td>
                    <td class="borderOk" align="center" colspan="2" style="font-size:18px;font-weight:normal;"><i>'.$pName1.'</i></td>
                    <td class="borderOk" align="center" colspan="2" style="font-size:18px;font-weight:normal;"><i>'.$pName2.'</i></td>
                </tr>
                <tr>
                    <td class="borderOk"><strong><i>Price</i></strong></td>
                    <td class="borderOk" colspan="2" >&nbsp;</td>
                    <td class="borderOk" colspan="2" >&nbsp;</td>
                </tr>
                <tr>
                    <td class="borderOk"><strong><i>Options</i></strong></td>
                    <td class="borderOk" colspan="2" >&nbsp;</td>
                    <td class="borderOk" colspan="2" >&nbsp;</td>
                </tr>
                <tr>
                    <td class="borderOk" >&nbsp;</td>
                    <td class="borderOk" colspan="2" >&nbsp;</td>
                    <td class="borderOk" colspan="2" >&nbsp;</td>
                </tr>
</table>';

With my styles that look like this "Also is within the $html variable at the top"

<style type="text/css">

    td .borderOk{  
     border-style: solid;
     border-width: 1px;
     border-color: #A5C3E0;
}
</style>

The borders show perfectly in my Browser but when rendering it using domPDF the pdf file shows without the inner td borders, only the outline border is shown.

My DomPDF code looks like this

$dompdf = new DOMPDF();

$dompdf->load_html($_SESSION['html'],'UTF-8');
$dompdf->set_paper('a4', 'portrait');
$dompdf->render();
$dompdf->stream(date("YmdHis").".pdf");

Upvotes: 1

Views: 5537

Answers (3)

shivshankar
shivshankar

Reputation: 691

Try to use dompdf version 0.6.0 beta3. It will work for sure. I had tried your code.

http://code.google.com/p/dompdf/downloads/detail?name=dompdf_0-6-0_beta3.tar.gz

Upvotes: 1

SpaceGeneral
SpaceGeneral

Reputation: 727

I had the same issue. Remove the border="0" then do as Fabien noted: td.borderOk or just .borderOk

Upvotes: 2

Fabien M&#233;nager
Fabien M&#233;nager

Reputation: 140195

Your CSS selector should be

td.borderOk

(without the space)

Or better : add the borderOK class to the table and leave your CSS as it is.

Upvotes: 3

Related Questions