第一次搜索后,将命中pageRendered并包含页码。第二次搜索后,pageNumber如果为null。如果用户刷新页面,它将再次运行一次。
<pdf-viewer [src]="pdfHelpManual"
[show-all]="false"
[page]="page"
(after-load-complete)="afterLoadComplete($event)"
(page-rendered)="pageRendered($event)"
style="display: block;">
</pdf-viewer>
组件:
pageRendered(e: CustomEvent) {
this.page = e.detail.pageNumber;
}
search(stringToSearch: string, e: CustomEvent) {
this.pdfComponent.pdfFindController.executeCommand('find', {
caseSensitive: false, findPrevious: undefined, highlightAll: true, phraseSearch: true, query: stringToSearch
});
}