Socket
Book a DemoInstallSign in
Socket

html-png-stream

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-png-stream

Convert a stream of HTML documents into PNG Buffer Objects

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
2
Created
Source

html-png-stream

Convert a stream of HTML documents into PNG Buffer Objects

build status

Installation

This module is installed via npm:

$ npm install html-png-stream

Example Usage

Render some HTML into a PNG Buffer Object

var htmlPngStream = require('html-png-stream');
var ps = htmlPngStream({ width: 1280, height: 720, browser: 'phantomjs' });
var rs = stream.Readable();
rs._read = function () {};

rs.pipe(ps);

ps.on('data', function (data) {
  // data will contain a screenshot of the HTML as a node.js Buffer
  console.log(data);
  //<Buffer 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 02 80 ...>
});

// render some HTML
rs.push('<b>Hello</b>');

API

htmlPngStream([options])

The constructor is passed an options object:

  • width, height - the width and height of the browser. NB: This is not the maximum dimensions of each screenshot. So if the rendered page is higher than height the screenshot returned will be the full rendered height of the page.
  • browser - The browser to use for rendering. By default this is phantomjs and this module bundles together a static binary of phantomjs with phantomjs-bin. If you have Google Chrome installed and chromedriver is in your PATH, then you can render with Chrome.

write(chunk, [enc], [cb])

You can pipe a HTML fragment or a URL to this stream and it will be rendered.

Keywords

html

FAQs

Package last updated on 22 Jan 2015

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