Embedding fonts in PDF-files

A while back I wrote a course-reader in OpenOffice.org Writer on Ubuntu. When I submitted it for printing, it turned out that not all fonts were embedded in the document, which led to various printing- and layout-problems. Here's some advice on how to create PDFs that are suitable for printing by third parties.

OpenOffice.org

Make sure you use OpenOffice.org 3.x, export as PDF and try selecting select the option "PDF A/1". This should produce a PDF/A compliant file which is suitable for archiving, and therefore has to have all fonts embedded. Also, for best printing-results the compression of images should be set to lossless.
In the past there were several problems with this method. First, PDF/A apparently does not support transparant objects. Unfortunately, instead of simply blending my embedded PNG-files with the background, older versions of OpenOffice.org PDF/A export seemed to erraticly convert transparant areas to black. Moreover, in some versions of OpenOffice.org Writer (e.g. 3.0.1) PDF A/1 export seems to produce invalid PDF-files (Adobe Reader 9 complains about an invalid colorspace). Luckily a "normal" PDF-export seems to work fine these days, and also seems to include all the fonts I need for printing...

Mac

MacOS X natively supports printing as PDF from within any application. When printing, select PDF and then Save as PDF-X. This will produce a PDF/X compliant file which is suitable for device-independent printing, and therefore has to have all fonts embedded.

Windows

You can use the excellent and free PDFCreator to print as PDF from within any application. When printing, select PDFCreator as the printer. When printing, a dialog comes up that allows you to enter metadata (title, author, etc.). Click Options, then click Formats and select PDF. Select the Fonts tab, and make sure the "Embed all fonts" option is selected. For best printing-results, all image-compression-options should also be deselected in the Compression tab. Newer versions of PDFCreator also have an option for creating PDF/A compliant files. I haven't tested it though.

If you use Adobe Acrobat (Distiller, PDF Writer or PDFMaker) to create PDFs, you can select PDF/A compliance (in newer versions) or alternatively follow this guide by Adobe or this guide from Planet PDF to make sure all fonts are embedded.

Checking your PDF-file

As most people use Adobe Acrobat or Adobe Reader to print PDFs, it's always a good idea to open the file in Adobe Reader and check for layout-problems. On Ubuntu, you can install Adobe Reader from the Medibuntu repository. You can also see which fonts are embedded by clicking File > Properties > Document Properties > Fonts. All fonts should have "Embedded" or "Embedded Subset" listed after the font name. In Ubuntu and other Linux-distros you can also use the pdffonts command to list all fonts in a PDF-file. Embedded fonts have "yes" in the "emb" column.

Embedding fonts into an existing PDF-file

In Ubuntu: Make sure you install all fonts that you want to embed. Here I have listed some tips for installing fonts in Ubuntu. You can use Ghostscript to create a new PDF-file that has all fonts embedded. The easiest way is to use Ghostscript's internal PDF-reader to convert the file:

gs -q -dNOPAUSE -dBATCH -dPDFSETTINGS=/prepress -sDEVICE=pdfwrite -sOutputFile=output.pdf input.pdf

This usually works fine, but Ghostscript's PDF parser is known to sometimes mess up graphics. To avoid this, you can first use the tool pdftops that comes with Poppler/Xpdf (packages poppler-utils and/or xpdf-utils) to convert the PDF-file to PostScript:

pdftops input.pdf
gs -q -dNOPAUSE -dBATCH -dPDFSETTINGS=/prepress -sDEVICE=pdfwrite -sOutputFile=output.pdf input.ps

In Windows: Make sure you have all fonts installed. If you have Adobe Acrobat, you can open the PDF file and use Tools > Advanced Editing > Touch Up Text Tool. Select the text that uses a non-embedded font, right-click and select Properties. Select the font you would like to embed and then save the document. With recent versions of Acrobat you can use the Preflight tool to convert PDFs to PDF/X or PDF/A compliant files (Options > Convert Current PDF To PDF/X).

If you don't have Adobe Acrobat, you can try downloading a Windows-version of AFPL-Ghostscript and following the instructions for Ubuntu above.

On MacOS X:Follow the instructions above, either with the Mac version of Adobe Acrobat, or with a recent version of Ghostscript for MacOS X. GPL Ghostscript versions (gplgs) for MacOS X can be found e.g. here: http://www.openprinting.org/download/printdriver/macosx/ Or you can try the older ESP version of Ghostscript: http://gimp-print.sourceforge.net/MacOSX.php

Extracting fonts from a PDF

This may occasionally be useful and can easily be done in Ubuntu using Fontforge. Note that fonts in PDF-files (that are not PDF/A or PDF/X compliant) tend to be subsetted and therefore incomplete.
Follow this guide: http://init.sh/?p=13
Or alternatively see this page for additional methods: http://cg.scs.carleton.ca/~luc/pdfextract.html

References:

http://www.sas.upenn.edu/computing/help/students/dissertation-pdf
http://zeppethefake.blogspot.com/2008/05/embedding-fonts-in-pdf-with-gho...
http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=4338