imagemagick - rails: produce pdf and render it as image -


i'm trying produce pdf , send file, or, better, render image in browser, using imagemagick , wicked_pdf.

i'm able send something, it's not recognized image os. pdf string generated correctly, suppose problem in image part

this code of controller:

  format.jpg     @format = :pdf      pdfstr =  render_to_string 'generated_graphics/tag.erb', :pdf => "tag", :layout => nil, :page_height => '38mm', :page_width => '129mm'      file = tempfile.new('foo')     file.write pdfstr     file.close      require 'rmagick'       pdf = magick::imagelist.new(file.path)     send_data pdf.write("myimage.jpg"), :type => 'image/jpg'   end 

take @ imagemagick , rmagick plugin ruby. allows kinds of image conversions, including pdf jpeg.

http://rmagick.rubyforge.org/

edit:

untested sample code:

require 'rmagick'   pdf = magick::imagelist.new("doc.pdf") pdf.write("myimage.jpg")  

if doc.pdf has 3 pages, should output 3 images: myimage.jpg.0 myimage.jpg.1 myimage.jpg.2

take @ end of documentation on page, shows similar example multi-frame gif converted multiple pngs


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -