protected void Dispose(bool disposing) { if (_disposed) { return; } StreamDictionary.Remove(_streamId); if (_form != IntPtr.Zero) { PdfiumLibrary.FORM_DoDocumentAAction(_form, FPDFDOC_AACTION.WC); PdfiumLibrary.FPDFDOC_ExitFormFillEnvironment(_form); _form = IntPtr.Zero; } if (_document != IntPtr.Zero) { PdfiumLibrary.FPDF_CloseDocument(_document); _document = IntPtr.Zero; } if (_formCallbacksHandle.IsAllocated) { _formCallbacksHandle.Free(); } if (_stream != null) { _stream.Dispose(); _stream = null; } _disposed = true; }