pdf-maker
Version:
easy pdf generation using phantom.js
64 lines (48 loc) • 1.12 kB
Markdown
An easy way to generate pdf files from ejs templates or html files
```js
npm i --save pdf-maker
```
```js
var pdfMaker = require('pdf-maker');
var template = 'path/to/ejsTemplate.ejs';
var data = {
name: 'node.js'
};
var pdfPath = '/path/of/pdf/file.pdf';
var option = {
{
paperSize: {
format: 'A4',
orientation: 'portrait',
border: '1.8cm'
}
};
};
pdfMaker(template, data, pdfPath, option);
```
Here, 'option' parameter is optional.
'data' is the data which will be used in the ejs template.
'pdfPath' is the path with where the pdf file will be saved.
```js
var pdfMaker = require('pdf-maker');
var template = 'path/to/htmlFile.html';
var pdfPath = '/path/of/pdf/file.pdf';
var option = {
{
paperSize: {
format: 'A4',
orientation: 'portrait',
border: '1.8cm'
}
};
};
pdfMaker(template, pdfPath, option);
```
Adding test cases.
Removing external dependencies.