Hi Concrete Forum
Does anyone ever developed something like this? Uploading a PDF in the filemanager generates a preview of the first page and can be showed als preview thumnail instead of the pdf icon.
We were asked if we could do this for an extranet. There are stored a lot of pdfs and a thumbnail would be a nice improvement for readers before the download it.
Yes, I’ve done this, and add-on to make the file manager pick up that it’s a PDF you are uploading, and create a jpg preview of the first page and associate that as an attribute. It relies on ImageMagick being available. That codes doesn’t create a file manager thumb as such (so the File Manager will still show the icon), but assigning an image as a file attribute made it pretty easy to then output it in a list of files. (List Files From Set, for example). It might be possible to also assign the preview as a file manager thumb as well.
Alongside that add-on I have a similar one that fetches the initial text from a PDF and stores that in an attribute, to make it searchable. I mention that, as for something like a library of PDFs, being able to search them to some extent by their contents might be just as important as seeing a preview.
I wrote both add-ons for 5.7 sites, so haven’t tested them for V9, but I suspect they would still work with only minor updates needed. Feel free to get in contact if you’d want to test out the code I have, or if you wanted to discuss me putting together something more ‘finished’ for V9.
Thanks @TMDesigns for your answer. This suggestion would be the way to go and using a separate attribute to save the associated thumbnail. And using imagick ore something else to generate the thumbnail.
Mesuvas suggestion seems to have a similar approach.
Thanks for your feedback!
We are going to use imagick for the moment and will see if it could handle our pdfs. Mesuva is helping us out.
An plan b could be to use an external service for generating that thumbnail (we also use cloudinary on one project as another user mentioned above).