navjotdhanawat / dynamic-html-pdf

Create dynamic PDF from HTML template using handlebars
MIT License
34 stars 10 forks source link

how to repeat table header/footer? #15

Open Noman2011 opened 4 years ago

Noman2011 commented 4 years ago

I am trying to render a table in pdf which spawns across multiple pages. I want the header to appear on every page. I tried multiple things including having a thead, tbody, thead {display: table-header-group; } etc but nothing worked. When viewed in html and printed to pdf from the browser, the page renders correctly with table headers on each page. Please help.

mmnithin commented 3 years ago

I have also faced the same issue. I tried 2-3 methods by changing CSS but nothing happened. And last I solved this issue by changing "options" object const options = { "format": "A4", "orientation": "portrait", "border": { "top": "10mm", "right": "10mm", "bottom": "0mm", "left": "10mm" }, "header" : { "height": "28mm", }, "footer": { "height": "5mm", "contents": { default: '<span style="color: #444; text-align: right;">Page - {{page}}</span>/<span>{{pages}}</span>', } } }; await pdf.create(document, options); For More Information - you can refer https://www.npmjs.com/package/html-pdf?activeTab=readme (the two packages are almost identical)