@sugo/wkhtmltopdf
v1.0.2
Published
A wrapper for the wkhtmltopdf HTML to PDF converter
Downloads
124
Readme
@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']);