html-screenshots
TypeScript icon, indicating that this package has built-in type declarations

1.1.9 • Public • Published

HTML Screenshots

This module generates a preview image from HTML content using Puppeteer. It allows the injection of custom CSS and JavaScript files, saves the generated image as a JPEG, and returns a base64 string representation of the image.

Installation

Install HTML Screenshots with npm:

  npm install html-screenshots

Usage/Examples

import icon from 'html-screenshots';

const basePath: '/path/to/save/image',

const htmlContent = `
  <div>
    <h1>Hello, World!</h1>
    <p>This is a test.</p>
  </div>
`;

const options = {
  cssFiles: ['styles.css'],
  jsFiles: ['script.js']
};

(async () => {
  try {
    await icon(basePath, htmlContent, options);
  } catch (error) {
    console.error('Error generating image:', error.message);
  }
})();

Readme

Keywords

none

Package Sidebar

Install

npm i html-screenshots

Weekly Downloads

1

Version

1.1.9

License

MIT

Unpacked Size

15.6 kB

Total Files

7

Last publish

Collaborators

  • diogoangelim