我在Asp.net上做报告。当我打印报告时,背景颜色没有出现在firefox中的打印预览中。我想在Printer中打印背景颜色。请指导我的工作。我的代码如下。我想用编程来做这件事。
在页面设置中不启用背景颜色和图像
jsfiddle.net/waqas786/6AHRH
<style type="text/css" media="print" >
.repFont
{
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
width: 53px;
}
table {
border: 1px solid black;
border-spacing:0px;
}
td {
border: 1px solid black;
border-spacing:0px;
font-size:11PX;
text-align:center;
padding: 0px;
}
.auto-style1 {
height: 27px;
}
.bgtd1 {
background-color:#FFFF99;
}
.title {
color:#CC3333;
}
.titleMale {
color:#3366FF;
}
.titleTotal {
font-weight:bold;
font-size:12PX;
}
.maintitle {
font-size:12px;
}
.maintileArabic {
color:#CC3333;
padding-left: 187px;
}
.maintileEng {
color:#3366FF;
padding-left: 113px;
padding-bottom: 11px;
}
</style>
<table id="tblid" runat="server" border="1" >
<tr class="bgtd1">
<td colspan="2" rowspan="2" class="title">Region</td>
<td colspan="3" class="title"><span id="result_box" lang="ar" xml:lang="ar">المجموع العام</span></td>
<td colspan="2" class="title"> سلطانالخارج</td>
<td colspan="2" class="title">مسندم</td>
<td colspan="2" class="title">مسندم</td>
<td colspan="2" class="title">مسندم</td>
<td colspan="2" class="title">مسندم</td>
<td colspan="2" class="title">مسندم</td>
<td colspan="2" class="title">مسندم</td>
<td colspan="2" class="title">مسندم</td>
<td colspan="2" class="title">مسندم</td>
<td colspan="2" class="title">مسندم</td>
<td colspan="2" class="title">مسندم</td>
<td colspan="2" class="title">مسندم</td>
<td colspan="2" rowspan="2" class="title"><span id="result_box2" lang="ar" xml:lang="ar">منطقة</span></td>
</tr>
<tr class="bgtd1">
<td colspan="3" class="auto-style1">Grand Total</td>
<td colspan="2" class="auto-style1"> </td>
<td colspan="2" class="auto-style1">
Musandam </td>
<td colspan="2" class="auto-style1"> Al-wusta </td>
<td colspan="2" class="auto-style1"> Alburaimi </td>
<td colspan="2" class="auto-style1"> Al-Dhahira </td>
<td colspan="2" class="auto-style1"> Dohfar </td>
<td colspan="2" class="auto-style1"> Al-dhakhila </td>
<td colspan="2" class="auto-style1"> Al-sharqiya(n) </td>
<td colspan="2" class="auto-style1"> Al-sharqiyah </td>
<td colspan="2" class="auto-style1"> Albatiniah(s) </td>
<td colspan="2" class="auto-style1"> Al-Albatinah </td>
<td colspan="2" class="auto-style1"> Muscat </td>
</tr>
<tr>
<td colspan="2" class="bgtd1">Gender</td>
<td class="title"><span id="result_box8" lang="ar" xml:lang="ar"> مجموع </span></td>
<td >١</td>
<td class="titleMale">ذ</td>
<td >١</td>
<td class="titleMale">ذ</td>
<td >١</td>
<td class="titleMale">ذ</td>
<td >١</td>
<td class="titleMale">ذ</td>
<td>١</td>
<td class="titleMale" >ذ</td>
<td >١</td>
<td class="titleMale">ذ</td>
<td >١</td>
<td class="titleMale">ذ</td>
<td >١</td>
<td class="titleMale">ذ</td>
<td >١</td>
<td class="titleMale">ذ</td>
<td>١</td>
<td class="titleMale">ذ</td>
<td>١</td>
<td class="titleMale">ذ</td>
<td>١</td>
<td class="titleMale">ذ</td>
<td >١</td>
<td class="titleMale">ذ</td>
<td colspan="2" class="bgtd1"><span id="result_box3" lang="ar" xml:lang="ar">جنس</span></td>
</tr>
<tr>
<td colspan="2" class="bgtd1">Specialization</td>
<td class="title">Total</td>
<td>F</td>
<td class="titleMale">M</td>
<td>F</td>
<td class="titleMale">M</td>
<td>F</td>
<td class="titleMale">M</td>
<td>F</td>
<td class="titleMale">M</td>
<td>F</td>
<td class="titleMale">M</td>
<td>F</td>
<td class="titleMale">M</td>
<td>F</td>
<td class="titleMale">M</td>
<td>F</td>
<td class="titleMale">M</td>
<td>F</td>
<td class="titleMale">M</td>
<td>F</td>
<td class="titleMale">M</td>
<td>F</td>
<td class="titleMale">M</td>
<td>F</td>
<td class="titleMale">M</td>
<td>F</td>
<td class="titleMale">M</td>
<td colspan="2" class="bgtd1" ><span id="result_box4" lang="ar" xml:lang="ar">تخصص</span></td>
</tr>
<tr>
<td rowspan="4" class="bgtd1"><div class="repFont bgtd1">Foundation</div></td>
<td class="bgtd1">Engnieering</td>
<td >120</td>
<td>48</td>
<td class="titleMale">72</td>
<td>0</td>
<td class="titleMale">0</td>
<td>0</td>
<td class="titleMale">0</td>
<td>1</td>
<td class="titleMale">1</td>
<td>0</td>
<td class="titleMale">0</td>
<td>1</td>
<td class="titleMale">1</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td class="titleMale">1</td>
<td>0</td>
<td class="titleMale">0</td>
<td>1</td>
<td class="titleMale">1</td>
<td>0</td>
<td class="titleMale">0</td>
<td>1</td>
<td class="titleMale">1</td>
<td>0</td>
<td class="titleMale">0</td>
<td class="bgtd1">الهندسة </td>
<td rowspan="4" class="bgtd1"><div class="repFont "> مؤسسة </div></td>
</tr>
<tr>
<td class="bgtd1">Information Technology</td>
<td>213</td>
<td>147</td>
<td class="titleMale">66</td>
<td>1</td>
<td class="titleMale">2</td>
<td>0</td>
<td class="titleMale">0</td>
<td>1</td>
<td class="titleMale">1</td>
<td>0</td>
<td class="titleMale">0</td>
<td>1</td>
<td class="titleMale">1</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td class="titleMale">1</td>
<td>0</td>
<td class="titleMale">0</td>
<td >1</td>
<td class="titleMale">1</td>
<td>0</td>
<td class="titleMale">0</td>
<td>1</td>
<td class="titleMale">1</td>
<td>0</td>
<td class="titleMale">0</td>
<td class="bgtd1"> تكنولوجيا المعلومات </td>
</tr>
<tr>
<td rowspan="2" class="bgtd1"><span class="titleTotal">Total</span></td>
<td rowspan="2">313</td>
<td >195</td>
<td class="titleMale">138</td>
<td>1</td>
<td class="titleMale">2</td>
<td>0</td>
<td class="titleMale">0</td>
<td>2</td>
<td class="titleMale">2</td>
<td>0</td>
<td class="titleMale">0</td>
<td>2</td>
<td class="titleMale">2</td>
<td>0</td>
<td>0</td>
<td>2</td>
<td class="titleMale">2</td>
<td>0</td>
<td class="titleMale">0</td>
<td>2</td>
<td class="titleMale">2</td>
<td>0</td>
<td class="titleMale">0</td>
<td>2</td>
<td class="titleMale">2</td>
<td>0</td>
<td class="titleMale">0</td>
<td rowspan="2" class="bgtd1" >إجمالي</td>
</tr>
<tr>
<td colspan="2">313</td>
<td colspan="2">3</td>
<td colspan="2">0</td>
<td colspan="2">4</td>
<td colspan="2">0</td>
<td colspan="2">4</td>
<td colspan="2">0</td>
<td colspan="2">4</td>
<td colspan="2">0</td>
<td colspan="2">4</td>
<td colspan="2">0</td>
<td colspan="2">4</td>
<td colspan="2">0</td>
</tr>
</table>
或有没有办法通过编程启用
答案 0 :(得分:0)
我认为它是一个浏览器设置。您无法在CSS中执行任何操作。在Windows中 - File > Page Setup... > Print Background.
答案 1 :(得分:0)
Css Webkit Property Works正常"-webkit-print-color-adjust: exact;"
@media print {
element {
background-color: #1a4567 !important;
-webkit-print-color-adjust: exact;
}}
@media print {
.vendorListHeading th {
color: white !important;
}}
希望这个帮助!!
<强>更新强>: - http://jsfiddle.net/7xTQY/
答案 2 :(得分:0)
点击打印设置(Chrome)点击背景颜色并打印它肯定会有效。
此致 马哈德