文档生成
文档预览
PDF预览
使用docx-preview的文档预览方案不够完善,显示不够完美,因此采用后端使用docxtemplater文档生成,再使用libreoffice-convert转换成pdf,再下载到前端使用pdfjs预览pdf的方案。
开发环境
- nodejs: v12.18.4
 - express: “^4.18.2”
 - docxtemplater: “^3.36.1”
 - libreoffice-convert: “^1.4.1”
 - spark-md5: “^3.0.2”
 - pdfjs: 2.16.105
 
注意:在使用libreoffice-convert将docx转换成pdf之前,需要安装libre office软件,使用默认配置安装。
参考链接
- 使用vue+docxtemplater导出word,by 实迷途其未远.
 - 详细|vue中使用PDF.js预览文件实践,by 灵扁扁.
 - docx-preview实现移动端word文件预览,by LXLong.
 - vue项目,npm install方式使用pdfjs,by 下一秒.
 - Vue 实现 PDF 文件在线预览 - 手把手教你写 Vue PDF 预览功能,by 蒋川.
 - PDF.js访问远程服务器报file origin does not match viewer’s,by 心灵的学霸.
 - 深入理解xhr responseType blob arrayBuffer document text json使用,by 柚子=_=.
 - 【实战分享】js生成word(docx),以及将word转成pdf解决方案分享,by 前端开发小陈.
 - libreoffice-convert not working in nodejs,by stackoverflow.