Skip to content

Instantly share code, notes, and snippets.

@kubicek
Created March 20, 2009 22:27
Show Gist options
  • Save kubicek/82621 to your computer and use it in GitHub Desktop.
Save kubicek/82621 to your computer and use it in GitHub Desktop.
/usr/local/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=ljet4 -sOutputFile=- /home/kubicek/margin.ps - | /usr/local/libexec/tray_select.rb -L
source_pdf=$1
pages_count=`pdftk $source_pdf dump_data | grep NumberOfPages | awk '{print $2}'`
echo "Processing $pages_count pages"
if test $pages_count -eq 1
then
echo "Printing first page"
cat $source_pdf | lpr -Pir1022_lower_tray
fi
if test $pages_count -gt 1
then
echo "Printing first two pages"
pdftk $source_pdf cat 1-2 output - | lpr -Pir1022_lower_tray
fi
if test $pages_count -gt 2
then
echo "should print some pages on white paper"
echo "printing aditional pages"
pdftk $source_pdf cat 3-end output - | lpr -Pir1022_upper_tray
fi
#!/usr/local/bin/ruby
data = $stdin.read
case ARGV[0]
when "-L": print "\e&l4H" # Lower
when "-U": print "\e&l1H" # Upper
else print "\e&l2H" # Manual
end
print "\e&l1S" # DUPLEX
puts data[2..-1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment