tfk-template-to-pdf

v3.0.1
Create pdf document from template
convert pdf template tfk Telemark fylkeskommune

Build Status js-standard-style

tfk-template-to-pdf

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

Installation

From npm

$ npm install tfk-template-to-pdf

From GitHub

$ git clone [email protected]:telemark/tfk-template-to-pdf.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

const createPdfFromTemplate = require('tfk-template-to-pdf')
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',
  pdfServiceUrl: 'http://192.168.99.100:3000'
}

createPdfFromTemplate(options, (error, data) => {
  if (error) {
    console.error(error)
  } else {
   console.log(data)
  }
})

License

MIT

npm i tfk-template-to-pdf

Metadata

  • MIT
  • >=10.15.0
  • Geir GĂ„sodden
  • released 1/8/2019

Downloads