I am trying to print the page by java script. The code is like :
<script type="text/javascript">
function PrintContent(){
var DocumentContainer = document.getElementById("divtoprint");
var WindowObject = window.open("", "PrintWindow","width=1200,height=650,top=50,left=50,toolbars=no,scrollbars=yes,status=no,resizable=yes");
WindowObject.document.writeln(DocumentContainer.innerHTML);
WindowObject.document.close();
WindowObject.focus();
WindowObject.print();
WindowObject.close();
}
</script>
Then I called that function <a onclick="PrintContent();" style="cursor:pointer;"><img src="images/printer.png" alt="Print" title="printer"/></a>
Also the contents which I want to print, put within <div id="divtoprint"> </div>.
But in this case, I am getting the print page without css style. So how to integrate the css to my print page also? Please help me.
Try: