Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 30 Oct 2014, 15:20
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Unsorted
PDF printer for puppy
Moderators: deshlab, Flash, GuestToo, Ian, JohnMurga, Lobster
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 2 of 7 Posts_count   Goto page: Previous 1, 2, 3, 4, 5, 6, 7 Next
Author Message
DavidBell

Joined: 24 Nov 2006
Posts: 132

PostPosted: Sat 23 Jun 2007, 00:35    Post_subject:  

Is this make it into 2.16 final (DLed a week or so ago)? If so what steps do I need to take to print a pdf from Seamonkey? I couldn't find it in the Puppy printer wizard.

TIA. DB
Back to top
View user's profile Send_private_message 
BarryK
Puppy Master


Joined: 09 May 2005
Posts: 7060
Location: Perth, Western Australia

PostPosted: Sat 23 Jun 2007, 01:34    Post_subject:  

Menu -> System -> Xpdq printer management.

The pdf print entries should be there, you choose one of them and make it the default printer (Xpdq has a menu selection for that).

For any app, if you print to lpr, it should end up as a pdf file.
Back to top
View user's profile Send_private_message Visit_website 
DavidBell

Joined: 24 Nov 2006
Posts: 132

PostPosted: Sat 23 Jun 2007, 02:26    Post_subject:  

Thanks Barry (and jcoder). This is something I really wanted. DB
Back to top
View user's profile Send_private_message 
jcoder24


Joined: 06 May 2005
Posts: 601
Location: Barbados

PostPosted: Mon 16 Jul 2007, 16:04    Post_subject:  

The following script creates a pdf printer for CUPS called CUPS-PDF. This script was adapted from http://www.novell.com/coolsolutions/feature/17636.html. It works the same way as the PDQ version. After testing I'll package it as a dotpet. Please test.

Code:
#!/bin/sh

> /usr/lib/cups/backend/pdf-writer
cat >> /usr/lib/cups/backend/pdf-writer << EOF_BACKEND
#!/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\`

# USERMODE="on" changes PDFPATH to "\$HOME/<user-name>/PDF"
#
USERMODE="off"
DEFGROUP="users"
JOB=\$1
PRTUSER=\$2

# Check DEVICE DISCOVERY + test PS2PDF
#
if [ "\$JOB" = "" ]; then
        if test -f "\$PS2PDF" ; then
                echo "file 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 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"

if [ "\`whoami\`" = "root" ]; then
   export XAUTHORITY="/root/.Xauthority"
   export "FOLDER=/root"
else
   export XAUTHORITY="/home/\`whoami\`/.Xauthority"
   export FOLDER="/home/\`whoami\`"
fi

FILENAME=\`Xdialog --title "PDF-Writer - Save As..." --fselect "\$FOLDER" 28 60 2>&1 | tail -1 | gawk '{gsub (/\.pdf\$|\.PDF\$/,"",\$0); print \$0'}\`

if [ -z "\$FILENAME" ]; then
   exit 0
fi

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: \"\$FILENAME\" was placed in: \$PDFPATH"

# 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 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/init.d/cups restart
sleep 5
lpadmin -p CUPS-PDF -v pdf-writer:/export/share/pdf/ -E -P /usr/share/cups/model/ghostpdf.ppd
/etc/init.d/cups restart
Back to top
View user's profile Send_private_message 
BarryK
Puppy Master


Joined: 09 May 2005
Posts: 7060
Location: Perth, Western Australia

PostPosted: Mon 16 Jul 2007, 20:20    Post_subject:  

jcoder24, that's great that you're tackling the CUPS implementation of print-to-pdf! ...now that Puppy has CUPS.

If we get some positive tests, then it would be good to get it into the 2.17-final.
Back to top
View user's profile Send_private_message Visit_website 
JB4x4

Joined: 30 Jul 2006
Posts: 256

PostPosted: Mon 16 Jul 2007, 22:54    Post_subject:  

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

Edited_time_total
Back to top
View user's profile Send_private_message YIM 
disciple

Joined: 20 May 2006
Posts: 6449
Location: Auckland, New Zealand

PostPosted: Mon 16 Jul 2007, 23:49    Post_subject:  

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.
Back to top
View user's profile Send_private_message 
disciple

Joined: 20 May 2006
Posts: 6449
Location: Auckland, New Zealand

PostPosted: Tue 17 Jul 2007, 01:40    Post_subject:  Breaks when you cancel a job  

Sad 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

Edited_time_total
Back to top
View user's profile Send_private_message 
BarryK
Puppy Master


Joined: 09 May 2005
Posts: 7060
Location: Perth, Western Australia

PostPosted: Tue 17 Jul 2007, 08:11    Post_subject:  

JB4x4 wrote:
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.

Yes, Puppy 2.17 has the script at /etc/init.d/cups.
Back to top
View user's profile Send_private_message Visit_website 
disciple

Joined: 20 May 2006
Posts: 6449
Location: Auckland, New Zealand

PostPosted: Tue 17 Jul 2007, 21:19    Post_subject:  

Thanks.

Do other people have the same problem when cancelling, or is there something funny about my system?
Back to top
View user's profile Send_private_message 
jcoder24


Joined: 06 May 2005
Posts: 601
Location: Barbados

PostPosted: Tue 17 Jul 2007, 22:32    Post_subject:  

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
Code:
if [ $# -eq 6 ]; then
        $PS2PDF $6 $FILENAME >& /dev/null
else
        $PS2PDF - $FILENAME >& /dev/null
fi


to
Code:
if [ $# -eq 6 ]; then
        $PS2PDF $6 $FILENAME
else
        $PS2PDF - $FILENAME
fi


Updated 2007/07/18, follow link below
http://www.murga-linux.com/puppy/viewtopic.php?p=129067#129067

Edited_time_total
Back to top
View user's profile Send_private_message 
disciple

Joined: 20 May 2006
Posts: 6449
Location: Auckland, New Zealand

PostPosted: Tue 17 Jul 2007, 23:25    Post_subject:  

Wow - you are fast. That is very kind of you supporting such obsolete software, and presumably the problem would occur in all (or at least most) Puppy 1.xs
But I had the problem in Puppy 2.16.1 as well - do others not have the problem, or have you fixed it?
Back to top
View user's profile Send_private_message 
disciple

Joined: 20 May 2006
Posts: 6449
Location: Auckland, New Zealand

PostPosted: Wed 18 Jul 2007, 01:29    Post_subject:  

You are a legend jcoder:) I fixed the script and reran it in Grafpup 104, and now it works great. Thanks!! Smile
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.
Back to top
View user's profile Send_private_message 
disciple

Joined: 20 May 2006
Posts: 6449
Location: Auckland, New Zealand

PostPosted: Wed 18 Jul 2007, 02:25    Post_subject:  

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 Smile
Back to top
View user's profile Send_private_message 
disciple

Joined: 20 May 2006
Posts: 6449
Location: Auckland, New Zealand

PostPosted: Wed 18 Jul 2007, 02:54    Post_subject:  

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
pdf-writer.gz
Description 
gz

 Download 
Filename  pdf-writer.gz 
Filesize  1.55 KB 
Downloaded  601 Time(s) 

Edited_times_total
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 2 of 7 Posts_count   Goto page: Previous 1, 2, 3, 4, 5, 6, 7 Next
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Unsorted
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1094s ][ Queries: 12 (0.0045s) ][ GZIP on ]