Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
  <script src="https://html2canvas.hertzen.com/build/html2canvas.js"></script>
</head>
<body>
  <p style="background: #F00; color: #0F0" id="Element">Hello World</p>
  
  
  <script>
   $(() => {
     var ReportTitle = 'Hello world!';
     
     var bigCanvas = $("<div>").appendTo('body');
     var scaledElement = $("#Element").clone()
     .css({
      'transform': 'scale(3,3)',
      'transform-origin': '0 0'
     })
     .appendTo(bigCanvas);
     
     var oldWidth = scaledElement.width();
     var oldHeight = scaledElement.height();
     var newWidth = oldWidth * 3;
     var newHeight = oldHeight * 3;
     
     bigCanvas.css({
       'width': newWidth,
       'height': newHeight
     })
     html2canvas(bigCanvas, {
       onrendered: function(canvasq) {
         var w=window.open();
         w.document.write("<h3 style='text-align:center;'>"+ReportTitle+"</h3>");
         w.document.write("<img width='"+oldWidth+"' height='"+oldHeight+"' src='"+canvasq.toDataURL()+"' />");
         w.print();
         bigCanvas.remove() 
       }
     });
   })
  </script>
  
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers