Generate images from HTML and take screenshots from URLs using Puppeteer and puppeteer core
npm install puppeteer-html-imagebash
npm install puppeteer-html-image
`
$3
`
import { htmlToImage, urlToImage } from "puppeteer-html-image";
// Convert HTML to Image
const htmlContent =
This is an example HTML content rendered by Puppeteer.
;
htmlToImage(htmlContent, "html-screenshot.png");
// Convert URL to Image
urlToImage("https://example.com", "url-screenshot.png");
`
$3
htmlToImage(htmlContent: string, outputPath: string): Promise
htmlContent: The HTML content to be rendered.
outputPath: The path where the screenshot will be saved.
urlToImage(url: string, outputPath: string): Promise
url: The URL to be rendered.
outputPath: The path where the screenshot will be saved.