Passed
Push — master ( bae175...7396a8 )
by Vitor
04:40 queued 01:42
created

export-pdf-resume.js ➔ exportResumeAsPdf   A

Complexity

Conditions 1

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 16
c 0
b 0
f 0
rs 9.9
cc 1
1
/* eslint-disable no-console */
2
import puppeteer from 'puppeteer';
3
import path from 'path';
4
5
const rootDir = process.cwd();
6
const sourceHtmlFile = path.join('public', 'resume', 'index.html');
7
const targetPdf = path.join('static', 'vitor-mello-resume.pdf');
8
9
async function exportResumeAsPdf() {
10
  console.log('Starting PDF export.', '\n');
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
11
  const browser = await puppeteer.launch({ headless: true });
12
  const page = await browser.newPage();
13
14
  console.log(`Opening "/${sourceHtmlFile}"...`);
15
16
  await page.goto(`file://${path.join(rootDir, sourceHtmlFile)}`, { waitUntil: 'networkidle0' });
17
18
  await page.pdf({ format: 'A4', path: targetPdf, margin: { top: 0, right: 0, bottom: 0, left: 0 } });
19
20
  await page.close();
21
  await browser.close();
22
23
  console.log('\n', `✅  All done! PDF exported to "/${targetPdf}".`);
24
}
25
26
exportResumeAsPdf();
27