<div id="pdfArea">
<span>make PDF</span>
</div>
<button type="button" onclick="savePDF()">PDF 다운</button>
<script type="text/javascript">
function savePDF(){
html2canvas($('#pdfArea')[0] ,{
allowTaint : true,
useCORS: true,
scale : 2
}).then(function(canvas) {
var imgData = canvas.toDataURL('image/png');
var imgWidth = 190;
var pageHeight = imgWidth * 1.414;
var imgHeight = canvas.height * imgWidth / canvas.width;
var heightLeft = imgHeight;
var margin = 10;
var doc = new jsPDF('p', 'mm');
var position = 0;
doc.addImage(imgData, 'PNG', margin, position, imgWidth, imgHeight);
heightLeft -= pageHeight;
while (heightLeft >= 20) {
position = heightLeft - imgHeight;
position = position - 20 ;
doc.addPage();
doc.addImage(imgData, 'PNG', margin, position, imgWidth, imgHeight);
heightLeft -= pageHeight;
}
doc.save('filename.pdf');
});
}
</script>