PDF thumbnail

How do I create a thumbnail of PDF file, maybe the thumbnail of the cover page.

Using Imagemagick:


exec("convert -density 300 input.pdf[0] -thumbnail 200x200 output.jpg");