开发者

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 cl开发者_如何学编程ass="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");


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.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