我正在尝试在 ng2-pdfjs-viewer 中加载 PDF,但我得到“无效的 PDF 结构,未定义的错误”。后端以 Blob 格式将数据返回给我,但是当我提供给 UI 时,它给出了上述错误:
HTML 代码:
<div class="mlp-flex-container mlp-flex-container--relative mlp-flex-item">
<div *ngIf="!showReport" class="informationMessage">Please Select a Trader</div>
<ng2-pdfjs-viewer *ngIf="showReport" #pdfViewer class="pdfViewer"></ng2-pdfjs-viewer>
</div>
JS代码:
private async getDataAsync(message: ReportGroupMessage) {
const rawData = await this.croDashboardPerformanceReportsDataService.getPerformanceReportsLocationDataAsync(message);
this.pdfViewer.pdfSrc = rawData;
this.pdfViewer.refresh();
}
public getPerformanceReportsLocationDataAsync(reportGroupMessage: ReportGroupMessage | any): Promise<any> {
debugger
const url = `Confidential URL`;
return this.http.get(url, { responseType: 'blob' })
.pipe(
map((result: any) => {
return result;
})
).toPromise();
}
有人可以帮忙吗?