javascript - Node JS, Ideas on Template For PDF Creation -
how create pdf documents in node.js.? there better solution manage templates different types of pdf creation.
i using pdfkit
create pdf documents , server side using javascript. can not use html create pdf. blob of paragraphs , sections replacing tags in.
does know node.js has npm package can deal templates paragraphs sections headers.
something gettemplatebyid()
returns template contains sections , headers, paragraphs , use replace appropriate tags within template.
in case, have html template database (postgresql) stocked stream. request db template , create tmp file.
inside template, have angularjs tags compile template datas 'ng-node-compile' module:
var ngcompile = require('ng-node-compile'); var ngenvironment = new ngcompile(); var templatehtml = gettemplatebyid(id); templatehtml = ngenvironment.$compile(templatehtml)(datas);
now have compiled template (where can set paragraph etc.) , convert them pdf phantomjs module 'phantom-html-to-pdf'
var phantomhtml2pdf = require('phantom-html-to-pdf')(options); phantomhtml2pdf(convertoptions, function (error, pdf) { if(error) console.log(error); // here have 'pdf.stream.path' tmp pdf file callback(pdf); });
now have compiled , converted template (pdf), can whatever want ! :)
useful links:
i hope !
Comments
Post a Comment