11import { PdfViewer , Toolbar , Magnification , Navigation , Annotation , LinkAnnotation , ThumbnailView , BookmarkView , TextSelection , TextSearch , FormFields , FormDesigner , Print , CustomToolbarItemModel } from '@syncfusion/ej2-pdfviewer' ;
2-
2+ import { ComboBox } from "@syncfusion/ej2-dropdowns" ;
3+ import { TextBox } from "@syncfusion/ej2-inputs" ;
34PdfViewer . Inject ( Toolbar , Magnification , Navigation , Annotation , LinkAnnotation , ThumbnailView , BookmarkView , TextSelection , TextSearch , FormFields , FormDesigner , Print ) ;
4- let toolItem : CustomToolbarItemModel = {
5+ let toolItem1 : CustomToolbarItemModel = {
56 prefixIcon : 'e-icons e-paste' ,
67 id : 'print' ,
78 tooltipText : 'Custom toolbar item' ,
8- align : 'left'
99} ;
10+ let toolItem2 : CustomToolbarItemModel = {
11+ id : 'download' ,
12+ text : 'Save' ,
13+ tooltipText : 'Custom toolbar item' ,
14+ align : 'right'
15+ } ;
16+ let LanguageList : string [ ] = [ 'Typescript' , 'Javascript' , 'Angular' , 'C#' , 'C' , 'Python' ] ;
17+ let toolItem3 : CustomToolbarItemModel = {
18+ type : 'Input' ,
19+ tooltipText : 'Language List' ,
20+ cssClass : 'percentage' ,
21+ align : 'Left' ,
22+ id : 'dropdown' ,
23+ template : new ComboBox ( { width : 100 , value : 'TypeScript' , dataSource : LanguageList , popupWidth : 85 , showClearButton : false , readonly : false } )
24+ } ;
25+ let toolItem4 : CustomToolbarItemModel = {
26+ type : 'Input' ,
27+ tooltipText : 'Text' ,
28+ align : 'Right' ,
29+ cssClass : 'find' ,
30+ id : 'textbox' ,
31+ template : new TextBox ( { width : 125 , placeholder : 'Type Here' , created : OnCreateSearch } )
32+ }
1033let pdfviewer : PdfViewer = new PdfViewer ( ) ;
1134pdfviewer . documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf" ;
1235pdfviewer . resourceUrl = "https://cdn.syncfusion.com/ej2/23.1.43/dist/ej2-pdfviewer-lib" ;
13- pdfviewer . toolbarSettings = { toolbarItems : [ toolItem , 'OpenOption' , 'PageNavigationTool' , 'MagnificationTool' , 'PanTool' , 'SelectionTool' , 'SearchOption' , 'PrintOption' , 'DownloadOption' , 'UndoRedoTool' , 'AnnotationEditTool' , 'FormDesignerEditTool' , 'CommentTool' , 'SubmitForm' ] }
14-
36+ pdfviewer . toolbarSettings = { toolbarItems : [ toolItem1 , toolItem2 , 'OpenOption' , 'PageNavigationTool' , 'MagnificationTool' , toolItem3 , 'PanTool' , 'SelectionTool' , 'SearchOption' , 'PrintOption' , 'DownloadOption' , 'UndoRedoTool' , 'AnnotationEditTool' , 'FormDesignerEditTool' , toolItem4 , 'CommentTool' , 'SubmitForm' ] }
1537pdfviewer . appendTo ( '#PdfViewer' ) ;
16- //To handle custom toolbar click event.
17- pdfviewer . toolbarClick = function ( args ) {
18- if ( args . item && args . item . id === 'print' ) {
19- pdfviewer . print . print ( ) ;
20- }
21- else if ( args . item && args . item . id === 'download' ) {
22- pdfviewer . download ( ) ;
23- }
24- } ;
38+ //To handle custom toolbar click event.
39+ pdfviewer . toolbarClick = function ( args ) {
40+ if ( args . item && args . item . id === 'print' ) {
41+ pdfviewer . print . print ( ) ;
42+ }
43+ else if ( args . item && args . item . id === 'download' ) {
44+ pdfviewer . download ( ) ;
45+ }
46+ } ;
47+ function OnCreateSearch ( this : any ) : any {
48+ this . addIcon ( 'prepend' , 'e-icons e-search' ) ;
49+ }
0 commit comments