<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
</head>
<body>
<form id="form1">
<div id="dvContainer">
This content needs to be printed.
</div>
<input type="button" value="Print Div Contents" id="btnPrint" />
</form>
<script>
$("#btnPrint").on("click", function() {
//alert($(window).height());
var ht = $(window).height();
var wt = $(window).width();
var divContents = $("#print_content").html();
var printWindow = window.open('', '', 'height=' + ht + 'px,width=' + wt + 'px');
printWindow.document.write('<html><head><title>Rail Bhojan Order details</title>');
printWindow.document.write('<link href="<?=base_url()?>web_assets/css/bootstrap.css" rel="stylesheet" media="screen"> <link href="<?=base_url()?>web_assets/css/custom.css" rel="stylesheet" media="screen">');
printWindow.document.write('</head><body>');
printWindow.document.write(divContents);
printWindow.document.write('</body></html>');
printWindow.document.close();
printWindow.print();
});
</script>
</body>
</html>
0 comments:
Post a Comment