1.1.1 • Published 1 year ago

puppeteer-html-image v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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

1.1.1

1 year ago

1.1.0

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago