I have an MDI MFC app-wizard generated application. Printing works fine EXCEPT when printing to acrobat 6 printer (ie distiller). I can compile and run the program in the debugger and it will print fine. I close my program, re-run it immediately, and when trying to print to acrobat, I get assertions in wingdi on seemingly random DC function calls (eg LineTo, Rectangle) because the m_hDC is NULL.
I'm not doing anything 'fancy' - just drawing rectangles and text.

My biggest problem is when I try to step through in the debugger, it always works fine (ie produces the pdf).

Please let me know if you have had similar problems. Any suggestions on how to get to the root of the problem?

Thank you
Jon