|
@@ -1,4 +1,4 @@
|
|
-// import html2pdf from "html2pdf.js";
|
|
|
|
|
|
+import html2pdf from "html2pdf.js";
|
|
import html2canvas from "html2canvas";
|
|
import html2canvas from "html2canvas";
|
|
import jsPDF from "jspdf";
|
|
import jsPDF from "jspdf";
|
|
|
|
|
|
@@ -14,6 +14,27 @@ export const jsPDFConfigs = {
|
|
},
|
|
},
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+export async function buildPdfSimple(
|
|
|
|
+ { element, pageSize, filename },
|
|
|
|
+ returnBlob = false
|
|
|
|
+) {
|
|
|
|
+ const opt = {
|
|
|
|
+ margin: 0,
|
|
|
|
+ html2canvas: { scale: 6, useCORS: true },
|
|
|
|
+ filename: filename || "",
|
|
|
|
+ image: { type: "jpeg", quality: 0.8 },
|
|
|
|
+ jsPDF: {
|
|
|
|
+ ...jsPDFConfigs[pageSize],
|
|
|
|
+ },
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ if (returnBlob) {
|
|
|
|
+ return await html2pdf().set(opt).from(element).outputPdf("blob");
|
|
|
|
+ } else {
|
|
|
|
+ await html2pdf().set(opt).from(element).save();
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
export async function buildPdf(
|
|
export async function buildPdf(
|
|
{ elements, pageSize, filename, scale },
|
|
{ elements, pageSize, filename, scale },
|
|
returnBlob = false
|
|
returnBlob = false
|