Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

puppeteer-html-image

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

puppeteer-html-image

Generate images from HTML and take screenshots from URLs using Puppeteer and puppeteer core

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15
decreased by-6.25%
Maintainers
0
Weekly downloads
 
Created
Source

puppeteer-html-image

A Node.js package to convert HTML to image and URL to screenshot using Puppeteer and Puppeteer Cluster.

Installation

Install the package via npm:

npm install puppeteer-html-image

Convert HTML to Image and URL To Image

import { htmlToImage, urlToImage } from "puppeteer-html-image";

// Convert HTML to Image
const htmlContent = `
<!DOCTYPE html>
<html>
<head>
  <title>Example HTML</title>
  <style>
    body { font-family: Arial, sans-serif; margin: 0; padding: 0; }
    .container { padding: 20px; }
    h1 { color: #333; }
  </style>
</head>
<body>
  <div class="container">
    <h1>Hello, World!</h1>
    <p>This is an example HTML content rendered by Puppeteer.</p>
  </div>
</body>
</html>
`;
htmlToImage(htmlContent, "html-screenshot.png");

// Convert URL to Image
urlToImage("https://example.com", "url-screenshot.png");

API

htmlToImage(htmlContent: string, outputPath: string): Promise` Converts the provided HTML content to an image and saves it to the specified output path.

htmlContent: The HTML content to be rendered.

outputPath: The path where the screenshot will be saved.

urlToImage(url: string, outputPath: string): Promise<void> Takes a screenshot of the specified URL and saves it to the specified output path.

url: The URL to be rendered. outputPath: The path where the screenshot will be saved.

Author

website: [https://subodha-protofolio-personal.netlify.app/]

Github: SubodhaSahu

Keywords

FAQs

Package last updated on 04 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc