I am working on an asp.net MVC project and I need to convert a HTML div into a PDF with two separate pages. Here is an example of my code: HTML Code
<div class="row" id="mycanvas">
<p>This is the first part of my content.</p>
<p>This is the second part of my content.</p>
</div>
<button type="button" onclick="savePdf()"> Save As PDF </button>
Javascript Code
function savePdf() {
html2canvas($("#mycanvas"), {
onrendered: function (canvas) {
var imgData = canvas.toDataURL("image/jpeg", 1.0);
generatePDF(canvas);
}
});
}
function generatePDF(imgData) {
var doc = new jsPDF("p", "mm", "a4");
var width = doc.internal.pageSize.width;
var height = doc.internal.pageSize.height;
doc.addImage(imgData, 'JPEG', 0, 0, width, height);
doc.addPage();
doc.addImage(imgData, 'JPEG', 0, 0, width, height);
doc.save('download.pdf');
}
I am looking to split this div into two separate PDF pages.