December 11, 2013

Embed fonts in a pdf after pdflatex

Command to embed fonts in pdf :)

gs -q -dNOPAUSE -dBATCH -dPDFSETTINGS=/prepress -sDEVICE=pdfwrite -sOutputFile=output.pdf input.pdf

If you run this in your final pdf file then you can end up having multiple copies of the embedded fonts -- thanks to pdflatex thinking that each font missing is belongs to a different font family.  
 I had this problem because I used R to generate the plots.
So for the folder in which the plots are present I ran the following command. 



for d in *.pdf; do gs -q -dNOPAUSE -dBATCH -dPDFSETTINGS=/prepress -sDEVICE=pdfwrite -sOutputFile=output.pdf ${d}; mv output.pdf ${d}; done

I then ran pdflatex and it worked :)



No comments: