Files
CrazeAnalytix/generate-pdf.js
T

30 lines
868 B
JavaScript

const puppeteer = require('puppeteer');
const path = require('path');
(async () => {
const browser = await puppeteer.launch({ headless: 'new' });
const page = await browser.newPage();
// Set viewport for presentation
await page.setViewport({ width: 1280, height: 720 });
// Load the HTML file
const filePath = path.join(__dirname, 'presentacion.html');
await page.goto(`file://${filePath}`, { waitUntil: 'networkidle0' });
// Wait for images to load
await page.waitForTimeout(2000);
// Generate PDF
await page.pdf({
path: path.join(__dirname, 'CrazeAnalytix_Presentation.pdf'),
format: 'A4',
landscape: true,
printBackground: true,
margin: { top: '0', right: '0', bottom: '0', left: '0' }
});
console.log('PDF generated successfully!');
await browser.close();
})();