5

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; }
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

5 Answers5

6

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

  • external stylesheet works, as it's explained below. The problem then is to know which kinds of CSS statements are supported, you'll find them in the docs. border-collapse is not one of them. – Dominique Guardiola Sep 30 '11 at 17:00
  • 1
    External stylesheets do work, but it's not always easy to tell if it's finding them correctly. – Cole Maclean Mar 19 '12 at 22:44
3

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>
Ayman Al-Absi
  • 2,630
  • 24
  • 22
3

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

Community
  • 1
  • 1
Tim Sutton
  • 661
  • 5
  • 4
2

I had the same problem.

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

kuhn
  • 176
  • 3
  • 5
2

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

Jaya
  • 21
  • 1