Crash using PDFDCEX and freeing the CDC object

Question:

I get a crash using PDFDCEX when I call DeleteDC.

PDFDCEX pdfDc; CDC pDC; pDC.m_hDC = pDC.m_hAttribDC = pdfDc.Begin(*pdfDoc, Point( 8.5, 11 ) ); CDC tempDC; tempDC.CreateCompatibleDC(&pDC); // ... pdfDc.End(); pDC.DeleteDC();

Answer:

The HDC object returned by PDFDCEX::Begin is owned by the instance. Clients should not delete the object themselves. This occurs in the call to PDFDCEX::End