Powered By Blogger

Tuesday, December 8, 2015

Dynamic content convert into doc or docx file




loadFile("tagExample.docx",function(err,content){
                doc=new DocxGen(content)
                doc.setData( {"first_name":"Hipp",
                    "last_name":"Edgar",
                    "phone":"0652455478",
                    "description":"New Website"
                    }
                ) //set the templateVariables
                doc.render() //apply them (replace all occurences of {first_name} by Hipp, ...)
                out=doc.getZip().generate({type:"blob"}) //Output the document using Data-URI
                saveAs(out,"output.docx")
            })

Source : 
http://javascript-ninja.fr/docxtemplater/v1/examples/demo.html

https://github.com/open-xml-templating/docxtemplater

No comments:

Post a Comment