Preview Thumbnails for PDFs - possible?

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.

I’m curious, Roland

I did this on a website.

I set up an image attribute and the assigned it to files. I then upload a jpg to the pdf and pulled it into the list on the website.

Unfortunately it was automatically generated.

1 Like

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.

2 Likes

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.

Thank you mesuva for you reply. I will contact you directly to discuss this further.

I’m using a cloudinary free account for this:
If you map cloudinary to your website

is available at


and there are many url-options to edit the result:

1 Like

We’ve done the custom implementation using ImageMagik and AWS Lambda.

The flow is

  • Fire a script to send PDF file to the internal (script with ImageMagik) or external service (AWS Lambda)
  • The external service mentioned above create the thumbnail image
  • The external service ping back to Concrete to import the image & register it to thumbnail attribute or simply upload as a new image

The problem was that PDF file size could be very large.
ImageMagik couldn’t handle large PDF file.

So we ended up using AWS Lambda + Step Functions.
But it was a lot of work and test.

1 Like

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).

We use cloudinary elsewhere, that could work if we cannot handle it with imagick. Thanks for your suggestion!

I have tested the addon that @mesuva was suggesting and it’s awesome.

It’s really works, just upload the pdf and it generates the thumbnail.