A wrapper around pdfmake to make it easier to use with node.
const fs = require('fs');
const createPdfPrinter = require('node-pdfmake');
const printer = createPdfPrinter();
const content = 'This is an sample PDF printed with node-pdfmake';
const document = printer.createPdf({ content });
document.getBuffer().then(buffer => fs.writeFileSync('sample.pdf', buffer));
Create a new pdf printer.
Type: Object
A pdfmake
font object (read more here)
Note: By default node-pdfmake
includes the default Roboto
font (default font of pdfmake
) and the standard-14-fonts
Create a new pdf document.
Type: Object
A pdfmake
document definition object (read more here)
Type: Object
Some additional options normally set through pdfmake
(e.g. tableLayouts
, progressCallback
)
Return the pdf document as a stream
.
Return a Promise
that resolves with the pdf document as a Buffer
.
Return a Promise
that resolves with the pdf document encoded as a base64
string.
A shortcut to create a pdf document, fonts can be added by defining options.fonts