)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to customize the PDF viewer default toolbar?

Platform: ASP.NET Web Forms |
Control: PdfViewer |
Published Date: May 23, 2018 |
Last Revised Date: June 20, 2019

This article explains how to customize the default toolbar of PDF viewer in ASP.NET. Customization is the process of designing your own toolbar using the exposed public APIs in PDF viewer.

 

The following code example illustrates how to create custom toolbar for the PDF viewer with the given items:

  • Previous
  • Next
  • ZommIn
  • ZoomOut
  • FitToPage
  • FitToWidth
  • Download
  • Print

 

HTML

//creating custom toolbar
<div id="toolbarDiv" style="height:38px;width:100%;border:solid black 1px" class="toolbarclass " role="toolbar">
              <div style="float:left; padding:5px;">         
                    <div class="e-pdfviewer-icon e-pdfviewer-gotoprevious" id="viewer-previous" onclick="callClientSideMethod('previous')"></div>
                    <div class="e-pdfviewer-icon e-pdfviewer-gotonext" id="viewer-next" onclick="callClientSideMethod('next')"></div>
                    <div class="e-pdfviewer-icon e-pdfviewer-zoomin" id="viewer-zoomin" onclick="callClientSideMethod('zoomin')"></div>
                    <div class="e-pdfviewer-icon e-pdfviewer-zoomout"id="viewer-zoomout" onclick="callClientSideMethod('zoomout')"></div>
                    <div class="e-pdfviewer-icon e-pdfviewer-fitwidth" id="viewer-fitwidth" onclick="callClientSideMethod('fitwidth')"></div>
                    <div class="e-pdfviewer-icon e-pdfviewer-fitpage" id="viewer-fitpage" onclick="callClientSideMethod('fitpage')"></div>                          
             </div>
            <div style="float:right; padding:5px;">
               <div class="e-pdfviewer-icon e-pdfviewer-print" id="viewer-print" onclick="callClientSideMethod('print')"></div>
                <div class="e-pdfviewer-icon e-pdfviewer-download" id="viewer-download" onclick="callClientSideMethod('download')"></div>
            </div>
        </div>

 

Note:

Syncfusion PDF viewer toolbar icons are used for customization in the previous code, your own icons can be used for custom toolbar.

JS

$(function () {
            var pdfviewer = $("#PdfViewer1").data("ejPdfViewer");
//hide the default toolbar of the PDF Viewer
            pdfviewer.showToolbar(false);
        });
              function callClientSideMethod(apiName) {
             var _ejPdfViewer = $("#PdfViewer1").data("ejPdfViewer");
//call the client-side events
            switch (apiName) {
                case 'print':
                    _ejPdfViewer.print();
                    break;
                case 'zoomin':
                    _ejPdfViewer.zoomIn();
                     break;
                case 'zoomout':
                    _ejPdfViewer.zoomOut();
                    break;
                case 'fitpage':
                    _ejPdfViewer.fitToPage();
                    break;
                case 'fitwidth':
                     _ejPdfViewer.fitToWidth();
                     break;
                case 'previous':
                    _ejPdfViewer.goToPreviousPage();                    
                    break;
                case 'next':
                    _ejPdfViewer.goToNextPage();                    
                    break;
                case 'download':
                    _ejPdfViewer.download();
                    break;               
            }
        }

Sample:

http://www.syncfusion.com/downloads/support/directtrac/general/ze/PdfViewerWeb-1747609725

2X faster development

The ultimate ASP.NET Web Forms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon