Skip to content
This repository has been archived by the owner on Sep 22, 2021. It is now read-only.

A simple Node.js server for generating and distributing PDFs from Handlebars templates

License

Notifications You must be signed in to change notification settings

itsahappymedium/hm-pdf-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HM PDF Server

Summary

hm-pdf-gen is a lightweight PDF generation server built on Node.js

The server manages a configuration of key=>template pairs that act as REST endpoints which return dynamically generated PDF files.

Templates are written in Handlebars and are built using data sent to the API through GET parameters. Any GET parameters not sent are ignored, so be sure to document your templates!

Prerequisites

This server requires a few things to be installed on the server ecosystem, particularly:

Installation

Like pretty much every Node app, start by installing dependencies using npm install

npm install

Running the Server

Run the server using NPM: npm start

npm start

Configuration

All configuration is done using JSON files located in ./config.

config.JSON

Manages the configuration for the server as a whole. Current options include:

  • port - the port the server runs on
  • template_dir - the directory you wish to store your templates in
  • output_dir - the directory to store generated PDF files in

template_maps.JSON

This JSON file contains an array of key-template pairs (where the template is the name of the template file located within template_dir). Each new key-value pair establishes a REST endpoint at <server_url>/pdf/.

Be sure to include the file extension (.handlebars) in the maps declaration.

Example

{
  "maps" : [
    {
      "id" : "template_id",
      "template" : "template_name.handlebars"
    }
  ]
}

wkhtmltopdf_config.JSON

This will be translated (literally) to the wkhtmltopdf_opts in renderer.js. Refer to the wkhtmltopdf documentation for further reading.

About

A simple Node.js server for generating and distributing PDFs from Handlebars templates

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published