Virtual printer driver help

Hi experts,

Newbie here, so please forgive any egregious demonstrations of stupidity on my part. If I’m missing something obvious, then I’ll gratefully accept pointers (hehe). I’m trying to do something that seems like it should be really simple, and after a good amount of poking around I’m more confused than ever… I’m clearly missing something. Let me explain what I’m trying to do in the simplest way possible. Forgive the length of the post, but I want to be as clear as I can.

Project:

I want to connect a little board (think Arduino or Raspberry PI) to my network, and “register” it as a printer. It is not a printer (it’s an arduino!) but I want it to look like a printer to my windows machines. If I print a (text-only) doc to this device I want the following to happen:

1 - convert the text doc into an XML or similar format, i.e. do some processing on the text information before it is sent
2 - once the processing is complete, transmit it to the arduino virtual printer over the network
3 - the arduino receives this input stream, and simply forwards it as an HTTP message to a server.

I know this is a pretty convoluted thing to do, but I am trying to create a “virtual” printer that can receive a doc from the print spooler but do some virtual tricks with it, rather than print it to paper. It’s possible that I’m trying to re-invent a 21st century fax machine, but there are other parts to this process that I want to get to once I’ve solved this puzzle. Later I will want to incorporate simple black and white images, but that’s a future extension.

Questions:

1- Do I need to actually write a new virtual printer driver?
2- Can I modify the already extensive existing windows printer driver to do steps 1 and 2 above?
3- If so, which driver should I be looking at, and finally
4- Can anyone point me in a direction as to how to do that?

I’m not looking to reinvent the wheel, so if I can extend/customize existing windows drivers then I’d be ecstatic. I’ve looked through the microsoft printer design guide (https://docs.microsoft.com/en-us/windows-hardware/drivers/print/) , but I have to say that I really didnt get anywhere with it. There seem to be no truly simple examples of virtual printer drivers that I can find…

Any thoughts, pointers or other advice gratefully appreciated.

Cheers!

It’s pretty easy to make yourself a network printer. You can Google to search for the available network printing protocols. LPD (port 515), JetDirect (port 9100), and IPP (port 631) should all be recognized by Windows (and the other operating systems as well). The protocol lets you advertise what format you want. Most are PostScript or PCL.

And this is not a “virtual” device – even though you don’t produce paper, you ARE a printer.

You shouldn’t really want to write a driver. Just let one of the standard drivers do it for you. You won’t get XML, but PostScript can be converted to a bitmap pretty easily.

1 Like

sage advise from Tim as usual

Hi Tim,

Such a quick response - thanks! I wasn’t expecting that. So, just to be sure that I am understanding you, your suggestion is to use one of the existing windows postscript drivers (for example) and use an existing printer protocol to act as a communication channel to the arduino. Doing it this way, also means that I should just be able to install the arduino as a printer without needing any further instruction to windows to recognise it as such.

Did I follow you correctly there?

That sounds really interesting, and I will definitely go look into that. If it turns out that I do want to pursue the custom xml route then it seems I will at some stage have to write a new printer driver to make that work, yes?

Many thanks for the advice!

Did I follow you correctly there?

Yes. Think about how existing printers work. When you have a printer on your network, the operating system can search for and drive that printer directly. It doesn’t need anything special. That works because those devices adhere to the standards. Your device is exactly the same.

… I do want to pursue the custom xml route …

Remember that Windows natively supports XPS. The XPS format is XML-based. It was invented by Microsoft to try to take over Postscript’s market share, but now it’s an open standard. It would be much easier for you to advertise XPS, and transcode XPS XML into your XML in the device. Printer drivers tend to be a headache.

Why do you want to make a non-printer pretend to be a printer? It’s much easier to pass data over a custom TCP/IP port.

It would be very odd if you really did want to implement a custom print protocol. Remember that the CR LF standard go back to the pinters and automated type writters of the 1940’s, 1950’s and 1960’s. that’s how long it takes to addopt a new printing standard

@Tim_Roberts, Many thanks again for reply, you’ve been really helpful. I was looking at the XPS format over the weekend - it may be all I need. As for why, I’m trying to build some custom peripherals that work together with a couple of third party applications. I want to take data from those third party applications (that I have no way of modifying or seeing the code for) and then transmit it to a bunch of places via these peripherals. The easiest way to get data out of these third party apps was to add a new printer (something that they already support) and then use the “printer” to route the information wherever I want it.

Trying to use TCP/IP would most likely involve having to add specific extra functionality into the third party applications so that they can communicate that way - something that I have no way of doing.

Anyway - you’ve given me a lot of good leads. I’m off to research, code and play. Cheers!