Writing your own printer driver is not the most easy task you can take on, but there some alternatives.
You can have a look at this article for how to use Redmon and Ghostscript
PDF Writer[
^]
Also check the comments, there are some extra information there.
Redmon lets you redirect the printer output to a virtual port, then you can write your own software and do what you want.
See also
RedMon - Redirection Port Monitor[
^]
There is something called Printer++. This might be interesting to look into as well.
See
Printer++[
^]