Tuesday, June 19, 2012

Create Thumbnails of PDF files in PHP, Java, Perl, or Ruby? - Yahoo! Answers

Create Thumbnails of PDF files in PHP, Java, Perl, or Ruby? - Yahoo! Answers


Best Answer - Chosen by Asker

It is possible in PHP, although you were right, you need a few libraries.

ImageMagic:
http://us3.php.net/imagick

Ghostscript:
http://sourceforge.net/projects/ghostscr…

Then, this code will get your thumbnail:

<?php
$im = new imagick('file.pdf[0]');
$im->setImageFormat( "jpg" );
header( "Content-Type: image/jpeg" );
echo $im;
?>

Haven't tried it myself, but seems like it would work

Source(s):

  • 1 person rated this as good
Asker's Rating:
3 out of 5
Asker's Comment:
Thanks I got it figured out, I just ended up pointing a new variable ($pdf) to the array item ($pdf_file_list[23]) and then set imageMagick to just convert the first page which is the cover by doing this: $im->readImage( 'library/'.$pdf.'[0]'); The code you gave me did work though.




0 comments:

Post a Comment