简体   繁体   中英

html-pdf nodejs page cutting issue

I use table in pdf but when new page starting at that time row is cut half In upper page and half in next page.
I use html-pdf for creating pdf.
I also try page break css property but no any change in my output.

used ejs

i resolved that add small CSS

page-break-inside

and it's working table row is not cutting on ending of first page and starting of second page of first ans second page.

Adding page-break-inside alone may not solve the problem when the table is long. I solved a similar problem by turning a table into multiple mini tables with the command not to break them.

Example CSS:

table, tr, td { page-break-inside: avoid; }

Example HTML:

<table>
    <tr>
        <th>Title A</th>
        <th>Title B</th>
        <th>Title C</th>
    </tr>
</table>
<table>
    <tr>
        <td>1</td>
        <td>2</td>
        <td>3</td>
    </tr>
</table>
<table>
    <tr>
        <td>1</td>
        <td>2</td>
        <td>3</td>
    </tr>
</table>
<table>
    <tr>
        <td>1</td>
        <td>2</td>
        <td>3</td>
    </tr>
</table>
...

Well, this is not the best programming practice, however this is a very reported error and I have not found any other solution for this problem that the html-pdf lib generates on node.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM