You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<html><body><buttononclick="generate()">Generate document</button></body><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/docxtemplater/3.22.8/docxtemplater.js"></script><scriptsrc="https://unpkg.com/[email protected]/dist/pizzip.js"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.8/FileSaver.js"></script><scriptsrc="https://unpkg.com/[email protected]/dist/pizzip-utils.js"></script><script>
function loadFile(url,callback){PizZipUtils.getBinaryContent(url,callback);}
function generate() {loadFile("https://docxtemplater.com/tag-example.docx",function(error,content){if(error){throwerror};functionreplaceErrors(key,value){if(valueinstanceofError){returnObject.getOwnPropertyNames(value).reduce(function(error,key){error[key]=value[key];returnerror;},{});}returnvalue;}functionerrorHandler(error){console.log(JSON.stringify({error: error},replaceErrors));if(error.properties&&error.properties.errorsinstanceofArray){consterrorMessages=error.properties.errors.map(function(error){returnerror.properties.explanation;}).join("\n");console.log('errorMessages',errorMessages);}throwerror;}varzip=newPizZip(content);vardoc;try{doc=newwindow.docxtemplater(zip,{paragraphLoop: true,linebreaks: true});}catch(error){errorHandler(error);}doc.setData({first_name: 'John',last_name: 'Doe',phone: '0652455478',description: 'New Website'});try{doc.render();}catch(error){errorHandler(error);}varout=doc.getZip().generate({type:"blob",mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",});saveAs(out,"output.docx");})}</script></html>
Hi, I want to do multiple pages repeating the same template in different pages with different datas in each page, I was looking for somethig like that in the issues and docs, but only found how to do multiples files and save it in a zip, i hope can you help me, thanks a lot.
The text was updated successfully, but these errors were encountered:
Environment
How to reproduce my problem :
My template is the following : https://docxtemplater.com/tag-example.docx
With the following js file :
Hi, I want to do multiple pages repeating the same template in different pages with different datas in each page, I was looking for somethig like that in the issues and docs, but only found how to do multiples files and save it in a zip, i hope can you help me, thanks a lot.
The text was updated successfully, but these errors were encountered: