I have file module, where I want to list all files,with thumbnail preview.
as like follows,
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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With