1 | import path from 'path'; |
||
2 | import puppeteer from 'puppeteer'; |
||
3 | |||
4 | const sourceUrl = 'http://localhost:9000/resume'; |
||
5 | const targetPdf = path.join('public', 'vitor-mello-resume.pdf'); |
||
6 | |||
7 | async function exportResumeAsPdf() { |
||
8 | console.log('Starting PDF export.', '\n'); |
||
0 ignored issues
–
show
Debugging Code
introduced
by
![]() |
|||
9 | const browser = await puppeteer.launch({ headless: true }); |
||
10 | const page = await browser.newPage(); |
||
11 | |||
12 | console.log(`Opening "${sourceUrl}"...`); |
||
13 | |||
14 | await page.goto(sourceUrl, { waitUntil: 'networkidle0' }); |
||
15 | |||
16 | await page.pdf({ format: 'A4', path: targetPdf, margin: { top: 0, right: 0, bottom: 0, left: 0 } }); |
||
17 | |||
18 | await page.close(); |
||
19 | await browser.close(); |
||
20 | |||
21 | console.log('\n', `✅ All done! PDF exported to "/${targetPdf}".`); |
||
22 | } |
||
23 | |||
24 | exportResumeAsPdf(); |
||
25 |