Arthik
Arthik

Reputation: 41

How to take convert a webpage to a image in javascript / Google web tool kit

I have a requirement to convert a webpage into a image. When a user clicks a button the new window need to display the webpage as a image.

IS it possible to do in Javascript or Google web tool kit?

Upvotes: 4

Views: 1021

Answers (1)

Joeri Sebrechts
Joeri Sebrechts

Reputation: 11146

Take a screenshot of a webpage with JavaScript?

Firefox has a "drawWindow" method on the canvas element that lets you copy a screenshot of the window into a canvas element (from where it can then be extracted). This is however not enabled for webpages (only for add-ons), because it forms a security risk: http://mxr.mozilla.org/mozilla/source/content/canvas/src/nsCanvasRenderingContext2D.cpp#2352

In short, plugins (or activex components) are the only sure way to go. Browsers aren't going to provide this as standard functionality because the risks outweigh the benefits.

Upvotes: 2

Related Questions