@fiialo/pdf-generator
v1.0.4
Published
Usage ``` npm i --save @fiialo/pdf-generator
Downloads
2
Readme
This is simple wrapper for pdfmake lib
Usage
npm i --save @fiialo/pdf-generator
Then in code
const generator = require('@fiialo/pdf-generator');
//definition here is in pdfmake format - with required content property
var definition = {
content: [
// if you don't need styles, you can use a simple string to define a paragraph
'This is a standard paragraph, using default style',
// using a { text: '...' } object lets you set styling properties
{ text: 'This paragraph will have a bigger font', fontSize: 15 },
// if you set pass an array instead of a string, you'll be able
// to style any fragment individually
{
text: [
'This paragraph is defined as an array of elements to make it possible to ',
{ text: 'restyle part of it and make it bigger ', fontSize: 15 },
'than the rest.'
]
}
]
};
//this will create by default pdf directory (always created at current working directory) and uuid as pdf file's name
generator.create(definition);
//to change behavior, init generator your own config object
let config = {
filename:`another_name`,
directory:'pdf/invoices'
}
generator.init(config);
generator.create(definition);
Find us in github