Exemple #1
0
        private void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                StreamManager.Unregister(_id);

                if (_form != IntPtr.Zero)
                {
                    NativeMethods.FORM_DoDocumentAAction(_form, NativeMethods.FPDFDOC_AACTION.WC);
                    // this call is needed for PDFium builds with PDF_ENABLE_XFA enabled
                    // and PDF_ENABLE_XFA implies JS support (PDF_ENABLE_V8 is needed for that)
                    // since we don't ship PDFium with V8 we can skip this
                    // otherwise we have to deal with some nasty unmanaged memory corruption
                    //NativeMethods.FPDFDOC_ExitFormFillEnvironment(_form);
                    _form = IntPtr.Zero;
                }

                if (_document != IntPtr.Zero)
                {
                    NativeMethods.FPDF_CloseDocument(_document);
                    _document = IntPtr.Zero;
                }

                if (_formCallbacksHandle !.IsAllocated)
                {
                    _formCallbacksHandle !.Free();
                }

                if (_stream != null)
                {
                    _stream.Dispose();
                    _stream = null;
                }

                _disposed = true;
            }
        }