Print a PDF on a printer without CUPS or other driver

linux

Revision history

I think CUPS is too much. I just want to print simple files from the command line. This is how it works for me with the printers I have been connecting too.

Depending on how your printer is connected, the target to which you can pipe to will be either

In the examples below I am using a network printer and connecting to it using the following information:

$ export PRINTER_IP=192.168.0.5 PRINTER_PORT=9100

If you simply want to print plain text, you can pipe it straight through

$ echo "hello, world!" | nc -w 1 $PRINTER_IP $PRINTER_PORT

If you want to print a PDF, you most probably have to convert it to PostScript first. I use pdf2ps for this. Using - as a target filename will output to stdout.

$ pdf2ps ~/my-file.pdf - | nc -w 1 $PRINTER_IP $PRINTER_PORT

Using lp

If you want to use lp for printing, use the -h argument. Specifying - as input filename will make it read from stdin.

$ echo foobar | lp -h ${PRINTER_IP}:${PRINTER_PORT} -

References

If you have any comments or feedback, please send me an e-mail. (stig at stigok dotcom)