打开pdf老是意外的服务器响应,internet-explorer

我正在使用ng2-pdfjs-viewer来显示用户已上传到我的服务器的PDF。 每次用户在其视图中单击该文件时,都会从服务器中检索该文件并将其放入blob中,并提供给ng2-pdfjs-viewer以显示在externalWindow中。 这对于除IE11之外的所有浏览器都适用。

最初,它在IE上可以正常运行,但是如果我多次关闭并打开同一文件,则过一阵子,pdf查看器会在检索PDF时给我一个“服务器意外响应(500)”'blob:B04FA5CB-1012-4CBC-8DFB- 59C4CE02C34A'”。 如果我使用IE打开网站的第二个实例,也会发生这种情况。 当它开始出现此错误时,必须关闭整个浏览器,然后我必须返回该网站并再次尝试-然后它再次起作用。

我与Fiddler核对过,我对服务器的所有请求都顺利通过。 唯一提供给查看器的是Blob,因此我不知道它在哪里得到意外的服务器响应。 一切都可以在其他浏览器上完美运行。

如果没有pdf查看器,则可以在所有浏览器上毫无问题地检索文件,并且可以在IE上使用msSaveOrOpenBlob打开这些文件。 pdf查看器似乎引起了麻烦。

[externalWindow]="true"

[downloadFileName]="'document.pdf'"

[openFile]="false"

[viewBookmark]="false"

[download]="true">

//x.component.ts code

@ViewChild('pdfViewer', {static: false}) pdfViewer;

openDocument(doc: Document) {

this.storageService.fetchDocument(doc).subscribe(

res => {

let type: string = res['type'];

let file: string = res['file'];

var promise = this.uploadService.decodeFromBase64(file);

promise.then((result:string)=> {

var byteArray = [];

for (let i = 0; i < result.length; i++) {

byteArray.push(result.charCodeAt(i));

}

const blob = new Blob([new Uint8Array(byteArray)], {type: type});

var fileURL = URL.createObjectURL(blob);

if (type == "application/pdf") {

this.pdfViewer.pdfSrc = fileURL;

this.pdfViewer.refresh();

}

else {

//...

}

})

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值