print pdfs and send mails with ics file
This commit is contained in:
parent
5f827fb177
commit
728c4e05fa
12 changed files with 461 additions and 183 deletions
|
@ -39,7 +39,7 @@ export abstract class PdfExport {
|
|||
const page = await browser.newPage();
|
||||
await page.setContent(body, { waitUntil: "domcontentloaded" });
|
||||
|
||||
const exportPath = FileSystemHelper.formatPath(process.cwd(), "export", folder, `${filename}.pdf`);
|
||||
const exportPath = FileSystemHelper.formatPath(folder, `${filename}.pdf`);
|
||||
|
||||
let pdf = await page.pdf({
|
||||
...(saveToDisk ? { path: exportPath } : {}),
|
||||
|
@ -66,10 +66,12 @@ export abstract class PdfExport {
|
|||
|
||||
let pdfFilePaths = FileSystemHelper.getFilesInDirectory(inputFolder, ".pdf");
|
||||
|
||||
if (pdfFilePaths.length == 0) return;
|
||||
|
||||
const mergedPdf = await PDFDocument.create();
|
||||
|
||||
for (const pdfPath of pdfFilePaths) {
|
||||
const pdfBytes = FileSystemHelper.readFile(pdfPath);
|
||||
const pdfBytes = FileSystemHelper.readFileasBase64(inputFolder, pdfPath);
|
||||
const pdf = await PDFDocument.load(pdfBytes);
|
||||
const copiedPages = await mergedPdf.copyPages(pdf, pdf.getPageIndices());
|
||||
copiedPages.forEach((page) => mergedPdf.addPage(page));
|
||||
|
@ -77,8 +79,6 @@ export abstract class PdfExport {
|
|||
|
||||
const mergedPdfBytes = await mergedPdf.save();
|
||||
|
||||
const exportPath = FileSystemHelper.formatPath(process.cwd(), "export", outputFolder, `${outputFile}.pdf`);
|
||||
|
||||
FileSystemHelper.writeFile(exportPath, mergedPdfBytes);
|
||||
FileSystemHelper.writeFile(outputFolder, `${outputFile}.pdf`, mergedPdfBytes);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue