forked from WebPraktikos/universal-resume
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgeneratePDF.mjs
More file actions
31 lines (23 loc) · 713 Bytes
/
generatePDF.mjs
File metadata and controls
31 lines (23 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import puppeteer from 'puppeteer';
(async () => {
try {
// connects to browserless container
const browser = await puppeteer.connect({
browserWSEndpoint: 'ws://localhost:3000'
});
const page = await browser.newPage();
const fileUrl = 'http://localhost:3000/resume/index.html';
await page.goto(fileUrl, { waitUntil: 'domcontentloaded', timeout: 10000 });
// create a PDF of the page
await page.pdf({
path: 'resume.pdf', // path to save the PDF
format: 'letter', // paper size
printBackground: false,
});
// close the browser
await browser.close();
console.log('PDF generated!');
} catch (e) {
console.error(e)
}
})();