« "Required Reading" | Main | California Election Analysis - June 6, 2006 »

May 21, 2006

DrvStartDoc without a JobId

If you don't write Windows print drivers, this won't be interesting; this is here mostly for Google.

I write Windows print drivers, mostly built on the Microsoft OEM PostScript driver using customization DLLs, and I spent days tracking down a problem where DrvStartDoc() was called with no job ID. This is part of the interface, and the driver depended on getting it, but even though it worked for months, upgrading to Word 2003 broke it. No Job ID.

After days of research I figured it out: DrvStartDoc() can be called more than once per document. The first time it's called with the Job ID as expected, but if the application does a ResetDC(), we'll get called again with the new DEVMODE. Those subsequent calls don't get the Job ID.

The solution is to save the Job ID into the OEM PDEV (pdevobj->pdevOEM) the first time we see it, and to be sure to implement the ResetPDEV() call to copy the private OEM PDEV as it gets reset. I had omitted the ResetPDEV() call, thinking it was not necessary, so the saved Job ID was discarded when the application changed the DEVMODE.

Even without the ResetPDEV / ResetDC, this is necessary if the application is printing via a metafile, which is set via the Enable advanced printing features checkbox in the Advanced tab in printer properties. Without proper PDEV management, it will break badly.

Posted by steve at May 21, 2006 11:15 PM

Comments