Discussion Locked

Generate PDF on the fly on Linux

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I would like to Generate PDF on the fly. Basically, I need to be able to grab information from mysql and generate a Certificate or Diploma on the Fly.

I found this site that sells the PDFLib and just wondering if you know of any other open Source or similar product that I can use. http://www.pdflib.com/shop/index.php

Thank you.

7 replies

by jaqui

cups, html2pdf being 2 that are included with all distros.

the cups system has the biltin ability to print to pdf. you can have a script send the file to cups, then direct cups to create a pdf, and have the server send the pdf to the required location.

generate html from the sql query results, then send that to html2pdf ( could actually be pdf2html, but it does work both ways I beleive.
then send the resulting pdf to where it's needed.

by oz_media

BUY Adobe Acrobat and use the Distiller to create PDF's from the print command, just like sending to a printer.

No it isn't free but is is the best PDF creator I've ever used and it builds nicely comressed files.

by dproske

you can use sql to create a spreadsheeat and then use open office to create PDF.

by oz_media

I find the graphics compression and file sizes aren't as good as Adobe's. I require online sharing and editing functionality too that even the last Acrobat couldn't provide.

While I am an OO advocate, I find it's best used for those who don't fo a LOT of PDF editing/sharing.

by mickey6

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

This discussion is closed to new replies.