[ale] /dev/pdf

Marvin Dickens mpdickens at tlanta.com
Sat May 31 00:18:37 EDT 2003


On Fri, 2003-05-30 at 18:43, Jim Philips wrote:

> Maybe you have done it a little differently, but KDE already comes with this 
> feature.

It has a bare minimum of error control and further only spits out pdf
format version 1.2 (Acrobat 3) due to it's exclusive reliance on ps2pdf
as the engine that generates output. In addition, there is no way to
hand that backend arguements that other versions of ps2pdf (Namely
ps2pdf12 and ps2pdf13) take to address other compatibility issues.
Further, this backend is shell script (No a bad thing, but not a great
thing either). The backend I am writing for the customer is written in
perl (Cross platform usable within their corporation...) and uses
pdf::create to ensure extensibility and maintainability.
 

In short: the script shipped with kde functional, but not robust. That
is not to say it does not fill the needs of most uses: It does. However,
my client wants robust. Here is a copy of the script you are talking
about. I shamelessly admit to having studied it (Plus some other stuff
too). Considering what it does within the shell, it's amazingly short in
line count. Michael Goffioul, who wrote it is obviously very
accomplished at scripting:

#!/bin/sh
# Copyright (C) Michael Goffioul (goffioul at imec.be) 2001
LOGFILE=/tmp/pdf.log
PDFBIN=`which ps2pdf`
FILENAME= 
# this is borrowed from printpdf script for the filename
PRINTTIME=`date +%b%d-%H%M%S`

echo "Executable: $PDFBIN" > $LOGFILE
echo "Arguments: |$1|$2|$3|$4|$5|$6|" >> $LOGFILE 
echo $# $PRINTTIME >> $LOGFILE

# case of no argument, prints available URIs
if [ $# -eq 0 ]; then
	if [ ! -x "$PDFBIN" ]; then
		exit 0
	fi
	echo "direct pdf \"Unknown\" \"PDF Writing\""
	exit 0
fi 

# case of wrong number of arguments
if [ $# -ne 5 -a $# -ne 6 ]; then
	echo "Usage: pdf job-id user title copies options [file]"
	exit 1
fi 

# get PDF directory from device URI, and check write status
PDFDIR=${DEVICE_URI#pdf:}
if [ ! -d "$PDFDIR" -o ! -w "$PDFDIR" ]; then
	echo "ERROR: directory $PDFDIR not writable"
	exit 1
fi 

echo "PDF directory: $PDFDIR" >> $LOGFILE 

# generate output filename
OUTPUTFILENAME=
if [ "$3" = "" ]; then
	OUTPUTFILENAME="$PDFDIR/unknown.pdf"
else
	# OUTPUTFILENAME="$PDFDIR/${3//[^[:alnum:]]/_}.pdf"
	# I changed this to user name, and the printtime to track down who
	# printed the PDF and when, samba printing just uses nobody

	OUTPUTFILENAME="$PDFDIR/$2-$PRINTTIME.pdf"
	echo "PDF file: $OUTPUTFILENAME placed in: $PDFDIR" >> $LOGFILE
fi 

echo "Output file name: $OUTPUTFILENAME" >> $LOGFILE 

# run ghostscript
if [ $# -eq 6 ]; then
	$PDFBIN $6 "$OUTPUTFILENAME"
#>& /dev/null
else
	$PDFBIN - "$OUTPUTFILENAME" >& /dev/null
fi

# modify ownership and permissions on the file
#  - world readable
#  - owns to user specified in argument
chmod a+r "$OUTPUTFILENAME"
if [ "$2" != "" ]; then
	chown $2 "$OUTPUTFILENAME"
fi 

exit 0

_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale





More information about the Ale mailing list