From 667111bd63470cb272a5f6cdb6a5390f06c29952 Mon Sep 17 00:00:00 2001 From: rca Date: Mon, 12 Aug 2024 17:25:57 +0900 Subject: [PATCH] =?UTF-8?q?cjs=E3=81=AB=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/convert.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/scripts/convert.ts b/scripts/convert.ts index ea23b8e..f7625be 100644 --- a/scripts/convert.ts +++ b/scripts/convert.ts @@ -1,18 +1,23 @@ -import PuppeteerHTMLPDF from "puppeteer-html-pdf"; +import PuppeteerHTMLPDF from 'puppeteer-html-pdf'; -const htmlPdf = new PuppeteerHTMLPDF(); +async function generatePDF() { + const htmlPdf = new PuppeteerHTMLPDF(); -htmlPdf.setOptions({ + htmlPdf.setOptions({ format: "A4", -}); + }); -const html = await htmlPdf.readFile(`${__dirname}/dist/all.html`, "utf8"); + try { + const html = await htmlPdf.readFile(`${__dirname}/../dist/all.html`, "utf8"); -try { const pdfBuffer = await htmlPdf.create(html); - const path = `${__dirname}/dist/result.pdf`; + const path = `${__dirname}/../dist/result.pdf`; await htmlPdf.writeFile(pdfBuffer, path); + console.log("PDF created successfully"); -} catch (error) { + } catch (error) { console.error("Error creating PDF", error); + } } + +generatePDF();