https://github.com/holyshared/template2pdf
PDF conversion module using the template engine
https://github.com/holyshared/template2pdf
Last synced: 2 months ago
JSON representation
PDF conversion module using the template engine
- Host: GitHub
- URL: https://github.com/holyshared/template2pdf
- Owner: holyshared
- License: mit
- Created: 2015-09-20T06:42:05.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-09-23T07:37:15.000Z (over 10 years ago)
- Last Synced: 2025-10-07T01:58:19.431Z (9 months ago)
- Language: JavaScript
- Homepage:
- Size: 244 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
template2pdf
======================
[](https://travis-ci.org/holyshared/template2pdf)
[](https://coveralls.io/github/holyshared/template2pdf?branch=master)
[](https://www.versioneye.com/user/projects/55feb03c601dd9001c00003a)
[](https://waffle.io/holyshared/template2pdf)
Installation
----------------------
npm install template2pdf
Basic usage
--------------------------
Use the template engine, you can convert content to PDF.
```js
import jade from 'template2pdf-jade';
import exporter from 'template2pdf';
exporter(jade({ /* jade options */ }))
.render('views/content.jade', { name: 'jade' })
.then((result) => {
return result.saveAs('/tmp/content.pdf');
}).then(() => {
//successful
});
```
Stream
--------------------------
Using the Stream, you can also chain the output.
```js
import jade from 'template2pdf-jade';
import exporter from 'template2pdf';
import fs from 'fs';
exporter(jade({ /* jade options */ }))
.render('views/content.jade', { name: 'jade' })
.then((result) => {
result.pipe(fs.createWriteStream('/tmp/stream.pdf'));
});
```
Javascript & Stylesheet
--------------------------
You can incorporate your own stylesheets or javascript files.
```js
import exporter from 'template2pdf';
import jade from 'template2pdf-jade';
import { resolve } from 'path';
exporter(jade())
.stylesheet('style.css')
.javascript('main.js')
.render(resolve(__dirname, './report.jade'), {
title: 'jade-example',
content: 'Example content'
})
.then((result) => {
return result.saveAs('./report.pdf');
}).then(() => {
//successful
});
```