creating pdf files from lpd
jim
jim at jimani.com
Wed Nov 14 06:42:48 CST 2001
Rich,
On Tue, Nov 13, 2001 at 04:06:11PM -0600, Rich Minear wrote:
> I have the need to try to create pdf files from a postscript printer stream.
> What I would like to do is:
>
> 1. Have a user send a print job to a lpr printer;
> 2. Have lpd take the job, create a pdf file,
> 3. Then take the file and mail it to the user.
>
> This would all be automatic....can it be done?
You can define a new printer, say ps2pdf, that will do the above. The user
invokes it "lpr -P ps2pdf file.ps". In the /etc/printcap file you get to
specify a print filter, a script that will have the file to be printed on
its STDIN and the printer device on its STDOUT. I think the user that
submitted the job is one of the parameters to the script with non-LPRng but
it looks like LPRng passes it in the environment as USER. While in
/etc/printcap you can set the printer device to /dev/null since you won't
need a real printer. A quick check found this man page:
PS2PDF(1) Ghostscript Tools PS2PDF(1)
NAME
ps2pdf - Ghostscript PostScript to PDF translator
SYNOPSIS
ps2pdf [ options ] input.ps output.pdf
So the filter shouldn't be too difficult
#/bin/bash
# Save the file.
cat > /tmp/$$.ps
# Convert to PDF.
ps2pdf /tmp/$$.ps /tmp/$$.pdf
# Mail the result.
mail < /tmp/$$.pdf ${USER}
# Clean up.
rm -f /tmp/$$.ps /tmp/$$.pdf
It will take some playing but it should work.
--
Jim
More information about the Kclug
mailing list