1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
| # Define where gs is
####gs="/usr/sfw/bin/gs"
gs="/opt/sfw/bin/gs"
outdir="/home/p3rtp/SmartPdf"
if [ $# -ne 2 ]; then
echo "Usage : SmartPdf <size> <filename>
echo " size can be a3 and a4 "
echo " filename is only required if not used in the printer command"
echo " of Pinnacle"
echo " For use in Pinnacle, just make a printer with the line :"
echo " SmartPdf a4 " and select the according pagesize"
exit 1
fi
if test ! -x "$gs"; then
echo "gs is not present or not executable. Bailing out"
echo "Please try to configure SmartPdf with the correct executable"
exit 1
fi
if test ! -d "$outdir"; then
echo "Directory $outdir does not exit"
mkdir -m777 $outdir
fi
if test ! -f $2 ; then
echo "File $2 not found"
echo "$2 should be the file to be converted"
exit 1
fi
if [ "$1" != "a4" ] && [ "$1" != "a3" ] ; then
echo "The size supported at this modent is a4 and a3"
exit 1
fi
OPTIONS="-dSAFER "
GS_LIB="/usr/openwin/lib/X11/fonts/Type1"
GS_LIB="$GS_LIB:/usr/openwin/lib/X11/fonts/Type1/outline"
GS_LIB="$GS_LIB:/usr/openwin/lib/X11/fonts/Type1/sun"
GS_LIB="$GS_LIB:/usr/openwin/lib/locale/iso_8859_8/X11/fonts/Type1"
GS_LIB="$GS_LIB:/usr/openwin/lib/locale/iso_8859_13/X11/fonts/Type1"
###GS_LIB="$GS_LIB:/usr/sfw/share/ghostscript/fonts"
GS_LIB="$GS_LIB:/opt/sfw/share/ghostscript/fonts"
GS_LIB="$GS_LIB:/opt/sfw/share/a2ps/fonts"
GS_LIB="$GS_LIB:/opt/sfw/share/ogonkify/fonts"
GS_LIB="$GS_LIB:/opt/sfw/share/groff/font/devps"
export GS_LIB
## I want the in file to be the last option
infile="$2"
format="$1"
outfile=` grep "106 562" $infile | sed s/"106 562 moveto "/""/ | sed s/") show"/""/ | sed s/"("/""/ | cut -d" " -f1 `
if [ "$outfile" = "" ] ; then
{
# see if this is a print plan
outfile=` grep "131 727" $infile | sed s/"131 727 moveto "/""/ | sed s/") show"/""/ | sed s/"("/""/ | cut -d" " -f1 `"_Plan_"
}
fi
if [ "$outfile" = "" ] ; then outfile="SmartPdf"
fi
outdate=`date '+%m.%d.%y-%H:%M:%S'`
# We have to include the options twice because -I only takes effect if it
# appears before other options.
# exec causes this shell to be closed, and no further commands are taken.
# So not using exec
# exec can be given to the last command run from this shell.
# exec "$gs" $OPTIONS -q -dNOPAUSE -dBATCH -sPAPERSIZE=$format -sDEVICE=pdfwrite "-sOutputFile=$outdir/$outfile.$outdate.pdf" $OPTIONS -c .setpdfwrite -f $infile
#echo "$infile"
#echo "$gs" $OPTIONS -q -dNOPAUSE -dBATCH -sPAPERSIZE=$format -sDEVICE=pdfwrite "-sOutputFile=$outdir/$outfile.$outdate.pdf" $OPTIONS -c .setpdfwrite -f $infile
$gs $OPTIONS -q -dNOPAUSE -dBATCH -sPAPERSIZE=$format -sDEVICE=pdfwrite "-sOutputFile=$outdir/$outfile.$outdate.pdf" $OPTIONS -c .setpdfwrite -f $infile |
Partager