Javascript iframe中的PDF显示标题为“匿名”
我正在使用Angular2。我从后端API中得到PDF响应为BLOB。PDF在iframe中显示良好,但标题显示为“匿名”。有人能给我引路吗 html代码:Javascript iframe中的PDF显示标题为“匿名”,javascript,angular,pdf,iframe,Javascript,Angular,Pdf,Iframe,我正在使用Angular2。我从后端API中得到PDF响应为BLOB。PDF在iframe中显示良好,但标题显示为“匿名”。有人能给我引路吗 html代码: <iframe id="showPDFIframe" allowtransparency="false" title="TestPDF" width="100%" height="800" [attr.src]="dataLo
<iframe id="showPDFIframe" allowtransparency="false" title="TestPDF" width="100%" height="800" [attr.src]="dataLocalUrl" type="application/pdf"></iframe>
pdfModelService.ts
showPDF(options?: RequestOptions): any {
return this._http.get(this.endpoints.showPDF.uri, options)
.map( (res) => {
return new Blob([res], { type: 'application/pdf' })
});
}
请参见下面显示的“匿名”图像
注意:后端API提供我们在BLOB中强制转换的字节。您是否尝试在选项中提供标题:
showPDF(options?: RequestOptions): any {
return this._http.get(this.endpoints.showPDF.uri, options)
.map( (res) => {
return new Blob([res], { type: 'application/pdf', title: 'testpdf' })
});
}
虽然我不确定代码中指定的标题字段TestPDF为什么没有出现在页面上,但显示的匿名值可能只是从PDF文件本身提取元数据。一个可能的解决方案是检查PDF文档属性中的标题字段,以便在其中设置标题。在Adobe Acrobat中,从文件菜单中选择属性>描述以检查/更新标题字段
来自W3.org的参考文章:没有标题为BLOB的属性您能显示您的响应标题吗?
showPDF(options?: RequestOptions): any {
return this._http.get(this.endpoints.showPDF.uri, options)
.map( (res) => {
return new Blob([res], { type: 'application/pdf', title: 'testpdf' })
});
}