onPrint(event, ownerInstance){
const _this=this
const doc = new jsPDF('l', 'pt', 'a4');
const printWarper=document.getElementById('printWarper')
const printWidth=printWarper.offsetwidth
const printHeight=printWarper.offsetHeight
let position = 0;
html2canvas(printWarper, {
width:printWidth,
height:printHeight,
scrollY: 0, // html2canvas默认绘制视图内的页面,需要把scrollY,scrollX设置为0
scrollX: 0,
useCORS: true //支持跨域
}).then(function(canvas) {
const contentHeight=canvas.height;
const contentWidth=canvas.width;
let pageHeight = contentWidth / 841.89 * 592.28;
let pageData = canvas.toDataURL('image/png');
doc.addImage(pageData, 'png', 0, 0, contentWidth, contentHeight)
doc.save('CTStest.pdf');
ownerInstance.callMethod('printAction', {
test: 'test'
})
});
}
1 个回复
晴天i
解决了吗?我也遇到这个问题了