Help on Print Finish Event

Hi all,

I am writing bitmap printer driver, i have modified OEMUNI sample and
after lots of efforts i am able to generate the bmp files as output of
print command.

Now, I want to notify the completion of this job to my user-mode UI.

Can I Send message to my UI from oemuni.dll–oemenddoc()?

Can I do CreateProcess from oemuni.dll–oemenddoc() ?

Do i Need to write Ui-plugin dll for printer driver? if so which source
code of DDK,XP, i need to look up? and which functions i need to
override?

Which approach should be taken into account?

I also want to have my bmp file to be fixed height/width based on
portrait mode or landscape mode ? how to achive this? How to Set page
margins (top, left, etc) to zero or some fixed values rather than rely
on user? For this do i need to have ui-dll? which source code i need to
look at? is it oemui or psuirep?

Thanks in advance

jrc

Regards,
jrc

I’m not sure this is the best place to ask such a question, because
printer drivers aren’t really kernel drivers (even when they actually
lived there).

I’ll answer what I can, though. I don’t know of any printer-specific
forums / newslists, unfortunately.

One caveat- I’m not intimate with UniDrv- all of my professional work
[with one or two very small exceptions] was with the core driver model
underlying it.

>Can I Send message to my UI from oemuni.dll–oemenddoc()?

The UniDrv UI already processes DrvDocumentEvent. Use
IPrintOEMUI2::DocumentEvent if you want to filter this behavior
yourself.

>Can I do CreateProcess from oemuni.dll–oemenddoc() ?

Yes. In fact, you can do just about anything you want to in terms of
API- this is user mode.

But I’d consider it a method of last resort. It can lead to
“interesting times” when you step outside the architected usage models.

>Do i Need to write Ui-plugin dll for printer driver? if so which
>source code of DDK,XP, i need to look up? and which functions i need
>to override?

My best guess at a sample is oemui [don’t know the samples], and the
interface above is the one you want to override.

>Which approach should be taken into account?

I don’t fully understand what you are trying to accomplish. Perhaps I
got lucky and already answered it for you?

>I also want to have my bmp file to be fixed height/width based on
portrait mode or landscape mode ? how to achive this? How to Set page
margins (top, left, etc) to zero or some fixed values rather than rely
on user? For this do i need to have ui-dll? which source code i need to
look at? is it oemui or psuirep?

The GPD file is generally enough to control most of this sort of thing.
You only need a UI plugin when you’re providing choices beyond what
UniDrv supplies, not restricting choices- or when you want your own
because you think the one in the OS doesn’t match your vision of the
perfect UI. By default, UniDrv will only present choices you say exist
in the GPD.

The margins (“printable area” is the preferred term) and resolution are
reported in the GDIINFO returned at DrvEnablePDEV time. There is a
printOEMUni override for this. These do have to be consistent with
resolutions and paper information reported by the UI side, but if you
use the GPD, none of that should matter to you.

Even if you change the printable area, the app is still free to draw
wherever it wants, effectively making it the final arbiter of margins.
You’ll just wind up with a blank area in your bitmap if your effective
margins are smaller than the app wants to use.

Thanks a lot bob.

I have seen many post regarding bitmap printer driver on this forum by ashwin n many other gurus. That was the sole reason for posting it here.

What i want to do is bitmap printer driver, which needs application name (which has init print), document name( in startdoc) and page no of page being printed ( still dont know how to get that)… up on completion of printing, driver should notify one application that it has completed printing so that it can load bmps in UI.

Can u provide me pointers to missing parts?

thanks anyway.

jrc

For some reason, every attempt to reply from my mail program gets bounced saying I provided an attachment (which I didn’t).


What do you mean by “completion of printing”? Is it when the printer driver has completed its task? Or when the pages are actually sitting in the printer? The printer driver itself doesn’t and can’t know anything about the latter event. The hook I mentioned to you covers the first event (the printer driver has finished rendering the job).

Since the job could be going into a long print queue or even get printed to a held print queue, I’m guessing you actually want the latter info, in which case, there is a different and rather flawed solution.

In that case, your app (which can be completely independent of the driver) wants to use the Win32 print API FindFirstPrinterChangeNotification, FindNextPrinterChangeNotification and FindClosePrinterChangeNotification. The first creates an object upon which you wait- when signaled, you then call the second to see what the event was that occurred, and you use the last when you are done. It is not a very easy API set to use, though, IMO.

