Socket
Socket
Sign inDemoInstall

template-pdf-generator

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

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
186
increased by36.76%
Maintainers
1
Weekly downloads
 
Created
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.

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

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

Package last updated on 09 Feb 2018

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc