PDF printer for puppy
I tried the script in Puppy 2.16 using pakt's CUPS install v0.3 and it worked as expected (very good). I did notice that everything was "printing" black and white, but did not take time to investigate.
EDIT: I needed to change a couple of lines at the end of the script to read /etc/rc.d/rc.cups instead of /etc/init.d/cups to work with 2.16 properly.
JB
EDIT: I needed to change a couple of lines at the end of the script to read /etc/rc.d/rc.cups instead of /etc/init.d/cups to work with 2.16 properly.
JB
Last edited by JB4x4 on Tue 17 Jul 2007, 09:38, edited 1 time in total.
Is this just aimed at 2.17 at the moment?
I installed the Cups dotpup in 2.16.1, and have no /etc/init.d/cups, so get this when I run the script:
sh-3.00# ./pdf
./pdf: line 115: /etc/init.d/cups: No such file or directory
lpadmin: Unable to connect to server: Connection refused
./pdf: line 118: /etc/init.d/cups: No such file or directory
I just rebooted, and then ran the second to last line in the script again, and then rebooted again, but if someone can advise how to restart cups, then that would help other people.
I installed the Cups dotpup in 2.16.1, and have no /etc/init.d/cups, so get this when I run the script:
sh-3.00# ./pdf
./pdf: line 115: /etc/init.d/cups: No such file or directory
lpadmin: Unable to connect to server: Connection refused
./pdf: line 118: /etc/init.d/cups: No such file or directory
I just rebooted, and then ran the second to last line in the script again, and then rebooted again, but if someone can advise how to restart cups, then that would help other people.
Breaks when you cancel a job
OK.
So I installed in my Grafpup 104 install, which uses the latest CUPS dotpup. I went to print something to pdf, then on a whim pressed cancel when it asked me where to save it. Now when I try to print to pdf the job gets added to the queue, it asks me where I want to save it, and then it pauses the printer (according to CUPS). Telling CUPS to start the printer starts it, then pauses it immediately, and the job stays in the queue. If the printer was paused when I printed the job, it starts the job, asks me where to save it, then pauses the job straight away. My real printer works fine still. I never printed a page, so can't tell if the PDF printer worked to start with and is just broken because I cancelled a job.
So I installed in Puppy 2.16.1 with the same CUPS dotpup, and printed a test page (colour worked). So it definitely worked here to start with. I then printed something, but pressed cancel when it asked me where to save it, like before. Now when I print something it goes through the thing preparing it for printing, adds it to the queue, doesn't ask me where to save it, and pauses the printer. Unlike in Grafpup, if I now tell CUPS to start the printer, it starts and then pauses straight away, but does not ask where to save it. So it is impossible to get to the stage where it asks me where to save it.
More disturbingly, I then installed my real printer in Puppy (an HP PSC1610), using the HPIJS PSC1600 driver, from the same CUPS dotpup that works in Grafpup104 and in Puppy 2.02, and it does not print. Jobs go to the queue, then leave there, but the printer doesn't do anything. I don't know if this is because of the pdf thing or not because I haven't used the printer with 2.16 before, but if it isn't then it is very sad, and indicates that having CUPS in 2.17 may not be quite as wonderful as we think... ---EDIT--- My HP works in a fresh install
So I installed in my Grafpup 104 install, which uses the latest CUPS dotpup. I went to print something to pdf, then on a whim pressed cancel when it asked me where to save it. Now when I try to print to pdf the job gets added to the queue, it asks me where I want to save it, and then it pauses the printer (according to CUPS). Telling CUPS to start the printer starts it, then pauses it immediately, and the job stays in the queue. If the printer was paused when I printed the job, it starts the job, asks me where to save it, then pauses the job straight away. My real printer works fine still. I never printed a page, so can't tell if the PDF printer worked to start with and is just broken because I cancelled a job.
So I installed in Puppy 2.16.1 with the same CUPS dotpup, and printed a test page (colour worked). So it definitely worked here to start with. I then printed something, but pressed cancel when it asked me where to save it, like before. Now when I print something it goes through the thing preparing it for printing, adds it to the queue, doesn't ask me where to save it, and pauses the printer. Unlike in Grafpup, if I now tell CUPS to start the printer, it starts and then pauses straight away, but does not ask where to save it. So it is impossible to get to the stage where it asks me where to save it.
More disturbingly, I then installed my real printer in Puppy (an HP PSC1610), using the HPIJS PSC1600 driver, from the same CUPS dotpup that works in Grafpup104 and in Puppy 2.02, and it does not print. Jobs go to the queue, then leave there, but the printer doesn't do anything. I don't know if this is because of the pdf thing or not because I haven't used the printer with 2.16 before, but if it isn't then it is very sad, and indicates that having CUPS in 2.17 may not be quite as wonderful as we think... ---EDIT--- My HP works in a fresh install
Last edited by disciple on Wed 18 Jul 2007, 06:26, edited 1 time in total.
My apologies as the script was written an tested in 2.17 alpha only.
I've since done some updates and converted the script to a dotpet package.
Updates
1) Added check for location of cups start|stop|restart script (/etc/init.d/cups or /etc/rc.d/rc.cups)
2) Reduced amount of logging to /var/log/messages
3) Removed some code from the original script
4) Added additional comments
This package has been tested on successfully Puppy 2.17 alpha, Puppy 2.16 and Grafpup 2.00. Grafpup 1.04 requires that /usr/lib/cups/backend/pdf-writer be modifed as follows to fix the problem reported by disciple (which only occurs in Grafpup 1.04).
Change
to
Updated 2007/07/18, follow link below
http://www.murga-linux.com/puppy/viewto ... 067#129067
I've since done some updates and converted the script to a dotpet package.
Updates
1) Added check for location of cups start|stop|restart script (/etc/init.d/cups or /etc/rc.d/rc.cups)
2) Reduced amount of logging to /var/log/messages
3) Removed some code from the original script
4) Added additional comments
This package has been tested on successfully Puppy 2.17 alpha, Puppy 2.16 and Grafpup 2.00. Grafpup 1.04 requires that /usr/lib/cups/backend/pdf-writer be modifed as follows to fix the problem reported by disciple (which only occurs in Grafpup 1.04).
Change
Code: Select all
if [ $# -eq 6 ]; then
$PS2PDF $6 $FILENAME >& /dev/null
else
$PS2PDF - $FILENAME >& /dev/null
fi
Code: Select all
if [ $# -eq 6 ]; then
$PS2PDF $6 $FILENAME
else
$PS2PDF - $FILENAME
fi
http://www.murga-linux.com/puppy/viewto ... 067#129067
Last edited by jcoder24 on Wed 18 Jul 2007, 19:32, edited 1 time in total.
You are a legend jcoder:) I fixed the script and reran it in Grafpup 104, and now it works great. Thanks!!
Cups seemed to be permanently broken in Puppy 2.16.1, so I started with a fresh save file and installed the .pet and it works great. Thanks. This should definitely be in 2.17
Thoughts/Suggestions:
I have no idea how possible it would be to change, but I think it might be better for a print job to be deleted if you press cancel, than for it to stay in the queue and the printer to go off line. I think the current behaviour would be confusing to most users.
Also, it would be handy to have a printer option to turn off the feature to add a date to prevent overwriting a file - often people want to overwrite a file. I guess we could manually edit the script, but it would be handy to be able to turn it on or off.
Cups seemed to be permanently broken in Puppy 2.16.1, so I started with a fresh save file and installed the .pet and it works great. Thanks. This should definitely be in 2.17
Thoughts/Suggestions:
I have no idea how possible it would be to change, but I think it might be better for a print job to be deleted if you press cancel, than for it to stay in the queue and the printer to go off line. I think the current behaviour would be confusing to most users.
Also, it would be handy to have a printer option to turn off the feature to add a date to prevent overwriting a file - often people want to overwrite a file. I guess we could manually edit the script, but it would be handy to be able to turn it on or off.
This is curious. I have gtklp installed (both my systems), and I don't know if the problems are with CUPS, GTKLP, the PDF printer and/or Seamonkey/Firefox.
To change my paper size I have to change it it the CUPS web interface AND in GTKLP AND I have to restart cups, otherwise it will still print on the old size.
Printing from Firefox or Seamonkey I also have to specify the same size when I go to print it, otherwise it scales to the size specified by the browser, but puts it on the size paper specified by CUPS. How annoying. Why can't the browser dictate the paper size?
Nothing is ever simple. At least I can print to pdf now
To change my paper size I have to change it it the CUPS web interface AND in GTKLP AND I have to restart cups, otherwise it will still print on the old size.
Printing from Firefox or Seamonkey I also have to specify the same size when I go to print it, otherwise it scales to the size specified by the browser, but puts it on the size paper specified by CUPS. How annoying. Why can't the browser dictate the paper size?
Nothing is ever simple. At least I can print to pdf now
In case anybody else wants to print to pdf from CUPS from Puppy 1.x, run this and it should work ---EDIT---I can't quite figure out how to modify the script for version 0.2, so run it and then replace /usr/lib/cups/backend/pdf-writer with the attached file (make sure you unzip it)---
#!/bin/sh
#################################################################################
#
# File: pdf-writer
#
# Description: A simple PDF Writer for CUPS
#
# Copyright: (c) 2007 jcoder24 on puppylinux forum
# (c) 2006 Axel Schmidt, SUSE LINUX GmbH, Nuernberg, Germany
# (c) 2001 Michael Goffioul (kdeprint <at> swing <dot> be)
#
# License: GPL
#
#################################################################################
PS2PDF=`which ps2pdf`
# USERMODE="on" changes PDFPATH to "$HOME/<user-name>/PDF"
#
DEFGROUP="users"
JOB=$1
PRTUSER=$2
# Check DEVICE DISCOVERY + test PS2PDF
#
if [ "$JOB" = "" ]; then
if [ -f "$PS2PDF" ]; then
echo "file pdf-writer:/export/share/pdf \"unkown\" \"pdf writer\" "
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 filename from user via xdialog
# added by jcoder24
export PATH=$PATH:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/X11R7/bin
export DISPLAY=":0.0"
#cups sets an env var called USER, which we will access here
#The env variables DISPLAY (above) & XAUTHORITY (below) are needed by xdialog
if [ "$USER" = "root" ]; then
export XAUTHORITY="/root/.Xauthority"
FOLDER="/root"
else
export XAUTHORITY="/home/$USER/.Xauthority"
FOLDER="/home/$USER"
fi
FILENAME=`Xdialog --title "PDF-Writer - Save As..." --fselect "$FOLDER" 28 60 2>&1 | tail -1 | gawk '{gsub (/\.pdf$|\.PDF$/,"",$0); print $0'}`
#if user choses not to save file, exit gracefully
if [ -z "$FILENAME" ]; then
logger "pdf-writer: INFO: JOB $JOB aborted by $USER!"
exit 0
fi
#if selected file exists, append timestamp to filename
if [ -f "$FILENAME.pdf" ]; then
FILENAME="$FILENAME-`date +%m%d-%H%M-%S`.pdf"
else
FILENAME="$FILENAME.pdf"
fi
# get PDF-WRITER directory file selected
# modified by jcoder24
PDFPATH="`dirname $FILENAME`"
#logger "pdf-writer: Created pdf \"$FILENAME\"."
# 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
else
$PS2PDF - $FILENAME
fi
# Chown + set permissions for the user
# Note: this will not work if CUPS runs as lp
if [ "$PRTUSER" != "" ]; then
chmod 644 $FILENAME
chown $PRTUSER:$DEFGROUP $FILENAME
fi
exit 0
#
######################### CUPS pdf-writer ends here ########################
#
EOF_BACKEND
chmod 755 /usr/lib/cups/backend/pdf-writer
ln -sf /usr/share/ghostscript/8.15/lib/ghostpdf.ppd /usr/share/cups/model/ghostpdf.ppd
/etc/rc.d/rc.cups restart
sleep 5
lpadmin -p CUPS-PDF -v pdf-writer:/export/share/pdf/ -E -P /usr/share/cups/model/ghostpdf.ppd
/etc/rc.d/rc.cups restart
#!/bin/sh
#################################################################################
#
# File: pdf-writer
#
# Description: A simple PDF Writer for CUPS
#
# Copyright: (c) 2007 jcoder24 on puppylinux forum
# (c) 2006 Axel Schmidt, SUSE LINUX GmbH, Nuernberg, Germany
# (c) 2001 Michael Goffioul (kdeprint <at> swing <dot> be)
#
# License: GPL
#
#################################################################################
PS2PDF=`which ps2pdf`
# USERMODE="on" changes PDFPATH to "$HOME/<user-name>/PDF"
#
DEFGROUP="users"
JOB=$1
PRTUSER=$2
# Check DEVICE DISCOVERY + test PS2PDF
#
if [ "$JOB" = "" ]; then
if [ -f "$PS2PDF" ]; then
echo "file pdf-writer:/export/share/pdf \"unkown\" \"pdf writer\" "
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 filename from user via xdialog
# added by jcoder24
export PATH=$PATH:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/X11R7/bin
export DISPLAY=":0.0"
#cups sets an env var called USER, which we will access here
#The env variables DISPLAY (above) & XAUTHORITY (below) are needed by xdialog
if [ "$USER" = "root" ]; then
export XAUTHORITY="/root/.Xauthority"
FOLDER="/root"
else
export XAUTHORITY="/home/$USER/.Xauthority"
FOLDER="/home/$USER"
fi
FILENAME=`Xdialog --title "PDF-Writer - Save As..." --fselect "$FOLDER" 28 60 2>&1 | tail -1 | gawk '{gsub (/\.pdf$|\.PDF$/,"",$0); print $0'}`
#if user choses not to save file, exit gracefully
if [ -z "$FILENAME" ]; then
logger "pdf-writer: INFO: JOB $JOB aborted by $USER!"
exit 0
fi
#if selected file exists, append timestamp to filename
if [ -f "$FILENAME.pdf" ]; then
FILENAME="$FILENAME-`date +%m%d-%H%M-%S`.pdf"
else
FILENAME="$FILENAME.pdf"
fi
# get PDF-WRITER directory file selected
# modified by jcoder24
PDFPATH="`dirname $FILENAME`"
#logger "pdf-writer: Created pdf \"$FILENAME\"."
# 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
else
$PS2PDF - $FILENAME
fi
# Chown + set permissions for the user
# Note: this will not work if CUPS runs as lp
if [ "$PRTUSER" != "" ]; then
chmod 644 $FILENAME
chown $PRTUSER:$DEFGROUP $FILENAME
fi
exit 0
#
######################### CUPS pdf-writer ends here ########################
#
EOF_BACKEND
chmod 755 /usr/lib/cups/backend/pdf-writer
ln -sf /usr/share/ghostscript/8.15/lib/ghostpdf.ppd /usr/share/cups/model/ghostpdf.ppd
/etc/rc.d/rc.cups restart
sleep 5
lpadmin -p CUPS-PDF -v pdf-writer:/export/share/pdf/ -E -P /usr/share/cups/model/ghostpdf.ppd
/etc/rc.d/rc.cups restart
- Attachments
-
- pdf-writer.gz
- (1.55 KiB) Downloaded 779 times
Last edited by disciple on Thu 19 Jul 2007, 04:45, edited 2 times in total.
This is taken care of by this piece of code.disciple wrote:I think it might be better for a print job to be deleted if you press cancel, than for it to stay in the queue and the printer to go off line. I think the current behaviour would be confusing to most users.
Code: Select all
#if user choses not to save file, exit gracefully
if [ -z "$FILENAME" ]; then
logger "pdf-writer: INFO: JOB $JOB aborted by $USER!"
exit 0
fi
I have modifed the printer so that if the file exists it ask you if you want to overwrite with a yes or no option. If the answer no, display they dialog again.disciple wrote:Also, it would be handy to have a printer option to turn off the feature to add a date to prevent overwriting a file
In Seamonkey/Firefox I can change the paper size by clicking the properties button next to the printer name. Unfortunately all programs don't have this option eg geany.disciple wrote:Printing from Firefox or Seamonkey I also have to specify the same size when I go to print it, otherwise it scales to the size specified by the browser, but puts it on the size paper specified by CUPS. How annoying. Why can't the browser dictate the paper size?
Thanks for all of your testing disciple
- Attachments
-
- cupspdf-0.2.pet
- (2.1 KiB) Downloaded 930 times
--I'm testing the latest version, in a fresh 2.16.1 frugal install, with just the CUPS dotpup, XPDF and GTKLP installed--
The new overwrite behaviour is suberb. Thanks
Pressing enter instead of clicking OK works fine.
Apart from that it is absolutely great, and I can't get it to break or anything.
The only other enhancement I can think of is to not let a user click OK without putting in a name, but I don't know if this is even possible. At the moment if you are in /root/my-documents, it will make /root/my-documents.pdf, which is a little confusing.
-----------
Just because I like to document everything: If /usr/lib/cups/backend/pdf-writer gets deleted then you get the symptoms I reported before, where jobs will queue, but you never get asked where to save it. If you uninstall the .pet, then this will be deleted, but the printer will still appear to be on the system. (This is not why I initially had the problem, as that was before the .pet )
-----------
Printing from browsers etc - that's interesting if it works for you - for me the printer properties from Seamonkey/Firefox scale what is printed, but don't actually change the papersize. Changing the page size from Openoffice just prints it at the size set by CUPS. I don't think it has anything to do with the PDF printer, I was just commenting on it. Another funny thing is that when you print from Seamonkey or Firefox, while it is preparing to print it has a window with a cancel button that doesn't actually cancel anything
The new overwrite behaviour is suberb. Thanks
On my system it isn't. If I press cancel when asked where to save it, the job stays in the queue and the printer gets stopped. The same thing happens if I press X to close the window - or do you mean that this code makes it behave like this, rather than preventing it? It would be much more user-friendly if somehow the job could just be deleted and the printer stay online.This is taken care of by this piece of code.
Pressing enter instead of clicking OK works fine.
Apart from that it is absolutely great, and I can't get it to break or anything.
The only other enhancement I can think of is to not let a user click OK without putting in a name, but I don't know if this is even possible. At the moment if you are in /root/my-documents, it will make /root/my-documents.pdf, which is a little confusing.
-----------
Just because I like to document everything: If /usr/lib/cups/backend/pdf-writer gets deleted then you get the symptoms I reported before, where jobs will queue, but you never get asked where to save it. If you uninstall the .pet, then this will be deleted, but the printer will still appear to be on the system. (This is not why I initially had the problem, as that was before the .pet )
-----------
Printing from browsers etc - that's interesting if it works for you - for me the printer properties from Seamonkey/Firefox scale what is printed, but don't actually change the papersize. Changing the page size from Openoffice just prints it at the size set by CUPS. I don't think it has anything to do with the PDF printer, I was just commenting on it. Another funny thing is that when you print from Seamonkey or Firefox, while it is preparing to print it has a window with a cancel button that doesn't actually cancel anything
Barry,
lpadmin adds these lines to /etc/cups/printers.conf if its the first printer to be installed.
If not, then the first line becomes
You should be able to just add those lines to /etc/cups/printers.conf to simiulate running lpadmin when creating the live-cd.
lpadmin adds these lines to /etc/cups/printers.conf if its the first printer to be installed.
Code: Select all
<DefaultPrinter CUPS-PDF>
Info CUPS-PDF
DeviceURI pdf-writer:/export/share/pdf/
State Idle
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
</Printer>
Code: Select all
<Printer CUPS-PDF>
-
- Posts: 405
- Joined: Mon 01 Jan 2007, 20:24
- Location: Hayslope, near Middlemarch, Midlands, England
HP Drivers PET
In Barry's 2.17 Release Notes he mentions that the HPIJS drivers were moved to a seperate PET. The forum also suggests that this should be installed prior to running CUPS.
Can someone direct me to the PET as I cannot see it in the list of "Official PETs"? Thanks.
And also, IS there a preferred sequence for the installattion?
Can someone direct me to the PET as I cannot see it in the list of "Official PETs"? Thanks.
And also, IS there a preferred sequence for the installattion?
- BarryK
- Puppy Master
- Posts: 9392
- Joined: Mon 09 May 2005, 09:23
- Location: Perth, Western Australia
- Contact:
Re: HP Drivers PET
Yes it is, I just checked. Click the 'install' button on the desktop, then follow your nose from there, and there it is in the left pane.nic2109 wrote:Can someone direct me to the PET as I cannot see it in the list of "Official PETs"? Thanks.
And also, IS there a preferred sequence for the installattion?
Install the hpijs package, then choose Setup --> CUPS printer wizard.
-
- Posts: 405
- Joined: Mon 01 Jan 2007, 20:24
- Location: Hayslope, near Middlemarch, Midlands, England
Re: HP Drivers PET
Er...... this is odd since it's not there for me. Is there something to do first to refresh the list of packages?BarryK wrote:Yes it is, I just checked. Click the 'install' button on the desktop, then follow your nose from there, and there it is in the left pane.nic2109 wrote:Can someone direct me to the PET as I cannot see it in the list of "Official PETs"? Thanks.
And also, IS there a preferred sequence for the installattion?
Install the hpijs package, then choose Setup --> CUPS printer wizard.
I tried MU's PSI and there it is, but that does have a "Do you want to refresh the list?" dialogue first.
As usual with new/nervous users my assumption is that I have done something wrong (or failed to do something right) but what might that be?
- BarryK
- Puppy Master
- Posts: 9392
- Joined: Mon 09 May 2005, 09:23
- Location: Perth, Western Australia
- Contact:
Re: HP Drivers PET
hpijs is in the list if you are running 2.17. If not, you will have to go to ibiblio and download the hpijs PET package, then just click on it -- well, just clicking on it in the ibiblio site, seamonkey will offer to download or install it directly.nic2109 wrote:Er...... this is odd since it's not there for me. Is there something to do first to refresh the list of packages?BarryK wrote:Yes it is, I just checked. Click the 'install' button on the desktop, then follow your nose from there, and there it is in the left pane.nic2109 wrote:Can someone direct me to the PET as I cannot see it in the list of "Official PETs"? Thanks.
And also, IS there a preferred sequence for the installattion?
Install the hpijs package, then choose Setup --> CUPS printer wizard.
I tried MU's PSI and there it is, but that does have a "Do you want to refresh the list?" dialogue first.
As usual with new/nervous users my assumption is that I have done something wrong (or failed to do something right) but what might that be?