Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pupeteer: take webpage screenshot with zoom (scale)

I am using puppeteer to take page screnshot of a particular width:

await page.setViewport({width: 320, height: 0})
await page.goto(url)
await page.screenshot({path: `screenshot.png`, fullPage: true});

The width of screenshot is exactly 320px. But is it possible to save scaled screenshot (e. g. 2 times larger)? Like in Developer Tools - I can set zoom 150% there.

like image 438
cronfy Avatar asked Aug 27 '17 18:08

cronfy


1 Answers

You can use deviceScaleFactor on page.setViewport

await page.setViewport({width: 320, height: 0, deviceScaleFactor:2});
like image 92
Joel Avatar answered Nov 17 '22 16:11

Joel