Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Looking for a way to automatically generate a thumbnail from PDF file

595 views
Skip to first unread message

briant...@gmail.com

unread,
Feb 8, 2016, 5:35:48 PM2/8/16
to mozilla-d...@lists.mozilla.org
I'm using pdf.js as my PDF viewer on multiple websites where the PDF's change every week. I have this repetitive task of creating a thumbnail of the first page of the PDF documents every time and am hoping someone might have a script that can automate this.

I tried searching through the posts in this group, as it seems this would be a fairly common request, but everything close seemed to be asking for extra things on top of this and it was hard to separate everything out; I'm more of a designer than a programmer. I can work my way through code when I see it, it's just hard to write it from scratch.

If you can at least point me in the right direction I'd really appreciate it.

Thanks.

Daan Sprenkels

unread,
Feb 9, 2016, 10:05:26 AM2/9/16
to briant...@gmail.com, mozilla-d...@lists.mozilla.org
Hey Brian,

Unless you would like to do this on the client side, I would recommend
taking a look at ImageMagick. (stackoverflow-ref
<http://stackoverflow.com/q/2869908/5207081>, docs
<http://www.imagemagick.org/script/command-line-processing.php>). Using
this, you can generate the thumbnail on the server.
The command for the conversion of the first page of a PDF file could be:

convert a.pdf[0] -resize x300 a-thumbnail.png

This will load the first page of a.pdf, resize it so that it has a height
of 300 pixels and output the image to a-thumbnail.png.

Best regards,
Daan Sprenkels
> _______________________________________________
> dev-pdf-js mailing list
> dev-p...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-pdf-js
>
0 new messages