Table of Contents
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
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 |
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.
Puppeteer sets an initial page size to 800px x 600px, which defines the screenshot size. The page size can be customized with Page.setViewport()
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.