How to convert a generated word document using Docxtemplater to PDF?

Viewed 666

Hello everyone I am currently developing a website using Angular.js where I would like to generate a word document from the user's input and thats worked just fine with!!

The problem is I want to let the user preview and download the word document as a PDF document Hence i tried changing the MIME type and changing the SaveAs format however it didn't work

I have also tried changing the word to PDF using packages with no luck so far

Here is the code for saving the generated word doc

this.loadFile("/assets/document/Template.docx", function(
  error,
  content
) {
  if (error) {
   console.log("Load file error: ",error) ;
  }
  var zip = new PizZip(content);
  var doc = new Docxtemplater().loadZip(zip);
doc.setData({
  tag: "Hello"
});
try {
   
        doc.render();
      } catch (error) {
       console.log(error)
      }
       var out = doc.getZip().generate({
        type: "blob",
        mimeType:
        //"application/pdf;charset=utf-8"
        "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
      }); //Output the document using Data-URI

     saveAs(out, "GeneratedDocx.docx");
    });
  }

and i still can't use the out variable to convert using docxConverter or any other package

0 Answers
Related