| Total Complexity | 1 |
| Complexity/F | 1 |
| Lines of Code | 25 |
| Function Count | 1 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | // this script assumes you have puppeteer installed, but its not in the list of dependencies |
||
| 3 | import puppeteer from 'puppeteer'; |
||
| 4 | import path from 'path'; |
||
| 5 | |||
| 6 | const rootDir = process.cwd(); |
||
| 7 | const sourceHtmlFile = path.join('public', 'resume', 'index.html'); |
||
| 8 | const targetPdf = path.join('static', 'resume-html.pdf'); |
||
| 9 | |||
| 10 | async function exportResumeAsPdf() { |
||
| 11 | console.log('Starting PDF export.', '\n'); |
||
| 12 | const browser = await puppeteer.launch({ headless: true }); |
||
| 13 | const page = await browser.newPage(); |
||
| 14 | |||
| 15 | console.log(`Opening "/${sourceHtmlFile}"...`); |
||
| 16 | |||
| 17 | await page.goto(`file://${path.join(rootDir, sourceHtmlFile)}`, { waitUntil: 'networkidle0' }); |
||
| 18 | |||
| 19 | await page.pdf({ format: 'A4', path: targetPdf, margin: { top: 0, right: 0, bottom: 0, left: 0 } }); |
||
| 20 | |||
| 21 | await page.close(); |
||
| 22 | await browser.close(); |
||
| 23 | |||
| 24 | console.log('\n', `✅ All done! PDF exported to "/${targetPdf}".`); |
||
| 25 | } |
||
| 26 | |||
| 27 | exportResumeAsPdf(); |
||
| 28 |