Socket
Socket
Sign inDemoInstall

template-pdf-generator

Package Overview
Dependencies
13
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    template-pdf-generator

Generate a pdf from a template and some json data.


Version published
Weekly downloads
125
increased by10.62%
Maintainers
1
Install size
4.14 MB
Created
Weekly downloads
 

Readme

Source

Template pdf generator

This is a small nodejs-script that generates a pdf-file, given some data and a twig template. It uses wkhtmltopdf through the wkhtmltopdf node package. wkhtmltopdf has to be installed.

Installation

npm install template-pdf-generator

Usage

var pdfGenerator = require('template-pdf-generator');
var fs = require('fs');

var data = {
  name: 'World'
};

var template = '<h1>Hello {{name}}</h1>';

var css = 'h1 {color: red}';

pdfGenerator(data, template, css).pipe(fs.createWriteStream('out.pdf'));

You can also use some options:

pdfGenerator(data, template, css, options)

The options object is the same as documented in the wkhtmltopdf node package.

Usage as a command line tool

Clone or download the project.

From the directory of the project run:

node index.js -data data.json -template template.html

Options :

  • -data or -D (mandatory) : path and name of the json data file
  • -template or -T (mandatory) : path and name of the template file
  • -css : path and name of the css file, if necessary
  • -out : path and name of the resulting pdf file. By default, the created file is out.pdf in the script root directory.

Further work

  • Allow other template engines than twig
  • Allow other encoding than utf-8

FAQs

Last updated on 15 Mar 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc