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

0.0.19 • Public • Published

nodehtml2img

A simple node.js module that renders an HTML content and generates an image from it.

how it works

nodehtml2img uses puppeteer to launch an headless browser and render the given html content. Simple like that, nothing more, nothing less.]

install

npm install --save nodehtml2img

usage

using defaults:

import nodehtml2img from "nodehtml2img";
 
const buffer = nodehtml2img("<h1>Hello, World</h1>");
  • In the example above it will use the following default settings:
const defaultSettings: Settings = {
  transparent: false,
  puppeteerArgs: {},
  encoding: Encoding.BINARY,
  imageFormat: ImageFormat.PNG,
};
  • Using custom settings:
import nodehtml2img, { Encoding, ImageFormat } from "nodehtml2img";
 
const buffer = nodehtml2img("<h1>Hello, World</h1>", {
  transparent: true,
  puppeteerArgs: {},
  encoding: Encoding.BASE_64,
  imageFormat: ImageFormat.JPEG,
  quality: 95, // from 0 to 100,
  viewport: {
    width: 2000,
    height: 1000,
    deviceScaleFactor: 1,
  },
});

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.19
    1
    • latest

Version History

Package Sidebar

Install

npm i nodehtml2img

Weekly Downloads

0

Version

0.0.19

License

MIT

Unpacked Size

107 kB

Total Files

24

Last publish

Collaborators

  • pedroviniv