F
F
FallenBlick2015-02-03 17:08:58
PHP
FallenBlick, 2015-02-03 17:08:58

How to display a thumbnail of a pdf file on a website?

There are 10 pdf files. Each contains several pages.
The site has a page with links to download and view these pdf files.
I want to display thumbnails of the first pages of PDF files next to it.
Tried Imagick, but something is still wrong.

$myurl = realpath('file.pdf[0]');
  $image = new Imagick($myurl);
  $image->setResolution( 300, 300 );
  $image->setImageFormat( "png" );
  $image->writeImage('newfilename.png');

OpenServer 5.1.1. outputs the following message:
( ! ) Fatal error: Uncaught exception 'ImagickException' with message 'Can not process empty Imagick object' in D:\OpenServer\domains\test.local\index.php on line 18
( ! ) ImagickException: Can not process empty Imagick object in D:\OpenServer\domains\test.local\index.php on line 18

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Max, 2015-02-03
@AloneCoder

In general, it would be better for you to walk along the crown to do a preview in advance
. And in your realpath - is the path recognized correctly?

M
Moskus, 2015-02-04
@Moskus

Do you have ghostscript installed? Without it, IM cannot read PostScript and PDF as its special case.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question