/puppeteer-test

Just a test of the new Puppeteer 2.0

Primary LanguageJavaScript

Puppeteer test

Now for something simple with the new version of Puppeteer v2.0.

To get a PDF version of this repository click on this ./readme.pdf

1. Installation

To use Puppeteer in your project, run:

npm i puppeteer
Note
When you install Puppeteer, it downloads a recent version of Chromium (~170Mb Mac, ~282Mb Linux, ~280Mb Win) that is guaranteed to work with the API. To skip the download

2. Example PNG

First program takes a PNG of the example.com web page

example.js
link:./example.js[role=include]

Which when it’s run with the

node example.js

Result in the example.com website being called up and a snapshot taken into a png file.

example
Figure 1. Captured PNG file

Puppeteer sets an initial page size to 800px x 600px, which defines the screenshot size. The page size can be customized with Page.setViewport()

3. Example PDF

Second program produces a PDF file

hn.js
link:./hn.js[role=include]

Result is the hn.pdf file being created from the ycombinator.com web page.

Click on the following link to see the generated file.

4. Document History

Table 1. Document History
Date Version Author Description

11/04/2019

V2.1b

JHRS

Initial version