npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wkhtmltox

v1.1.6

Published

high performance access to `wkhtmltopdf` and `wkhtmltoimage` from node.js.

Downloads

1,664

Readme

wkhtmltox

The goal of this module is to provide high performance access to wkhtmltopdf and wkhtmltoimage from node.js. Those two tools are from wkhtmltopdf, a software package that provides utilities for rendering HTML into various formats using the QT Webkit rendering engine.

This module is based on an MIT licensed module named node-wkhtmltopdf.

Requirements

Install

The latest and greatest version of this software is available through npm.

npm install wkhtmltox

Examples

HTML to PDF, JPG, PNG with custom path

// include the node module
var wkhtmltox = require("wkhtmltox");

// instantiate a new converter.
var converter = new wkhtmltox();

// Locations of the binaries can be specified, but this is
// only needed if the programs are located outside your PATH
converter.wkhtmltopdf   = '/opt/local/bin/wkhtmltopdf';
converter.wkhtmltoimage = '/opt/local/bin/wkhtmltoimage';

// Convert to pdf.
// Function takes (inputStream, optionsObject), returns outputStream.
converter.pdf(fs.createReadStream('foo.html'), { pageSize: "letter" })
    .pipe(fs.createWriteStream("foo.pdf"))
    .on("finish", done);

// Convert to image.
// Function takes (inputStream, optionsObject), returns outputStream.
converter.image(fs.createReadStream('foo.html'), { format: "jpg" })
    .pipe(fs.createWriteStream("foo.jpg"))
    .on("finish", done);

converter.image(fs.createReadStream('foo.html'), { format: "png" })
    .pipe(fs.createWriteStream("foo.png"))
    .on("finish", done);

Simple HTML to PDF web service

Here's a simple web server that converts HTML to PDF. Options can be supplied as query parameters:

var url = require('url');
var http = require('http');
var wkhtmltox = require('wkhtmltox');
var converter = new wkhtmltox();

http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'application/pdf'});
    converter.pdf(req, url.parse(req.url, true).query).pipe(res);
}).listen(1337, '127.0.0.1');

console.log('Server running at http://127.0.0.1:1337/');

Access it with curl

curl -d @test.html -s "http://localhost:1337/?copies=2" -o test.pdf