Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

node-wkhtmltopdf

francisdaigle6kISC2.0.0

A simple wrapper for wkhtmltopdf

wkhtmltopdf

readme

node-wkhtmltopdf

A very simple wrapper for wkhtmltopdf.

Dependencies

Installation

  1. Install wkhtmltopdf.

  2. Install node-wkhtmltopdf:

    npm install node-wkhtmltopdf

Usage

wkhtmltopdf(options, input, output);

Examples

Render and Save:

wkhtmltopdf(null, 'http://google.com', 'google.pdf');

Render and Stream:

var options = [
'--quiet',
'--cookie connect.sid ' + connectSid,
'--margin-bottom 1',
'--margin-left 1',
'--margin-right 1',
'--margin-top 1'
];

var input = 'http://mydomain.com/mysecurehtmlpage';

var doc = wkhtmltopdf(options, input);

doc.stdout.pipe(res);

res.writeHead(200, {
'Content-Type': 'application/pdf',
'Access-Control-Allow-Origin': '*',
'Content-Disposition': 'inline; filename=order.pdf'
});

Test

npm test

To test via server implementation:

 node test/server.js

Then navigate to:

 http://localhost:8080/?input=https://en.wikipedia.org/wiki/Foobar#Usage_in_code

changelog

Changelog

2.0.0

  • Changed so as to return "child_process" sans "stdout". Thanks goes to Marius Ghita for making this suggestion.
  • Added server implementation.
  • Improved testing.

1.1.0

  • Updated README.

1.0.1

  • Updated README.

1.0.0

  • Initial commit.