20

I want to create a virtual printer driver for Windows. How and where can I start properly? The WDK has some printing drivers examples that do not seems a good introductory. MSDN also doesn't seems to be very helpful for a novice.

There are a lot of virtual printers for Windows out there (mostly they generate PDFs), I wonder if someone could tell my how can I do the same?

Any links to the elaborating documentations are appreciated in advance.

Thanks.

amirfg
  • 272
  • 2
  • 6
  • 21
Terminus
  • 902
  • 2
  • 10
  • 21
  • 2
    You might get more help if you said what problem you have that is not addressed by the sample drivers. – John Saunders Jun 30 '09 at 09:35
  • 1
    They are a good starting point if you want to develop "real" drivers but they are not as helpful if all you need are "virtual", non-hardware based drivers. The bitmap sample is the most helpful, though. – Terminus Jun 30 '09 at 18:13

6 Answers6

14

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
  • 54,973
  • 13
  • 116
  • 224
3

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
  • 4,652
  • 10
  • 40
  • 49
  • 1
    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 Jun 19 '09 at 17:49
3

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

A list of my links

  1. http://www.codeproject.com/KB/system/driverdev.aspx
  2. http://www.microsoft.com/whdc/ddk/winddk.mspx
  3. http://jungo.com/wdusb.html
  4. https://web.archive.org/web/20130717135254/https://msdn.microsoft.com/en-us/library/ff554651.aspx
  5. http://channel9.msdn.com/posts/Rory/Driver-Development-and-Much-More-With-Mike-Calligaro/
Entity
  • 7,972
  • 21
  • 79
  • 122
pedrofernandes
  • 16,354
  • 10
  • 36
  • 43
  • 1
    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 Jun 30 '09 at 08:52
  • Link #4 is now broken unfortunately. What was that? – Mooing Duck Jun 09 '14 at 23:27
2

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
  • 16,140
  • 11
  • 48
  • 75
  • Unfortunately (most of it?) is written in Visual Basic. If there were one written in C/C++... :-). – Terminus Jun 19 '09 at 17:30
  • 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 Jun 19 '09 at 17:43
  • 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 Jun 19 '09 at 17:45
  • Would be more helpful to link to the source instead of the company that funds it – Mooing Duck Jun 09 '14 at 23:46
2

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
  • 13,388
  • 3
  • 31
  • 46
0

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