0

As we can verify by copying/pasting the following html on the following w3schools.com link that it highlights the word highlighted with yellow background, and the word test with red foreground. But, as shown in the image below, when you print this html page with Window.Print() command, it does not print the yellow background of the word highlighted. Question: Is there a workaround to make Window.Print() method work for highlighted text, as well?

<!DOCTYPE html>
<html>
<body>

<h2>The window.print() Method</h2>

<p>Click the button to print the current page.</p>
<p>This is a <span style='background:yellow;'> highlighted</span> text. And <span style='color:red;'>test</span> for font color.</p>

<button onclick="window.print()">Print this page</button>

</body>
</html>

snapshot in Windows 10 of Print to PDF preview of the above html

enter image description here

nam
  • 21,967
  • 37
  • 158
  • 332
  • 2
    Does this answer your question? [Background color not showing in print preview](https://stackoverflow.com/questions/14987496/background-color-not-showing-in-print-preview) – JS_INF Jun 22 '21 at 04:12
  • 2
    I think you might need to enable "print backgrounds" under "more settings" in the print dialog. – Emaro Jun 22 '21 at 14:13
  • 1
    @Emaro Your suggestion worked (thank you for sharing your thoughts). Under `More Settings`, on my Windows 10 built-in printer preview, there are two options `Headers and Footers`, and `Background Graphics`. The Background Graphics option is unchecked by default. When I checked it - Voila - it started showing highlights correctly in both print preview and in actual print. – nam Jun 22 '21 at 14:37
  • Glad it worked! :) – Emaro Jun 22 '21 at 14:42

0 Answers0