Chapter 14

cpdf -list-fonts in.pdf

cpdf -copy-font fromfile.pdf -copy-font-page <int>
     -copy-font-name <name> in.pdf [<range>] -o out.pdf

cpdf -remove-fonts in.pdf -o out.pdf

cpdf -missing-fonts in.pdf

cpdf -embed-missing-fonts -gs <path to gs> in.pdf -o out.pdf

14.1 Listing Fonts

Described in Section 11.1.

14.2 Copying Fonts

In order to use a font other than the standard 14 with -add-text, it must be added to the file. The font source PDF is given, together with the font’s resource name on a given page, and that font is copied to all the pages in the input file’s range, and then written to the output file.

The font is named in the output file with its basefont name, so it can be easily used with -add-text.

For example, if the file fromfile.pdf has a font /GHLIGA+c128 with the name /F10 on page 1 (this information can be found with -list-fonts), the following would copy the font to the file in.pdf on all pages, writing the output to out.pdf:

cpdf -copy-font fromfile.pdf -copy-font-name /F10
     -copy-font-page 1 in.pdf -o out.pdf

Text in this font can then be added by giving -font /GHLIGA+c128. Be aware that due to the vagaries of PDF font handling concerning which characters are present in the source font, not all characters may be available, or the encoding (mapping from input codes to glyphs) may be non-obvious.

14.3 Removing Fonts

To remove embedded fonts from a document, use -remove-fonts. PDF readers will substitute local fonts for the missing fonts. The use of this function is only recommended when file size is the sole consideration.

cpdf -remove-fonts in.pdf -o out.pdf

14.4 Missing Fonts

The -missing-fonts operation lists any unembedded fonts in the document, one per line.

cpdf -missing-fonts in.pdf

The format is

Page number, Name, Subtype, Basefont, Encoding

The operation -embed-missing-fonts will process the file with gs (which must be installed) to embed missing fonts (where found):

cpdf -embed-missing-fonts -gs gs in.pdf -o out.pdf