Penguin

Under Linux

From any PostScript document

Many applications are capable of generating PostScript. Since PDF is actually a container format that relies on PostScript for the actual document image, generating PDFs from PostScript documents is trivial. The GhostScript package processes both formats and comes with a script called ps2pdf(1) (Debian package: gs-common) which does exactly what its name suggests. Older versions of GhostScript (such as the widely used version 5.50) embed any non-core fonts as bitmap fonts, which AcrobatReader doesn't do a very good job of rendering. More recent versions of GhostScript (6.x or 7.x) do a much better job of embedding scalable fonts in the document.

See the notes below for hints about using ps2pdf/ghostscript.

As a special printer

You can set up a fake printer that will generate a PDF file. Most of these techniques are wrappers to ps2pdf. This means you can make a PDF file from any program that can print. See the SambaPDFPrinter and CUPSNotes pages.

From LaTeX documents

You can use LaTeX to make good quality PDF files: PdfLatexNotes or LaTeXpdf are good places to look.

From OpenOffice

Version 1.0 of OpenOffice allows you to set up a special PDF printer. From the correct installation directory (such as /usr/lib/openoffice/program), run ./spadmin, select New Printer and then Connect a PDF converter and then OpenOffice will see its own special extra printer. Debian has a wrapper script called oopadmin that you can run from any directory.

Version 1.1 of OpenOffice does PDF "natively" - it is merely another filetype you can save as, rather than setting up fake printers. It also has Export to PDF... which allows you to save optimised for Size, Print, or Press.

Hint: OpenOffice will embed TrueType fonts into the PDF file it creates. You may get better results if you use fonts with the same name as the "core" fonts built into the PDF file format. For example, use "Times" instead of "Times New Roman" for your serif font, "Helvetica" as your sans-serif font, and "Courier" as your monotype font. If you do this, then no font information needs to be embedded in the PDF (which some viewers might have problems with), and the PDF file is smaller as a result.


ps2pdf hints

  • ps2pdf is really just a wrapper script that calls gs(1) with the correct options, such as -sDEVICE=pdfwrite (meaning to use the "pdfwrite" output device). Make sure you are using the most recent version of GNU ghostscript, since each version seems to improve greatly on previous versions. (Current version in debian testing at time of writing is 7.07).
  • If you are trying to make a pdf from a postscript file that has a funny size (ie, using "gv" shows it is using the BoundingBox), use the "-dEPSCrop" option. Otherwise it will default to landscape A4 and probably things wrong. Or you could try the epstopdf wrapper script (part of LaTeX).
  • If your document is black-and-white/grayscale, you might be able to make use of some optimisations by adding "-dProcessColorModel=/DeviceGray" as a command-line option.
  • You can add a -r<n> option for the resolution... eg a low resolution like -r75 if you are only creating a PDF designed to be viewed on-screen.
  • Apparently, the default options for ghostscript's "pdfwrite" device changed with ghostscript 7, and it now defaults to using DCT/JPEG compression on images, which isn't very good for screenshots or other low-res images. Add the
-dColorImageFilter=/FlateEncode -dAutoFilterColorImages=false

and/or

-dGrayImageFilter=/FlateEncode -dAutoFilterGrayImages=false

options to your ps2pdf/gs command.

  • You can join (ie concatenate) multiple PostScript and PDF files together, for example:
 gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite \
  -sOutputFile=/tmp/merged.pdf file1.ps file2.pdf file3.pdf ...

Under Windows

OpenOffice

The windows version of OpenOffice will work, as discussed above.

Via a special Printer Queue

The SambaPDFPrinter described above can almost certainly be shared via samba and printed to from Windows Applications, something similar can probably be done for the CUPS version mentioned above as well. If I ever get around to setting this up I'll wiki the results.

PDF-creator is a special PDF printer driver for Windows, based on GhostScript. (Released under GPL). This method has an advantage over the other Free methods in that it allows you to set access/print/copy permissions on the generated PDF. One disadvantage is that it must be installed by an Administrator. (In contrast, you can install and run OpenOffice as a normal windows user.)

From Word documents

If you don't have any PDF software installed (either Adobe or other), and just want to convert a Word document to PDF, there's an easy-to-use service at http://www.fastpdf.com. You upload your document, and enter your email address, and the service sends you a note when the conversion is done. (You then pick up the conversion from the website.) The service is free for short documents, and relatively inexpensive for longer docs ('much' cheaper than purchasing Adobe's software!). Note: this is a somewhat shameless plug (since I built the thing), but many people do find it convenient.

As with any PDF conversion service, Fast PDF can get confused by unusual fonts found in Word docs. But if you embed the fonts you use in your document prior to submitting it to the service, the service works very well.

Note: Anyone considering using the above website should be aware of the following from the terms of service:
You acknowledge and agree that Fast PDF, LLC may at its discretion insert advertising material into the file or files resulting from the conversion process.

In practice, the service adds a Converted at Fast PDF watermark in the margins of conversions done for free (but not those paid for).

PDFs with Macrons from Word documents

This can be a problem when the document contains Macrons and other characters not in all the standard character sets. The following technique appears to work at least in some cases where you have a PostScript printer visible and Adobe PDFWriter installed.

  1. Open the document in Word
  2. From the File / Print... dialog, select a PostScript printer and check the Print to file checkbox
  3. Hit Ok and supply a filename to save the .prn file with
  4. Open Notepad, and open the .prn in Notepad (not by double clicking it)
  5. The first line of the .prn should be quite long and contain lots of junk. Delete everything up to the "%!PS-Adobe-3.0". These must be the first characters in the file.
  6. Save the result as a .ps file
  7. Double clicking on the .ps file should launch Adobe PDFWriter to automatically create a PDF

The PDF file will almost certainly look dreadful because all the fonts that make things look nice on the screen got thrown away in the Print to file step. It should print nicely however.

For those without the budget for the full Acrobat, you can use the ps2pdf(1) program from GhostScript mentioned in the Linux section above.

From Publisher, for online publishing

You can use the MS Imagesetter Printer that is created by the Commercial Printer option when installing Publisher. This creates a pair of pseudo-printers on a Windows box, which can be used to Print to file if the app doesn't support such. The printers are called MS Publisher Colour Printer and MS Publisher Imagesetter and both are capable of colour. The Imagesetter one seems to work better.


Under MacOSX

The following have been tested under OSX 10.3 (Panther) only; someone else might want to confirm them on earlier versions.

  • From most applications (Safari, iCal, TextEdit and Preview etc...), you can select Print from the File menu and click on the Save As PDF... button and select your destination for your PDF.
  • From Preview, you can also select Export from the File menu, select PDF from the Format pulldown menu and select your destination for your PDF.