clawdbot-workspace/proposals/convert-solvr-pdf.js

28 lines
872 B
JavaScript

const puppeteer = require('puppeteer-core');
const path = require('path');
(async () => {
const browser = await puppeteer.launch({
headless: true,
executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
args: ['--no-sandbox']
});
const page = await browser.newPage();
const htmlPath = path.resolve(__dirname, 'solvr-deliverables-simple.html');
await page.goto(`file://${htmlPath}`, { waitUntil: 'networkidle0', timeout: 30000 });
// Wait for images and fonts to load
await new Promise(r => setTimeout(r, 3000));
await page.pdf({
path: path.resolve(__dirname, 'solvr-deliverables-simple.pdf'),
format: 'Letter',
printBackground: true,
margin: { top: '0', bottom: '0', left: '0', right: '0' }
});
await browser.close();
console.log('PDF generated: solvr-deliverables-simple.pdf');
})();