angular - 下载文件和转换器以输入 doc 或 pdf
问题描述
我有一个返回 .dat 文件的 URL,我想下载它但转换为 .pdf 或 .doc 扩展名,有人可以帮我吗?
我在打字稿
网址:http ://172.17.0.53: 8060/leisarq/\originais\0000000\0000000000353.dat
解决方案
Assuming that you just want to grab the file, change the extension on the fly and save it, you can use the file-saver
helper (more details here: https://www.npmjs.com/package/file-saver)
I've prepared you a simple example here:
https://stackblitz.com/edit/angular-za1kbf
The idea is quite simple, just get the original file using Angular's http.get()
and finally, trigger a download on the client-side using the file-saver
utility.
download() {
return this.http.get("https://i.ibb.co/n3Y038T/a52b055eafb69acd427c99c25bc0fd02.jpg", {
responseType: "blob"
}).subscribe((response)=>{
saveAs(response, "new-image.png");
});
}
Maybe is worth to mention that this only changes the extension, the file are still a JPG (but with .PNG extension)
推荐阅读
- groovy - 在 groovy 中获取 URL 参数
- reactjs - ReactTS 通过动态组件道具扩展类型?
- java - 如何使用 snmp4j-2.7.0 在 snmpv3 中获取系统信息
- tensorflow - scikit 学习模型部署在 tensorflow 服务中
- c# - 请求实体太大 WCF REST 服务
- php - Laravel 如何像数组一样使用 app 对象?
- dart - 断言失败:布尔表达式不能为空
- java - 为什么这个冒泡排序不能通过使用简单的静态整数数组来工作?
- dart - 如何在颤动中制作圆形的相机预览
- javascript - 在地图上的正确位置制作贝塞尔曲线控制点