scale:2 可以增加打印内容的清晰度
windowWidth: 1200可以根据实际内容调整
printPaper() {
this.printing = true
this.$nextTick(() => {
html2canvas(this.$refs.printPaperRef, {
useCORS: true,
foreignObjectRendering: false,
windowWidth: 1200,
//windowWidth: document.body.scrollWidth,
//windowHeight: document.body.scrollHeight,
scale: 2
}).then((canvas) => {
const url = canvas.toDataURL()
printjs({
printable: url,
type: 'image',
documentTitle: "这是页眉的标题",
base64: 'true'
})
}).finally(() => {
this.printing = false
})
})
}