mirror of
https://github.com/r-ca/md2pdf-meow.git
synced 2024-11-26 09:13:15 +00:00
マージン追加
This commit is contained in:
parent
f15f3baece
commit
5ba02f1054
|
@ -1,23 +1,29 @@
|
|||
import PuppeteerHTMLPDF from 'puppeteer-html-pdf';
|
||||
|
||||
async function generatePDF() {
|
||||
const htmlPdf = new PuppeteerHTMLPDF();
|
||||
const htmlPdf = new PuppeteerHTMLPDF();
|
||||
|
||||
htmlPdf.setOptions({
|
||||
format: "A4",
|
||||
});
|
||||
htmlPdf.setOptions({
|
||||
format: "A4",
|
||||
margin: {
|
||||
top: "20mm",
|
||||
right: "20mm",
|
||||
bottom: "20mm",
|
||||
left: "20mm"
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
const html = await htmlPdf.readFile(`${__dirname}/../dist/all.html`, "utf8");
|
||||
try {
|
||||
const html = await htmlPdf.readFile(`${__dirname}/../dist/all.html`, "utf8");
|
||||
|
||||
const pdfBuffer = await htmlPdf.create(html);
|
||||
const path = `${__dirname}/../dist/result.pdf`;
|
||||
await htmlPdf.writeFile(pdfBuffer, path);
|
||||
|
||||
console.log("PDF created successfully");
|
||||
} catch (error) {
|
||||
console.error("Error creating PDF", error);
|
||||
}
|
||||
const pdfBuffer = await htmlPdf.create(html);
|
||||
const path = `${__dirname}/../dist/result.pdf`;
|
||||
await htmlPdf.writeFile(pdfBuffer, path);
|
||||
|
||||
console.log("PDF created successfully");
|
||||
} catch (error) {
|
||||
console.error("Error creating PDF", error);
|
||||
}
|
||||
}
|
||||
|
||||
generatePDF();
|
||||
|
|
Loading…
Reference in New Issue
Block a user