node-wkhtmltopdf

A simple wrapper for wkhtmltopdf

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
node-wkhtmltopdf
912.0.09 years ago9 years agoMinified + gzip package size for node-wkhtmltopdf in KB

Readme

node-wkhtmltopdf
A very simple wrapper for wkhtmltopdf.

Dependencies

Installation

  1. Install wkhtmltopdf.

  1. 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#Usageincode ```