Sunday 21 June 2015

Visualforce page screenshots with JavaScript - html2canvas

html2canvas



This script allows you to take "screenshots" of webpages or parts of it, directly on the users browser. The screenshot is based on the DOM and as such may not be 100% accurate to the real representation as it does not make an actual screenshot, but builds the screenshot based on the information available on the page.

In Visualforce page
<apex:page showHeader="false">
<script src="//cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js"></script>
<div>
    Hello world !
</div>

<script>
html2canvas(document.body, 
 {
    useCORS: true,
    onrendered: function(canvas) 
    {
        document.body.appendChild(canvas);
    }
 })
</script>
</apex>

No comments:

Post a Comment