fx-template-to-pdf-node
v1.0.2
Published
Create pdf document from template
Downloads
7
Readme
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 [email protected]: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