Print Background colours in Chrome

CssGoogle ChromePrinting

Css Problem Overview


I am trying to print a PHP generated document in chrome, on the browser it looks fine Link to the page I want to print But my printer will not print any coloured backgrounds, can anyone offer any suggestions please? Can I do this with CSS?

Css Solutions


Solution 1 - Css

You adjust in the browser, whether the background colors and images are printed. See your browsers printing options.

Google Chrome offers this feature starting from version 26 (march 2013).

Also starting from version 17, Chrome allows changing the background print behavior programmatically by using -webkit-print-color-adjust:exact; in the element CSS to print the background.

Solution 2 - Css

Gordon's answer is great, but for people whose CSS skills are rusty, here's a more complete example.

Put the following in your document's <head> section.

<style type="text/css">
@media print { body { -webkit-print-color-adjust: exact; } }
</style>

By the way, although Chrome/Chromium's print dialog now has a Background graphics checkbox, it only seems to work if you do not click Print using system dialog (observed with Chromium in Linux).

Solution 3 - Css

Chrome > Print (cmd P) > click More Settings > Options: check Background graphics

Chrome Print Preview

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMickView Question on Stackoverflow
Solution 1 - CssGordonView Answer on Stackoverflow
Solution 2 - CssBrent BradburnView Answer on Stackoverflow
Solution 3 - CssGeoffrey HaleView Answer on Stackoverflow