0

This is my footer in javascript.

$("").printThis({
     footer: " "+$("#table").text()+" <br><h4>Total in Words : 
     "+$("#txtWord").text()+"</h4>"
});

this is my table

<div id="table">
    <div class="col-sm-12">

        <table id="tabledata" width="500" style="font-family: arial; text-align: center;border-collapse: collapse;  border: 0.1px solid black;padding: 7px; display: none;">
            <thead>
                <tr>
                    <th>Sl.No</th>
                    <th>Emp Name</th>
                    <th>Emp ID</th>
                    <th>Emp Gender</th>
                    <th>Emp Salary</th>
                </tr>
            </thead>

       </table>
   </div>

I am printing this table in my print page. I want to print this table using jQuery footer. but not able to get that values. that just printing the values as

Sl.No Emp Name Emp ID Emp Gender Emp Salary 910/02/201863TOTAL63=00

This is the output from the print page that I was printing. Anyone knows how to print please tell me. Thanks in advance.

2
  • Have to edited your CSS @page rule Commented Apr 23, 2018 at 5:06
  • I am using Print.js plugin for printing page. I am not able to css files in that plugin. Commented Apr 23, 2018 at 5:21

2 Answers 2

1

If your table visible, you can simply add footer: $("#table"), but here, your table not hidden.

So, first, we need to add visible to the table before pass the data

$(function(){    
    $('').printThis({
        debug: false,        
        footer: $("#table").clone().children().find('table').css('display','block').get(0),
    });
});

working example : https://jsfiddle.net/kk35mcnx/1/

Sign up to request clarification or add additional context in comments.

Comments

0

You can use http://www.w3.org/TR/CSS21/media.html

You can realize that through popup window - in this window show only table and send it to printer.

Simple example

<script>
    function printDiv() {
        var divToPrint = document.getElementById('areaToPrint');
        newWin = window.open("");
        newWin.document.write(divToPrint.outerHTML);
        newWin.print();
        newWin.close();
   }
</script>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.