1
I’m generating my own html
in PDF with JsPDF
. My html
is larger than an A4 sheet. To solve the problem I need to create paging in Jspdf
.
Code I have that only generates pdf with a page:
window.html2canvas = html2canvas;
function demoFromHTML() {
const html_source = document.getElementById('employee_detail'); // O id do elemento que contém o Html que quer imprimir.
const filename = 'Test.pdf';
html2canvas(html_source).then(function(canvas) {
let imgData = canvas.toDataURL('image/png');
let pdf = new jsPDF('p', 'mm', 'a4'); // Essas demissões [297, 210] correspondem a um A4
// addImage(imageData, format, x, y, width, height, alias, compression, rotation)
// x: Coordenada (em unidades declaradas no início do documento PDF) contra a borda esquerda da página
// y: Coordenada (em unidades declaradas no início do documento PDF) contra a borda superior da página
pdf.addImage(imgData, 'PNG', 10, 10);
pdf.save(filename);
})
}
To create this pagination I need to use the pagesplit
, but I am unable to generate pdf with more than one page.
Hello. I have an idea to help you. But I need your help, meet me at chat room.
– Cristiano Gilberto João