How to hide the toolbar items from the PDF Viewer toolbar?
Essential JS 2 PDF Viewer
The Syncfusion PDF Viewer in ASP.NET MVC (Essential JS 2) is a modern enterprise UI toolkit that has been built from the ground up to be lightweight, responsive, modular, and touch-friendly. It also available in other frameworks such as JavaScript Angular and React.
Refer to the following UG link for getting started with the PdfViewerControl.
Show or Hide toolbar items from the PDF Viewer toolbar
You can show or hide the toolbar items from PDF Viewer in the following ways:
- Using the toolbarSettings property during control initialization.
- Dynamically using the showToolbarItem method.
Show or hide toolbar items during control initialization
The toolbar settings of the PDF Viewer can be set using the toolbarSettings API during control initialization and it contains the following properties:
- ShowTooltip: Shows or hides the tooltip of the toolbar items.
- ToolbarItems: Shows or hides the toolbar items in the PDF Viewer toolbar.
List of available toolbar items:
The toolbar items are identified using the ToolbarItems property:
- OpenOption
- PageNavigationTool
- MagnificationTool
- PanTool
- SelectionTool
- SearchOption
- PrintOption
- DownloadOption
- UndoRedoTool
- AnnotationEditTool
- CommentTool
Refer to the following code to show the Open icon and Download icon in the PDF Viewer toolbar.
JavaScript
@Html.EJS().PdfViewer("pdfviewer").ServiceUrl(VirtualPathUtility.ToAbsolute("~/PdfViewer")).DocumentPath("PDF Succinctly.pdf").ToolbarSettings(new Syncfusion.EJ2.PdfViewer.PdfViewerToolbarSettings {ToolbarItems = "OpenOption", "DownloadOption" } ).Render()
The tooltip of the toolbar items can be shown or hidden using the following code.
JavaScript
@Html.EJS().PdfViewer("pdfviewer").ServiceUrl(VirtualPathUtility.ToAbsolute("~/PdfViewer")).DocumentPath("PDF Succinctly.pdf").ToolbarSettings(new Syncfusion.EJ2.PdfViewer.PdfViewerToolbarSettings { ShowTooltip = true } ).Render()
Show or hide toolbar items dynamically
You can hide the toolbar items form the PDF Viewer toolbar dynamically using the showToolbarItem method. The list of available toolbar items is identified using the ToolbarItems property. Refer to the following code to hide the Open icon from the PDF Viewer toolbar.
window.onload = function () { var pdfViewer = document.getElementById('pdfviewer').ej2_instances[0]; pdfViewer.toolbar.showToolbarItem(new Array("OpenOption"), false); }
Sample link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/EJ2PdfViewer-1188995630
In the preceding sample, the Open and Download icons will be shown in the PDF Viewer toolbar.
I hope you enjoyed learning about How to hide the toolbar items from the MVC PDF Viewer toolbar.
You can refer to our ASP.NET MVC PDF Viewer's feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our .NET MVC PDF Viewer example to understand how to create and manipulate data.
For current customers, you can check out our ASP.NET Core Components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!