html2canvas不可见区域截取不到问题解决---自己项目中出现问题(有效 个人记录)

download: function() {
				    var _this = this;
                    var targetDom = $("#demo");
                    var copyDom = targetDom.clone();
                    copyDom.width(targetDom.width() + "px");
                    copyDom.height(targetDom.height() + "px");
                    $('body').append(copyDom);
                    html2canvas(copyDom, {
                        onrendered:function(canvas) {
                            var contentWidth = canvas.width;
							var contentHeight = canvas.height;
							var pageHeight = contentWidth / 592.28 * 841.89;
							var leftHeight = contentHeight;
							var position = 0;
							var f="p";
							contentHeight > contentWidth ? f = 'p' : f = 'l';
							var pageData = canvas.toDataURL('image/png', 1.0);
							_this.aaa = canvas.toDataURL();
							var pdf = new jsPDF(f, 'px', [contentWidth, contentHeight]);
							pdf.addImage(pageData, 'png', 0, 0, contentWidth, contentHeight);
							pdf.save('content.pdf');
                            copyDom.remove();
             }
       });
},

 

你可能感兴趣的:(html,三方)