30 lines
932 B
JavaScript
30 lines
932 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, 'onepager.html');
|
|
await page.goto(`file://${htmlPath}`, { waitUntil: 'networkidle0', timeout: 30000 });
|
|
|
|
await page.evaluate(() => document.fonts.ready);
|
|
await new Promise(r => setTimeout(r, 2000));
|
|
|
|
await page.pdf({
|
|
path: path.resolve(__dirname, '..', 'Documents', 'Career', 'WheelOfWellnessOnePager.pdf'),
|
|
width: '8.5in',
|
|
height: '11in',
|
|
printBackground: true,
|
|
margin: { top: '0', right: '0', bottom: '0', left: '0' },
|
|
preferCSSPageSize: false
|
|
});
|
|
|
|
console.log('PDF generated successfully!');
|
|
await browser.close();
|
|
})();
|