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 TeroKarvinen.com"|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/
job_183-untitled_document.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!
    thanks!

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

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Picks

  • Boxing Clock for AndroidOcton8 Diving T-ShirtsShaking Tower Panda Android GameLearn Chinese with Android
  • Student projects