Printing Image in asp dot net
-
I have image control on my asp.dot page, i want to print that image. how can i do it? help please
-
I have image control on my asp.dot page, i want to print that image. how can i do it? help please
You know 'window.print()' function will print the HTML content of the current page in the browser window. Put the image in a DIV tag and then use the following code. The content of the DIV is written to a new window and then printed in this code.,
<script type="text/javascript">
function ClientSidePrint(idDiv)
{
var w = 600;
var h = 400;
var l = (window.screen.availWidth - w)/2;
var t = (window.screen.availHeight - h)/2; var sOption="toolbar=no,location=no,directories=no,menubar=no,
scrollbars=yes,width=" + w + ",height=" + h + ",left=" + l + ",top="+t;
// Get the HTML content of the div
var sDivText = window.document.getElementById(idDiv).innerHTML;
// Open a new window
var objWindow = window.open("", "Print", sOption);
// Write the div element to the window
objWindow.document.write(sDivText);
objWindow.document.close();
// Print the window
objWindow.print();
// Close the window
objWindow.close(); }
</script>