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 :)

cod3fr3ak
May 8th, 2004, 10:07
Hmmm very nice. I needed something like this for my pdfs at home. I decided to dump them all to dvd and then use alcohol 120% to keep the image shared out to all the machines on my intranet. great idea though. is there a way to sort?

soup4you2
May 8th, 2004, 11:57
i normally map the dropbox and the web location to where they will be held and sort then and name them myself

cod3fr3ak
May 10th, 2004, 08:07
I just got to work and was thinking I'd have to do the same thing. No worries its a good idea.

cod3fr3ak
May 10th, 2004, 11:11
Soup do you think this would work for OpenBSD? I suppose it should just using the ghostscript-7.05p2.tgz package???

soup4you2
May 10th, 2004, 13:38
should work on anything... just change the parhs to the approporate places..

cod3fr3ak
May 11th, 2004, 13:32
Hmmm... I get the following error:
gs: can't load library 'libX11.so.7.0'

I assume its complaining about X. is there an OpenBSD version that uses no X. I didn't see one in the i386 package list?

Loop
May 11th, 2004, 18:31
What should I have in the printcap file? I'm getting
[2004/05/11 15:03:20, 0] printing/pcap.c:pcap_printer_fn(372)
Unable to open printcap file cups for read!
I am using cups as the print system, and until now this has worked fine, what would be different?

soup4you2
May 11th, 2004, 19:01
What should I have in the printcap file? I'm getting
[2004/05/11 15:03:20, 0] printing/pcap.c:pcap_printer_fn(372)
Unable to open printcap file cups for read!
I am using cups as the print system, and until now this has worked fine, what would be different?

try it w/ just the samba config provided... nothing more nothing less... tell me if that works.

Loop
May 12th, 2004, 07:04
The config as written works, in as far as a PDF is generated, but the Windows Reader can't display it, but it does show the document properties.

I wonder if cups could print to pdf like this - or if both vups and the bsd print systems could co-exist.

soup4you2
May 12th, 2004, 08:41
i have no problems having acrobat read it...

as far as other OS's works great on freebsd and openbsd.. and i'm sure others... btw openbsd 3.5 rocks!!

Atlas
June 4th, 2004, 12:08
soup4you2, this is awesome. Thanks for the great idea!