Impossible to print .doc or .ppt in PDF with cups/cups-pdf
Louis-Marie de Langlois
kakt at free.fr
Wed Jul 15 07:54:58 PDT 2009
Hello everyone,
After a few weeks of tests and searchs I'm calling for help with this problem.
I have a Server with Lenny Debian, with cups and cups-pdf installed. After a while I've managed to print (in PDF, with the lp /tmp/*file* command) .txt files and .jpg images, but I can't print .doc or .ppt : no errors are printed and I have a blank 2kb pdf file.
I tried loads of methods, using or not cups-pdf, and the last one (not using cups-pdf but a customized backend file) is on the following page, http://www.novell.com/coolsolutions/feature/17636.html, and I always have the same result : a blank PDF.
I tried a2ps too, it works with text files and images but when I try .ppt or .doc I have a huge file with a lot of unwanted characters, whatever encoding I'm trying to use.
My /etc/cups/cupsd.conf file is the following :
LogLevel warning
SystemGroup lpadmin
# Allow remote access
Port 631
Listen /var/run/cups/cups.sock
# Show shared printers on the local network.
Browsing On
BrowseOrder allow,deny
BrowseAllow all
DefaultAuthType Basic
<Location />
Allow From All
# Allow remote administration...
Order allow,deny
Allow all
</Location>
<Location /admin>
Allow From All
# Allow remote administration...
Order allow,deny
Allow all
</Location>
<Location /admin/conf>
Allow From All
AuthType Default
Require user @SYSTEM
# Allow remote access to the configuration files...
Order allow,deny
Allow all
</Location>
<Policy default>
<Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job CUPS-Move-Job>
Require user @OWNER @SYSTEM
Order deny,allow
</Limit>
<Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default>
AuthType Default
Require user @SYSTEM
Order deny,allow
</Limit>
<Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After CUPS-Accept-Jobs CUPS-Reject-Jobs>
AuthType Default
Require user @SYSTEM
Order deny,allow
</Limit>
<Limit Cancel-Job CUPS-Authenticate-Job>
Require user @OWNER @SYSTEM
Order deny,allow
</Limit>
<Limit All>
Order deny,allow
</Limit>
</Policy>
And here is my backend file /usr/lib/cups/backend/pdf-writer:
#!/bin/sh
#################################################################################
#
# File: pdf-writer
#
# Description: A simple PDF Writer for CUPS
#
# Copyright: (c) 2006 Axel Schmidt, SUSE LINUX GmbH, Nuernberg, Germany
# (c) 2001 Michael Goffioul (kdeprint <at> swing <dot> be)
#
# License: GPL
#
#################################################################################
PS2PDF=`which ps2pdf`
DATE=`date +%Y-%m-%d-%H:%M.%S`
# USERMODE="on" changes PDFPATH to "$HOME/<user-name>/PDF"
#
USERMODE="off"
DEFGROUP="users"
HOME="/home"
JOB=$1
PRTUSER=$2
# Create user based file name
#
create_user_fname()
{
if [ "$PRTUSER" != "" ]; then
FILENAME="$PDFPATH/$PRTUSER-$DATE.pdf"
logger "pdf-writer: \"$PRTUSER-$DATE.pdf\" was placed in: $PDFPATH"
else
FILENAME="$PDFPATH/$DATE.pdf"
logger "pdf-writer: \"$DATE.pdf\" was placed in: $PDFPATH"
fi
}
# Check DEVICE DISCOVERY + test PS2PDF
#
if [ "$JOB" = "" ]; then
if test -f "$PS2PDF" ; then
echo "network pdf-writer:/export/share/pdf \"unkown\" \"pdf writer\" "
logger "pdf-writer: INFO: USERMODE=\"$USERMODE\""
if [ "$USERMODE" = "on" ]; then
logger "pdf-writer: CUPS user must be set to root with USERMODE=\"on\"!"
fi
exit 0
else
echo "Error: $0 - ps2pdf is not available!"
logger "pdf-writer: ERROR: ps2pdf is not available!"
exit 1
fi
fi
logger "pdf-writer started: $1 $2 $3 $4 $5 $6"
# Check number of command line arguments
#
if [ $# -ne 5 -a $# -ne 6 ]; then
echo "Usage: $0 job-id user title copies options [file]"
logger "pdf-writer: CRITICAL: Printer stopped !"
exit 1
fi
# get PDF-WRITER directory from device URI
#
PDFPATH=${DEVICE_URI#pdf-writer:}
# Create output filename based on user name and user mode
#
if [ "$USERMODE" = "on" -a "$PRTUSER" != "" ]; then
mkdir -p $HOME/$PRTUSER/PDF
chown $PRTUSER $HOME/$PRTUSER/PDF
# check if cups run as lp or root
# user lp may not run chown
#
if [ $? -eq 1 ]; then
create_user_fname
else
chgrp $DEFGROUP /home/$PRTUSER/PDF
PDFPATH=$HOME/$PRTUSER/PDF
FILENAME="$PDFPATH/$DATE.pdf"
logger "pdf-writer: \"$DATE.pdf\" was placed in: $PDFPATH"
fi
else
create_user_fname
fi
# Check write status
#
if [ ! -d "$PDFPATH" -o ! -w "$PDFPATH" ]; then
logger "pdf-writer: ERROR: directory $PDFPATH not writeable"
exit 1
fi
# Run ps2pdf (ghostscript)
if [ $# -eq 6 ]; then
$PS2PDF $6 $FILENAME >& /dev/null
else
$PS2PDF - $FILENAME >& /dev/null
fi
# Chown + set permissions for the user
# Note: this will no work if CUPS runs as lp
if [ "$PRTUSER" != "" ]; then
chmod 644 $FILENAME
chown $PRTUSER:$DEFGROUP $FILENAME
fi
exit 0
#
######################### CUPS pdf-writer ends here ########################
#
Thank you for your attention, please ask for details if this post needs more, and excuse my sloppy English.
More information about the cups-devel
mailing list