使用JSPDF进行多个画布的屏幕截图
希望我想做的事情的解决方案很简单。我使用以下代码成功将画布打印为 pdf:
<!-- Start PDF Script -->
<script type="text/javascript">
function getPDFFileButton () {
return html2canvas($('canvas'), {
background: "#ffffff",
onrendered: function(canvas) {
var myImage = canvas.toDataURL("image/png,1.0");
// Adjust width and height
var imgWidth = (canvas.width * 20) / 240;
var imgHeight = (canvas.height * 20) / 240;
// jspdf changes
var pdf = new jsPDF('p', 'mm', 'a4');
pdf.addImage(myImage, 'png', 15, 2, imgWidth, imgHeight); // 2: 19
pdf.save('H&H-Carport-Design.pdf');
}
});
}
$("#btnPrint").on("click", function () {
getPDFFileButton ()
});
</script>
<!-- End PDF Script -->
<button type="button" class="btn btn-lg btn-secondary" id="btnPrint">Print PDF <i class="fas align-middle fa-file-pdf"></i></button>
我需要帮助修改代码以从前、后、左和右拍摄画布的照片,并在单击“打印 PDF”按钮。这可能吗?
Hopefully the solution to what I would like to do is easy. I successfully have the canvas printing to a pdf using the following code:
<!-- Start PDF Script -->
<script type="text/javascript">
function getPDFFileButton () {
return html2canvas($('canvas'), {
background: "#ffffff",
onrendered: function(canvas) {
var myImage = canvas.toDataURL("image/png,1.0");
// Adjust width and height
var imgWidth = (canvas.width * 20) / 240;
var imgHeight = (canvas.height * 20) / 240;
// jspdf changes
var pdf = new jsPDF('p', 'mm', 'a4');
pdf.addImage(myImage, 'png', 15, 2, imgWidth, imgHeight); // 2: 19
pdf.save('H&H-Carport-Design.pdf');
}
});
}
$("#btnPrint").on("click", function () {
getPDFFileButton ()
});
</script>
<!-- End PDF Script -->
<button type="button" class="btn btn-lg btn-secondary" id="btnPrint">Print PDF <i class="fas align-middle fa-file-pdf"></i></button>
I need help modifying the code to take a picture of the canvas from the Front, Back, Left and Right and put all of the images on the same PDF when you click the "Print PDF" button. Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论