Embed all fonts in a pdf file


Vinh Nguyen


September 3, 2011

I recently had to embed all fonts in a pdf file for electronic submission of my dissertation. Embedding of fonts is usually required for publishing academic articles as well.

I generate my pdf files mainly with LaTeX using the pdflatex command. This post shows how one can embed fonts generated by the tex file; this option was turned on (default?) on my Ubuntu 11.04 laptop with TeX Live (2009?). However, this does not embed fonts from pdf files (figures) that are included in the tex file. This post and this post shows how to embed all fonts used in a pdf file:

pdf2ps myfile.pdf
ps2pdf13 -dPDFSETTINGS=/prepress myfile.ps myfile_embedded.pdf


gs -dSAFER -dNOPLATFONTS -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sPAPERSIZE=letter -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dCompatibilityLevel=1.4 -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true -sOutputFile=myfile_embedded.pdf -f myfile.pdf

My embedFontsPdf.sh script:

#! /bin/bash

# http://colinm.org/tips/latex
for file in "$@"
bn=`basename "$file"`
NameNoExt=${bn%.*} ## no extension
Ext=${bn/*./} ## extension http://www.linuxforums.org/forum/programming-scripting/128625-how-get-file-extension-without-dot.html
gs -dSAFER -dNOPLATFONTS -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sPAPERSIZE=letter -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dCompatibilityLevel=1.4 -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true -sOutputFile="${NameNoExt}_FontsEmbedded.pdf" -f "$file"

Use pdffonts to check that all fonts are embedded.