Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@toast38coza
Last active August 31, 2020 00:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toast38coza/9e34888e7567058f58e10cf56cb1ff1b to your computer and use it in GitHub Desktop.
Save toast38coza/9e34888e7567058f58e10cf56cb1ff1b to your computer and use it in GitHub Desktop.
Download a pdf of a webpage using puppeteer
const puppeteer = require('puppeteer');
const fs = require('fs');
const URL = https://apexcharts.com/" // set this to the url you want to generate a pdf of
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(URL, {waitUntil: 'networkidle2'});
await page.pdf({path: 'download.pdf', format: 'A4'});
await browser.close();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment