How to transform a pdf document into an image..?

I would like to display in my app the image of the cover page af an
pdf document produced internnally within my app ( wich plugin should
be better … ? pdfwrite ?.. generally it will be a less than 2 pages
on the home page I would like to display the cover pages as png or jpg
with a link to the document or another action…

thanks for your suggestions


  1. We’re using PDF:Writer and it should be fine with a small, 2 page
    document that you’re describing.

  2. We’re doing exactly the sort of image conversion that you’re
    describing via RMagick. We’d originally installed RMagick for use
    with the early versions of acts_as_attachment (necessary for image
    uploading). It has some well-documented memory leaks, though. The
    code below is based on attachment_fu/acts_as_attachment but should be
    easily enough adapted:

file_path = File.join(RAILS_ROOT, “public”, @image.public_filename)
img = Magick::Image::read(file_path)
img[0].write File.join(RAILS_ROOT, “public”, “images”, “temp_pdf.jpg”)

(I’m off to get that last bit cleaned up… as is, each user will
clobber the other :frowning:

For image attachments and showing their thumbnails, Paperclip is a good
alternative to attachment_fu. It doesn’t need RMagick, but it does need
ImageMagick. Here’s the introductory blog post:

Googling for

rails paperclip

produces lots of relevant hits.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs