大家好,我目前在使用Angular.js开发网站,想要从用户的输入中生成一个Word文档,并且已经成功完成了!但是问题是,我想让用户预览并下载该Word文档的PDF版本。因此,我尝试更改MIME类型和SaveAs格式,但是没有成功。
我还尝试使用软件包将Word转换为PDF,但是迄今为止没有成功。
以下是保存生成的Word文档的代码:
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");
});
}
我仍然无法使用输出变量通过docxConverter或任何其他软件包进行转换。