"But I'm just sending data to Windows - why doesn't the Windows printer driver just take care of it?"
I probably hear that question at least a dozen times a year. Somebody wants to send Unix/Linux print jobs through Samba to a shared Windows printer and it's not working. Why not?
Well, if the printer is a so called GDI, Windows-only ( sometimes called host-based) printer, the reason is simple: you aren't giving the driver what it wants.
GDI printer drivers expect GDI data, a Microsoft format that is used both for displays and printers. It's basically a bit map of the page to be printed, but what's more important is what it is not: it isn't text, it isn't PostScript and it isn't PCL. The driver that Windows sends the GDI data to can't handle anything complicated like that; it can't convert text to graphics, can't draw lines from vector descriptions, etc. It needs GDI data and that's that.
You'd think that there would be things that convert arbitrary data (text? PostScript?) to GDI. In fact, if you are even vaguely familiar with Linux, you would immediately think that GhostScript has an output that will produce GDI. You'd be right, too, except that it's apparently only available on Windows Ghostscript. That's called "mswinpr2", and you'd use it in combination with Redmon (a Windows print redirector) to do the translation. See Creating a Virtual Postscript Printer in Windows using Ghostscript for details.
You could also use PrintFile but again, that's done on the Windows side.
You'd think that the easy way to do this would be to produce GDI output on the Linux side and then ship that through Samba to unmodified Windows machines. Or that's what I'd think anyway, and tantalizingly enough, "gs --help" lists "gdi" as one of its output formats. However, it looks to me like that produces PJL files. Unless I'm horribly misunderstanding what GDI looks like (see GDI printers under Linux), this isn't the answer.
There ARE Linux drivers for some GDI printers. These seem to be printer specific and don't solve the general problem of shipping to any old Windows shared printer. There's also a "libgdiplus" that's part of Mono; the description makes you wonder if it could be used to construct such a general purpose translator.
If anyone reading this knows more than I do about this, please do comment. At a casual glance, converting to GDI seems like the most direct method - and indeed it's what the Windows GhostScript does. I suspect the reason is that the Windows GS mswinpr2 can call upon Windows DLL's to do it's work, and that's why I wonder if Mono's libgdiplus would be the answer for that.. but I haven't been able to find out enough about that to say.
If you found something useful today, please consider a small donation.
Got something to add? Send me email.
More Articles by Anthony Lawrence © 2009-11-07 Anthony Lawrence
The less accurate your mental model of a given process is, the less accurate is any guess you make about its malfunction. (Tony Lawrence)