Forked from adisetiawan/html to pdf using puppeteer
Created
November 7, 2017 11:25
-
-
Save zoutepopcorn/fa02175a6c877a38e1af1f56db83d4c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//npm init -y | |
//npm install --save puppeteer | |
//usage: node script.js /path/to/input.html /path/to/output.pdf | |
//script.js | |
const puppeteer = require('puppeteer'); | |
(async () => { | |
let fileinput = process.argv[2]; | |
let fileoutput = process.argv[3]; | |
const browser = await puppeteer.launch(); | |
const page = await browser.newPage(); | |
await page.goto('file:///${fileinput}', {waitUntil: 'networkidle'}); | |
await page.pdf({path: fileoutput, format: 'A4'}); | |
browser.close(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment