I wanted to publish my master’s thesis using the Lulu Marketplace. If you upload a PDF file to Lulu a requirement is that all fonts are embedded. I thought that this was no problem because I had configured my Latex distribtion to embed all fonts when producing PDF files (if you want to know how to do this read on here). But I was wrong.
The Lulu upload
system insisted that my PDF file did not have all fonts embedded. I used the
pdffonts utility (it comes with Poppler)
to check if there were really some fonts missing. And Lulu was right, some
fonts were not embedded in the PDF file.
The problem was that some of the PDF figures which I included in my thesis did
not embed the used fonts themselves and
pdflatex does not embed fonts in
included PDF files. I searched the web for solutions and quickly found out that
missing fonts can be embedded into a PDF file using Ghostscript. So I tried the
various found ghostscript command lines on the PDF file of my thesis. But the
fonts of the included PDF figures were not embedded. I had to find out that
Ghostscript behaves much the same like
pdflatex when embedding fonts. Missing
fonts in “nested” PDF files are not embedded. The solution is that you have to
embed the missing fonts in the PDF figures prior to processing them with
pdflatex. To embed missing fonts into a PDF file you can use this command:
$ gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=<output file> -c ".setpdfwrite <</NeverEmbed [ ]>> setdistillerparams" -f <input file>
After I have used this command on all my PDF figures and reran
accepted my master’s thesis. This command line is pretty cryptic so I will
loose a few words about it. You can either directly use a command called
ps2pdf or use gs with the correct options. That’s how I did it.
just a script which calls
ps2pdf14 which in turn
finally invoke the
gs program with some specific options set. In summary, the
used options cause Ghostscript to produce a PDF file from the input and to
immeditely return after it has finished. To understand the used ghostscript
command one has to check various manuals:
- Documentation of the Acrobat Distiller 5 parameters: The ps2pdf utility from Ghostscript 8 vastly corresponds to Acrobat Distiller 5. Though the documentation of ps2pdf lists all the supported Acrobat Distiller 5 parameters and their default values the parameters itself are not described. An explanation of the parameters can only be found in the Adobe document about the Acrobat Distiller Parameters for version 5.
- Documentation of the ps2pdf command: As already
ps2pdfutility is a work-alike for nearly all the functionality (but not the user interface) of Adobe’s Acrobat Distiller product (it converts PostScript files to PDF files). The Ghostscript options which are specific to the handling of PDF files are documented in this document.
- Documentation of the gs program: This document documents the generic Ghostscript options.
When the default PDF profile is used (
-dPDFSETTINGS) only one
thing has to be changed in order for all fonts to be embedded. Parameters like
SubsetFonts are already correctly set. The only exception
NeverEmbed parameter. This is an array which specifies which fonts
will never be embedded. When using the default, screen or ebook PDF profile it
includes the 14 standard fonts (Courier, Helvetica, and Times families, Symbol,
and ZapfDingbats). The NeverEmbed array can not be specified on the command
line. To specify it you must use PostScript by passing the -c command-line
parameter to ghostscript as described.