Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

text-shadow and box-shadow while printing (Chrome)

I'm making some printable calendar website using HTML, CSS and JS.

Unfortunately I cannot use CSS property called text-shadow, because shadow behind text prints as solid black text without any blur or transparency.

Same problem occurs when I'm trying to use box-shadow for any div - shadow prints like solid black color with no transparency.

I'm using Chrome with style html {-webkit-print-color-adjust: exact;} to ensure all background colors will be printed.

Any workaround? I would prefer not to use any background image.

Edit: I don't want to hide shadows, it's very easy of course. I want to have shadows printed correctly.

like image 333
hogancool Avatar asked Dec 20 '12 15:12

hogancool


People also ask

What is CSS text shadow?

The text-shadow CSS property adds shadows to text. It accepts a comma-separated list of shadows to be applied to the text and any of its decorations . Each shadow is described by some combination of X and Y offsets from the element, blur radius, and color.

How do I add shadow to text in Wordpress?

From the Style tab, go to Text Shadow section. Now you have full access to customization options of the element's text shadow.


2 Answers

I realise this is an old question, but just to note that it is possible to make shadows print correctly in Chrome. You need to set both -webkit-print-color-adjust and a filter, as found in this bug thread: https://code.google.com/p/chromium/issues/detail?id=174583

.thing {
    -webkit-print-color-adjust:exact;
    -webkit-filter:opacity(1);
}

(I prefer to set opacity rather than blur as used in the bug, simply because it seems likely to cause fewer problems).

Note that this will limit the resolution of the print (filter makes it send a rasterised version), so text might become harder to read. If you really want to work around that, I'd suggest duplicating the div (one for the shadow, with the filter hack and transparent text, and another for the text with no shadow)

like image 84
Dave Avatar answered Sep 23 '22 19:09

Dave


Here is the solution:

@media print {
  .item {
    -webkit-filter: drop-shadow(4px 4px 1px #ccc);
    text-shadow: 4px 4px 1px #ccc;
  }
}
like image 34
Nazar Vynnytskyi Avatar answered Sep 23 '22 19:09

Nazar Vynnytskyi