soup4you2
May 7th, 2004, 21:50
Ok.. i'm not putting any effort into this howto.. i'm feeling mighty lazy tonight.. but i've always liked to keep a nice online library.. expecially at work.. so i've always liked setting up apache w/ some docs i can share w/ my co-workers.. plus saving on trees this is a might nice thing to do..
so lets get started shall we...
($:~)=> cd /usr/ports/print/ghostscript-gnu-nox11
($:~)=> make install clean
($:~)=> cd /usr/ports/net/samba
($:~)=> make install clean
($:~)=> mkdir /usr/local/share/pdf_printer
($:~)=> mkdir /usr/local/share/pdf_printer/drop_box
($:~)=> chmod 007 /usr/local/share/pdf_printer/drop_box
($:~)=> vi /usr/local/bin/printpdf.sh
------ BEGIN SNIPLET
#!/bin/sh
DEFAULT_PATH=/usr/local/share/pdf_printer/drop_box
if test $# -lt 5
then
if test $# -ne 1
then
echo "Usage: $0 <postscript file>"
echo " : If you want to execute this script from samba you must give at least 5 values"
exit;
fi
fi
if ! test -e $1
then
echo "Error: File does not exist."
exit
fi
if test $# -lt 5
then
base_name="tmp"
else
base_name=$2
fi
FILENAME=$base_name" "$(/bin/date '+%d-%m-%Y')
counter="1"
while test -e "$DEFAULT_PATH/$FILENAME.pdf";do
counter=`expr $counter + 1`
FILENAME=$base_name" "$(/bin/date '+%d-%m-%Y')" ($counter)"
done
ps2pdf $1 "$DEFAULT_PATH/$FILENAME.temp"
mv "$DEFAULT_PATH/$FILENAME.temp" "$DEFAULT_PATH/$FILENAME.pdf"
FILESIZE=$(/usr/bin/du -h "$DEFAULT_PATH/$FILENAME.pdf" | /usr/bin/awk '{print $1}')
if ! test $# -lt 5
then
printf "Your printjob \"$6\" is processed.\n\nLocation\t\t= $8\nOwner\t\t= $2\nDocument name\t= $FILENAME.pdf\nDocument size\t= $FILESIZE\n\n" | smbclient -U 'PDF Printer' -M $4
rm $1
else
echo "PDF File is created: $DEFAULT_PATH/$FILENAME.pdf"
fi
---------END SNIPLET
($:~)=> chmod 755 /usr/local/bin/printpdf.sh
($:~)=> vi /usr/local/etc/smb.conf
---------BEGIN SNIPLET
# Global parameters
[global]
netbios name = PDF-SERVER
workgroup = WORKGROUP
server string = File & Printer Server
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_SNDBUF=8192
security = share
printcap name = /etc/printcap
; printer driver file = /etc/printers.def
# PDF Document share
[PDF Dropbox]
comment = Output from PDF printer.
path = /usr/local/share/pdf_printer/drop_box
read only = No
guest ok = Yes
# PDF Printer
[pdfprint]
comment = PDF Document Generator
path = /tmp
guest ok = Yes
printable = Yes
print command = /usr/local/bin/printpdf.sh %s %U %G %m %I '%J' %z '\\\\%L\\PDF Dropbox' &
use client driver = Yes
; printer driver = HP Color LaserJet 5/5M PS
; printer driver location = \\%h\printer$
lpq command =
lprm command =
----------END SNIPLET
Be sure to change:
netbios name = PDF-SERVER
workgroup = WORKGROUP
($:~)=> /usr/local/etc/rc.d/samba.sh start
now if you want to connect this to a windows box open up explorer and view your share \\xx.xx.xx.xx and connect to the new PDF printer.. when prompted for a driver select HP Color LaserJet 5/5M PS
congrats now all your pdf's will be in the /usr/local/share/pdf_printer/dropbox directory... pretty swanky :)
so lets get started shall we...
($:~)=> cd /usr/ports/print/ghostscript-gnu-nox11
($:~)=> make install clean
($:~)=> cd /usr/ports/net/samba
($:~)=> make install clean
($:~)=> mkdir /usr/local/share/pdf_printer
($:~)=> mkdir /usr/local/share/pdf_printer/drop_box
($:~)=> chmod 007 /usr/local/share/pdf_printer/drop_box
($:~)=> vi /usr/local/bin/printpdf.sh
------ BEGIN SNIPLET
#!/bin/sh
DEFAULT_PATH=/usr/local/share/pdf_printer/drop_box
if test $# -lt 5
then
if test $# -ne 1
then
echo "Usage: $0 <postscript file>"
echo " : If you want to execute this script from samba you must give at least 5 values"
exit;
fi
fi
if ! test -e $1
then
echo "Error: File does not exist."
exit
fi
if test $# -lt 5
then
base_name="tmp"
else
base_name=$2
fi
FILENAME=$base_name" "$(/bin/date '+%d-%m-%Y')
counter="1"
while test -e "$DEFAULT_PATH/$FILENAME.pdf";do
counter=`expr $counter + 1`
FILENAME=$base_name" "$(/bin/date '+%d-%m-%Y')" ($counter)"
done
ps2pdf $1 "$DEFAULT_PATH/$FILENAME.temp"
mv "$DEFAULT_PATH/$FILENAME.temp" "$DEFAULT_PATH/$FILENAME.pdf"
FILESIZE=$(/usr/bin/du -h "$DEFAULT_PATH/$FILENAME.pdf" | /usr/bin/awk '{print $1}')
if ! test $# -lt 5
then
printf "Your printjob \"$6\" is processed.\n\nLocation\t\t= $8\nOwner\t\t= $2\nDocument name\t= $FILENAME.pdf\nDocument size\t= $FILESIZE\n\n" | smbclient -U 'PDF Printer' -M $4
rm $1
else
echo "PDF File is created: $DEFAULT_PATH/$FILENAME.pdf"
fi
---------END SNIPLET
($:~)=> chmod 755 /usr/local/bin/printpdf.sh
($:~)=> vi /usr/local/etc/smb.conf
---------BEGIN SNIPLET
# Global parameters
[global]
netbios name = PDF-SERVER
workgroup = WORKGROUP
server string = File & Printer Server
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_SNDBUF=8192
security = share
printcap name = /etc/printcap
; printer driver file = /etc/printers.def
# PDF Document share
[PDF Dropbox]
comment = Output from PDF printer.
path = /usr/local/share/pdf_printer/drop_box
read only = No
guest ok = Yes
# PDF Printer
[pdfprint]
comment = PDF Document Generator
path = /tmp
guest ok = Yes
printable = Yes
print command = /usr/local/bin/printpdf.sh %s %U %G %m %I '%J' %z '\\\\%L\\PDF Dropbox' &
use client driver = Yes
; printer driver = HP Color LaserJet 5/5M PS
; printer driver location = \\%h\printer$
lpq command =
lprm command =
----------END SNIPLET
Be sure to change:
netbios name = PDF-SERVER
workgroup = WORKGROUP
($:~)=> /usr/local/etc/rc.d/samba.sh start
now if you want to connect this to a windows box open up explorer and view your share \\xx.xx.xx.xx and connect to the new PDF printer.. when prompted for a driver select HP Color LaserJet 5/5M PS
congrats now all your pdf's will be in the /usr/local/share/pdf_printer/dropbox directory... pretty swanky :)