I'm trying to use the library docxtemplater in an XPages application.
Javascript library docxtemplater (https://docxtemplater.com/) use as a
dependency another library opensource jszip-utils.js
(http://stuk.github.io/jszip/) to zip and unzip the docx files.
The problem is that the javascript library jszip-utils.js in XPages is not
working .
I inserted javascript libraries in a folder (jslib) who is under the WebContent folder.
Here's my test page;
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<script src="jslib/main.min.js"></script>
<script src="jslib/angular-expressions.js"></script>
<script src="jslib/jszip.js"></script>
<script src="jslib/jszip-utils.js"></script>
<script src="jslib/FileSaver.min.js"></script>
<xp:button value="Label" id="button1">
<xp:eventHandler event="onclick" submit="false">
<xp:this.script><![CDATA[
var loadFile=function(url,callback){
JSZipUtils.getBinaryContent(url,callback);
}
loadFile("tagExample.docx",function(err,content){
doc=new DocxGen(content)
doc.setData( {"first_name":"Hipp",
"last_name":"Edgar",
"phone":"0652455478",
"description":"New Website",
"image":'image.png'
}
) //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")
})]]></xp:this.script>
</xp:eventHandler></xp:button>
</xp:view>
Has anyone dealt with the problem?