且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PDF中的图像被截断:如何使画布完全适合PDF页面?

更新时间:2023-11-29 15:34:10

还尝试设置图像的宽度和高度(无论如何,似乎没有关于addImage的文档):

Try setting the width and height of the image as well (in any case, there is little documentation for addImage it seems):

var pdf = new jsPDF("l", "mm", "a4");
var imgData = canvas.toDataURL('image/jpeg', 1.0);

// due to lack of documentation; try setting w/h based on unit
pdf.addImage(imgData, 'JPEG', 10, 10, 180, 150);  // 180x150 mm @ (10,10)mm