ng2-pdf-viewer 呈现大型 PDF(超过 300 页)的问题

ng2-pdf-viewer problems with render large PDF (over 300pages)

我在使用 ng2-pdf-viewer 库加载大型 PDF 时遇到问题,因为如果我向下滚动,我必须等到所有页面都呈现完。

可以强制渲染当前页面吗?

HTML:

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

请指教!

你需要给 pdf 分页

// html 

    <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;
      }