pgmura
pgmura

Reputation: 716

Generate a thumbnail for the first page of a PDF within a rails App?

Is there anyway to generate a thumbnail image for the first page of an uploaded PDF file. I want to display this image along with the description (provided by the user) of the file.

Upvotes: 3

Views: 6140

Answers (2)

wesgarrison
wesgarrison

Reputation: 7105

You can use an image processing library like ImageMagick to convert a PDF into an image.

Call out to the system with something like:

system("convert -size 150x150 /path/to/uploaded/document.pdf /path/to/thumbnail/file.png")

Upvotes: 0

mopoke
mopoke

Reputation: 10685

The first answer from this question looks like it'll do what you want.

Upvotes: 2

Related Questions