-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-cv.js
44 lines (33 loc) · 909 Bytes
/
generate-cv.js
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
43
44
const fs = require('fs')
const puppeteer = require('puppeteer')
async function generateCV() {
const { userName } = getProcessArgs()
const browser = await puppeteer.launch({
headless: true
})
const page = await browser.newPage()
const document = fs.readFileSync('./cv.html', 'utf8')
await page.setContent(document, {
waitUntil: ['load', 'domcontentloaded', 'networkidle0']
})
// Apply additional settings for better text rendering
await page.emulateMediaType('print')
await page.pdf({
format: 'A4',
path: `./${userName}.pdf`,
printBackground: true
})
await browser.close()
}
function getProcessArgs() {
const args = process.argv.slice(2)
const parsedArgs = {}
args.forEach(arg => {
if (arg.startsWith('--')) {
const [key, value] = arg.slice(2).split('=')
parsedArgs[key] = value || true
}
})
return parsedArgs
}
generateCV()