Close the comment panel programmatically

23 Oct 20251 minute to read

The Syncfusion ASP.NET MVC PDF Viewer allows you to programmatically close the comment panel using a JavaScript function. This can be useful for customizing the user interface, responding to specific user actions, or enhancing accessibility by providing alternative controls.

NOTE

The comment panel must already be open for this action to have an effect.

To close the comment panel programmatically, follow these steps:

Step 1: Create an ASP.NET MVC PDF Viewer sample by following the getting started guide.

Step 2: Add a button and the following JavaScript code to your Razor view (e.g., Index.cshtml) to close the comment panel on click:

<button type="button" onclick="closeCommentPanel()">CloseCommentPanel</button>

<script>
    function closeCommentPanel() {
        var viewer = document.getElementById('pdfviewer').ej2_instances[0];
        viewer.viewerBase.navigationPane.closeCommentPanelContainer();
    }
</script>

Download the sample how to close comment panel