cups/cups-pstopdf

66 lines
1.1 KiB
Bash

#!/bin/sh
# $Id: pstopdf,v 1.2 2003/01/02 15:39:26 gurubert Exp $
#
# This is a Postscript to PDF filter for CUPS
#
# (C) 2003 Robert Sander <robert.sander@epigenomics.com>
#
# Released under GPL
#
# NO WARRANTY AT ALL
#
echo "INFO: pstopdf argv[$#] = $@" >&2
if [ $# -lt 5 -o $# -gt 6 ]; then
echo "ERROR: $0 job-id user title copies options [file]" >&2
exit 1
fi
jobid=$1
#infile=`mktemp /tmp/$jobid.pstopdf.in.XXXXXX`
#if [ $? -ne 0 ]; then
# echo "ERROR: Error creating tmpfile $infile" >&2
# exit 1
#fi
#outfile=`mktemp /tmp/$jobid.pstopdf.out.XXXXXX`
#if [ $? -ne 0 ]; then
# echo "ERROR: Error creating tmpfile $outfile" >&2
# exit 1
#fi
if [ $# -eq 6 ]; then
echo "INFO: file is $6" >&2
#cp $6 $infile
#rm -f $6
infile="$6"
outfile="$infile".pdf
/usr/bin/ps2pdf "$infile" "$outfile" 2>&1 >> /tmp/pstopdf.log
else
outfile=`mktemp /tmp/$jobid.pstopdf.out.XXXXXX`
if [ $? -ne 0 ]; then
echo "ERROR: Error creating tmpfile $outfile" >&2
exit 1
fi
/usr/bin/ps2pdf - "$outfile" 2>&1 >> /tmp/pstopdf.log
fi
cat $outfile
# cp "$infile" "$outfile" /tmp/cups/
rm -f "$outfile"
exit 0