How to React Pdf Viewer Document can close?

Hi, 

I am using ej2-pdfviewer. Everything is fine. Document can be load, pages can be rendered etc. But I wanna unload a pdf from pdfViewer container. There is some code examples for closing document or unload something  but none of them is about react pdfviewer. 

How can I destroy pdfviewer from pdf object. I did search all props and functions which can I use but from ref object these methods cannot be accessable. 

Attachment: Doc_e4480e10.rar

1 Reply 1 reply marked as answer

DM Dhivyabharathi Mohan Syncfusion Team April 2, 2021 10:39 AM UTC

Hi Burcu, 
  
Thank you for contacting Syncfusion support. 
  
In our PDF Viewer, we can use the unload method to unload the document from the viewer and use the destroy method to destroy the PDF Viewer. We have shared the React sample and code snippet for your reference. 
 
 
 
Code snippet: 
 
<button onclick ="unloadDocument()"> unloadDocument </button> 
  <button onclick ="destroy()"> destroy</button> 
 
For Unload: 
function unloadDocument() { 
      var pdfviewer = document.getElementById('container').ej2_instances[0]; 
      pdfviewer.unload(); 
} 
 
For Destroy: 
function destroy() { 
      var pdfviewer = document.getElementById('container').ej2_instances[0]; 
      pdfviewer.destroy(); 
  } 
 
 
 
Kindly try it and revert us, if you have any concerns about this. 
 
Regards, 
Dhivya. 
 


Marked as answer
Loader.
Up arrow icon