将自己遇到的一些有用的知识记录下来.大家如果有遇到有用的知识可以跟我分享下,谢谢
使用download属性,如
<a href="text.jpg" download="thisismyname">测试图</a>
这样,你点下a标签后,就会下载该图片,并且该图片名为thisismyname.jpg
环境:nodejs npm包:node-msoffice-pdf 依赖:你本机必须要有office 2013以上的版本,因为他是直接使用office的转化功能
var msopdf = require('node-msoffice-pdf');
module.exports = function(input, output, type) {
msopdf(null, function(err, office) {
if (err) {
console.log("Init failed", error);
return;
}
//转化word文档为pdf
if (type == "doc" || type == "docx") {
office.word({input: input, output: output}, function(err, pdf) {
if (err) {
console.log(err);
}
})
}
//转excel文档为pdf
else if (type == "xls") {
office.excel({input: input, output: output}, function(err, pdf) {
if (err) {
console.log(err);
}
})
}
office.close(null);
})
}
如上图,上面那个函数是功能是将word文档和excel转为pdf
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有