You can create PDF files directly from many desktop Linux applications. But some Linux users take another route. They create a Postscript file (with the extension .ps), and then convert it to PDF using ps2pdf.
ps2pdf is a script that comes bundled with Ghostscript, which is a standard part of most Linux systems. To find out if you have ps2pdf, type which ps2pdf at the command line. If a path is displayed (for example, /usr/bin/ps2pdf), then you’re ready to go. If not, you’ll need to install Ghostscript.
There are a number of ways to create a Postscript file. Enough for at least another article. But let’s assume that you have a Postscript file that you want to run through ps2pdf. What do you do?
Open a terminal window and change to the directory containing the Postscript file. Then type ps2pdf followed by the name of your Postscript file. For example:
This creates the file penguin.pdf.
Note: Running ps2pdf on some Linux distributions like Knoppix, might not work. Try using the command ps2pdfwr instead.
One way to enhance your PDF files is to use ps2pdf with one or more options that enable you to change how your PDF’s are produced. You can learn more here. There are a large number of options, but I have found the three explained in this article to be the most useful.
To use the options type ps2pdf followed by -d, followed by the option, followed by the name of the Postscript file:
In some PDF files the fonts appear fuzzy. If you find that the fonts in your PDF file are fuzzy, you can embed the fonts used in the source document with the PDF. Embedding fonts ensures that:
- Your PDF is created with the standard 12 Postscript fonts
- Any fonts that may not be installed on the computer, on which your PDF is being viewed are available
Embed fonts by adding the EmbedAllFonts=true parameter to the command line:
ps2pdf -dEmbedAllFonts=true WonderDog.ps
Your PDF will become noticeably larger if you use this option though.
Compressing the PDF
You can shrink large PDF files by as much as half of their original size with the UseFlateCompression=true parameter. To use this option, type the following at the command line:
ps2pdf -dUseFlateCompression=true myNovel.ps
Specifying the target device
One of the great things about PDF files is that they can be used for a variety of purposes – viewing on screen, downloaded as electronic books or run off on a printer. You can specify five types of target device’s for your PDF using the PDFSETTINGS parameter:
- /screen – creates a PDF optimized for reading on a monitor.
- /ebook – the PDF is easily read on a monitor and as a PDA or an electronic book reader.
- /printer – the PDF is generated for printing on a laser or ink jet printer and can be distributed on a disk or CD-ROM.
- /prepress – the PDF is generated for a high-quality printing press.
- /default – the PDF can be used for all the output listed above. However the file will be larger than it would, if you had used a single type.
To specify the target device, type the following at the command line:
ps2pdf -dPDFSETTINGS=/printer finalDraft.ps
ps2pdf is a powerful tool for creating PDF files. While using it seems a bit complex. It’s a lot more flexible than simply outputting PDF’s from a desktop application. It’s flexibility is what Linux and the command line are all about?