https://github.com/elitdevs/pdf-ghost-report
Open Source pdf generator for node
https://github.com/elitdevs/pdf-ghost-report
node-module node-pdf nodejs npm-package pdf pdf-generation report-generator reporting-engine typescript typescript-library
Last synced: 9 months ago
JSON representation
Open Source pdf generator for node
- Host: GitHub
- URL: https://github.com/elitdevs/pdf-ghost-report
- Owner: ElitDevs
- License: mit
- Created: 2020-05-17T11:09:53.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-02-28T02:20:48.000Z (about 2 years ago)
- Last Synced: 2025-06-17T13:45:04.820Z (9 months ago)
- Topics: node-module, node-pdf, nodejs, npm-package, pdf, pdf-generation, report-generator, reporting-engine, typescript, typescript-library
- Language: TypeScript
- Size: 2.37 MB
- Stars: 21
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pdf-ghost-report
an open source solution for your nodejs reporting
[](https://www.npmjs.com/package/pdf-ghost-report)  
[](https://nodei.co/npm/pdf-ghost-report/)

## Usage
```js
// example using express web framework
const express = require('express');
const { generatePdf } = require('pdf-ghost-report');
router = express.Router();
router.post('/getpdf', async (req, res, next) => {
// step 01 : get template name
const template_name = 'template_name';
const data = req.body;
// step 02 : call pdf making function by passing the template folder and name
const config = {
emulator: 'screen' || 'print',
printBackground: true,
format: 'A4',
margin: {
top: '50px',
bottom: '50px',
left: '20px',
right: '20px',
},
displayHeaderFooter: true,
};
/**
* args :
* templateFolderPath: string,
* templateFileName: string,
* templateExtension: string,
* config: object,
* data: object
*
* return stream
* */
const pdf = await generatePdf('templates', 'test', 'hbs', config, data);
// // step 03 : return the blob pdf stream to the client
res.writeHead(200, {
'Content-Type': 'application/pdf',
'Content-Disposition': `attachment; filename=${template_name}.pdf`,
'Content-Length': pdf.length,
});
res.end(pdf);
});
module.exports = router;
```
## config
[For more config Info check Puppeteer pdf section](https://pptr.dev/#?product=Puppeteer&version=v3.0.4&show=api-pagepdfoptions)
## Installation
```bash
npm install pdf-ghost-report
```
```bash
yarn add pdf-ghost-report
```
## Run Tests
- for now we haven't created any test
```bash
npm test
```
## Todo
[ ] add tests
[ ] add docker
[ ] support more template engins like : `ejs, ...etc`
#### Author: [BARAKA LARBI -laridev-]