我的问题是如何直接从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);
};
});
}HTML:
<ejs-pdfviewer id="pdfViewer" [serviceUrl]='service' style="height:640px;display:block"></ejs-pdfviewer>
发布于 2020-01-23 13:09:10
Syncfusion PDF Viewer控件是面向服务器和客户端的。PDF viewer控件在服务器端(使用.NET环境开发)处理PDF文档,并使用web服务将处理后的PDF数据发送到客户端以呈现PDF文档,并在PDF viewer中进行进一步的操作。所以,目前不可能在没有服务器端的PDF Viewer中加载PDF文档。
致敬,Akshaya
https://stackoverflow.com/questions/59720520
复制相似问题