Member-only story

How to programmatically convert Web Page to PDF?

Siva
Dec 31, 2019

--

There are numerous ways to download Webpage as PDF. The below gist's explains the ways to upload files in GITPOD.

Once you load the files in Gitpod. You’d execute the code the extract the PDF file.

$ node app.js

const puppeteer = require('puppeteer');

(async () => {
const browser = await puppeteer.launch({
headless: true,
args: ['--no-sandbox', '--disable-setuid-sandbox'],
});
const page = await browser.newPage();
await page.goto('https://itnext.io/using-service-objects-in-go-d899dc599335', {waitUntil: 'networkidle2'});
await page.pdf({path: 'output.pdf', format: 'A4'});

await browser.close();
})();

--

--

No responses yet