【发布时间】:2015-06-17 04:38:05
【问题描述】:
当使用 jspdf 库将画布放置在 PDF 中时,图像会被截断。
html2canvas(myContainer, {background: 'red'}).then (canvas) ->
imgData = canvas.toDataURL('image/jpeg', 1.0)
window.open(imgData) # this is just a test that opens the image in a new tab and it displays nicely, the entire image
pdf = new jsPDF("l", "pt", "b1") # tried a variety of formats but no luck
pdf.addImage(imgData, 'JPEG', 0, 0)
pdf.save('file.pdf') # the generated pdf that contains the image gets trimmed
有没有人知道如何使画布适合?
【问题讨论】:
-
控制台有错误吗?
-
@KenFyrstenberg 没有错误。从 HTML 制作画布并将其放入 PDF 中一切都很好,只是它不完全适合并最终将画布/图像的其余部分剪掉,就像它不在乎一样。
标签: canvas html2canvas jspdf