Page Screenshot in Rails

Have you ever been through a situation where you need to embed a Flash object or some other element in a pdf file which cant be done directly? There is gr8 solution for it

with the help or combination of RMagick + Image Magick + win32Screenshot gem you can take the screenshot of the desktop or webpage and generate an image from it and eventually embed it in your pdf file

Here is the code for it

require 'win32screenshot'
require 'RMagick'
def screenCapture
  width, height, bitmap = Win32::Screenshot.desktop
  img_lst = ImageList.new
  img_lst.from_blob(bitmap)
  img_lst.write('public/screen.png')
 true
end

If you are stuck any where just write to me or post a comment hereI would be pleased to solve your error
Be Sociable, Share!

Leave a Reply

Your email address will not be published. Required fields are marked *