Read more

Linux: How to print PDF files from the command line

Arne Hartherz
April 17, 2014Software engineer at makandra GmbH

Sometimes you may want to print files from the command line, especially when you have lots of them.
You can use lp for that.

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

To print a single example.pdf file on your default printer, simply say:

lp example.pdf

lp accepts multiple filenames, so to print all PDF files in the current directory:

lp *.pdf

You can specify a printer via the -d switch:

lp -d YOUR_PRINTER_NAME *.pdf

Your printer's name is then one you defined on your system. You can check with your CUPS configuration by visiting http://localhost:631/printers. So, for example:

lp -d Brother-MFC-9840CDW *.pdf

Plain-text or PostScript files are also supported.

Posted by Arne Hartherz to makandra dev (2014-04-17 10:10)