3

I use WKHTMLTOPDF to generate a pdf. On my page, I have a table with no border. In the browser everything is fine. Example of table:

<table class="noborder" border="0">
    <tbody>
        <tr class="noborder">
            <th colspan="2" class="noborder">MyHeader</th>
         </tr>
     </tbody>
</table>

CSS: Noborder:

.noborder {
    border: 0px solid black;
}

But in the generated PDF there are the borders.

Peter
  • 1,011
  • 2
  • 16
  • 39
  • 1
    Out of curiosity, does the pdf only show borders when you open it in the browser? When I open my PDF in Mac via the standard viewer, it displays correctly. It's only when I render within Chrome that I have this issue. It also displays as expected in Safari. – Kenny Cason Dec 11 '20 at 23:28

2 Answers2

5

I am having the exact same problem. In browser everything renders ok. But when I render in pdf, borders appear in all tables. I had to use tables because wkhtml and pdfkit were not able to interpret div class row and div class col; consequently text never appeared as desired in the pdf.

However this seems to work:

td {
    border-style : hidden!important;
   }

This was reported: Removing unwanted table cell borders with CSS

LeninGF
  • 332
  • 3
  • 10
0

I know its a late answer, but none of the above worked for me. Only some of the table cells required a border by design, so adding transparent border to all cells fixed it.

.c-info-table td,
.c-info-table th{
    padding: 5px 10px;
    border: 1px solid transparent;
}
.c-info-table tbody tr:nth-child(odd) td{
    background-color: #ecf2f6;
}

before / after

Nikolay Mihaylov
  • 3,868
  • 8
  • 27
  • 32