Unload document in React Pdfviewer component

23 Jul 20261 minute to read

The PDF Viewer provides the [unload()] (https://ej2.syncfusion.com/react/documentation/api/pdfviewer/#unload) method to remove the currently loaded PDF from the viewer instance. Use this API to free memory or reset the viewer when navigating between documents or closing the viewer.

The following steps are used to unload the PDF document programmatically.

Step 1: Follow the steps in the Getting Started with React PDF Viewer guide to create a simple PDF Viewer sample.

Step 2: Add the following code snippet to perform the unload operation.

     <button onclick="unload()">Unload Document</button>

<script>
function unload() {
    var viewer = document.getElementById('container').ej2_instances[0];
    // Unload the currently loaded PDF document.
    viewer.unload();
}
</script>

Find the sample how to unload the PDF document programmatically.

See also