如何使用html2canvas配置分页符

时间:2018-07-05 13:08:49

标签: javascript jspdf html2canvas

我需要将html页面转换为pdf。我具有可以转换并保存的测试代码,但无法获取整个页面, 代码:

document.body.style.zoom = 1.0;

$.getScript("https://html2canvas.hertzen.com/dist/html2canvas.min.js", function(event) {});
$.getScript("https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.3/jspdf.min.js", function(event) {});
html2canvas(document.body).then(canvas => {

  var imgData = canvas.toDataURL("image/jpeg", 1.0);
  var pdf = new jsPDF();
  pdf.addImage(imgData, 'JPEG', 0, 0);
  pdf.save("download.pdf");

});

0 个答案:

没有答案