Friday, 5 February 2016

No border on HTML table when printing solution

Put style code within Printable Div

<script>
function printDiv(divid) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

     document.body.innerHTML = printContents;

     window.print();

     document.body.innerHTML = originalContents;
}
</script>
    <input type="button"  class="btn btn-primary pull-right" onclick="printDiv('printableArea')" value="Print Invoice" />


<div id="printableArea">
 <style>
table, td, th {  
    border: 1px solid #ddd;
    text-align: left;
}
table {
    border-collapse: collapse;
    width: 100%;
}
th, td {
    padding: 15px;
}
</style>


content to print


<div>

No comments:

Post a Comment