Pupeteer: take webpage screenshot with zoom (scale)

8.4k views Asked by At

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.

1

There are 1 answers

1
Joel On BEST ANSWER

You can use deviceScaleFactor on page.setViewport

await page.setViewport({width: 320, height: 0, deviceScaleFactor:2});