mirror of
https://github.com/r-ca/md2pdf-meow.git
synced 2024-11-22 23:53:14 +00:00
cjsに対応
This commit is contained in:
parent
5851c14527
commit
667111bd63
|
@ -1,18 +1,23 @@
|
||||||
import PuppeteerHTMLPDF from "puppeteer-html-pdf";
|
import PuppeteerHTMLPDF from 'puppeteer-html-pdf';
|
||||||
|
|
||||||
|
async function generatePDF() {
|
||||||
const htmlPdf = new PuppeteerHTMLPDF();
|
const htmlPdf = new PuppeteerHTMLPDF();
|
||||||
|
|
||||||
htmlPdf.setOptions({
|
htmlPdf.setOptions({
|
||||||
format: "A4",
|
format: "A4",
|
||||||
});
|
});
|
||||||
|
|
||||||
const html = await htmlPdf.readFile(`${__dirname}/dist/all.html`, "utf8");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const html = await htmlPdf.readFile(`${__dirname}/../dist/all.html`, "utf8");
|
||||||
|
|
||||||
const pdfBuffer = await htmlPdf.create(html);
|
const pdfBuffer = await htmlPdf.create(html);
|
||||||
const path = `${__dirname}/dist/result.pdf`;
|
const path = `${__dirname}/../dist/result.pdf`;
|
||||||
await htmlPdf.writeFile(pdfBuffer, path);
|
await htmlPdf.writeFile(pdfBuffer, path);
|
||||||
|
|
||||||
console.log("PDF created successfully");
|
console.log("PDF created successfully");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error creating PDF", error);
|
console.error("Error creating PDF", error);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
generatePDF();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user