I am using window.print() for printing page, but I got header and footer contains page title, file path, page number, and date. How to remove them or edit?
I tried this also.
@media print {
@page { margin: 0; }
body { margin: 1.6cm; }
}
i try all solution of this page but any solution is not working for me.
this is my div content that is find from POJO.
<div id="textDiv">
<pre id="foo"><%= student.getDescription()%></pre>
</div>
this is my button.
<button onclick="printDiv('textDiv')">Print PDF</button>
this is my Script for Print.
function printDiv(divName) {
var printContents = document.getElementById(divName).innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
}
// Use this method
@media print {
.footer,
#non-printable {
display: none !important;
}
#printable {
display: block;
}
}