【发布时间】:2019-11-30 10:16:12
【问题描述】:
在 Angular 应用程序后端文件响应是 Blob 类型。使用 IFrame 我可以打印文件,但是当我选择另存为 PDF 时。屏幕显示从 url 获取的随机名称。
点赞 - 1231-35677-345.pdf
但我希望名称默认显示为 Summary.pdf
我的代码 -
const newBlob = new Blob([blob], { type: type });
const fileURL = URL.createObjectURL(newBlob);
const iframe = document.createElement('iframe');
iframe.style.display = 'none';
iframe.src = fileURL;
iframe.name = fileName;
document.body.appendChild(iframe);
iframe.contentWindow.print();
【问题讨论】:
标签: angular typescript pdf iframe printing