Automating the Generation Script
I wrote a Node.js build script that spins up Playwright, visits the local rendering routes, and prints them to PDF format:
const { chromium } = require('playwright');
async function generatePDF(url, outputPath, format) {
const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto(url, { waitUntil: 'networkidle' });
await page.pdf({
path: outputPath,
format: format, // 'Letter' or 'A4'
landscape: true,
printBackground: true,
});
await browser.close();
}
This static pipeline outputs clean, minimal vector PDFs directly into my public directory during the build process, ensuring fast static page delivery without on-the-fly PDF generation overhead. Let me know what you think of this approach!
Top comments (0)