Print PDF document is disposing my Main Form

I am trying to use pdf document print in a DLL I am creating:

        /// <summary>
        /// Print current Document
        /// </summary>
        /// <returns></returns>
        public bool Print()
        {
            if (DocumentName() == string.Empty) return false;

            // Print selected PDF to selected printer
            _pdfDocument = PdfDocument.Load(Document.FullName);
            _pdfDocument.Print(Settings.PrinterName);
            return true;
        }

I’ve got a Button Click Event Handler which simply calls this routine in my DLL. I can use the free version of GemBox.pdf. The label prints OK but when I finish the Event Handler, I get a ‘Cannot access disposed object’ exception because my Main Form has been disposed. I don’t call Main Form.Dispose, so I don’t know how it is getting disposed. If I comment out the _pdfDocument.Print(Settings.PrinterName); line the dispose of the Main Form doesn’t happen.

mssloan

Hi,

This issue was resolved in the following bugfix version of GemBox.Pdf:

Install-Package GemBox.Pdf -Version 17.0.1375-hotfix

Regards,
Mario