打印后,html表格会错过边框颜色和背景颜色

时间:2012-08-09 11:06:24

标签: javascript asp.net css printing

<input type= "button" value="Print"  onclick="return PrintReport()" class="lbutton"/>
 <iframe frameborder="0" height="768px" width="95%" id="loader" src="" name="loader"/>
 function PrintReport()
        {
            document.getElementById('loader').contentWindow.document.execCommand('Print',false,null);
            return false;
         }

包含aspx页面的iframe名称加载器(html表报告)

单击按钮打印成功,但是当我以pdf格式预览时。

然后 html报告错过了边框颜色和背景颜色

我检查设置,即8允许背景颜色和图像。

打印后如何获得表格边框颜色和背景颜色。

2 个答案:

答案 0 :(得分:2)

尝试使用内联CSS作为边框颜色。

style="border: 5px solid #333"

答案 1 :(得分:0)

我无法重新确定你的场景,但是当我无意中“自闭”一个iframe元素时,我遇到了很多样式问题。它不是一个自闭元素。值得一试......

而不是:

 <iframe frameborder="0" height="768px" width="95%" id="loader" src="" name="loader"/>

这样做:

 <iframe frameborder="0" height="768px" width="95%" id="loader" src="" name="loader"></iframe>