views:

2743

answers:

7

I want to create a virtual printer driver for Windows. Where should I start? The WDK has some printing drivers examples, but nothing I can use. MSDN doesn't seem to be very helpful.

There are a lot of virtual printers for Windows out there (mostly they generate PDFs), how do they do it?

Any links to the documentation I seem to miss are appreciated.

Thanks.

+6  A: 

When I did it (which about 12 years ago) I started with the postscript driver sample, replaced all the postscript-specific stuff (in my case, to write to a bitmap instead of generating postscript commands).

I also wrote a custom print monitor (the driver writes to the spooler, which write to a monitor): my monitor wrote to a file instead of e.g. to the parallel port.

However, printer driver architecture and/or the set of sample drivers may have changed since then.

ChrisW
They have changed - userspace nowadays.
MSalters
Userspace only in post-Vista -- I need to support Windows 2000.
Terminus
+2  A: 

One of the drivers you mention is open-source (GPL), maybe you could explore its source or adapt it: http://www.pdfforge.org/products/pdfcreator/download

JCCyC
Unfortunately (most of it?) is written in Visual Basic. If there were one written in C/C++... :-).
Terminus
That may not be the printer driver; its directories like "Version 0.9.8\Printer\Adobe\WinXP2k3-x86\English" are empty, so far as I can see, except for a readme. Maybe the VB is some kind of front end to GhostScript, available separately.
ChrisW
The contents of "Version 0.9.8\Printer\Adobe\WinXP2k3-x86\English\readme.txt" is "psui.dll", "pscript5.dll", and "pscript.hlp"; these filenames suggests to me that these driver files too were created from the postscript sample driver.
ChrisW
+3  A: 

You can look to the 'minidriver' development in the from Microsoft (Microsoft MDT), that might help depending on your exact needs. If the port you need to deal with (ie: you are going to take the data from an existing printer driver and want to process) you could look to the source code for RedMon. It doesn't support Vista/Win7 but might point you in the right direction.

Douglas Anderson
Yes, the 'virtual' (non-hardware) part is the monitor not the driver. The driver controls the format of the output (not the output's location/destination)
ChrisW
+2  A: 

This book maybe help you Developing Drivers with the Windows® Driver Foundation

A list of my links

http://www.codeproject.com/KB/system/driverdev.aspx
http://www.microsoft.com/whdc/ddk/winddk.mspx
http://jungo.com/wdusb.html
http://msdn.microsoft.com/en-us/library/ms791686.aspx
http://channel9.msdn.com/posts/Rory/Driver-Development-and-Much-More-With-Mike-Calligaro/
pho3nix
Well, I already have that book. The problem is not developing drivers, the problem is finding specific information relevant to developing the kind of Virtual Printer drivers that I want.
Terminus
+1  A: 

Someone else already mentioned PDFCreator. Here's a more specific link to their code that's creating the printer, port and monitor. Despite being in VB, I can follow it as someone more used to C++, so I guess you can too. modPrinter.bas does the leg work. modMain.bas, from about line 28 onwards, calls into modPrinter.bas.

Jon Bright
+1  A: 

PDF forge is the way to go >>

Gaurav M
A: 

Create a Print Port Monitor, associate that port with a printer, and you'll get the data the printer driver sends to the port.

working example of how is it done in Cpp and java can be found here: http://www.mms-computing.co.uk/uk/co/mmscomputing/device/printmonitor/index.php