openhtmltopdf icon indicating copy to clipboard operation
openhtmltopdf copied to clipboard

Border not working on <tr>/<thead> tag as expected

Open kareem-abdul opened this issue 3 years ago • 2 comments

Hi, the border style does not seem to work on tr / thead tag of a table. Attaching the HTML below.

<table style="border-collapse: collapse;">
    <tr style="border-bottom: 1px solid black">
        <td>1</td>
        <td>2</td>
        <td>3</td>
    </tr>
</table>

The above code gives the following output on chrome image

but gives the following on the generated pdf image

As you can see the border is not getting rendered on the pdf. The same can be observed on <thead> tag. Adding the code that I used to generate pdf below.

PdfRendererBuilder builder = new PdfRendererBuilder();
builder.useFastMode();
builder.useUnicodeBidiSplitter(splitter);
builder.useUnicodeBidiReorderer(reorderer);
builder.useUriResolver((baseUri, uri) -> {
    Object file = attributes.get(uri);
    if (file instanceof File) {
        uri = ((File) file).getName();
    }
    return uriResolver.resolveURI(baseUri, uri);
});
ByteArrayOutputStream bos = new ByteArrayOutputStream();
builder.withHtmlContent(html, Paths.get(this.fileStoreLocation).toUri().toURL().toExternalForm());
builder.toStream(bos);
builder.run();

kareem-abdul avatar Aug 15 '21 19:08 kareem-abdul

Hi @kareem-abdul,

A bit late, but you can use a border on the descendant td or th elements.

This is a good bug write-up and ideally we'd support borders on tr, but given the workaround is simple, it's not a priority at the moment.

danfickle avatar Sep 10 '21 11:09 danfickle

hey @danfickle any updates on this?

jonathansp avatar Apr 05 '24 15:04 jonathansp