I am considering using pupeteer for a project I am working on, but I can't seem to figure out if I can take the screenshot taken with puppeteer and display it as an image on an html page automatically. I read through the docs but didn't see anything related to this.

Thanks in advance!

1

There are 1 answers

0
hardkoded On

You can get the image as a base64 string using the encoding option:

const screenshot = await page.screenshot({ encoding: 'base64' });

Then you can load that in an HTML as a base64 image:

var html = `<img src="data:image/png;base64, ${screenshot}" />`