2

I'm using html-pdf nodejs library to render html table to PDF. It seems all works good. But tables rows at the end of the page looks like broken.Here the results. enter image description here

I've already used page-break-inside rule. And I've also put DIV inside the table's cells. That all does not help me.

I'm using meteor+react bundle.

Configuration

const config= {
    "format": "A4",
    "orientation": "portrait",
    "border": {
        "top": "0.2in",
        "right": "0.2in",
        "bottom": "0.2in",
        "left": "0.2in"
    },
    "timeout": "120000",
    "type": "pdf",
}

Server Side code:

pdf.create(html, config).toFile(_storage_path, Meteor.bindEnvironment((err, res) => { .... }));

Client Side

    const html = ReactDOM.findDOMNode(this.refs.PDF).outerHTML; 
    Meteor.call('vote.toPDF', html , function(res, err) {...});

Is there any way to avoid row breaking ? Did I miss anything ?

(UPDATE) Here similar articles. There are a lot of other possible solutions:

young B
  • 127
  • 1
  • 11
  • Have you tried the `page-break-after:always;` CSS rule? – Tholle Jul 07 '18 at 17:54
  • @Throlle, Yes, I've used this rule for **td** and **tr** tags. It not helping. – young B Jul 07 '18 at 17:56
  • That's frustrating. Have you tried using `page-break-after:always;` on just your `tr` tags, and removing `page-break-inside` and`page-break-after` from your `table`? – Tholle Jul 07 '18 at 17:58
  • 1
    @Tholle, I've tried different combinations. And nothing helped me. =( I forgot to mention that I've also used **borderSpacing: 0** rule for table. And all other borders I've specified via **border: 1px solid black** rule(for table, tr,td) – young B Jul 07 '18 at 18:02
  • Gotcha. Have you [tried this](https://github.com/marcbachmann/node-html-pdf/issues/226)? – Tholle Jul 07 '18 at 18:05
  • 1
    @Throlle, Yeap. I tried it. I had find a lot of articles concerning this issue and they did not help me. Perhaps it happen due to meteor or react. However I'm passing the right data I suppose. Maybe I should have a rest for a while. Because I've spent a lot of time today in an attempt to solve this issue. Thanks for your reply. – young B Jul 07 '18 at 18:14
  • 1
    @Tholle. Hello again. I've added **display: table** for each tr and defined **fixed** width for each **TD** and **TH**. So this has fixed my issue in spite of it's a dirty fix. For now, I think, I will use this solution. However, I will also try to find the best one. And if I find, I will publish the results here. Thanks for your help =) – young B Jul 07 '18 at 22:08

0 Answers0