2

Trying to create image(screenshot) of a HTML page using javascript. Able to generate the html blob and display the same in new tab as read only HTML page using the below code.

var scr = document.documentElement.cloneNode(true);
var blob = new Blob([scr.outerHTML], {type: 'text/html'});
window.open(window.URL.createObjectURL(blob));

Please anyone could tell me how to save the same as image.

Bakudan
  • 19,134
  • 9
  • 53
  • 73
Krish
  • 21
  • 1
  • 3
  • 1
    yes couldn't get anything near – Krish Nov 15 '12 at 05:04
  • here is what i found: http://html2canvas.hertzen.com/ http://www.nihilogic.dk/labs/canvas2image/ http://grabz.it/ http://stackoverflow.com/a/9269601/834424 – dbrin Nov 15 '12 at 06:47

1 Answers1

0

Take a look at FileSaver.js,

var bb = new BlobBuilder();
bb.append((new XMLSerializer).serializeToString(document));
var blob = bb.getBlob("application/xhtml+xml;charset=" + document.characterSet);
saveAs(blob, "document.xhtml");

Some Documentation

API

Dane Balia
  • 5,271
  • 5
  • 32
  • 57