Files
klz-cables.com/create_pdf.mjs

39 lines
1.1 KiB
JavaScript

import puppeteer from 'puppeteer';
import fs from 'fs';
async function generatePDF() {
const pandocHtml = fs.readFileSync('AVB_2026.html', 'utf-8');
const html = `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
body { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 10pt; line-height: 1.5; color: #000; margin: 40px; }
h2 { font-size: 16pt; margin-bottom: 20px; font-weight: bold; }
h3 { font-size: 12pt; margin-top: 25px; margin-bottom: 10px; font-weight: bold; color: #222; }
p { margin-bottom: 12px; text-align: justify; }
</style>
</head>
<body>
${pandocHtml}
</body>
</html>
`;
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setContent(html, { waitUntil: 'networkidle0' });
await page.pdf({
path: 'KLZ_AVB_April_2026.pdf',
format: 'A4',
margin: { top: '2cm', right: '2cm', bottom: '2cm', left: '2cm' },
printBackground: true
});
await browser.close();
console.log('PDF generated: KLZ_AVB_April_2026.pdf');
}
generatePDF().catch(console.error);