0

I have a 'design' web page which have some design templates frame with some theme images and colors. and i want to convert this web page to an image. I tried to use imgKit, wkhtml2image gem but it is only displaying Login page as image, It is not showing the page which we require. I tried to go with "html2canvas" as well but it only displays layout. It does not display the page content. Please see the code:

def design_update
  respond_to do |f|
    f.json do
      just_promo_params = promotion_params
      theme_params = just_promo_params.delete(:theme_attributes)

      if ThemeEngine::UpdatesThemeWithHistory.update_with_promotion(
        promotion,
        just_promo_params,
        theme_params,
        current_user)

        ASNWithControllerContext.instrument 'promotion.saved_design',
        context: self,
        promotion: promotion

        render status: 200, json: {errors: []}
      else
        render status: 200, json: {errors: [promotion.errors.full_messages]}
      end
    end
  end
end

I have to convert this json content into image. Any ideas how to do this?

Pardeep Dhingra
  • 3,916
  • 7
  • 30
  • 56
Bharat Bhushan
  • 305
  • 1
  • 14
  • Do you mean that you want to generate an image file of the rendered web page, like you would get from a screengrab? If so then I believe `htmlcanvas2` will do it: if you tried this and it's not working then you should try to find out why and fix it. http://stackoverflow.com/questions/18231259/how-to-take-screen-shot-of-current-webpage-using-javascript-jquery – Max Williams Jan 14 '16 at 09:28
  • yes, @MaxWilliams I am getting content in JSON format. We have to covert this to image JPG/PNG – Bharat Bhushan Jan 14 '16 at 09:31
  • Your first step should be to simply render it out as a web page and get it looking like you want it to look there. Then take a screengrab, either via rails (ie server side) or via javascript (client side). You say you tried some gem and it's showing the login page: this looks like it's getting bounced to the login page by your authentication system, when it tries to load the page. This must be a common problem and i'm sure there are many well documented approaches to get past it. – Max Williams Jan 14 '16 at 09:35

0 Answers0