Turns out this is almost like a browser bug in FireFox. I noticed that at any time (on the screen), when svg refers to what the browser cannot find, I get the same problem as when printing: the layout of the image will be reserved, but it will be empty space. This prompted me to wonder if there is a difference in what can be loaded / detected when rendering for the printer, and not on the screen, so I started trying different ways to download / link to svg. I tried loading svg from a separate file, from id to html and inline, all in combination with a filter definition in a separate css file, in-page classes and inline styles. Of all the combinations, this is what worked:
Define svg in html and link to it using inline styles or css classes on the page.
I know this sounds strange, but literally everything else I tried breaks, including the same thing, but setting the css filter property in an external css file. Turning to the class approach on the page, here is what the fixed html looks like:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title></title> <style type="text/css"> .grayscale { filter: url(#grayscale); filter: gray; -webkit-filter: grayscale(100%); } img { width:100px; } </style> </head> <body> <img class="grayscale" src="http://alltheragefaces.com/img/faces/png/rage-nuclear.png" /> <img src="http://alltheragefaces.com/img/faces/png/rage-nuclear.png" /> <svg xmlns='http://www.w3.org/2000/svg' height="0px"> <filter id='grayscale'> <feColorMatrix type='matrix' values='0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0'/> </filter> </svg> </body> </html>
And again, the modified fiddle from which you can print, and now you see the image is just fine in Firefox.
Siiigh, this is what I expect from IE ... hope helps someone save time / sadness / suicidal thoughts
dasch88
source share