使用ng2-pdf-viewer库加载大型PDF时遇到问题,因为如果向下滚动,则必须等到所有页面都呈现出来。
是否可以强制渲染当前页面?
HTML:
type State =
State String Bool
请咨询!
答案 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;
}