Tuesday 18 June 2013

Print the Report or Page using Javascript And PHP


Javascript file:
<script>
function printDiv(id)
{
  var divToPrint=document.getElementById(id);
  newWin=window.open('', '', 'left=5,top=10,width=1024,height=768,toolbar=0,scrollbars=0,status=0');
  var str='<html><head><link href="css/css.css" rel="stylesheet" type="text/css"/></head><body><div align="center"><img src="image/logo.png" border="0"></div><br/><div align="center"><b>Outstanding Report</b></div><br></body></html>';
  newWin.document.write(str);
  newWin.document.write(divToPrint.outerHTML);
  newWin.print();
  newWin.close();
}
</script>

Passing the Div ID parameter:
<input type="image" onClick="return printDiv('sprint');"  value="print"  src="image/printj.png" class="flrt" title="print report"/>
<div id="sprint">
<?php
// Dynamic Code here
?>
</div>
Expected Output:

No comments:

Post a Comment