How to Unload the document in WPF Pdf Viewer
14 Aug 20261 minute to read
The WPF PDF Viewer also allows a user to Unload the PDF document using Unload() API of the PdfViewerControl and PdfDocumentView classes. A user can dispose the PDF document by passing the Boolean parameter as ‘true’ to the Unload(Boolean) API. The below code illustrates how to dispose the PDF document programmatically.
private void UnloadButton_Click(object sender, RoutedEventArgs e)
{
//Unload the PDF document
pdfviewer.Unload(true);
}Private Sub UnloadButton_Click(sender As Object, e As RoutedEventArgs)
'Unload the PDF document
pdfviewer.Unload(true)
End SubIn PdfViewerControl, it is recommended not to unload the PDF document externally when loading a new PDF document, as the control internally handles the unloading process.