Capturing multiple page outputs?

I am working on a virtual printer driver… I have used the bitmap sample in WDK… But the problem is that it cant render multiple pages output… EXample : If a MS Word document of 2 pages is input to the printer, then it renders only the last page as a BMP file… First page is not rendered as output… Help me in knowing this… Thank you all for posting replies to my previous queries and to this query too…

xxxxx@gmail.com wrote:

If a MS Word document of 2 pages is input to the printer, then it
renders only the last page as a BMP file… First page is not
rendered as output…

Found by: Google search “multi page BMP”, selecting 5th link in list
“Ashwin Needamangala’s Blog : How to write a bitmap driver”

http://blogs.msdn.com/ashwinn/archive/2006/02/21/BitmapDriver.aspx

“This task of dumping the bitmap data to file is done by implementing
the OEMEndDoc DDI hook. This results in all the pages being part of a
single output bitmap file. If you wanted each page saved as a separate
bitmap file, you should perform the dumping of the bitmap data using the
OEMEndPage DDI hook.”

HTH -H

Where could i learn or find code for OEMEndPage DDI hook… I have visited your blog and made all corrections needed… But it is still capturing many pages (Ex: 6 pages of a word document) in only one bmp image… So please help me in knowing about which material to refer for writing source code… Where to look for OEMEndPage DDI hook… Thanks a lot for all your suggestions being given…

On Feb 18, 2008 11:43 AM, wrote:
> Where could i learn or find code for OEMEndPage DDI hook… I have visited your blog and made all

One quick workaround: Use one of the reserved fields in the bmp-header
to store the last page number. But this only works if .bmp isn’t your
final target and you have some sort of conversion utility that will
take the pre-processed .bmp and transform it into something else…

If such is not the case, then you will have to store the bitmap to
file in EndPage and create a new one if needed. (Which I doubt you can
do, because the printer driver is merely streaming stuff to the port
monitor which is responsible for the physical storage)


Rune

xxxxx@gmail.com wrote:

Where could i learn or find code for OEMEndPage DDI hook…

You will have to write this routine yourself. In order to learn:

  • Download the WDK6000RTM or WDK6001.18000.
  • Install the WDK and Help files.
  • READ the bitmap sample files. All of them.
  • UNDERSTAND the bitmap driver sample (using WDK help).
  • READ in the WDK help about GDI/DDI in general.
  • PLAN your driver changes
    (what needs to be different? how can I achieve this?), and
  • IMPLEMENT your changes
  • TEST your driver.

My guess after 5 minutes of looking at WDK help and bitmap\enable.cpp is
that there is a typo in the blog entry I quoted: not “OEMEndPage”, but
OEMSendPage is present in the sample code (hooking - if enabled -
DrvSendPage).

And DrvSendPage is called by the DDI at the end of each page.

Looks like the logical place for code to generate a bitmap file per page.

You will have to write the OEMSendPage routine yourself, so that it
creates a new file (e.g. getting the name via a printer dialog UI or
registry setting), writes the page data (cum bitmap and color header)
into it, closes the file, then resets the bitmap data buffers for the
next page).

(And you will still need some part of the old OEMEndDoc to completely
cleanup everything at the end of the job/document.)

As I am not a printer driver developer myself, everything I wrote above
was glanced from the bitmap sample and from WDK help. Becoming a printer
driver developer, and therefore having more time for it, you should be
able to do much better. Now go on, learn, and write a good driver! -H