JSFiddle - React, Tailwind, and code Playground

by ano

HTML

<script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>
<TITLE>
  A Small Hello
</TITLE>

<BODY id="test">
  <H1>Hi</H1>
  <P>This is very minimal "hello world" HTML document.</P>
</BODY>

JavaScript

function domElementToImg(domElement, callBackFunction) {
  html2canvas(domElement, {
    onrendered: function(canvas) {
      callBackFunction(canvas.toDataURL('image/jpeg',0.5));
    },
     width: 300,
  height: 300
  });
}


domElementToImg($('#test'), function(imgData) {
  //console.log(imgData);
  window.open();
});