A webserver as a printer?

Solution 1:

Any host can disguise as a network printer, as long as it speaks the same protocol – that's how print servers work. Most operating systems will allow you to add a network printer by its URL.

There are a few standard print job submission protocols that are spoken by network printers – IPP (port 631), HP JetDirect (port 9100), and occassionally lpr (port 515).

Out of those, IPP is the most interesting choice for you, both because it is in fact HTTP-based (i.e. you could implement it on a webserver), and because of the 'IPP Everywhere' standard for driverless printing, which allows print jobs to be submitted in the form of standard PDF files instead of requiring a vendor-specific driver.

Implementing IPP from scratch may be complex; however, the Linux/macOS 'CUPS' software, although mostly used for local printing, is actually an IPP server at its core – it's possible that you could configure it to have a fake queue that just stores jobs on the filesystem, somehow.

And if you cannot get clients to submit jobs as "driverless" PDF files, then look for a driver that submits jobs in the PCL5 format (which Ghostscript can convert to PDF for previewing, and your printers most likely accept PCL5 straight on port 9100). At this point, you don't necessarily need to use IPP – you could also write a server that accepts the same print jobs via JetDirect or lpr instead.


Additional explanation:

Keep in mind that printing does not send the original files to the printer. Whether you're printing a PDF or a DOC or a JPEG, the client always rasterizes it into some sort of generic format, so the network printer (or your print server, in this case) only receives jobs in that final raster format – it won't know anything about the original.

That means it's not enough to implement just the network protocol – you will also need to un­der­stand the raster format that the client sends you. (This depends on the printer driver used by the client; e.g. printing through a Kyocera driver will generate KPDL-format print jobs.) This is where 'IPP Everywhere' comes in – if you want to receive PDFs, you will have to pretend to be a "driverless" printer that uses PDF as its raster format.

It also means that printing will lose all "digital" features of the original document. Even if you're printing a PDF to a PDF-based printer, you'll still most likely lose features like fillable forms or digital signatures in the process.