Question

I'm trying to have table borders in my PDF using pisa to generate the PDF from my html page. According to the documentation, I should use CSS to display borders in my table. However this is not working out. I can see the borders on my webpage, but on the generated PDF there's absent. Is there something I'm missing or doing wrong? I'm using the following styles for the table:

table { border: 1px solid #666666;  border-collapse:collapse; border-color:#ccc; }
td, th { border: 1px solid #666666; font-size:11px; line-height:13px; border-bottom:1px solid #666666; vertical-align:top; padding:5px; font-family:"Lucida Grande", Verdana, Arial, sans-serif; }
Was it helpful?

Solution

I forgot to update this question after I got the answer....the CSS should be in the HTML page that'll be used by pisa. Apparently external CSS stylesheets don't work. Hope this will someday help someone else

OTHER TIPS

Just to correct this - external css does work in PISA but you need to ensure it can locate the css at render time. See django - pisa : adding images to PDF output for more infor on how to do this.

Regards

Tim

Setting display:block for <table> and <td> elements solved this problem for me.

I had the same problem.

the solution was: 1 - CSS should be in the HTML page, 2 - CSS should be out of @page attribute.

For me, it worked if i assigned a class for it. for example to draw a border around the cell, use below css class:

td.box{
    border: 1px solid #666666;
}

in td, add the class:

<td class="box"> Something </td>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top