If you are fortunate enough to scroll to this point, I found a solution for Firefox. It will print content from a specific div without footer and headers. You can customize as you wish.
First, download and install this add-on: JSPrintSetup .
Secondly write this function:
<script> function PrintElem(elem) { var mywindow = window.open('', 'PRINT', 'height=400,width=600'); mywindow.document.write('<html><head><title>' + document.title + '</title>'); mywindow.document.write('</head><body >'); mywindow.document.write(elem); mywindow.document.write('</body></html>'); mywindow.document.close(); // necessary for IE >= 10 mywindow.focus(); // necessary for IE >= 10*/ //jsPrintSetup.setPrinter('PDFCreator'); //set the printer if you wish jsPrintSetup.setSilentPrint(1); //sent empty page header jsPrintSetup.setOption('headerStrLeft', ''); jsPrintSetup.setOption('headerStrCenter', ''); jsPrintSetup.setOption('headerStrRight', ''); // set empty page footer jsPrintSetup.setOption('footerStrLeft', ''); jsPrintSetup.setOption('footerStrCenter', ''); jsPrintSetup.setOption('footerStrRight', ''); // print my window silently. jsPrintSetup.printWindow(mywindow); jsPrintSetup.setSilentPrint(1); //change to 0 if you want print dialog mywindow.close(); return true; } </script>
Thirdly, in your code, wherever you want to write print code, do this (I used jQuery. You can use simple javascript):
<script> $("#print").click(function () { var contents = $("#yourDivToPrint").html(); PrintElem(contents); }) </script>
Obviously you need a link:
<a href="#" id="print">Print my Div</a>
And your div for printing:
<div id="yourDivToPrint">....</div>
Josiah May 29 '17 at 11:11 2017-05-29 11:11
source share