36 lines
982 B
JavaScript
36 lines
982 B
JavaScript
const puppeteer = require('puppeteer-core');
|
|
const path = require('path');
|
|
|
|
(async () => {
|
|
const browser = await puppeteer.launch({
|
|
executablePath: '/usr/bin/google-chrome-stable',
|
|
headless: 'new',
|
|
args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-gpu']
|
|
});
|
|
|
|
const page = await browser.newPage();
|
|
|
|
const htmlPath = path.resolve(__dirname, 'mockup.html');
|
|
await page.goto(`file://${htmlPath}`, {
|
|
waitUntil: 'networkidle0',
|
|
timeout: 30000
|
|
});
|
|
|
|
// Wait for fonts to load
|
|
await page.evaluate(() => document.fonts.ready);
|
|
await new Promise(r => setTimeout(r, 2000));
|
|
|
|
// Use landscape Letter size (11" x 8.5")
|
|
await page.pdf({
|
|
path: path.resolve(__dirname, 'WheelOfWellnessMockup.pdf'),
|
|
width: '11in',
|
|
height: '8.5in',
|
|
printBackground: true,
|
|
margin: { top: '0', right: '0', bottom: '0', left: '0' },
|
|
preferCSSPageSize: false
|
|
});
|
|
|
|
console.log('PDF generated successfully!');
|
|
await browser.close();
|
|
})();
|