Print pdf file directly without opening it?

Solution 1:

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.

Solution 2:

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.