0.4.1 • Published 7 years ago

puppeteer-screenshots v0.4.1

Weekly downloads
-
License
MIT
Repository
bitbucket
Last release
7 years ago

Puppeteer Screenshots

This package provides a simple way to take screenshots and PDFs of urls.

This is a wrapper around Google's Puppeteer package.

This package is in Alpha. This package follows SemVer.

Install

Install using

npm i puppeteer-screenshots

How to use

There is two ways to use puppeteer-screenshots, the first is by doing this in your app file

require('puppeteer-screenshots').init();

that way you can call your program from the command line like this

node app.js --url=https://www.google.com

and a screenshot will be made and into "image.png". You can optionally specify path with --path=/path/to/file.png.

The other way to use it is to do this

var ps = require('puppeteer-screenshots');

ps.screenshot({url: 'https://google.com', path: 'google.png'});

which will save a screenshot of Google in 'google.png'. Note that here we don't have the double hyphens as when using from the command line.

Options

The available options you can pass to 'puppeteer-screenshots' are as follows

--url - (required) the url to take screenshot of 
--path - (optional) the path to save the screenshot to, default is 'image.png' 
--viewportWidth - (optional) the viewport width, default value is 1280 pixels
--viewportHeight - (optional) the viewport height, default value is 768 pixels
--userAgent - (optional) the user agent to use
--mobile - (optional) if this is set to true it will use a mobile user agent and set the viewport width to 320px and the viewport height to 480px, note that this overrides viewportWidth, viewportHeight and userAgent
--pdf - (optional) if true saves the screenshot as pdf
--mediaTypePrint - (optional) if set emulates the media type as print
--hide - (optional) a comma separated list of css selectors of elements which to hide using JavaScript, e.g if there are any pop-ups you want to hide
--visibility (optional) a comma separated list of css selectors of elements which to hide using JavaScript this is different than `hide` in that it sets the visibility property to hidden rather than the display to none
0.4.1

7 years ago

0.4.0

7 years ago

0.3.0

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago