Ionic ng 2-pdf-viewer渲染大型PDF(超过300页)时的问题

wooyq4lh  于 2023-05-15  发布在  Ionic
关注(0)|答案(1)|浏览(193)

我在使用ng 2-pdf-viewer库加载大型PDF时遇到了一个问题,因为如果我向下滚动,我必须等到所有页面都渲染完毕。
可以强制渲染当前页面吗?
HTML:

<pdf-viewer [src]="pdfSrc" [render-text]="false" [original-size]="true" [fit-to-page]="true" style="display: block;"></pdf-viewer>

请指教!

fhity93d

fhity93d1#

你需要分页的PDF
超文本标记语言

<pdf-viewer 
 [src]="pdf" 
 [show-all]="false"  
 [page]="page" 
 (after-load-complete)="afterLoadComplete($event)" 
 [original-size]="false" [render-text]="true" >
</pdf-viewer>

 <button (click)="previousPage()" [disabled]="page === 1"></button>
   
 <button 
 (click)="nextPage()" 
 [disabled]="totalPages === 1 || page === totalPages">
 </button>

 <p>{{ page }} / {{ totalPages }}</p>

ts

totalPages: number;
  page: number = 1;
  isLoaded: boolean = false;
  
  nextPage() {
    this.page += 1;
  }
    
   previousPage() {
    this.page -= 1;
  }
    
  afterLoadComplete(pdfData: any) {
    this.totalPages = pdfData.numPages;
    this.isLoaded = true;
  }

相关问题