Also, while it will tell you the values of the fields “Total Number of Pages” and “Pages Printed”, these values will only be seen if someone (typically the print processor) reports those values. In practice, this means they are only valid when the print pass spools EMF, or a language monitor which can parse page boundaries out of RAW data is used (the latter is a theoretical possibility, but I don’t know if it’s been reduced to practice- Windows Printing System used such a monitor, but I don’t believe it updated these fields).

Otherwise, only the byte size and progress fields are going to be updated. The document event hook I pointed you to can count page events (start page or end page- the bitmap driver is a banding driver, and IIRC One of these isn’t called for a banding driver, but I can’t remember which). But if you print to a busy or held queue, it will look weird when a bunch of pages print, and it’s then a half hour (example, could be anything, including never) before you show the print job being finished.

Getting the app name is also problematic. Best guess I have is you use a NULL handle to get the process file name while your printer driver is rendering- if you did this at startdoc time, then you get back the job ID, and can pair the two together so you can track them somehow as the job wends its way through the print subsystem. IF the EXE name isn’t what you want (and I recall times when apps would spawn a second process in order to print), then I have no answer. It isn’t as easy as it sounds.

Hi Bob,

Thanks a lot.

By Completion of printing, i meant OemEndDoc called from driver for one job.

Thanks for valuable suggestion of XXchangenotification APIs, i will try to implement that.

By GetJob() with job-info-1, total no.s of page in docuemtn/page printed can be found. But i want to know which page is being print? that is say from word only page#4 is printed, in such case i want 4 as page no. right now implicit counter is there to maintain filename.

Just wondering, In Notepad, they allow footer text “page &p”, which gives page 4 in printed page/image. So is it managed by application? i want almost same thing in driver.

Getting app name, in OemStartDoc, i get document name and with job id, how can i get exe name. say notepad.exe…when printing done from word then i get something like “ms word- document.doc”…

Thanks a lot.

jrc

For page #:

In a monolithic driver, you can hook the DrvStartPage/DrvSendPage DDIs.
Don’t know if there is a unidrv equivalent.

ScottR

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Wednesday, September 13, 2006 1:28 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Help on Print Finish Event

Hi Bob,

Thanks a lot.

By Completion of printing, i meant OemEndDoc called from driver for one
job.

Thanks for valuable suggestion of XXchangenotification APIs, i will try
to implement that.

By GetJob() with job-info-1, total no.s of page in docuemtn/page printed
can be found. But i want to know which page is being print? that is say
from word only page#4 is printed, in such case i want 4 as page no.
right now implicit counter is there to maintain filename.

Just wondering, In Notepad, they allow footer text “page &p”, which
gives page 4 in printed page/image. So is it managed by application? i
want almost same thing in driver.

Getting app name, in OemStartDoc, i get document name and with job id,
how can i get exe name. say notepad.exe…when printing done
from word then i get something like “ms word- document.doc”…

Thanks a lot.

jrc


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

quote>
By GetJob() with job-info-1, total no.s of page in docuemtn/page printed can be found.
[/quote]

IIRC, JOB_INFO_x page counts are only valid if someone [usually named “you”] maintains them [i.e., calls SetJob API with the updated information]. If you do a lot of printing, you must have noticed the spooler UI sometimes displays byte progress and other times pages? This is because usually, only one or the other of these progress indicators is maintained. Pages with EMF, bytes with RAW.

Total pages may be correct, though- UniDrv may already do this on your behalf.

There is simply no ironclad way to do this. Only the app knows anything about pages- many apps print but have no such concept (notepad, for example, is one big text chunk). All you can do is count pages you are given (using the StartPage/SendPage hooks, again with the caveat that in a banding driver such as the bitmap driver is, only one of these will get called, and I cannot remember which it is- hook both and see which gets called- easy enough experiment). If the app is printing in reverse order, you will number the pages backwards. If it is printing even/odd for manual duplexing from the app, then the front and back of each page will have the same number. You cannot win this game in an automated way.

If you can live with all those limitations, then count them at the hooks.

Don’t use them in your printer driver. I could not tell if you are trying to do these things in the driver or in an outside application. If you have some kind of separate application, then these are what you should use. Attempting their use in a driver will most likely hang the printing app and maybe even more than that, because you will be waiting for events that can’t happen until you finish waiting and let the rest of the subsystem run.

The document name is a string the app gives you. It can even be blank. You can’t safely use it for anything other than a readable label to show somewhere.

As I tried to say before, the following snippet will give you the name of the process the driver is running in at startdoc time [please read the API documentation and make sure you understand what the caveats about long and short names and paths mean- basically you’re going to have to parse this name, and may also have to change forms to get what you want].

