1- import { PdfViewer , Toolbar , Magnification , Navigation , Annotation , LinkAnnotation , ThumbnailView , BookmarkView , TextSelection , TextSearch , FormFields , FormDesigner } from '@syncfusion/ej2-pdfviewer' ;
1+ import { PdfViewer , Toolbar , Magnification , Navigation , Annotation , LinkAnnotation , ThumbnailView , BookmarkView , TextSelection , TextSearch , FormFields , FormDesigner , PageOrganizer } from '@syncfusion/ej2-pdfviewer' ;
22import { MenuItemModel } from '@syncfusion/ej2-navigations' ;
33import { CheckBox , ChangeEventArgs } from '@syncfusion/ej2-buttons' ;
4-
5- PdfViewer . Inject ( Toolbar , Magnification , Navigation , Annotation , LinkAnnotation , ThumbnailView , BookmarkView , TextSelection , TextSearch , FormFields , FormDesigner ) ;
4+ PdfViewer . Inject ( Toolbar , Magnification , Navigation , Annotation , LinkAnnotation , ThumbnailView , BookmarkView , TextSelection , TextSearch , FormFields , FormDesigner , PageOrganizer ) ;
65
76let pdfviewer : PdfViewer = new PdfViewer ( ) ;
87pdfviewer . documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf" ;
98pdfviewer . resourceUrl = "https://cdn.syncfusion.com/ej2/23.1.43/dist/ej2-pdfviewer-lib" ;
10-
119var menuItems : MenuItemModel [ ] = [
1210 {
1311 text : 'Search In Google' ,
1412 id : 'search_in_google' ,
15- iconCss : 'e-icons e-de-ctnr-find '
13+ iconCss : 'e-icons e-search '
1614 } ,
1715 {
1816 text : 'Lock Annotation' ,
@@ -35,8 +33,6 @@ var menuItems: MenuItemModel[] = [
3533 id : 'read_only_false'
3634 } ,
3735] ;
38-
39-
4036pdfviewer . appendTo ( '#PdfViewer' ) ;
4137
4238pdfviewer . documentLoad = function ( args : any ) {
@@ -107,26 +103,24 @@ pdfviewer.customContextMenuBeforeOpen = function (args: any) {
107103} ;
108104
109105function lockAnnotations ( args : any ) {
110- var selectedAnnotations : any = pdfviewer . selectedItems . annotations ;
111- for ( var i = 0 ; i < selectedAnnotations . length ; i ++ ) {
112- var annotation = selectedAnnotations [ i ] ;
113- if ( annotation && annotation . annotationSettings ) {
114- annotation . annotationSettings . isLock = true ;
115- pdfviewer . annotationModule . editAnnotation ( annotation ) ;
116- args . cancel = false ;
106+ for ( var i = 0 ; i < pdfviewer . annotationCollection . length ; i ++ ) {
107+ if ( pdfviewer . annotationCollection [ i ] . uniqueKey === pdfviewer . selectedItems . annotations [ 0 ] . id ) {
108+ pdfviewer . annotationCollection [ i ] . annotationSettings . isLock = true ;
109+ pdfviewer . annotationCollection [ i ] . isCommentLock = true ;
110+ pdfviewer . annotation . editAnnotation ( pdfviewer . annotationCollection [ i ] ) ;
117111 }
112+ args . cancel = false ;
118113 }
119114}
120115
121116function unlockAnnotations ( args : any ) {
122- var selectedAnnotations : any = pdfviewer . selectedItems . annotations ;
123- for ( var i = 0 ; i < selectedAnnotations . length ; i ++ ) {
124- var annotation = selectedAnnotations [ i ] ;
125- if ( annotation && annotation . annotationSettings ) {
126- annotation . annotationSettings . isLock = false ;
127- pdfviewer . annotationModule . editAnnotation ( annotation ) ;
128- args . cancel = false ;
117+ for ( var i = 0 ; i < pdfviewer . annotationCollection . length ; i ++ ) {
118+ if ( pdfviewer . annotationCollection [ i ] . uniqueKey === pdfviewer . selectedItems . annotations [ 0 ] . id ) {
119+ pdfviewer . annotationCollection [ i ] . annotationSettings . isLock = false ;
120+ pdfviewer . annotationCollection [ i ] . isCommentLock = false ;
121+ pdfviewer . annotation . editAnnotation ( pdfviewer . annotationCollection [ i ] ) ;
129122 }
123+ args . cancel = false ;
130124 }
131125}
132126
@@ -158,18 +152,16 @@ function setReadOnlyFalse(args: any) {
158152
159153let defaultCheckBoxObj : CheckBox = new CheckBox ( {
160154 change : contextmenuHelper ,
161- cssClass : 'multiline' ,
155+ label : "Hide Default Context Menu"
162156} ) ;
163- defaultCheckBoxObj . appendTo ( '#hide-default-context-menu ' ) ;
157+ defaultCheckBoxObj . appendTo ( '#hide' ) ;
164158
165159let positionCheckBoxObj : CheckBox = new CheckBox ( {
166160 change : contextmenuHelper ,
167- cssClass : 'multiline' ,
161+ label : "Add Custom option at bottom"
168162} ) ;
169- positionCheckBoxObj . appendTo ( '#show-custom-menu-bottom ' ) ;
163+ positionCheckBoxObj . appendTo ( '#toolbar ' ) ;
170164
171165function contextmenuHelper ( args : ChangeEventArgs ) : void {
172166 pdfviewer . addCustomMenu ( menuItems , defaultCheckBoxObj . checked , positionCheckBoxObj . checked ) ;
173- }
174-
175- pdfviewer . appendTo ( '#PdfViewer' ) ;
167+ }
0 commit comments