diff --git a/src/htmlToPdf.js b/src/htmlToPdf.js
index 2e07fe8..6ce4e22 100644
--- a/src/htmlToPdf.js
+++ b/src/htmlToPdf.js
@@ -7,44 +7,44 @@ export default {
allowTaint: true,
scale: 2 // 提升画面质量,但是会增加文件大小
}).then(function (canvas) {
- var contentWidth = canvas.width
- var contentHeight = canvas.height
+ // var contentWidth = canvas.width
+ // var contentHeight = canvas.height
- var pageData = canvas.toDataURL('image/jpeg', 0.4)
+ // var pageData = canvas.toDataURL('image/jpeg', 0.4)
- var pdfWidth = ((contentWidth + 10) / 2) * 0.75
- var pdfHeight = ((contentHeight + 200) / 2) * 0.75 // 500为底部留白
+ // var pdfWidth = ((contentWidth + 10) / 2) * 0.75
+ // var pdfHeight = ((contentHeight + 200) / 2) * 0.75 // 500为底部留白
- var imgWidth = pdfWidth
- var imgHeight = (contentHeight / 2) * 0.75 // 内容图片这里不需要留白的距离
+ // var imgWidth = pdfWidth
+ // var imgHeight = (contentHeight / 2) * 0.75 // 内容图片这里不需要留白的距离
- var pdf = new JsPDF('', 'pt', [pdfWidth, pdfHeight])
- pdf.addImage(pageData, 'jpeg', 0, 0, imgWidth, imgHeight)
- // pdf.save('report_pdf_' + new Date().getTime() + '.pdf')
- pdf.save(title + '.pdf')
+ // var pdf = new JsPDF('', 'pt', [pdfWidth, pdfHeight])
+ // pdf.addImage(pageData, 'jpeg', 0, 0, imgWidth, imgHeight)
+ // // pdf.save('report_pdf_' + new Date().getTime() + '.pdf')
+ // pdf.save(title + '.pdf')
- // let contentWidth = canvas.width
- // let contentHeight = canvas.height
- // let pageHeight = (contentWidth / 592.28) * 841.89
- // let leftHeight = contentHeight
- // let position = 0
- // let imgWidth = 595.28
- // let imgHeight = (592.28 / contentWidth) * contentHeight
- // let pageData = canvas.toDataURL('image/jpeg', 0.4)
- // let PDF = new JsPDF('', 'pt', 'a4')
- // if (leftHeight < pageHeight) {
- // PDF.addImage(pageData, 'JPEG', 0, 0, imgWidth, imgHeight)
- // } else {
- // while (leftHeight > 0) {
- // PDF.addImage(pageData, 'JPEG', 0, position, imgWidth, imgHeight)
- // leftHeight -= pageHeight
- // position -= 841.89
- // if (leftHeight > 0) {
- // PDF.addPage()
- // }
- // }
- // }
- // PDF.save(title + '.pdf')
+ let contentWidth = canvas.width
+ let contentHeight = canvas.height
+ let pageHeight = (contentWidth / 592.28) * 841.89
+ let leftHeight = contentHeight
+ let position = 0
+ let imgWidth = 595.28
+ let imgHeight = (592.28 / contentWidth) * contentHeight
+ let pageData = canvas.toDataURL('image/jpeg', 0.4)
+ let PDF = new JsPDF('', 'pt', 'a4')
+ if (leftHeight < pageHeight) {
+ PDF.addImage(pageData, 'JPEG', 0, 0, imgWidth, imgHeight)
+ } else {
+ while (leftHeight > 0) {
+ PDF.addImage(pageData, 'JPEG', 0, position, imgWidth, imgHeight)
+ leftHeight -= pageHeight
+ position -= 841.89
+ if (leftHeight > 0) {
+ PDF.addPage()
+ }
+ }
+ }
+ PDF.save(title + '.pdf')
})
}
}
diff --git a/static/fontFile/MicrosoftYaHei.ttf b/static/fontFile/MicrosoftYaHei.ttf
deleted file mode 100644
index b4456b2..0000000
Binary files a/static/fontFile/MicrosoftYaHei.ttf and /dev/null differ