Skip to content

sugojs/sugo-wkhtmltopdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Simple promise-based wrapper for wkhtmltopdf.

Resources

Stars

Watchers

Forks

Packages

No packages published