wPDF 4, Getting generic error occurred in GDI+ on StartPage() call after about 200 pages.

  • System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
    at System.Drawing.Imaging.Metafile..ctor(IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type, String desc)
    at wPDF.PDFControl.NeedGraphic()
    at wPDF.PDFControl.StartPage(Int32 w, Int32 h, Boolean landscape)

    We have used this successfully for about 18 years... so we are not sure what we are doing wrong. One idea is that we are holding onto a canvas handle that is not being released in a timely manor/thread issues or something that has to do with timing?

    Any thoughts would be great.

    C# code:

    _pdfPrinter.PageMode = ePageMode.Default;
    _pdfPrinter.JPEGCompressMode = eJPEGCompressMode.NoJPEG;
    //(eJPEGCompressMode.JPEG_100 - 1) /* OFF-BY-ONE error in the ENUM definition */;
    _pdfPrinter.InputFileMode = eInputFileMode.IgnoreInput;
    _pdfPrinter.InfoProducer = "xxxxxxxxxxxxxxxxxxxxxxxxxxx";
    _pdfPrinter.Encoding = eEncoding.Binary;
    _pdfPrinter.TextCompression = eTextCompression.Deflate;
                
    _pdfPrinter.PageMode &= ~ePageMode.Outlines;
                
    _pdfPrinter.PDFMode =
    eDevMode.AlwaysHighResPDF |
    eDevMode.AllowTransparentBit; // support image issues to match Delphi
    _pdfPrinter.PDFOptions = ePDFOptions.Empty;
    _pdfPrinter.FontMode = eFontMode.EmbedTTFSubsetCharset;
    _pdfPrinter.PDFEncryption = ePDFEncryption.Empty;
    _pdfPrinter.PDFSecurity = ePDFSecurity.Std40bit;

    • Offizieller Beitrag

    Just to avoid confusion, this is the about wPDFControl for .NET - not wPDF.

    It can have several reasons:

    a) a 64 bit problem

    b) Out of resources

    If possible please send finished metafiles to the wPDFControl Engine.

    The wrapper also just creates a metafile:

    and send it later to the engine in CloseCanvas using DrawMetafileEx.

    Do you use native drawing code which uses the Graphics of wPDFControl?

    That could cause a resource leak.