|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: Add Save Button in Built-In Toolbar | Syncfusion |
| 4 | +description: Learn here all about adding save button in built-in Toolbar in Syncfusion ##Platform_Name## Pdfviewer component of Syncfusion Essential JS 2 and more. |
| 5 | +platform: ej2-asp-core-mvc |
| 6 | +control: PDF Viewer |
| 7 | +publishingplatform: ##Platform_Name## |
| 8 | +documentation: ug |
| 9 | +--- |
| 10 | + |
| 11 | +# Add Save Button in Built-In toolbar |
| 12 | + |
| 13 | +PDF Viewer allows you to customize(add, show, hide, enable, and disable) existing items in a toolbar. |
| 14 | + |
| 15 | +* Save button - New `save` button-item can be defined by **CustomToolbarItemModel** and with existing items in [**ToolbarSettings**](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.PdfViewer.PdfViewerToolbarSettings.html) property. Save button-item click action can be defined in `toolbarclick`. |
| 16 | + |
| 17 | +* Show, Hide - `Save` button-item can be shown or hidden using the [`ToolbarSettings`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.PdfViewer.PdfViewerToolbarSettings.html) property. Pre-defined toolbar items are available with [`ToolbarItem`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.PdfViewer.PdfViewerToolbarSettings.html#Syncfusion_EJ2_PdfViewer_PdfViewerToolbarSettings_ToolbarItems). |
| 18 | + |
| 19 | +* Enable, Disable - `Save` button-item can be enabled or disable using `enabletoolbaritem`. |
| 20 | + |
| 21 | +{% tabs %} |
| 22 | +{% highlight html tabtitle="Standalone" %} |
| 23 | + |
| 24 | +<div> |
| 25 | + <ejs-pdfviewer id="pdfviewer" |
| 26 | + style="width:1350px;height:100%" |
| 27 | + documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf" |
| 28 | + resourceUrl='https://cdn.syncfusion.com/ej2/24.1.41/dist/ej2-pdfviewer-lib' |
| 29 | + toolbarClick="toolbarClick"> |
| 30 | + </ejs-pdfviewer> |
| 31 | +</div> |
| 32 | + |
| 33 | +<script type="text/javascript"> |
| 34 | + window.onload = function () { |
| 35 | + var pdfViewer = document.getElementById('pdfviewer').ej2_instances[0]; |
| 36 | + var toolItem1 = { |
| 37 | + prefixIcon: 'e-icons e-save', |
| 38 | + id: 'download', |
| 39 | + text: 'Save', |
| 40 | + tooltipText: 'Save Button', |
| 41 | + align: 'left' |
| 42 | + }; |
| 43 | + pdfViewer.toolbarSettings = { |
| 44 | + showTooltip: true, |
| 45 | + toolbarItems: ['OpenOption', toolItem1, 'PageNavigationTool', 'MagnificationTool', 'PanTool', 'SelectionTool', 'SearchOption', 'PrintOption', 'UndoRedoTool', 'AnnotationEditTool', 'FormDesignerEditTool', 'CommentTool', 'SubmitForm'] |
| 46 | + }; |
| 47 | + function onCreate() { |
| 48 | + this.addIcon('prepend', 'e-icons e-search'); |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + // Define the toolbarClick event handler |
| 53 | + function toolbarClick(args) { |
| 54 | + var pdfViewer = document.getElementById('pdfviewer').ej2_instances[0]; |
| 55 | + |
| 56 | + if (args.item && args.item.id === 'download') { |
| 57 | + pdfViewer.download(); |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | +</script> |
| 62 | + |
| 63 | +{% endhighlight %} |
| 64 | +{% highlight html tabtitle="Server-Backed" %} |
| 65 | + |
| 66 | +<div> |
| 67 | + <ejs-pdfviewer id="pdfviewer" |
| 68 | + style="width:1350px;height:100%" |
| 69 | + documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf" |
| 70 | + serviceUrl="/api/PdfViewer" |
| 71 | + toolbarClick="toolbarClick"> |
| 72 | + </ejs-pdfviewer> |
| 73 | +</div> |
| 74 | + |
| 75 | +<script type="text/javascript"> |
| 76 | + window.onload = function () { |
| 77 | + var pdfViewer = document.getElementById('pdfviewer').ej2_instances[0]; |
| 78 | + var toolItem1 = { |
| 79 | + prefixIcon: 'e-icons e-save', |
| 80 | + id: 'download', |
| 81 | + text: 'Save', |
| 82 | + tooltipText: 'Save Button', |
| 83 | + align: 'left' |
| 84 | + }; |
| 85 | + pdfViewer.toolbarSettings = { |
| 86 | + showTooltip: true, |
| 87 | + toolbarItems: ['OpenOption', toolItem1, 'PageNavigationTool', 'MagnificationTool', 'PanTool', 'SelectionTool', 'SearchOption', 'PrintOption', 'UndoRedoTool', 'AnnotationEditTool', 'FormDesignerEditTool', 'CommentTool', 'SubmitForm'] |
| 88 | + }; |
| 89 | + function onCreate() { |
| 90 | + this.addIcon('prepend', 'e-icons e-search'); |
| 91 | + } |
| 92 | + } |
| 93 | + |
| 94 | + // Define the toolbarClick event handler |
| 95 | + function toolbarClick(args) { |
| 96 | + var pdfViewer = document.getElementById('pdfviewer').ej2_instances[0]; |
| 97 | + |
| 98 | + if (args.item && args.item.id === 'download') { |
| 99 | + pdfViewer.download(); |
| 100 | + } |
| 101 | + } |
| 102 | + |
| 103 | +</script> |
| 104 | + |
| 105 | +{% endhighlight %} |
| 106 | +{% endtabs %} |
| 107 | + |
| 108 | +N> Default value of toolbar items is ['OpenOption', 'PageNavigationTool','MagnificationTool', 'PanTool', 'SelectionTool', 'SearchOption', 'PrintOption', 'DownloadOption','UndoRedoTool', 'AnnotationEditTool', 'FormDesignerEditTool', 'CommentTool', 'SubmitForm'] |
| 109 | + |
| 110 | +### Align Property |
| 111 | + |
| 112 | +The align property is used to specify the alignment of a `save` button-item within the toolbar. |
| 113 | + |
| 114 | +`Left`: Aligns the item to the left side of the toolbar. |
| 115 | +`Right`: Aligns the item to the right side of the toolbar. |
| 116 | + |
| 117 | +### Tooltip Property |
| 118 | + |
| 119 | +The tooltip property is used to set the tooltip text for a `save` button-item. Tooltip provides additional information when a user hovers over the item. |
| 120 | + |
| 121 | +### CssClass Property |
| 122 | + |
| 123 | +The cssClass property is used to apply custom CSS classes to a `save` button-item. It allows custom styling of the save button-item. |
| 124 | + |
| 125 | +### Prefix Property |
| 126 | + |
| 127 | +The prefix property is used to set the CSS class or icon that should be added as a prefix to the existing content of the toolbar item. |
| 128 | + |
| 129 | +### ID Property |
| 130 | + |
| 131 | +The id property within a CustomToolbarItemModel is a compulsory attribute that plays a vital role in toolbar customization. It serves as a unique identifier for each toolbar item, facilitating distinct references and interactions. |
| 132 | + |
| 133 | +When defining or customizing toolbar items, it is mandatory to assign a specific and descriptive id to each item. |
| 134 | +These properties are commonly used when defining custom toolbar items with the `CustomToolbarItemModel`` in the context of Syncfusion PDF Viewer. When configuring the toolbar using the `ToolbarSettings`` property, you can include these properties to customize the appearance and behavior of each toolbar item. |
| 135 | + |
| 136 | +N> When customizing `save` button-item, you have the flexibility to include either icons or text based on your design preference. |
| 137 | + |
| 138 | +[View sample in GitHub](https://github.com/SyncfusionExamples/asp-core-pdf-viewer-examples/tree/master/How%20to) |
0 commit comments