4

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?

void
  • 36,090
  • 8
  • 62
  • 107
Arthik
  • 41
  • 2

1 Answers1

2

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.

Community
  • 1
  • 1
Joeri Sebrechts
  • 11,012
  • 3
  • 35
  • 50