danfickle / openhtmltopdf

An HTML to PDF library for the JVM. Based on Flying Saucer and Apache PDF-BOX 2. With SVG image support. Now also with accessible PDF support (WCAG, Section 508, PDF/UA)!
https://danfickle.github.io/pdf-templates/index.html
Other
1.93k stars 360 forks source link

Bug on text inside table when using margin-left #857

Open lagar84 opened 2 years ago

lagar84 commented 2 years ago

Hello,

I found an issue when using margin-left on table.

Reproducer:

<html>
<head>
<style>
@page {
    size: 200px 250px;
    margin: 10px 10px 10px 10px;
}
html {
    font-family: sans-serif;
    font-size: 14px;
    margin: 0;
    padding: 0;
}
body {
  margin: 0;
  padding: 0;
}
</style>
</head>
<body>
      With margin-left on table
    <table style="width: 100%; margin-left: 15px; border: 0;">
        <tr>
            <td style="width: 60px;">Label:</td>
            <td>a a a a a a a a a a a a a a a a a a a a a a</td>
        </tr>
    </table>
<br/><br/>
      Without margin-left on table
    <table style="width: 100%; border: 0;">
        <tr>
            <td style="width: 11px;"></td> <!-- workaround using empty cell -->
            <td style="width: 60px;">Label:</td>
            <td>a a a a a a a a a a a a a a a a a a a a a a</td>
        </tr>
    </table>
</body>
</html>

This results in the pdf below (using sandbox or on my local project using version 1.0.10):

image

I could workaround the problem by not using margin-left, and instead I used an empty cell.

However, it doesnt hurt to report the issue.

Thanks for this great library. Hope you can continue this great work.

Best wishes, lagar84.

lagar84 commented 2 years ago

PR #876