Reputation: 111
I'm using xhtml2pdf with Django to output a page that contains several tables; the html view displays exactly as I want it but the PDF output has no table borders displayed.
The CSS (in the template, not linked) is:
body {
font-size:11pt;
line-height:13pt;
font-family:Calibri,Candara,Segoe,Segoe UI,Optima,Arial,sans-serif;
}
table.table-bordered, table.table-bordered>thead>tr>th, table.table-bordered>tbody>tr>td {
border-top-width: 1pt;
border-top-style: solid;
border-top-color: #000000;
border-bottom-width: 1pt;
border-bottom-style: solid;
border-bottom-color: #000000;
border-left-width: 1pt;
border-left-style: solid;
border-left-color: #000000;
border-right-width: 1pt;
border-right-style: solid;
border-right-color: #000000;
padding-top: 12pt;
padding-right: 12pt;
padding-bottom: 12pt;
padding-left: 12pt;
}
.border-top {
border-top-width: 1pt;
border-top-style: solid;
border-top-color: #000000;
}
td th table {
width: 100%;
vertical-align: center;
text-align:center;
}
table {
margin-top:auto;
margin-right:auto;
margin-bottom:auto;
margin-left:auto;
display:block;
}
Upvotes: 4
Views: 5747
Reputation: 4690
Try to add border
attribute in your table like this
<table border="1"></table>
Upvotes: 3
Reputation: 350
This answer does not relate with Django but only with the Subject!!
If any one ends up here please take a note:
Supported CSS properties
xhtml2pdf supports the following standard CSS properties
background-color border-bottom-color, border-bottom-style, border-bottom-width border-left-color, border-left-style, border-left-width border-right-color, border-right-style, border-right-width border-top-color, border-top-style, border-top-width colordisplay font-family, font-size, font-style, font-weight height line-height, list-style-type margin-bottom, margin-left, margin-right, margin-top padding-bottom, padding-left, padding-right, padding-top page-break-after, page-break-before size text-align, text-decoration, text-indent vertical-align white-space width zoom
link: reference
Took me a while to figure out that it doesn't support border property rather it only supports border-[top/left/right/bottom]-[style/color/width] properties
Upvotes: 4