Мой вопрос: как загрузить PDF прямо из BLOB-объекта? Я не хочу звонить в API, чтобы получить ответ. Проблема в том, что приведенный ниже код вызывает api on / load. Почему и как я могу избежать этого?
Машинопись:
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>