Exception while creating a PDF

  • Hi,

    I'm getting an exception while generating a PDF. Can you provide any ideas on correcting this? Another developer on my team thought it might be related to the issue described here: http://wpcubed.com/forum/viewtopic.php?=&p=6029

    Versions:
    wPDF.dll - 2.94.2594.20078
    wPDFControl02.dll - 2.9.4.3

    Also, I don't think the source code I have for the .NET wrapper matches this version. Can you forward the correct source for the wrapper to me please? Tell me if you can't get my email from my forum registration and I'll send an email.

    Here is the callstack from the exception:

    Code
    at System.Drawing.Imaging.Metafile..ctor(IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type, String desc)
       at wPDF.PDFControl.NeedGraphic()
       at wPDF.PDFControl.StartGraphic()
       at wPDF.PDFControl.StartPage(Int32 w, Int32 h, Boolean landscape)
       at Fiserv.ASNET.Printing.PdfPrintController.OnStartPage(PrintDocument document, PrintPageEventArgs e)
       at System.Drawing.Printing.PrintController.PrintLoop(PrintDocument document)
       at System.Drawing.Printing.PrintController.Print(PrintDocument document)
       at System.Drawing.Printing.PrintDocument.Print()
       at Infragistics.Win.UltraWinGrid.UltraGrid.Print(UltraGridLayout layout, PrintDocument printDocument, RowPropertyCategories retainRowPropertyCategories)
    ...
  • That is correct. In this case the programmer had wrapped the initialization of the PDFControl in a using statement something like this:

    Code
    private void OnInitializePrint()
    {
        using(PdfControl pdfControl = new PdfControl)
        {
            (m_printDocument.PrintController as PdfPrintController).PdfControl = pdfControl;
    
    
            // other initilialization
        }
    }

    So effectively the pdfControl still existed because there was a reference held to it by the member variable m_printDocument. But the PdfControl.Dispose() method had been called upon exiting the using statement block. This caused the PdfControl.Reference to be cleared, which then led to the error in PdfControl.NeedGraphic (I think that is the method name)

    Thanks Julian.