1.0.2 • Published 5 years ago

@sugo/wkhtmltopdf v1.0.2

Weekly downloads
89
License
-
Repository
github
Last release
5 years ago

@sugo/wkhtmltopdf

Simple promise-based wrapper for wkhtmltopdf.

Requirements

node version >= 8 wkhtmltopdf installed

How to install

npm install --save @sugo/wkhtmltopdf

Create a PDF

From a HTML

const buffer = await wkhtmltopdf('<p>Test</p>');

From a URL

const buffer = await wkhtmltopdf('http://www.google.com');

Serve a pdf with a NodeJS Http Server

const filename = 'foo.pdf';
const buffer = await wkhtmltopdf('http://www.google.com');
res.setHeader('Content-Type', 'application/pdf');
res.setHeader('Content-Disposition', `attachment; filename=${filename}.pdf`);
res.setHeader('Content-Length', buffer.byteLength);
res.end(buffer);

Options

The wkhtmltopdf function recieves a list of wkhtmltopdf options.

Example

const buffer = await wkhtmltopdf('<p>Test</p>', ['--no-footer-line']);
1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.3.4

5 years ago