How to create PDF-files by using an E-Smith server and Ghostscript.


Author:       Lasse Johansson
Contributors: Filippo Carletti Dan Brown


Last modified 2002-02-17


Problem:  You want to find an easy way for all your local users to create PDF files.
Solution:  Install Ghostscript and ps2pdf on your E-Smith server and create a "pdf printer" by using Samba.


Note:

The steps in this HOWTO has been confirmed working on SME 5, but they would most probably be applicable on ESSG 4.1.2 as well.
Confirmed: It's perfectly OK to run these steps on ESSG 4.1.2.

If you use this HOWTO on a SME 5.1.2, you don't need to install Freetype, since it's allready a part of that distribution.






Sources of information:


The steps:


Step A:

First we'll have to install a number of rpm's (the links for each rpm package goes to the corresponding info page at rpmfind.net):

  1. (If installing on SME 5.1.2, start directly with #2) Install freetype-2.0.1-4 RPM for i386 (direct link) with the command:
    rpm -Uvh freetype-2.0.1-4.i386.rpm

  2. Install XFree86-libs-4.0.3-5 RPM for i386 (direct link) with the command:
    rpm -Uvh XFree86-libs-4.0.3-5.i386.rpm

  3. Install XFree86-xfs-4.0.3-5 RPM for i386  (direct link) with the command:
    rpm -Uvh XFree86-xfs-4.0.3-5.i386.rpm

  4. Install  chkfontpath-1.9.5-1 RPM for i386 (direct link) with the command:
    rpm -Uvh chkfontpath-1.9.5-1.i386.rpm

  5. Install urw-fonts-2.0-4 RPM for noarch (direct link) with the command:
    rpm -Uvh urw-fonts-2.0-4.noarch.rpm

  6. Install Omni-0.5.0-4 RPM for i386 (direct link) with the command:
    rpm -Uvh Omni-0.5.0-4.i386.rpm

  7. Install ttfonts-ja-1.0-6 RPM for noarch (direct link) with the command:
    rpm -Uvh ttfonts-ja-1.0-6.noarch.rpm

  8. Install VFlib2-2.25.1-20 RPM for i386 (direct link) with the command:
    rpm -Uvh VFlib2-2.25.1-20.i386.rpm

  9. And finally install the two packages ghostscript-fonts-5.50-1 RPM for noarch (direct link) and ghostscript-6.51-16 RPM for i386 (direct link) with the command:
    rpm -Uvh ghostscript-fonts-5.50-1.noarch.rpm ghostscript-6.51-16.i386.rpm
     

    We now have all the required (and a few not so required...) packages installed.
    To check this you can type:

    # ps2   ...followed by a TAB and you should end up with the following line:

    ps2ascii  ps2epsi   ps2pdf    ps2pdf12  ps2pdf13  ps2pdfwr  ps2ps


Step B:

It's now time to create an ibay where we pick up our PDF files.

 Just make an ibay named "pdfdrop" and set the group permissions read and write to all users on your LAN

 Now to the script printpdf itself,
it will be placed in /usr/bin/ so we make a

# cd /usr/bin/

and then a

# pico printpdf

Copy the entire script below into your pico editor and save your work with [ctrl x]


#!/bin/sh

# Simple script to convert a specified postscript file into a PDF document
# and place it in a location that is shared by the Samba server.
#
# Arguments:
#   1st - The name of the spool file
#
# John Bright, 2001, jbright@winfordeng.com

# We will create the pdf into a temporary file based upon the current date and time.
# After we are finished, we'll rename it to a file with the same date, but ending
# in .pdf.  We do this because if a user tries to open a PDF that is still being written,
# they will get a message that it is corrupt, when it is actually just not done yet.

DATE=`date +%b%d-%H%M%S`

# Directory in which to place the output
# Be sure this directory exists and is writable by the user that Samba
# is running as (for example, the nobody user)
OUTDIR=/home/e-smith/files/ibays/pdfdrop/files

#ps2pdf $1 $OUTDIR/$DATE.temp
#The following line changed by Lasse Johansson lasse@saxdalen.com to enable pdf1.3 outputs. Original line commented above.
ps2pdf13 $1 $OUTDIR/$DATE.temp
mv $OUTDIR/$DATE.temp $OUTDIR/$DATE.pdf
rm $1


Make your script executable:
chmod 755 printpdf


Step C:

Now we have to create a custom template for our "pdf-printer" and our pdfdropbox in smb.conf:
 


[pdf]
   path = /tmp
   printable = yes
   guest ok = yes
   print command = /usr/bin/printpdf %s

   ; There is no need to support listing or removing print jobs,
   ; since the server begins to process them as soon as they arrive.
   ; So, we set the lpq (list queued jobs) and lprm (remove jobs in queue)
   ; commands to be empty.
   lpq command =
   lprm command =
 



Step D:

You're actually finished with your server setup now!
Now we're going to set up the client machine (I assume here it's a M$ Windows 95 or 98, for Me, NT, 2000 and XP the procedure would probably be "simular", - anybody out there who would like to contribute with those sections to this How-To?)
 

What could be better?

There are, of course, several parts here that could be much improved.
In particular, I'm trying to determine the best proper way to make Windooze TTF fonts translate into PostScript fonts in the PDF document, and also how to insert TTF fonts directly into the PDF, if possible. (At present, the generated PDF is not always searchable and not always detatchable because of this font problem)
Anyone out there feeling smarter that me regarding font stuff and Ghostscript is welcome to contribute.

Also, finding a smarter approach of adding more useful fonts to Ghostscript (maybe instead of ttfonts-ja-1.0-6.noarch.rpm ...) would be greatly appreciated!


Comments, suggestions and improvements for this HowTo are welcome!
Please contact Lasse Johansson