He encontrado una solución alternativa (al menos, funciona para mí). En mi caso, tenía una página html básica con algunos estilos (screen.css & print.css) más algunos javascript para mejorar progresivamente la página con características adicionales, etc.
Cuando llegó el momento de imprimir la página me di cuenta de que el js estaba afectando el diseño (ya que estaba haciendo un estilo css a través de jquery).
lo que terminó haciendo fue la siguiente:
en "screen.css"
body {
background-color: #ccc; /* or whatever colour your designer chose; if it NEEDS to be white, simply change something else (e.g. background-image, font-size, etc.) */
}
en "print.css"
body {
background-color: #fff;
}
en el" -javascript-file.js "
$(document).ready(function()
{
if (isPrinting() == false)
{
init();
}
});
function isPrinting()
{
var isPrint = false;
/* I'm not 100% sure about the string literal check 'rgb(255, 255, 255)',
should do some testing here with other values || other attributes...
(font-size, color, line-height, other attributes that will have the
greatest difference/variation between "screen" and "print" styles)
*/
if ($('body').css('background-color') == 'rgb(255, 255, 255)')
{
isPrint = true;
}
return isPrint;
}
function init()
{
// All sorts of awesome goes here
}
Y eso fue todo! ¡Funcionó!
Aquí es una visión general de lo que está pasando: la página
- usuario carga
- cargas navegador está configurado "screen.css" color de fondo
- Administración a "#ccc"
- navegador carga "del -javascript-file.js"
- JS cheques de color de fondo ... es "#ccc" ...
- JS hace su cosa
- usuario golpea comando de impresión
- navegador carga "print.css"
- color de fondo cambia a "cuerpo" #fff
- cargas del navegador "la-javascript-file.js"
de color
- JS cheques del cuerpo de antecedentes
- JS da cuenta de color de fondo es "#fff"
- JS no hace nada :)
Espero que esto ayude a alguien por ahí :)
@Andy E's head - Gracias a editar mi pregunta para mejor. –