How to Capture .PDF Screen Shot using 0Browser, a Headless Browser as a Service

How to Capture PDF

In this example we will learn how to capture a .PDF file out of a web page using JavaScript, Puppeteer and 0Browser.


Make sure you have Node.js installed and Puppeteer added.
Also keep your 0Browser Account API Key handy.
If something doesn't add up here, please check out the 0Browser Getting Started guide for all details on this.


Now that we have the prerequisites in order, let's get to the fun part!

Use your favorite IDE to create a new JS file called index.js.
Following code snippet shows how to connect to 0Browser proxy to navigate to the YC news page and capture a .PDF screen-shot.

const puppeteer = require('puppeteer-core');

(async () => {
    const browser = await puppeteer.connect({

    const page = await browser.newPage();
    await page.goto('', 
                    {waitUntil: 'networkidle2'});
    await page.pdf({path: 'capture.pdf', 
                    format: 'A4'});  

    await browser.close();


Use NodeJS to run the script using below command.

 > node index.js

Then you will find a new file called capture.pdf in the same directory as index.js script lives.
Thats it, Great job!