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:

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

or

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 "$@"
do
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"
done

Use pdffonts to check that all fonts are embedded.

About Vinh Nguyen

Statistician

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>