I suppose you want a thin line, otherwise you would not set the width to 1px.
The key to having thin line borders displayed in PDF files made with wkhtmltopdf is to use the SVG background, for example:
.hairline-border { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100%' height='100%'><rect x='0' y='0' width='100%' height='100%' stroke='black' fill='white' stroke-opacity='1' /></svg>"); }
For the hair separator (think <hr>
), I use:
.hairline { height: 0.5mm; width: 100%; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100%' height='100%'><line x1='0mm' y1='0mm' x2='300mm' y2='0mm' style='stroke:black; stroke-width:0.25mm;' /></svg>"); }
and I use them like this:
<div class="hairline-border"></div>
And it displays correctly in Firefox and Safari / Chrome, and wkhtmltopdf at least keeps the line width as it is. There was some discussion that the base64 SVG conversion guarantees greater compatibility with IE. Honestly, I didn't care if IE would be happy or not, but see Inline SVG in CSS if you need to.
source share