Saturday, August 2, 2008

5) dump to printer

Yet another option for looking at PDF files is the use of a special purpose viewing device refered to as a 'printer'. For those of you who may be unclear on the concept, 'printer's use special chemicals to permenantly lay down a copy of the image that would normally be seen on the screen onto a thin sheet of organic celluloid material ("paper"). Bulky and cantankerous at best, the quaint devices are capable of handling not only PDF files, but with appropriate device drivers, such data formats as text, jpeg, png, gif etc.

Below is a script for sending a PDF to a 'printer'. It is set to scale the file to maximize it's use of the paper, but could easily be modified to throw up a menu of scaling factors, typical might be 25%, 33%, 50%, 66%, 75% etc.


#!/bin/bash  -


# ############## security pack ##############################

PATH='/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/local/bin:/usr/games:~/bin'  ;


hash -r  ;
#  -  Bash Cookbook, 1st ed.,, #14.5

ulimit  -H -c 0 --  ;
#  -  Bash Cookbook, 1st ed.,, #14.6

IFS=$' \t\n'  ;
#  -  Bash Cookbook, 1st ed.,, #14.7

UMASK='002'  ;
umask  $UMASK  ;
#  -  Bash Cookbook, 1st ed.,, #14.8

\unalias -a
#  -  Bash Cookbook, 1st ed.,, #14.4

# ############## security pack ##############################

USAGE="$0  -h | file.pdf | file.ps  "  ;

VERSION='$Id'  ;

set -e  ;
shopt -s  nocasematch    expand_aliases  ;

# alias RM='/bin/rm  -f   2> /dev/null '  ;
# alias RMDIR='/bin/rmdir 2> /dev/null '  ;
# alias MKDIR='/bin/mkdir 2> /dev/null '  ;
# alias EZGV='exec   /usr/bin/zgv'  ;
#  alias ZGV='/usr/bin/zgv'  ;
alias LPR='/usr/bin/lpr -o scaling=100%  '  ;


THEPDFFILE=${1}  ;

case  ${THEPDFFILE}  in
[-/][h?]* )
  echo 'Usage: '${USAGE}  ;
  exit  ;
  ;;
[-/]v* )
  echo ${VERSION}  ;
  exit  ;
  ;;
*.ps )
  THETTAG=${THEPDFFILE%.ps}  ;
  ;;
*.pdf )
  THETAG=${THEPDFFILE%.pdf}  ;
  ;;
* )
  exit  ;
esac

if [ ! -f ${THEPDFFILE} ]  ; then
   echo 'File needed'  ;
   echo ${USAGE}  ;
   exit  ;
fi

LPR  ${THEPDFFILE}  ;



exit  ;

No comments: