12

Currently I open the file in document viewer and select print etc. Is it not possible to right click the file and "send to" the printer?

1
  • What Ubuntu release are you using?
    – Mitch
    Jul 31, 2012 at 6:53

2 Answers 2

12

Use lpr to print PDF files directly from the command-line

I don't think you can do that directly, no. However, there's a command line program called lpr which sends pdf files directly to the printer. So if you have doc.pdf, you should be able to print it with lpr doc.pdf (assuming you're in the right folder on the command line).

You can also view the printer queue with lpq - besides the queue, this shows which is the default printer, and what its status is...

See the other answer for how to add lpr to the right-click menu.

1
  • 1
    Thanks. Is there a way to avoid that lp and lpr prints PDF annotations (like highlights)? Oct 3, 2018 at 21:06
8

Add lpr to the right-click menu

I didn't know about 'lpr' that Steve mentioned about, but I know how to add it to your right click menu, using the Nautilus Scripts function of Nautilus.

Just copy and paste the below text to Gedit:

#!/bin/bash
 
IFS_BAK=$IFS
IFS="
"
 
for line in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS; do
   if [[ "$line" = "" || "$line" = " " ]]; then
      exit
   fi
   lpr "$line"
   sleep 1;
done
 
IFS=$IFS_BAK
IFS_BAK=

Save the file as 'Send to Printer' and then, right click on it->Properties->Permissions->Tick "Allow executing file as program"

Finally, move the file under ~/.gnome2/nautilus-scripts

Now, in every .pdf file you want, you can right click on it and choose Scripts->'Send to Printer'. The command 'lpr' that Steve mentioned about will execute to the file you have selected.

7
  • Aaaargh - it doesn't work from windows shares! I print orders from a win98 program to pdf files. Then in ubuntu I print to paper.
    – HeyPaul
    Jul 31, 2012 at 8:33
  • Hm, that sounds logical, you should have mentioned that you wanted to work through windows shares, though :/ I don't know how nautilus scripts work through windows shares.... I will test it and post back. EDIT: I cannot currently test it but you could first download the pdfs from the network to your hard disk and then use the script...
    – hytromo
    Jul 31, 2012 at 8:35
  • Yes - but then I might as well just open them directly and print them!!
    – HeyPaul
    Jul 31, 2012 at 9:00
  • No, it is not the same. The failure is logical: The files are not in your PC, you can only see their filenames, how can your PC send them for printing? You can download all of them, select all of them and choose right-click->'Send to Printer'
    – hytromo
    Jul 31, 2012 at 9:20
  • I know this is really old, but for the benefit anyone else reading... If you can store the files on the ubuntu box and share that dir with the windows box(es) then this should work. Rather than storing on windows and sharing to ubuntu. Aug 5, 2014 at 8:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .