angular11 - 如何在 Angular 11 中隐藏 ng2-pdfjs-viewer 中的工具栏?
问题描述
如何在 ng2-pdfjs-viewer 中隐藏整个工具?我用它来显示pdf
提前致谢
在我的 html 中,我有这个:-
<ng2-pdfjs-viewer #embeddedPdf id="pdfViewer" aria-label="Embedded PDF" [pdfSrc]="pdfBlob" zoom="page-width" [download]="false" [find]="false"
[print]="false" [startPrint]="false" [startDownload]="false" [rotatecw]="false" [rotateccw]="false" [fullScreen]="false"
[openFile]="false" [viewBookmark]="false" [showSpinner]="true" [errorAppend]="false"></ng2-pdfjs-viewer>
在我的 Ts 文件中,我有这个:-
export class PdfComponent implements AfterViewChecked{
@Input() pdfBlob: Blob;
@ViewChild('embeddedPdf') embeddedPdf: PdfJsViewerComponent;
constructor(private sanitizer: DomSanitizer) {
}
ngAfterViewChecked() {
console.log("Toolbar = "+this.embeddedPdf);
if(this.embeddedPdf && this.embeddedPdf.PDFViewerApplication){
this.embeddedPdf.PDFViewerApplication.toolbar.toolbar.hidden=true;
console.log(this.embeddedPdf.PDFViewerApplication);
}
}
}
使用它我实际上可以隐藏组件:-
this.embeddedPdf.PDFViewerApplication.toolbar.toolbar.hidden=true;
但 PDFViewerApplication 仅在页面完全加载后可用。因此,在这种方法 ngAfterViewChecked 中,我无法在页面初始化时隐藏工具栏。
解决方案
推荐阅读
- c# - MongoDb中的查找方法使用Linq返回空数组
- java - android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class
- excel - 如何计算单元格中特定单词的总数并使用 VBA 对其他单元格执行相同操作?
- javascript - 隐藏带有标签的复选框
- javascript - 覆盖文件内容
- linux - Linux内核get_signal()中do_group_exit()的条件
- c# - 将属性动态添加到现有类以与 DataGrid 一起使用?
- python - 尝试使用时间,但类型错误:float() 参数必须是字符串或数字
- blockchain - 如何在corda的节点shell中打印输入数据和错误
- c++ - 从上下文共享的 QOpenGLWidget 崩溃