|
| 1 | +import { Component, ViewEncapsulation, OnInit,ViewChild} from '@angular/core'; |
| 2 | +import { PdfViewerComponent, LinkAnnotationService, BookmarkViewService, MagnificationService, ThumbnailViewService, ToolbarService, NavigationService, TextSearchService, TextSelectionService, PrintService, AnnotationService, FormFieldsService, FormDesignerService, PageOrganizerService,PdfViewerModule, TextSelectionStartEventArgs, AnnotationSelectEventArgs } from '@syncfusion/ej2-angular-pdfviewer'; |
| 3 | +import { SwitchComponent, SwitchModule } from '@syncfusion/ej2-angular-buttons'; |
| 4 | +import { ClickEventArgs } from '@syncfusion/ej2-buttons'; |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | +/** |
| 9 | + * Default PdfViewer Controller |
| 10 | + */ |
| 11 | +@Component({ |
| 12 | + selector: 'app-root', |
| 13 | + templateUrl: 'app.component.html', |
| 14 | + encapsulation: ViewEncapsulation.None, |
| 15 | + // tslint:disable-next-line:max-line-length |
| 16 | + providers: [LinkAnnotationService, BookmarkViewService, MagnificationService, ThumbnailViewService, ToolbarService, NavigationService, |
| 17 | + TextSearchService, TextSelectionService, PrintService, AnnotationService, FormFieldsService, FormDesignerService,PageOrganizerService], |
| 18 | + styleUrls: ['app.component.css'], |
| 19 | + standalone: true, |
| 20 | + imports: [ |
| 21 | + |
| 22 | + SwitchModule, |
| 23 | + PdfViewerModule, |
| 24 | + |
| 25 | + ], |
| 26 | +}) |
| 27 | + |
| 28 | +export class AppComponent { |
| 29 | + @ViewChild('pdfviewer') |
| 30 | + public pdfviewerControl: PdfViewerComponent | undefined; |
| 31 | + |
| 32 | + public document: string = 'https://cdn.syncfusion.com/content/pdf/blazor-annotations.pdf'; |
| 33 | + public resource:string = "https://cdn.syncfusion.com/ej2/30.1.37/dist/ej2-pdfviewer-lib"; |
| 34 | + ngOnInit(): void { |
| 35 | + // ngOnInit function |
| 36 | + } |
| 37 | + //Restrict Context Menu Option on TextSelection |
| 38 | + public textSelection(e: TextSelectionStartEventArgs): void { |
| 39 | + if(this.pdfviewerControl) |
| 40 | + this.pdfviewerControl.contextMenuOption = "None"; |
| 41 | + } |
| 42 | + //Context Menu Option on AnnotationSelection |
| 43 | + public annotationSelected(e: AnnotationSelectEventArgs): void { |
| 44 | + if(this.pdfviewerControl) |
| 45 | + this.pdfviewerControl.contextMenuOption = "RightClick"; |
| 46 | + } |
| 47 | +} |
0 commit comments