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

时间:2019-01-30 22:12:33

标签: angular ionic-framework pdf-viewer

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

是否可以强制渲染当前页面?

HTML:

type State =
  State String Bool

请咨询!

1 个答案:

答案 0 :(得分:1)

您需要对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></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;
      }