Tuesday, December 10, 2013

Print image from javascript




The below are the javascript function for print the image
 
<script type="text/javascript">
        function printImage() {
            var image = document.getElementById('imageControl');
            var printWindow = window.open('', 'Print Window', 'height=400,width=600');
            printWindow.document.write('<html><head><title>Print Window</title>');
            printWindow.document.write('</head><body ><img src=\'');
            printWindow.document.write(image.src);
            printWindow.document.write('\' /></body></html>');
            printWindow.document.close();
            printWindow.print();
        }
  </script>


Call the javascript function from below code 

<a id="link" style="font-size:2em" onclick="printImage()" href="#">
<img src="Images/print.png" />
</a>
 


 

No comments:

Post a Comment