2

I am trying to implement a backend to create a PDF printer using cups in freebsd. So far i am successful in creating a printer using a backend but the printer status is always idle and and not accepting any print jobs at all.

here is what i did so far,

I have used Allow All permission for both <Location /admin> and <Location /> in Cups configuration file, cupsd.conf for the testing purpose.

After that I have created a new file called pdf in backend directory under lib/cups/backend. In my pdf file I am using the following code,

#!/bin/sh
# -------------------------------------------------------------------
# "/usr/lib/cups/backend/pdf":
# -------------------------------------------------------------------
# I have modified the following link with the correct link where my 
# ps2pdf.cups is
PDFBIN=/usr/lib/cups/pdf/ps2pdf.cups
FILENAME=
# filename of the PDF File
PRINTTIME=`date +%Y-%m-%d_%H.%M.%S`
# no argument, prints available URIs
if [ $# -eq 0 ]; then
  if [ ! -x "$PDFBIN" ]; then
    exit 0
  fi
  echo "direct pdf \"Unknown\" \"PDF Creator\""
  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
# generate output filename
OUTPUTFILENAME=
if [ "$3" = "" ]; then
  OUTPUTFILENAME="$PDFDIR/unknown.pdf"
else
  if [ "$2" != "" ]; then
    OUTPUTFILENAME="$PDFDIR/$2-$PRINTTIME.pdf"
  else
    OUTPUTFILENAME="$PDFDIR/$PRINTTIME.pdf"
  fi
fi
# run ghostscript
if [ $# -eq 6 ]; then
  $PDFBIN $6 $OUTPUTFILENAME >& /dev/null
else
  $PDFBIN - $OUTPUTFILENAME >& /dev/null
fi

# Make the file visible (but read-only except for owner);
# This is only needed when the username ($2) is not set,
# for instance when printing a test page from the web interface.
chmod 644 $OUTPUTFILENAME


if [ "$2" != "" ]; then
      chown $2 $OUTPUTFILENAME
      chmod 700 $OUTPUTFILENAME
fi
exit 0

# EOF
# -------------------------------------------------------------------

Sourced from http://alien.slackbook.org/dokuwiki/doku.php?id=slackware:cups#pdf_printer_scripts

and Starting the printer using the following command,

lpadmin -p pdfprinter -v pdf:/var/spool/pdf/ -D "Generate PDF files" -E -P /home/pdfTest/disteller.ppd

I have also set the permission of myy backend pdf file to 755 and have also tried 775 and 777 but the printer status at localhost:631/printers is always idle.

When i click on "Print a Test Page" from localhost:631/printers

it shows the following error,

Print Test Page pdf Error

Unable to print test page:

No such file or directory

Can anyone tell me what i am missing here ?

Riley Willow
  • 143
  • 1
  • 1
  • 5

0 Answers0