pdf with preview image

9 posts by 4 authors in: Forums > CMS Builder
Last Post: January 20, 2014   (RSS)

By Maurice - January 14, 2014

Hi has anyone done this

upload a pdf and generate a preview image or upload a image.

grts Maurice 

-------------------------------------------

Dropmonkey.nl

By aev - January 16, 2014

Hi,

we are also very interested in a feature like this. We have many clients uploading PDFs of brochures and manuals, and it would be great to be able to present a thumbnail/preview from these uploads.

Did some googling and it seems like ImageMagick/Ghostscript can do this, I'm unsure if GD is capable.

Maybe Interactivetools can extend CMSB or create a plugin to do this?

-aev-

By Djulia - January 16, 2014

Hi,

I use this script for my projects :
http://www.veryinteractivepeople.com/?p=521

With a little chance, it can function on your server.

Djulia

By aev - January 16, 2014

This looks interesting, but it would great if this was integrated into CMSB making the thumbnails available to our clients by choosing thumb 1,2,3 or 4 like they can with images today.

Do you build sites for clients? If yes can you briefly describe the steps they have to do use the solution you linked to.

Thanks!

-aev-

By Djulia - January 16, 2014 - edited: January 16, 2014

An example :

if($upload['extension'] == 'pdf') {
    $path_parts = pathinfo($upload['filePath']);
    /*
    [dirname] => /home/www/folder/...
    [basename] => filename.pdf
    [extension] => pdf
    [filename] => filename
    */
   
    $pdf = $upload['filePath'];
    $quality = 90;
    $res = '30x30';
    $exportPath = $path_parts['dirname'].'/'.$record['num'].'_'.$path_parts['filename'].'.jpg';
    exec("'gs' '-dFirstPage=1' '-dLastPage=1' '-dNOPAUSE' '-sDEVICE=jpeg' '-dUseCIEColor' '-dTextAlphaBits=4' '-dGraphicsAlphaBits=4' '-o$exportPath' '-r$res' '-dJPEGQ=$quality' '$pdf'",$output);
}

echo '<img>...';

You must certainly adapt it to your need.

It is also possible to adapt it in a plugin for a use in backend.

Djulia

By aev - January 16, 2014

I think this would work great for an upload field. We can than run your code to produce and present the thumbnails (maybe there should be some kind of cache). But I was more thinking about a wysiwyg field, then the client must know the url to manually insert the thumbnail and then link it to the PDF. For most clients this would be too technical and difficult.

But thanks for your code, it is an interesting starting point, but I hope Dave and his team will implement this into CMSB.

-aev-

By Maurice - January 17, 2014

All the idea's look great!!

i'm going to look into it next week hope to come with some great idea's my self and with my programmers.

I too wish it would be a standard feature in cmsb

Thnx 

Maurice

-------------------------------------------

Dropmonkey.nl

By ross - January 20, 2014

Hi Maurice

At this time we don't have plans for PDF thumbnails officially but I also like the ideas brought up in this thread. Keep us up to date with how you make out!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/