我有一个 API,它将上传的文件作为 blob 返回。当我尝试绑定srcblob URL 时,它不会显示任何内容,但是,当我尝试绑定直接 URL 时,它可以显示 PDF 文件。这是我下面给出的代码。
我的 TS 代码
downloadFile(fileData: Fileuploader) {
this.tempBlob= null;
//Fetching Data File
this.apiservice.getDownloadfile(fileData).subscribe(
(retFileData: any) => {
this.tempRetFileData = retFileData;
this.tempBlob = new Blob([retFileData], { type: this.contentType });
},
(err: Error) => {
},
() => {
const blob: Blob = new Blob([this.tempBlob], { type: this.contentType });
const fileName: string ='ilvsna.pdf';
this.myBlobURL = URL.createObjectURL(blob);
}
);
}
Run Code Online (Sandbox Code Playgroud)
超文本标记语言
<pdf-viewer [src]="myBlobURL"
[render-text]="true"
[original-size]="false"
style="width: 400px; height: 500px"
></pdf-viewer>
Run Code Online (Sandbox Code Playgroud)
注意:如果我将 …