Super Nerdy Cool

My (technical) adventures through the professional world…
September 3, 2011

Embed all fonts in a pdf file

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:

 <pre class="src src-sh">pdf2ps myfile.pdf

ps2pdf13 -dPDFSETTINGS=/prepress myfile_embedded.pdf


 <pre class="src src-sh">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 script:

 <pre class="src src-sh"><span style="color: #ff4500;">#</span><span style="color: #ff4500;">! /bin/</span><span style="color: #00ffff;">bash</span>

# for file in “$@” do bn=basename "$file" NameNoExt=${bn%.} ## no extension Ext=${bn/./} ## extension 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” done

Use pdffonts to check that all fonts are embedded.

Leave a Comment