Last Updated: November 10, 2003
The probability is very good that you already have all the software you need to make PDF (portable document format) files on your Linux system. However, you may need/want to upgrade/add some programs to your Linux setup.
You should have the teTeX package installed from your distribution CD-ROM. All of these files are downloadable free of charge. You may use them indefinitely, but each has a different license agreement, particularly regarding redistribution.
Unless one is using a direct PDF generating tool, making PDF files is a 2 step process:
This is fairly easy since Linux uses PostScript as an abstraction layer for its printing system. Most Linux programs are designed to write postscript files as part of their printing commands or menus. If you use TeX or LaTeX, you need to use some command line switches with the the dvips command to put Type 1 font encoding in your PostScript file. If you do not do this, your PostScript file (and any PDF files made from it) will contain Type 3 fonts (print fine but look crummy in Acrobat Reader). This command is
dvips -Ppdf -G0 filename.dvi
where the -Ppdf switch tells dvips to use Type1 fonts in the output PostScript file and the -G0 makes a small change in the position of lowercase letters to improve their look in PDF files. You may also want to use the pslatex package, in order to force LaTeX to use fonts for which Acrobat Reader has internal support.
The newer versions of ghostscript come with a script called ps2pdf. This takes an existing PostScript file and builds a PDF file based on it.
ps2pdf filename.ps
Will produce a PDF file called filename.pdf from the PostScript file filename.ps. You can use most of the options for the "gs" program with "ps2pdf."
The ps2pdf command is just a well written script that calls the gs (main ghostscript) program to build PDF files from PostScript files. If you want, you can manually use gs to build PDF files by typing in
gs -q -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile="filename.pdf" "filename.ps"
When gs is finished, it will present a GS> prompt where you would type ``quit.''
Obviously, the ps2pdf script saves typing. You can make your own shell script to build PDF files if you want, such as my old ``makepdf'' shell script.
Because PDF is such a useful format and an open specification, some programs like LyX, OpenOffice, and kprinter now allow you to ``print'' to a PDF file directly, instead of first writing a PostScript file and converting it. LaTeX users also have the new pdflatex program, which is part of the teTeX package included with most Linux distributions. The pdflatex program is a modified version of LaTeX that outputs directly to a PDF file instead of a DVI file. Many LaTeX users will find it suits them.
The new kprinter system is particularly exciting because it allows almost every GUI program for Linux to print to a PDF file in an easy and seamless manner. Kprinter is a KDE-based GUI interface to printers on a Linux system. It is now set up by default to include some ``special'' printer targets, including a ``Print to File (PDF)''. If you select this target, kprinter will use gs to write the output directly to a PDF file! Kprinter is set to embed fonts by default.
KDE programs are designed to use kprinter automatically. Other GUI programs can be easily told to use kprinter. Usually, their print dialog boxes will have a space for a printing command, which is usually ``lpr.'' Replacing ``lpr'' with ``kprinter'' is all that is needed. Of course, kprinter only works with a GUI.
Acrobat reader contains internal support for only 5 font families
Ghostscript 5 and up can encode Type 1 fonts for all five of these families. A couple of fonts will get translated to one of these five (for example, Helvectica fonts are automatically changed to Arial). All other fonts are, by default, embedded in PDF files as Type 3 fonts which print perfectly but look bad in Acrobat Reader. If you want other fonts in your PDF files, and you want them to look good in Acrobat Reader, you must embed Type 1 or TrueType fonts. In order to do this, you must have Ghostscript 6 or greater. I recommend using at least Ghostscript version 7. The latest Linux distributions are (finally) shipping with Ghostscript 7. If you have an older one, you can download and use a newer version for free, even for commercial applications.
Ghostscript/ps2pdf automatically embeds scalable fonts provided:
You may see what kinds of fonts are encoded and/or embedded within a PDF file by opening it in Acrobat Reader, going to the File menu, selecting Document Properties, and finally selecting Fonts.
First of all, you must make sure you have Type 1 font files for the fonts you want to include. Note that almost all of the Type 1 fonts you would want to use are probably on your system anyway, but you can install others. To install the Type 1 fonts, put them into a certain directory and run the type1inst program from the command line while in that directory (the type1inst program is available in many formats, including RPM).
Finally, you must make sure that Ghostscript can see your fonts when you are making the PDF file. If you added new fonts, you have two ways to tell Ghostscript where to find them. The first way is by using the Ghostscript command line switch:
-sFONTPATH="path_to_new_fonts"
Note that the font directories must be separated by colons (``:'') with no spaces.
The second method is to set the GS_FONTPATH environment variable. First, find the default font search path that Ghostscript uses. Typing ``gs --help|grep font'' will show you these directories. For me, the only default fontpath directory that isn't empty is ``/usr/share/ghostscript/fonts'' so that is what I will use for the following example. If you are using bash (default shell in most Linux distributions) edit your .bashrc file and insert the following line:
export GS_FONTPATH="/usr/share/ghostscript/fonts:path_to_new_fonts"
Note again that the font directories must be separated by colons (``:'') with no spaces. Also note that anything you put in your .bashrc file will not take effect unless you open a new shell or type ``source ~/.bashrc''.
You can embed TrueType fonts into PDF files with Ghostscript under Linux. The TrueType fonts must be encoded into the PostScript file as Type 42 fonts. In such a case, ps2pdf will automatically embed them. You apparently do not even need to add the TrueType fonts to your Ghostscript font path (although this is a good idea for other reasons). I have successfully done this using Linux Ghostscript with a PostScript file containing Type 42 fonts generated by MS Word in Windows (see the PDF in Windows page).
This will only work for PostScript files that contain Type 42 fonts. Check the documentation for a specific program to see if it is capable of encoding Type 42 fonts.
LyX uses font settings which, by default, will put Type 3 fonts into PDF files. There are a few easy tricks to make LyX use Type 1 fonts. These have been moved to the LyX page.