-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-pdf.js
37 lines (32 loc) · 896 Bytes
/
build-pdf.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
const puppeteer = require('puppeteer')
const express = require('express')
const serveStatic = require('serve-static')
async function main() {
try {
const app = express()
app.use(serveStatic('./build', { index: ['index.html'] }))
app.listen(3001)
const browser = await puppeteer.launch({
args: [
'--font-render-hinting=none',
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-blink-features=LayoutNGPrinting',
],
})
const page = await browser.newPage()
await page.goto('http://localhost:3001', { waitUntil: 'networkidle2' })
await page.evaluateHandle('document.fonts.ready')
await page.pdf({
path: 'build/resume.pdf',
width: '8.5in',
height: '11in',
})
await browser.close()
} catch (exception) {
console.error(exception)
process.exit(1)
}
process.exit(0)
}
main()