npm.io
1.1.0 • Published 9 years agoCLI

json-to-svg-to-pdf

Licence
GPL-3.0
Version
1.1.0
Deps
6
Vulns
0
Weekly
0
Stars
5

json-to-svg-to-pdf

This is a silly module we wrote to generate business cards. As a result, consider this module very YMMV. (Spoiler alert: the code is intentionally dense for use as a refactoring exercise.)

To use this yourself:

  1. Define two SVG templates in template/front.svg and template/back.svg with whatever mustache template strings you like (e.g. {{fullName}})
  2. Create a JSON/CSON for each person in input/ (e.g. input/justin.cson) that defines those mustache attribute names
  3. Run json-to-svg-to-pdf

What you'll get is, for each input file, a pair of font-embedded PDFs in output/ (e.g. output/justin-front.pdf and output/justin-back.pdf).

Prerequisites

The PDF generation relies on Inkscape's inkscape binary being on your path.

To install it on a Mac with Homebrew and Homebrew Cask, run brew cask install xquartz inkscape.

TODO

The glaring limitation currently is the code assumes you have exactly two templates defined for each input. It could be complicated/improved to discover 1…n templates and follow the same naming pattern

Keywords