Hacker News new | ask | show | jobs
by angrygoat 2342 days ago
I think the issue here is the question that should be being asked is: "is this a postscript file?". `file` answers a different question, "what is the most likely type for this file?"
1 comments

There is no perfect heuristic here, because what if you, for example, want to print a plain text file that happens to be PostScript?
In most cases, you can't print plaintext easily to a printer, it needs some format like PS, so your PS file would be converted into a PS script that outputs your PS file.
Are you sure? I am pretty sure a lot of printers support text directly, they use control codes for additional capabilities.
I'm fairly certain (minus Linefeed Printers of the old days) most modern printers are either Host-rendered (ie, the host renders text and tells the printer what to print) or use something like PCL, which even in the most plaintext mode, still requires some setup to describe and format the page.

You can't just pipe a textfile into printer port and hope your printer spits out anything useful.

I'm not sure if there's a different process involved here, but I vaguely remember that a recent network printer I had came with an ftp server that could be used to print, simply by dropping supported files into it. I never experimented with it, though, so I have no idea if it supported simple text files or required PostScript or some such.
It most likely converted incoming files whenever necessary.
I remember the bad old days of only 10-20 years ago when it wasn't unheard of to send a document to the printer, then walk over to discover a zillion pages of plain text starting with %!PS-Adobe-3.0.