html2pdf().from(element).set(opt).toPdf().get('pdf').then(function (pdf) {
var totalPages = pdf.internal.getNumberOfPages();
console.log("getHeight:" + pdf.internal.pageSize.getHeight());
console.log("getWidth:" + pdf.internal.pageSize.getWidth());
for (var i = 1; i <= totalPages; i++) {
pdf.setPage(i);
pdf.setFontSize(10);
pdf.setTextColor(150);
//divided by 2 to go center
pdf.text('Page ' + i + ' of ' + totalPages, pdf.internal.pageSize.getWidth()/2,
pdf.internal.pageSize.getHeight()/ 2);
}
}).save();
I am using this code and it is working fine but instead of plain text I wanted to show some HTML code (actually I want to repeat the code of Header of my original HTML code on every page) but it is not working. Is there any way so that I can add HTML code just like the text here. I just simply wanted to show the table header on each page after the page break. I am using react 14 and the library to generate PDF is html2pdf 0.9.0*