@sugo/wkhtmltopdf
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@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']);

Readme

Keywords

none

Package Sidebar

Install

npm i @sugo/wkhtmltopdf

Weekly Downloads

23

Version

1.0.2

License

none

Unpacked Size

6.41 kB

Total Files

8

Last publish

Collaborators

  • andrea.sucre
  • franciscojsucreg