tfk-template-to-pdf-node

1.0.0 • Public • Published

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

Package Sidebar

Install

npm i tfk-template-to-pdf-node

Weekly Downloads

2

Version

1.0.0

License

MIT

Last publish

Collaborators

  • maccyber