我使用html2canvas和jspdf将多页网页导出为pdf。但是,生成的 pdf 中没有边距。如何使用 html2canvas 或 jspdf 添加边距。
html2canvas(document.body, {
scale: 0.8,
logging: true,
allowTaint: false,
backgroundColor: null
}).then(function(canvas) {
// Export the canvas to its data URI representation
var base64image = canvas.toDataURL("image/jpeg");
console.log('Report Image URL: ' + base64image);
var imgWidth = 295;
var pageHeight = 210;
var imgHeight = canvas.height * imgWidth / canvas.width;
var heightLeft = imgHeight;
var doc = new jsPDF("l", "mm", "a4"); // landscape
var position = 0;
var width = doc.internal.pageSize.getWidth();
var height = doc.internal.pageSize.getHeight();
doc.addImage(base64image,'JPEG', …Run Code Online (Sandbox Code Playgroud) html2canvas ×1