This function will generate a thumbnail in png format for a pdf document using - ImageMagick ( http://php.net/imagick ) , Ghostscript (https://sourceforge.net/projects/ghostscript/)
Download above files and uncomment usage example in index.php and open it in the browser , if everything goes right, a file with name pdfthumbdemo.png file will be created inside thumbails directory