我的问题是如何直接从 blob 加载 pdf。我不想调用 API 来获取响应。问题是下面的代码在 /load 上调用 api。为什么以及如何避免它?
字体:
public service = 'http://localhost:4200/api/';
public load() {
this.gdvService.getData(this.data.id, this.data.configuration)
.subscribe(gdvData => {
const responseData = gdvData[this.data.configuration.dataColumn];
const blob = new Blob([responseData], { type: 'application/pdf' });
const reader = new FileReader();
reader.readAsBinaryString(blob);
reader.onloadend = () => {
const base64data = reader.result;
const pdfviewer = (document.getElementById('pdfViewer') as any).ej2_instances[0];
pdfviewer.load(base64data, null);
};
});
}
超文本标记语言:
<ejs-pdfviewer id="pdfViewer" [serviceUrl]='service' style="height:640px;display:block"></ejs-pdfviewer>
Syncfusion PDF Viewer控件同时面向服务器和客户端。PDF查看器控件在服务器端处理PDF文档(使用。NET环境)并将处理后的PDF数据发送给使用web服务的客户端,以呈现PDF文档并在PDF viewer中进行进一步的操作。因此,目前不可能在没有服务器端的情况下在PDF Viewer中加载PDF文档。
此致,Akshaya