Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PDF Image thumbnail preview in laravel 5.1?

I have file module, where I want to list all files,with thumbnail preview.

as like follows,

enter image description here

I am storing files in storage folder,which is not accessible via http.

So How can I provide thumbnail preview for docs especially image and PDF.

Is there any package availabe in laravel 5.1?

like image 887
gsk Avatar asked Sep 17 '15 12:09

gsk


1 Answers

The preview image of a PDF file is usually the first page of the PDF file.

You can use ImageMagick to obtain that first page of the PDF file.

<?php
$imagick = new imagick('sample.pdf[0]'); // 0 specifies the first page of the pdf

$imagick->setImageFormat('jpg'); // set the format of the output image
header('Content-Type: image/jpeg'); // set the header for the browser to understand
echo $imagick; // display the image
?>

You can also output (save the contents of the image in a file) and store it under a thumbnail folder with the PDF name as the file name. like ( sample.jpg )

As for a solution based on laravel, I don't think laravel has any package that can do the same

like image 55
Magesh Kumaar Avatar answered Sep 27 '22 19:09

Magesh Kumaar