title: How do you convert PDFs to PNGs with ghostscript?
body: <p>I'm usually able to use ghostscript to convert PDFs to PNGs with the command:</p>
  
  <pre><code>gs \
   -q \
   -dNOPAUSE \
   -dBATCH \
   -sDEVICE=pnggray \
   -g2550x3300 \
   -dPDFFitPage \
   -sOutputFile=output.png \
    input.pdf
  </code></pre>
  
  <p>But this doesn't work for some PDF files. For example, the command above converts this <a href="http://partifi.org/stackoverflow/bad.pdf" rel="nofollow">PDF file</a> to this <a href="http://partifi.org/stackoverflow/bad.png" rel="nofollow">PNG</a> -- the original PDF is just a small image in the lower left corner of the PNG, instead of filling the entire page. </p>
  
  <p>Is there a more robust way to convert PDFs to PNGs with ghostscript, or perhaps some other command line tool?</p>
  
  <p>Note: If I generate a new PDF file from the problematic one via "print -> save as pdf" in Preview on OS X, then the command works fine.</p>