title: PDF: How to Optimize Filesize & Convert to PNG (embedded fonts problem)
body: <p>I have a PDF with embedded fonts that I can't seem to work with. Right now, I'm using GhostScript and trying to do 2 things:</p>
  
  <ul>
  <li><p>Minimize filesize of PDF:</p>
  
  <p>gswin32c -dSAFER -dBATCH -dNOPAUSE -dQUIET -sDEVICE=pdfwrite -sOutputFile=output.pdf input.pdf</p></li>
  <li><p>Convert PDF to PNG (super sample, to be used for creating other thumbnails):</p>
  
  <p>gswin32c -dSAFER -dBATCH -dNOPAUSE -dQUIET -dFirstPage=1 -dLastPage=1 -r288 -sDEVICE=png16m -sOutputFile=output.pdf input.pdf</p></li>
  </ul>
  
  <p>The above works well when working on scanned documents. But when I run them against PDFs with embedded fonts (the PDF is generated on the fly by an application), it fails. Here's the error I get:</p>
  
  <pre><code>GPL Ghostscript 8.71: Warning: 'loca' length 274 is greater than numGlyphs 136 i
  n the font UUGHDE+ArialMT.
  GPL Ghostscript 8.71: Warning: 'loca' length 274 is greater than numGlyphs 136 i
  n the font UUGHDE+ArialMT.
  GPL Ghostscript 8.71: Warning: 'loca' length 188 is greater than numGlyphs 93 in
   the font UUGHDE+Arial-BoldMT.
  GPL Ghostscript 8.71: Warning: 'loca' length 188 is greater than numGlyphs 93 in
   the font UUGHDE+Arial-BoldMT.
  </code></pre>
  
  <p>Aside from GhostScript, I also have access to PDFTK and ImageMagick (which might be replaced with GraphicsMagick). I'm also open to other solutions.</p>
  
  <p>Development is on WAMP. Deployment is to LAMP.</p>
  
  <p>Suggestions?</p>