[英]jsPDF HTML2Canvas + HTML + Images cut off capture
Is there a way to adjust the width and height when capturing with canvas? 使用画布拍摄时,是否可以调整宽度和高度?
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.0.272/jspdf.debug.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>
<script>
function demoFromHTML() {
var pdf = new jsPDF('p', 'pt', 'letter');
var options = {
background: '#fff'
};
html2canvas(jQuery("#pdf"), {
onrendered: function(canvas) {
var imgData = canvas.toDataURL(
'image/png');
var doc = new jsPDF('p', 'mm');
doc.addImage(imgData, 'PNG', 0, 0);
doc.save('results.pdf');
}
});
}
</script>
Use configuration options: https://html2canvas.hertzen.com/configuration 使用配置选项: https : //html2canvas.hertzen.com/configuration
width >> DEFAULT: Element width - The width of the canvas 宽度>>缺省值:元素宽度-画布的宽度
height >> DEFAULT:Element height - The height of the canvas 高度>>缺省值:元素高度-画布的高度
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.