Simple promise-based wrapper for wkhtmltopdf.
node version >= 8 wkhtmltopdf installed
npm install --save @sugo/wkhtmltopdf
From a HTML
const buffer = await wkhtmltopdf('<p>Test</p>');
From a URL
const buffer = await wkhtmltopdf('http://www.google.com');
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);
The wkhtmltopdf function recieves a list of wkhtmltopdf options.
const buffer = await wkhtmltopdf('<p>Test</p>', ['--no-footer-line']);