template2pdf

0.4.1 • Public • Published

template2pdf

Build Status Coverage Status Dependency Status Stories in Ready

Installation

npm install template2pdf

Basic usage

Use the template engine, you can convert content to PDF.

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.

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.

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
  });

Readme

Keywords

none

Package Sidebar

Install

npm i template2pdf

Weekly Downloads

6

Version

0.4.1

License

MIT

Last publish

Collaborators

  • holyshared