Static WCHAR Process[MAX_PATH * 2];
GetModuleFileNameW(NULL, Process, MAX_PATH * 2);

This approach also has two weaknesses I know of: If you are using a multipass spooling technology (such as EMF spooling, available from 95->Win2003 [don’t know about Vista and don’t want to, at the moment]), then this app is going to be the spooler process half the time. There have also been commercial apps, and probably still are, which print from a different process than the one the user sees [cheap form of crash protection from buggy printer drivers, among other things].

Hi bob,

Thanks a lot for your help.

I was going to use XXXnotification in UI application to create monitor directory kind.

Thanks for advice on not relying on pwszdocname param of OEMStartdoc()…i will get that from job id. and will attempt to get application name via API u suggested…Thanks.

For perticular page no. i think sattle with not getting or just counter StartPage/SenPage,

jrc

>Thanks for advice on not relying on pwszdocname param of OEMStartdoc()…i will
get that from job id.

I may not have been clear about this: pwszdocname is a string the application provides when it calls StartDoc or uses the STARTDOC escape. It can be anything, including NULL. Printing components (such as print processors and monitors) are expected to pass this along as the job gets processed. So the one you get from the Job API isn’t going to be any different than the one you see at OEMStartDoc.

All I meant is that while many apps identify themselves in the document name, you cannot rely upon this behavior- nobody requires it of all apps. There are printer test suites which specifically look to break your driver by passing a NULL name, for instance (I do not know if they are in the HCT).

Hi all,

bitmap driver for windows XP is working fine now…

Now i want same to be run on 9x/ME… i think for this i need to write the same using 98ddk and on win98…i’ve got the 98ddk,98 machine and vs6…but i read in help it will not work togather(vs6 n 98 ddk)…
What should be done to develop driver on 98.
how can i compile cbitmap source to driver?

please forgive me if very stupid thing asked…i believe i m lost completely :frowning:

thanks in advance

jrc

You need to use MSC V1.52 for 16-bit printer drivers. I don’t think it
is available on MSDN any more, you’ll probably have to find an old
CD/DVD.

I also don’t think cbitmap will back-port at all, but then I’m not a
unidrv person.

ScottR

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Wednesday, September 27, 2006 9:08 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Help on Print Finish Event

Hi all,

bitmap driver for windows XP is working fine now…

Now i want same to be run on 9x/ME… i think for this i need to write
the same using 98ddk and on win98…i’ve got the 98ddk,98 machine
and vs6…but i read in help it will not work togather(vs6 n 98
ddk)… What should be done to develop driver on 98. how can i compile
cbitmap source to driver?

please forgive me if very stupid thing asked…i believe i m lost
completely :frowning:

thanks in advance

jrc


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

The 9x/ME printer driver model is completely and totally incompatible with the 2K/XP model. Among other things, it requires 16-bit code and data segments.

If the sample you are referring to is a 9x/ME driver, then you may still be able to get the VC 1.52 compiler from Microsoft (perhaps someone here remembers how- I keep one at home for those rare opportunities I want it [kind of like the old DOS images with edlin and debug I still have]).

If you are trying to use the XP driver’s source, forget it. It simply will not ever work for you. Not only is the bitness different, the graphics interfaces are also completely and radically different.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Wednesday, September 27, 2006 6:08 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Help on Print Finish Event

Hi all,

bitmap driver for windows XP is working fine now…

Now i want same to be run on 9x/ME… i think for this i need to write the same using 98ddk and on win98…i’ve got the 98ddk,98 machine and vs6…but i read in help it will not work togather(vs6 n 98 ddk)…
What should be done to develop driver on 98.
how can i compile cbitmap source to driver?

please forgive me if very stupid thing asked…i believe i m lost completely :frowning:

thanks in advance

jrc


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Robins, Scott wrote:

You need to use MSC V1.52 for 16-bit printer drivers. I don’t think it
is available on MSDN any more, you’ll probably have to find an old
CD/DVD.

Actually, and perhaps surprisingly, Visual C++ 1.52 is still available
from the MSDN subscriber download area.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Well, he’s all set then. Just a recompile :slight_smile:

ScottR

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Wednesday, September 27, 2006 1:14 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Help on Print Finish Event

Robins, Scott wrote:

You need to use MSC V1.52 for 16-bit printer drivers. I don’t think it

is available on MSDN any more, you’ll probably have to find an old
CD/DVD.

Actually, and perhaps surprisingly, Visual C++ 1.52 is still available
from the MSDN subscriber download area.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer