|
@@ -128,6 +128,29 @@ export function calculationWeek(val, format) {
|
|
|
return week;
|
|
|
}
|
|
|
|
|
|
+export function getPdfNoPage(name, title) {
|
|
|
+ // Vue.prototype.htmlToPdf = function (name, title) {
|
|
|
+ html2Canvas(document.querySelector("#" + name), {
|
|
|
+ // allowTaint: true,
|
|
|
+ useCORS: true,
|
|
|
+ scale: 2, // 提升画面质量,但是会增加文件大小
|
|
|
+ dpi: window.devicePixelRatio * 1,
|
|
|
+ }).then((canvas) => {
|
|
|
+ const contentWidth = canvas.width;
|
|
|
+ const contentHeight = canvas.height;
|
|
|
+ /* 导出不分页处理 */
|
|
|
+ const pageData = canvas.toDataURL("image/jpeg", 1.0);
|
|
|
+ const pdfWidth = ((contentWidth + 10) / 2) * 0.75;
|
|
|
+ const pdfHeight = ((contentHeight + 200) / 2) * 0.75; // 500为底部留白
|
|
|
+ const imgWidth = pdfWidth;
|
|
|
+ const imgHeight = (contentHeight / 2) * 0.75; // 内容图片这里不需要留白的距离
|
|
|
+ const PDF = new JsPDF("", "pt", [pdfWidth + 50, pdfHeight + 100]);
|
|
|
+ PDF.addImage(pageData, "jpeg", 33, 33, imgWidth, imgHeight);
|
|
|
+ PDF.save(title + ".pdf");
|
|
|
+ });
|
|
|
+ // };
|
|
|
+}
|
|
|
+
|
|
|
export function getPdf(title, num, domId = "pdfDom") {
|
|
|
const element = document.getElementById(domId);
|
|
|
// var doc = new JsPDF("", "pt", "a4");
|