Is there a way to prevent the background color of a web page from being included in printouts when a user selects the "Background Graphics" checkbox in the printing pop up? I want the printed content to display only in black and white. Alternatively, can the option to include background graphics be disabled altogether?
https://i.sstatic.net/XoFGI.png
Here is the code snippet I am using for printing:
<script>
function printContent(el) {
var restorepage = $('body').html();
document.getElementById('<%=lblDateTime.ClientID %>').style.display = "block";
document.getElementById('<%=lblDateTime.ClientID %>').innerHTML = new Date().toLocaleString();
document.getElementById('<%=acrLogo.ClientID %>').style.display = "block";
document.getElementById('<%=compName.ClientID %>').style.display = "block";
var printcontent = $('#' + el).clone();
printcontent.removeAttr('style');
$('body').empty().html(printcontent);
window.print();
$('body').html(restorepage);
}
</script>
I have also tried adding this style to the page:
<style>
article {
-webkit-print-color-adjust: exact;
background: #222;
color: #eee;
}
</style>
Below is the div tag containing the content to be printed:
<div>
The contents needs to be printed. This is just a test.
</div>