Giter Club home page Giter Club logo

pdf-puppet's Introduction

PDF Puppet

PDF Puppet is a tool for creating pdfs using HTML and CSS along with a variety of templating and styles engines.

Install:

npm install --global pdf-puppet

Usage:

Usage: pdf-puppet <config> <output>

Options:
  -v, --version        output the version number
  -c, --config <file>  Path to the config yaml file. (default: "puppet")
  -o, --out <file>     Path to the output pdf file. (default: "output.pdf")
  -h, --help           output usage information

Commands:
  dev                  run a development server to render the markup before generating the pdf

Example:

pdf-puppet -c ./demo/twig/invoice.yml -o invoice.pdf

This will build the PDF using the files and data in the invoice.yml file and output it in the invoice.pdf file.

Dev Server

The dev server has 3 routes:

  • The fallback route that generates the HTML markup in the browser
  • Any route with .pdf in its name generates the pdf data
  • The route /viewer generates a page that shows the pdf and reloads on changes

Templating engines

The following are supported:

  • Handlebars
  • HTML (plain, no data)
  • Mustache
  • Pug
  • Twig

Style engines

The following are supported:

  • CSS
  • SCSS

Config file

You can find sample config files in the demo folder. Here is a breakdown of the different parts --

  • title: Title of document, it will appear in the title section during development
  • template: Path to the template file
  • styles: Path to the style file
  • markupEngine: Markup/Template engine to be used (pug, twig, etc.)
  • format: Print format (e.g. A4, A5, A6, etc.), overrides height and width
  • height: Specify height, defaults to auto-height
  • width: Specify width, defaults to auto-width
  • outputType: Specify your target output type (html, pdf), defaults to pdf
  • dev: Development settings object
    • port: Port for the dev server
    • host: Host for the dev server
    • open: Opens the browser automatically if set to true
  • data: Data object to be passed to the template

pdf-puppet's People

Contributors

jumballaya avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

pdf-puppet's Issues

Tests

This project needs some tests for:

  • Config reading, handle errors gracefully
  • Make sure all content is loaded before the pdf is created
  • Test any/all defaults

Feature: Ability to change styles engine

Add the ability to optionally specify:

  • LESS
  • Stylus
  • PostCSS (and plugins)

It should use SCSS by default. Allow user to (optionally) specify style engine on the command line or the config file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.