Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incorrect text colors when printing HTML page

Tags:

css

printing

Why do browsers change the color of text when printing?

For example, create a blank HTML document containing:

<span style="color: #80b831">test</span>
<button onclick="window.print()">Print</button>

Example here: http://jsfiddle.net/7z6c2/

The span has color: #80b831 on the screen, but when printed (even just print preview in Chrome) the color is different (lime greenish).

ScreenshotsfromPDFCreator

If I tick Chrome's "Background colors and images" option in Print Preview, the correct color is then used.

What's happening here? How can I get the right color to appear by default? Is this something to do with "web-safe" colors?

like image 790
Andrew Davey Avatar asked Aug 16 '13 15:08

Andrew Davey


1 Answers

Check this Fiddle

You have to use -webkit-print-color-adjust on the element which you are going to print

Also check here to know more about print color adjust https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-print-color-adjust

like image 138
Vikas Ghodke Avatar answered Nov 15 '22 22:11

Vikas Ghodke