4

This has been driving me mad all day. I at first went down the print settings route before realising that it's the "Print background colors and images" option in IE that's been tripping me up.

The last test case code I used:

<html>
<style type="text/css">body{font-family:Courier;}pre{display:inline;}</style>
<body>
<b><font color="#FFFF00">this is a test</font></b><br/>
</body>
</html>

When viewed in IE "this is a test" is displayed in bright yellow. However when printing or even print previewing it's rendered in what I'd describe as a muddy yellow. The same is true if I export to PDF via virtual PDF printer. If I enable "Print background colors and images" the correct yellow is used, but I understand from what I've read this option can't be set programmatically.

It's not just yellow, many similar colors end up the same as each other in the print preview, and I need to shade things according to error margin so can't just use ones that are very different.

So how to get round this??? I don't see why a setting for background colors is affecting foreground text like this (unless I can force foreground it? My HTML is only very basic and hasn't been used for a few years ...)

Cheers for any help

whoasked
  • 390
  • 2
  • 15
  • Do you have a RGB or a CMYK printer? If it is a CMYK then it will not print the same as on the screen, I suspect. – Gezzasa Nov 27 '14 at 14:44
  • I don't believe it's an RGB/CMYK issue. Just found this immediately after posting (yes, I did search first): http://stackoverflow.com/questions/22645762/font-colors-change-when-printing. Still, any more thoughts? – whoasked Nov 27 '14 at 14:46
  • Very interesting question although I wouldn't do such a thing since many people in the first place only have black and white laser printers. – www139 Nov 27 '14 at 15:22
  • Try a css media query for printing! – www139 Nov 27 '14 at 15:22
  • @whoasked I take it that didnt work? – Gezzasa Nov 27 '14 at 19:13
  • This might help: http://stackoverflow.com/questions/764520/how-do-i-make-firefox-print-a-background-color-style/34379688#34379688 – Musa Haidari Dec 22 '15 at 05:39
  • BTW I did report this to MS at the time: https://connect.microsoft.com/IE/Feedback/Details/1050622. Apparently though IE is now only receiving critical bug fixes in favour of Edge. – whoasked Feb 23 '16 at 17:54

1 Answers1

0

Try this css media query:

@media print {
  body {
    /*put your styles here*/
  }
}

I'm not sure if IE supports it though. I'm not sure what versions your dealing with.

www139
  • 4,960
  • 3
  • 31
  • 56
  • Thanks for the suggestion. But no, it didn't work in IE11 - same muddy yellow in print preview. I'm also unsure how I'd use this for for various colors throughout the page if the print media section can only have one color section - I only really know how to copy and paste in CSS ... This sounds like an IE bug to me tbh. – whoasked Nov 28 '14 at 10:55
  • I agree. Maybe you should try contacting who ever is 'in charge' if ie and ask some questions. I can't think of anything else to say or suggest. I actually don't have access to IE really, but you've tried everything I can think of. Have you tried googling the issue? Does it happen with other web pages? – www139 Nov 28 '14 at 14:20