Print PDF from Command Line – cups-pdf, lpr -P PDF

After installing cups-pdf, you can print to file with ‘lpr -P PDF’.

Install PDF printer

$ sudo apt-get -y install cups-pdf

List printer names that lpr can understand

$ lpstat -p -d
printer deadtree is idle.  enabled since 2011-06-22T08:09:05 EEST
printer PDF is idle.  enabled since 2011-03-08T15:25:42 EET
system default destination: deadtree

This system has two printers, “deadtree” and “PDF”.

Print in a command line pipeline

$ echo "Hello from"|lpr -P PDF

By default, lpr would print to system default printer “deadtree”. Here, we instruct it to print to printer named “PDF” instead.
You can see your PDF printouts in ~/PDF/ folder.

$ ls $HOME/PDF/

You can view your PDF file with okular or evince, or browse the folder with nautilus.
Well done, you can now print PDF from the command line.
Tested with Ubuntu 10.04 LTS on 2011-11-08.
Briefly in Finnish / Lyhyesti suomeksi: Voit tulostaa PDF:n suoraan komentoriviltä. Asenna cups-pdf. Anna tulostimen nimi komennossa ‘lpr -P PDF’. Valmiit PDF:t löytyvät kotihakemistostasi kansiosta PDF/.

Posted in Uncategorized | Tagged , , , , , , | 2 Comments

2 Responses to Print PDF from Command Line – cups-pdf, lpr -P PDF

  1. antonio loria says:

    This is great!
    Is there a way to specify a path/filename.pdf for the target PDF ?

  2. Eric Pulvino says:

    Yes, you can use the -T option to name the job which will translate into a PDF name.