1+ var pdfviewer = new ej . pdfviewer . PdfViewer ( {
2+ documentPath : 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf' ,
3+ resourceUrl : "https://cdn.syncfusion.com/ej2/35.1.37/dist/ej2-pdfviewer-lib" ,
4+ } ) ;
5+ ej . pdfviewer . PdfViewer . Inject ( ej . pdfviewer . TextSelection , ej . pdfviewer . TextSearch , ej . pdfviewer . Print , ej . pdfviewer . Navigation , ej . pdfviewer . Toolbar ,
6+ ej . pdfviewer . Magnification , ej . pdfviewer . Annotation , ej . pdfviewer . FormDesigner , ej . pdfviewer . FormFields , ej . pdfviewer . PageOrganizer ) ;
7+
8+ pdfviewer . appendTo ( '#PdfViewer' ) ;
9+ document . getElementById ( "AddInternalLink" ) . addEventListener ( 'click' , function ( ) {
10+ pdfviewer . annotation . addAnnotation ( 'Link' , {
11+ offset : { x : 200 , y : 480 } ,
12+ pageNumber : 1 ,
13+ width : 150 ,
14+ height : 75 ,
15+ destinationPageIndex : 4 ,
16+ destinationLocation : { x : 100 , y : 200 } ,
17+ zoomValue : 4 ,
18+ strokeColor : '#1433e3'
19+ } ) ;
20+ } ) ;
21+
22+ document . getElementById ( "AddExternalLink" ) . addEventListener ( 'click' , function ( ) {
23+ pdfviewer . annotation . addAnnotation ( 'Link' , {
24+ offset : { x : 450 , y : 480 } ,
25+ pageNumber : 1 ,
26+ width : 150 ,
27+ height : 75 ,
28+ url : 'https://www.syncfusion.com' ,
29+ strokeColor : '#FF0000'
30+ } ) ;
31+ } ) ;
32+
33+ document . getElementById ( "EditLink" ) . addEventListener ( 'click' , function ( ) {
34+ for ( var i = 0 ; i < pdfviewer . annotationCollection . length ; i ++ ) {
35+ if ( pdfviewer . annotationCollection [ i ] . subject === 'Link' ) {
36+ pdfviewer . annotationCollection [ i ] . strokeColor = '#1fcbd4' ;
37+ pdfviewer . annotationCollection [ i ] . thickness = 2 ;
38+ pdfviewer . annotationCollection [ i ] . bounds = { left : 100 , top : 100 , width : 100 , height : 100 } ;
39+ pdfviewer . annotationCollection [ i ] . url = 'https://www.google.com' ;
40+ pdfviewer . annotationCollection [ i ] . destinationPageIndex = 3 ;
41+ pdfviewer . annotationCollection [ i ] . destinationLocation = { x : 300 , y : 300 } ;
42+ pdfviewer . annotationCollection [ i ] . zoomValue = 1 ;
43+ pdfviewer . annotation . editAnnotation ( pdfviewer . annotationCollection [ i ] ) ;
44+ break ;
45+ }
46+ }
47+ } ) ;
48+
49+ document . getElementById ( "DeleteLink" ) . addEventListener ( 'click' , function ( ) {
50+ var linkAnnotation = pdfviewer . annotationCollection . find ( function ( item ) { return item . subject === 'Link' ; } ) ;
51+
52+ if ( linkAnnotation ) {
53+ pdfviewer . annotation . deleteAnnotationById ( linkAnnotation . annotationId ) ;
54+ }
55+ } ) ;
0 commit comments