Is genprint print processor the right palce to insert a watermark ?

I am trying to add a watermark page to all print jobs on our system, printed
on any printer. If necessary we can lock down the system to only allow
access to certain printers but would prefer not to.

We already have a hooking system that can intercept the print jobs and add
text at that stage but the added text overwrites the already printed text.
Ideally I want to shrink the page sent from any application and then add the
watermark around the shrunk page.

I have modified the genprint print processor example from the DDK and can
shrink the pages, but this also shrinks the text that was added with the
hooking code.

I have tried adding text in the print processor but cannot get that to work.
I create an EMF file using the code below:

// Create an in-memory EMF file
hdcMeta = CreateEnhMetaFile(hPrinterDC, NULL, &rectDocument,
TEXT(“Test Text”))))

// The next function uses GDI calls to set up and then write to the
EMF file
WriteLabel(hdcMeta, TEXT(“LABEL TEXT”), DT_CHARSTREAM))

// Play the EMF file
GdiPlayPageEMF(hSpoolHandle, hdcMeta, &rectDocument, &rectBorder,
prectClip))

DeleteEnhMetaFile(hdcMeta);

The GdiPlayPageEMF fails with error: 1813 (The specified resource type
cannot be found in the image file).

I have looked around and now realise that the spool files are not EMF files
so this is probably why it fails.

Is there a way to add the watermark text in the print processor? genprint
does have a variable declared HANDLE hFormEMF; that seems to imply
that this feature has been thought about a little but the variable is never
used and I cannot find any guidance that refers to it.

Any suggestions or alternative approaches would be welcome.

Richard Abraham

********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

Abraham, Richard W wrote:

I am trying to add a watermark page to all print jobs on our system, printed
on any printer. If necessary we can lock down the system to only allow
access to certain printers but would prefer not to.

You might try implementing an interface dll and handling the
DOCUMENTEVENT_CREATEDCPOST event in DrvDocumentEvent. At that point,
you should be able to write the watermark directly into the DC before
anything else is written there.

I’ve done similar stuff before. All you need to do is replace the
printer driver’s “Configuration File” entry in the registry, load the
“real” interface dll in your DllMain and then forward all Dev/DrvXxx
calls to the “real” dll.


Steve Johnson