【发布时间】:2020-08-10 01:03:33
【问题描述】:
我正在使用模型显示 PDFTron webviewer 的项目中工作。当从列表中选择 pdf 文件时,我正在使用模型弹出窗口在其中加载 webviewer。
第一次加载 pdf 文档,但是当“clr-modal”第二次打开 webviewer 时没有加载文档。
//PdfviewerComponent html.
<div class="page">
<div #viewer class="viewer"></div>
</div>
export class PdfviewerComponent implements OnInit, AfterViewInit, OnChanges {
@ViewChild('viewer', { static: true }) viewer: ElementRef;
@Input() hash: string;
wvInstance: any;
constructor() { }
ngOnInit(): void { }
ngAfterViewInit(): void {
console.log('AfterViewInit called');
WebViewer({
path: '../assets/lib'
}, this.viewer.nativeElement).then(instance => {
this.wvInstance = instance;
const idtoken = localStorage.getItem('id_token');
const options = {
customHeaders: { Authorization: 'Bearer ' + idtoken }
};
const hash = this.hash.split(' ')[0];
const url = `/api/project/readfile/${hash}`;
this.wvInstance.loadDocument(url, options);
});
}
}
//popup in main component
<clr-modal [(clrModalOpen)]="openModel" >
<h3 class="modal-title">{{currentFileName}}</h3>
<div class="modal-body">
<app-pdfviewer [hash]="currentFileHash"></app-pdfviewer>
</div>
</clr-modal>
【问题讨论】:
标签: pdftron