0.4.1 • Published 9 years ago

template2pdf v0.4.1

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

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

9 years ago

0.4.0

9 years ago

0.3.0

9 years ago

0.2.0

9 years ago

0.1.0

9 years ago