question about image printer driver sample code

Hi, anybody went through this sample code?

I built and installed the image printer driver. In the test of printing an Excel file (with extension .xls), I found out that there was no output file generated. It turned out that there was no problem in imageprocessing(). But a wrong pOEMDev pointer was being used in OEMEndDoc(). The one used in OEMEndDoc() was not the same one in imageProcessing(). I am not so familiar with COM interface. I don’t know how to fix this problem. Instead, I saved the pointer used in imageProcessing and forced OEMEndDoc() to use this saved pointer if something wrong. The result is fine. But I don’t think this is a real fix.
Anybody knows this? Any help will be greatly appreciated!

Thanks in advance!

Also, what is the best way to generate multiple pages output?