-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexport.js
More file actions
42 lines (36 loc) · 956 Bytes
/
export.js
File metadata and controls
42 lines (36 loc) · 956 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
31
32
33
34
35
36
37
38
39
40
41
42
import puppeteer from 'puppeteer';
import fs from 'fs/promises';
const exportStaticResume = async () => {
try {
const browser = await puppeteer.launch();
const page = await browser.newPage();
const html = await fs.readFile('./dist/index.html', 'utf8');
await page.setContent(html, { waitUntil: 'networkidle0' });
await page.emulateMediaType('screen');
const pdf = await page.pdf({
printBackground: true,
format: 'Letter',
});
await page.setViewport({
width: 510, // 8.5in
height: 660, // 11in
deviceScaleFactor: 3, // upscales images
});
await page.screenshot({
path: './dist/Resume.jpg',
fullPage: true,
type: 'jpeg',
quality: 90,
});
await browser.close();
await fs.writeFile('./dist/Resume.pdf', pdf);
} catch (error) {
throw error;
}
};
try {
exportStaticResume();
} catch (error) {
console.error(error);
process.exit(1);
}