I have asp.net MVC project and want to print HTML div as pdf into two Pages and this is Example of my code HTML Code
<div class="row" id="mycanvas">
<p>This is My Content1</p>
<p>This is My Content2</p>
</div>
<button type="button" onclick="savePdf()"> Save As PDF </button>
JS Code
function savePdf() {
html2canvas($("#mycanvas"), {
onrendered: function (canvas) {
var imgData = canvas.toDataURL("image/jpeg", 1.0);
// generatePDF(imgData);
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.save('download.pdf');
}
I Want Split this Div into 2 pdf Pages
Not sure how to split the SAME div over two pages. but with page breaks you should be able to put a specific div on a new page...
Something similar to this in the CSS:
@media print
{
.page-break { display:block; page-break-before:always; }
}
and then in the html where you want the break to happen
<div class="page-break"></div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.