Since you have the smarts to use mysql you are most certainly using linux.
Linux has the script ps2pdf native with most any distro. setup this script then install the Apple Color LW 12/660 Postscript driver.
Simply direct your printing to the virtual printer and your PDFs will be generated automaticlly.
Setup instructions are in the script.
it will also log your print jobs in the log file defined by the LOGFILE variable
Have fun....
#!/bin/sh
# ver 1.3.5
# Mickey Poppitz, DataSoft LLC.com
# mickey@(you guested it .com)
#
# script to enable samba printing to PDF files
# - add printer def to /etc/samba/smb.conf (remove #'s to enable in)
# - place script in /opt directory
# - chmod 777 /opt
# - chmod 777 /opt/*
# - thats it, PDFs will be placed in the directory
# defined by the $OUTDIR variable
# script usage
#
# samba prn definition
# [PDFprinter]
# comment="samba PDF printer engine"
# print ok = yes
# quest ok = yes
# path = /opt
# create mask = 0777
# print command =/opt/printpdf.sh %d %u %s %J %H %a %I
# force create mode = 0777
#
# where;
# %d = $1 current server process IP
# %u = $2 samba user
# %s = $3 session
# %J = $4 windows job name
# %H = $5 users home dirsctory
# %a = $6 clien pc type (win98,winNT,... or UNKNOWN)
# %I = $7 client IP address
# path in PDF printer def of smb.conf if different,
# make sure samba "path" and WORKDIR are the same
WORKDIR=/opt
# dir where PDFs will be put
# IE "public" share
OUTDIR=/home/samba/lib/public/pdf
#
LOGFILE=/opt/smb_print.log
#### NO EDITING NEEDED BELOW THIS LINE ####
JOB=`basename $3|cut -f2 -d"."`
# write Samba ENV vars into logfile
DATE=`date +%b%d-%H%M%S`
echo "$DATE - $1 - $2 - $3 - $4 - $5 - $6 -$7 " >> $LOGFILE
if [! -f $LOGFILE ]; then
touch $LOGFILE
chmod 777 $LOGFILE
echo "DATE - H M S - PID - USER - SESSION ID - JOB_NAME - PC - IP_ADDRESS" > $LOGFILE
fi
# convert ps file to PDF and place in user's home directory
/usr/bin/ps2pdf $WORKDIR/$3
#/usr/bin/ps2pdf $WORKDIR/$3 $WORKDIR/$2.$4.pdf
sleep 3
# remove ps file when done
mv $WORKDIR/$3.pdf $OUTDIR/$2.$4.$JOB.pdf
rm $WORKDIR/$3
# end script