1.0.2 • Published 8 years ago

fx-template-to-pdf-node v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

Build Status js-standard-style

tfk-template-to-pdf-node

This is a convenience module for creating pdf documents from templates by using node like pdftemplater-webservice-docker

Installation

From npm

$ npm install tfk-template-to-pdf-node

From GitHub

$ git clone git@github.com:telemark/tfk-template-to-pdf-node.git

cd into folder and run setup

$ npm run setup

Usage

Pass in an options object.

templateData key:value for data to render with template templateFilepath: path to .docx template documentFilepath: where to save the rendered document pdfServiceUrl: URL to pdf converter service

'use strict'

const createPdfFromTemplate = require('tfk-template-to-pdf-node')
const options = {
  templateData: {
    'title': 'My title is none of your concerns',
    'description': 'Describe me as your best friend',
    'body': 'My body is beautiful'
  },
  templateFilepath: 'test/data/template.docx',
  documentFilepath: 'test/data/document.pdf'
}

pdfTemplater(options)
  .then(console.log)
.catch((err) => {
  console.error(err)
})

You can also use callbacks

License

MIT