marcbachmann / node-html-pdf

This repo isn't maintained anymore as phantomjs got dreprecated a long time ago. Please migrate to headless chrome/puppeteer.
MIT License
3.56k stars 543 forks source link

Add pagination to the generated pdf #505

Open shah-pooja opened 5 years ago

shah-pooja commented 5 years ago

I need to apply pagination in the pdf generated. the data in the pdf will be a table of n rows and n is not fixed. At the footer of the page, it should display page x/y where x is current page and y is the total number of page.

yashm19 commented 5 years ago

var options = { format: 'A4', width: '8.2in', "border": { "top": "10mm", // default is 0, units: mm, cm, in, px "right": "6mm", "bottom": "3mm", "left": "6mm" }, "footer": { "height": "4mm", "contents": { default: '

{{page}}/{{pages}}
', } } };

pdf.create(html, options).toFile('./businesscard.pdf', function (err, res) { if (err) return console.log(err); console.log(res); // { filename: '/app/businesscard.pdf' } }); try this it's working for me