本文介绍了打印时保留HTML字体颜色 - IE设置,不是打印机问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这一直让我疯了一整天。我第一次走下打印设置路线,然后意识到这是IE中的打印背景颜色和图像选项,已经困扰我了。

This has been driving me mad all day. I at first went down the print settings route before realising that it's the "Print background colors and images" option in IE that's been tripping me up.

最后一个测试用例代码我使用了:

The last test case code I used:

<html>
<style type="text/css">body{font-family:Courier;}pre{display:inline;}</style>
<body>
<b><font color="#FFFF00">this is a test</font></b><br/>
</body>
</html>

在IE中查看时,这是测试显示为亮黄色。然而,当打印甚至打印预览它被呈现在我所描述的泥泞的黄色。如果我通过虚拟PDF打印机导出到PDF也是如此。如果我启用了打印背景颜色和图片,则使用正确的黄色,但是从我所阅读的内容来看,此选项不能以编程方式设置。

When viewed in IE "this is a test" is displayed in bright yellow. However when printing or even print previewing it's rendered in what I'd describe as a muddy yellow. The same is true if I export to PDF via virtual PDF printer. If I enable "Print background colors and images" the correct yellow is used, but I understand from what I've read this option can't be set programmatically.

不仅仅是黄色,许多相似的颜色在打印预览中最终会相同,我需要根据错误容限来遮挡事物,所以不能只使用非常不同的事物。

It's not just yellow, many similar colors end up the same as each other in the print preview, and I need to shade things according to error margin so can't just use ones that are very different.

那么如何获得这个???我不明白为什么背景颜色的设置影响前景文本像这样(除非我可以强制前台它?我的HTML只是非常基本的,没有使用几年...)

So how to get round this??? I don't see why a setting for background colors is affecting foreground text like this (unless I can force foreground it? My HTML is only very basic and hasn't been used for a few years ...)

欢迎任何帮助

推荐答案

尝试此css媒体查询:

Try this css media query:

@media print {
  body {
    /*put your styles here*/
  }
}

我不知道IE是否支持。我不知道你处理的是什么版本。

I'm not sure if IE supports it though. I'm not sure what versions your dealing with.

这篇关于打印时保留HTML字体颜色 - IE设置,不是打印机问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 02:06