![后端PDF打印机始终显示理想状态](https://linux22.com/image/683181/%E5%90%8E%E7%AB%AFPDF%E6%89%93%E5%8D%B0%E6%9C%BA%E5%A7%8B%E7%BB%88%E6%98%BE%E7%A4%BA%E7%90%86%E6%83%B3%E7%8A%B6%E6%80%81.png)
我正在尝试实现后端以使用 freebsd 中的 cups 创建 PDF 打印机。到目前为止,我已成功使用后端创建打印机,但打印机状态始终处于空闲状态,并且根本不接受任何打印作业。
这是我目前所做的,
为了测试目的,我已经使用了Cups 配置文件中的Allow All
权限。<Location /admin>
<Location />
cupsd.conf
之后,我在backend
目录下创建了一个名为 pdf 的新文件lib/cups/backend
。在我的pdf
文件中,我使用以下代码,
#!/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
# -------------------------------------------------------------------
来源:http://alien.slackbook.org/dokuwiki/doku.php?id=slackware:cups#pdf_printer_scripts
并使用以下命令启动打印机,
lpadmin -p pdfprinter -v pdf:/var/spool/pdf/ -D "Generate PDF files" -E -P /home/pdfTest/disteller.ppd
pdf
我也将 myy 后端文件的权限设置为755
,也尝试过了775
,777
但打印机状态localhost:631/printers
始终处于空闲状态。
当我点击“打印测试页”时localhost:631/printers
它显示以下错误,
Print Test Page pdf Error
Unable to print test page:
No such file or directory
谁能告诉我这里缺少什么?