[WinPrnDev] Re: Creating a Printer Driver

Hi Sam,

I wouldn't get caught up in the Operating System environment yet. The only
thing to remember about the Driver is 32BIT and 64 BIT. Primarily Windows
comes with a standard PScript.dll developed by Adobe for Microsoft and I
would always recommend using this first. So the only thing to design is a
suitable PPD file ( this is specific PostScript controls and what you want
to support Trays, Colour, Papersize, Duplex etc. ).
A printer driver consists out of a few basic components.

for Windows 2000, Windows XP, Windows Vista, Windows 2003, Windows 2008 32BIT

MYPPDFILE.PPD - This is the definitions file
PSCRIPT5.DLL - This is the Actual PostScript Driver
PS5UI.DLL - This provides the User Interface to Driver supporting the PPD
PSCRIPT.HLP - Helper file that supports the UI

Now you can wrap this up into a .inf file ( references the different parts
), so a user can install manually if required. I would advice installing
programatically as the experience for the user is better.
You will now need to learn about PrinterInfo_2 structure, CopyFile and
AddPrinter. AddPortMonitor etc.

YES, I wrote my own interfaces and driver using the NTDDK ( Win32 Drivers
Development Kit ). The developed a wrapper that installs the printer
driver with all references and files. Unfortunately this isn't always well
documented in the MSDN, but use this site as reference. If I remember
correctly there are a few great articles.

64 BIT is a different animal and one I still need to master. Primarily
there seems to be a control file and driver needs to be signed. Not sure
why this needs to be..
Personally I don't think the Driver needs to be 64BIT as this doesn't make
much sense, BUT I think they wanted to control driver support thus forcing
new developments.

A Portmonitor manages the output from the driver. Think of it as a hose
pipe. The tap opens, the HOSE ( which is the driver ) could be thin, red,
twisted etc. and the sprinkler or nossle is the portmonitor. Its main
purpose is the manage what to do with the output from driver ( LPT1, File,
TCP/IP Printing ).
You have always seen a Portmonitor with Windows Select a Printer Driver,
go to properties then select ports.

A PostScript Parser can become a very complexed thing. The first thing to
do before undertaking this task is to understand PostScript. As a
reference, grab the RED BOOK from Adobe. Understand the various operators
( functions ) that PostScript uses to detail STRINGS, BINARY, IMAGES. The
main thing to remember is that a PostScript operator loads and reads
everything from a stack memory block and outputs that memory reference
when it gets showpage. Everything in PostScript tends to be described as
straight lines and cubic Bézier curves.
The language syntax uses reverse Polish notation so read from right to left.
BUT First go to:

I would say Fonts is the most complexed part of PostScript as this can be
done in many ways, Hints are traditionally the de facto and the concept
was to minimise the file size by describing every character in the
dictionary to be used. You could also subset an existing dictionary (
redefine a section of characters ). This is where PostScript shows it
dynamic approach to everything as everything can be extended as long as it
adheres to the operators described and within the stack memeory size.

As always I could go on forever promoting and describing PostScript but
the best way to deal with a scripting language is to play with it. Once
you understand the principles then you can figure out "How to I place
marks within an existing PostScript File". The first thing to remember is
PostScript is interpreted from Top to Bottom. So you could place a White
Box over existing text then place replacement Text ontop.

Here is one I use every day..
gsave initclip
[0 0 0 0 0 0] currentmatrix initmatrix
0 842 translate
180 rotate -1 1 scale
548.00 340.00 moveto 548.00 546.40 lineto 680.20 546.40 lineto 680.20
340.00 lineto 536.00 340.00 lineto
1.000 1.000 1.000 setrgbcolor
setmatrix grestore
gsave initclip
[0 0 0 0 0 0] currentmatrix initmatrix
0 842 translate
180 rotate -1 1 scale
0 setlinecap
0.000 0.000 0.000 setrgbcolor

555 488 moveto
28 0 rlineto
1.3 setlinewidth
555 464 moveto
28 0 rlineto
1.3 setlinewidth
555 476 moveto
28 0 rlineto
1.3 setlinewidth
555 452 moveto
28 0 rlineto
1.3 setlinewidth
555 404 moveto
28 0 rlineto
1.3 setlinewidth
555 476 moveto
28 0 rlineto
1.3 setlinewidth
555 452 moveto
28 0 rlineto
1.3 setlinewidth
555 404 moveto
28 0 rlineto
1.3 setlinewidth
setmatrix grestore

Happy reading..
Hope it helps!

> Hey Clinton
> Sorry for the late reply but Iw as rebuilding my PC with Windows 7 because
> I heard that it is better as a printer driver building enviroment.
> I have read your email and have a few questions:
> 1) Did you use WDK to develop your driver? Did you write your driver
> yourself?
> 2) How do I start devloping this PostScript parser? and since its
> Postscript does it mean that I wont be ableto print to PCL drivers? Or
> willconverting it to PDF do the trick?
> 3) I have no idea what you mean by using Port monitors, is there any
> reference I can go back to and learn from?
> 4) I think for testing purposes we might have to assume no errors and get
> the actual driver working before installing checks to look for errors
> I just feel really lost and overwhelmed, where is the best place to start?
> RegardsSam
> From: clinton@xxxxxxxxxxxxxx
> To: winprndev@xxxxxxxxxxxxx
> Subject: [WinPrnDev] Re: Creating a Printer Driver
> Date: Sun, 28 Mar 2010 10:32:58 +0100
> Hi
> Sam,
> I'm doing this off the
> tail end of what seems like a long discussion.
> Not sure if you have
> your answer yet but might have a few design ideas for you.
> What you are trying to
> achieve has been done before and is possible.
> Back in 2002 I was faced
> with a similar issue. Getting a document off the client PC and sending it
> round
> the world to an unknown print server.
> The solution is a
> combination of technologies that each do their own part..
> 1.) I used a PostScript
> print driver ( Generic PPD will do the job ) that pass the print stream
> onto a
> portmonitor ( this gives you the control to assign to random filename and
> pass
> onto the next module either WebService or in my case a socket service
> client ).
> If you are to allow for
> duplex, orientation, colour etc, then you will need to gather this info
> and
> "drag" it along. I developed a PostScript parser that drives through the
> spool
> file ( PostScript ) extracts these bits and then passes this with the file
> along
> ( make use of network sockets and send as parameters or HASH index - a
> WenService or Socket listener would need to manage these parameters ). OR
> in the world of WebServices pass over an XML stream that can be
> managed.
> On the "Server" side
> either convert to a generic format i.e. PDF which then can be converted
> over to
> MOST printer specific languages
> 2.) Develop a
> portmonitor that manages the spoolfile and controls calling the "service
> client"
> either webservice or sockets. Remember to remove the file and close
> portinfo
> thus removing the JOB off the print queue.
> 3.) The bigest problem
> with transmitting data around is that we forget about the wonderful worl
> of
> TCP/IP packets and ERROR checking. What happens if network goes down
> during
> transmission, do I restart, fail, notify user or cycle through a number of
> socket trying to establish connection.
> Hope this helps for
> starters.
> Clinton
> Bessesen
> check out www.pdqit.com
> _________________________________________________________________
> Do you have a story that started on Hotmail? Tell us now
> http://clk.atdmt.com/UKM/go/195013117/direct/01/

Questions? First check the UndocPrint pages at 

To unsubscribe, visit the List Server page at 

Other related posts: