'convert docx file to PDF (vue.js)

I loaded a docx file changed it in my vue.js project and now I try to convert it to PFD file and download it to the user's computer. How can I do it ?

(the new docx file that I changed by the docxtemplater is not save on the project, but save as variable like you can see in the code).

<template>
<div>
    <button @click="renderDoc">
       Render docx template
    </button>
</div>
</template>

<script>
import Docxtemplater from "docxtemplater";
import PizZip from "pizzip";
import PizZipUtils from "pizzip/utils/index.js";
import { saveAs } from "file-saver";

function loadFile(url, callback) {
  PizZipUtils.getBinaryContent(url, callback);
}


export default {
  methods: {
    renderDoc() {
      loadFile("../templates/template.docx", function(
        error,
        content
      ) {      
        var zip = new PizZip(content);
        var doc = new Docxtemplater().loadZip(zip);

        doc.setData({
          first_name: "John",
          last_name: "Doe",
          phone: "0652455478",         
        });
        try {
          //change the doc file content
          doc.render();  
        } 
        catch (error) {         
          throw error;
        }
        var out = doc.getZip().generate({
          type: "blob",
          mimeType:
            "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
        }); //Output the document using Data-URI
        saveAs(out, "output.docx");   
        
      });
    }
  },

};

</script>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source