<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    夢幻之旅

    DEBUG - 天道酬勤

       :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      671 隨筆 :: 6 文章 :: 256 評論 :: 0 Trackbacks
    打印是一個頭痛的問題.
    AxtiveX控件收費,用戶使用需降低安全級別.
    最后還是打算用webBrowser打印.

    1.js
    /*
    *設置頁眉和頁腳
    */

    function setPageHF(isSet)
    {
        
    try
        

            
    var regWriteShell = new ActiveXObject("WScript.Shell");
            
    var regKey="HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
            
    if(isSet)
            
    {
                
    //設置
                regWriteShell.RegWrite(regKey+"header","");
                regWriteShell.RegWrite(regKey
    +"footer","&b科印傳媒 第&p頁 共&P頁");
                
    //regWriteShell.RegWrite(regKey+"footer","");
            }

            
    else
            

                
    //清除
                regWriteShell.RegWrite(regKey+"header","");
                regWriteShell.RegWrite(regKey
    +"footer","");
            }

        }
    catch(e){} 
    }


    /*
    *要完成打印的必須信息
    */

    function writeInfo()
    {
        
    //對象信息
        var objInfo = "<object id='WebBrowser' width=0 height=0 classid='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></object>";
        document.write(objInfo);
        
        
    //相關CSS
        var cssInfo = "<style media='print'>";
        cssInfo 
    += ".noPrint{display:none;background-color:#939392;}";
        cssInfo 
    += ".nextPage{page-break-after: always;}";
        cssInfo 
    += "</style>";
        
    //document.write(cssInfo);
    }


    /*
    *打印
    */

    function print()
    {
        document.all.WebBrowser.Execwb(
    6,1);
    }


    /*
    *直接打印
    */

    function printDirect ()
    {
        document.all.WebBrowser.ExecWB(
    6,6);
    }


    /*
    *打印預覽
    */

    function printView()
    {
        document.all.WebBrowser.ExecWB(
    7,1);
    }


    /*
    *打印設置
    */

    function printSet()
    {
        document.all.WebBrowser.ExecWB(
    8,1);
    }

    2.table html
       1).第個打印頁有表頭
       2).每頁表格線連續
    StringBuffer printPageStr = new StringBuffer();
            
    // 當前頁DIV
            printPageStr.append("<div id=\"page").append(currentPage).append("\" class='nextPage'>");
            printPageStr.append(
    "<table id=\"table_1");
            printPageStr.append("\" width=\"100%\" class=\"tabp\"  cellpadding='2' cellspacing='0'>");
            // 表頭
            printPageStr.append("<tr>");
            printPageStr.append(
    "<thead style='display:table-header-group;font-weight:bold;'>");
            
            
    for (Object headerName : baseInfoHeadLst)
            
    {
                printPageStr.append(
    "<th nowrap=\"nowrap\"  class='thp' style='border-top:1px solid #000000;'>");
                printPageStr.append(headerName 
    == null ? "" : headerName);
                printPageStr.append(
    "</th>");
            }

            printPageStr.append(
    "</thead></tr>");
            
    // 表體
            for(List innerLst : dataLst)
            
    {
                printPageStr.append(
    "<tr>");
                
    for(Object data : innerLst)
                
    {
                    printPageStr.append(
    "<td nowrap=\"nowrap\" class='tdp'>");
                    printPageStr.append(data 
    == null ? "" : data).append("&nbsp");
                    printPageStr.append(
    "</td>");
                }

                printPageStr.append(
    "</tr>");
            }

            printPageStr.append(
    "</table>");
            
            printPageStr.append(
    "<br/>");
            printPageStr.append(
    "</div>");
            
    return printPageStr.toString();

    3.jsp
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      
    <head>
        
    <title>打印</title>
        
        
    <meta http-equiv="pragma" content="no-cache"/>
        
    <meta http-equiv="cache-control" content="no-cache"/>
        
    <meta http-equiv="expires" content="0"/>    
        
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"/>
        
    <meta http-equiv="description" content="This is my page"/>
          
    <script type="text/javascript" src="/js/jquery.js"></script>
          
    <script type="text/javascript" src="/js/print2/print.js"></script>
        
    <style    type="text/css" media='print'> 
            .noprint 
    {display: none;}
        
    </style> 
        
    <style    type="text/css">
            .tdp 
            
    { 
                border-bottom
    : 1px solid #000000; 
                border-left
    : 1px solid #000000; 
                border-right
    : 0 solid #ffffff; 
                border-top
    : 0 solid #ffffff; 
            
            
    }

            .thp
            
    {
                border-bottom
    : 1px solid #000000; 
                border-left
    : 1px solid #000000; 
                border-right
    : 0 solid #ffffff; 
                border-top
    : 1px solid #ffffff; 
            
    }
     
            .tabp 
            
    { 
                border
    :1px solid #000000;
                border-top
    :1px solid #000000;
                border-right
    :2px solid #000000;
            
    }
     
        
    </style>
        
    <script type="text/javascript">
             writeInfo();
            setPageHF(
    true);
            
            
    /** 切換行是否打印 */
            
    function switchPrintRW(tableId)
            
    {
                $(
    "#"+tableId).find("tr").dblclick(function(i){
                    
    if($(this).prevAll().length>=0)
                    
    {
                        
    //如果存在則移作此css,如果不存在則添加此css類
                        $(this).find("td").each(function(j){
                            
    if($(this).css("background-color")!="#939392")
                            
    {
                                $(
    this).addClass("noprint");
                                $(
    this).css({"background-color":"#939392"});
                            }

                            
    else
                            
    {
                                $(
    this).removeClass("noprint");
                                $(
    this).css({"background-color":"white"});
                            }

                        }
    );
                    }

                }
    );
            }

            
            
    /** 切換列是否打印 */
            
    function switchPrintTD(tableId)
            
    {
                $(
    "#"+tableId).find("th").dblclick(function(){
                    
    //取出第幾列
                    var tdCount = $(this).prevAll().length;
                    
    //取出總列數
                    var rowTdTotalCount = $("#"+tableId).find("th").length;
                    
    //alert(tdCount + "" + "/" + ""+ rowTdTotalCount);
                    
                    
    //改變列的樣式
                    $(this).toggleClass("noprint");
                    
    if($(this).attr("class").indexOf("noprint")>=0)
                    
    {
                        $(
    this).css({"background-color":"#939392"});
                    }

                    
    else
                    
    {
                        $(
    this).css({"background-color":"white"});
                    }

                        
                    
    //改變列的樣式
                    $("#"+tableId).find('td').each(function(i){
                        
    if(i%rowTdTotalCount == tdCount)
                        
    {
                            
    //如果存在則移作此css,如果不存在則添加此css類
                            $(this).toggleClass("noprint");
                            
    if($(this).attr("class").indexOf("noprint")>=0)
                            
    {
                                $(
    this).css({"background-color":"#939392"});
                            }

                            
    else
                            
    {
                                $(
    this).css({"background-color":"white"});
                            }

                        }

                    }
    );
                }
    );
            }


            $(document).ready(
    function(){
                
    // 添加列事件
                //;switchPrintRW("table_1");
                switchPrintTD("table_1");    
            }
    );                
        
    </script>
      
    </head>
      
    <body oncontextmenu="self.event.returnValue=false" onselectstart="return false">
          
    <input type="button" value="打印預覽" class="noprint"  onClick="javascript:printView();" style="background:#ccc url('../images/button_bg.gif') no-repeat;border:0px;color:#333;width:100px;height:27px;font-size:13px;font-weight:normal;text-align:center;vertical-align:middle;"/><input type="button" value="打印" class="noprint"  onClick="javascript:printSet();" style="background:#ccc url('../images/button_bg.gif') no-repeat;border:0px;color:#333;width:100px;height:27px;font-size:13px;font-weight:normal;text-align:center;vertical-align:middle;"/><input type="button" value="打印" class="noprint"  onClick="javascript:print();" style="background:#ccc url('../images/button_bg.gif') no-repeat;border:0px;color:#333;width:100px;height:27px;font-size:13px;font-weight:normal;text-align:center;vertical-align:middle;"/><%=printPagesStr%>
      
    </body>
    </html>

    posted on 2010-05-27 14:06 HUIKK 閱讀(2099) 評論(2)  編輯  收藏

    評論

    # re: 還是WebBrowser打印 2010-05-27 14:31 惠萬鵬
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">  回復  更多評論
      

    # re: 還是WebBrowser打印 2010-05-27 14:32 惠萬鵬
    上面這句重要  回復  更多評論
      


    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 在线免费观看亚洲| 91香蕉在线观看免费高清| 亚洲日韩中文在线精品第一| 夜夜爽妓女8888视频免费观看| 亚洲精华国产精华精华液好用| 黄网站在线播放视频免费观看| 午夜免费福利片观看| 婷婷久久久亚洲欧洲日产国码AV | 亚洲Av高清一区二区三区| 69xx免费观看视频| 亚洲 日韩 色 图网站| 成年女人男人免费视频播放 | 亚洲色大网站WWW永久网站| 日韩一级视频免费观看| 一级毛片a免费播放王色电影| 三年片在线观看免费观看大全动漫 | 免费视频精品一区二区三区| 亚洲一区免费观看| 嘿嘿嘿视频免费网站在线观看 | 美女羞羞免费视频网站| 国产午夜亚洲精品国产成人小说| 亚洲日韩久久综合中文字幕| 免费看美女被靠到爽| eeuss免费影院| 亚洲福利视频网址| 亚洲国产精品综合久久网络 | 国产92成人精品视频免费| 中国china体内裑精亚洲日本| 国产免费的野战视频| 风间由美在线亚洲一区| 亚洲激情视频在线观看| 暖暖日本免费在线视频| 一区二区三区免费视频网站| 亚洲女人初试黑人巨高清| 亚洲无码视频在线| 岛国大片免费在线观看| 少妇人妻偷人精品免费视频| 一级A毛片免费观看久久精品 | 亚洲精品国产精品| 亚洲中文字幕不卡无码| 成人免费淫片在线费观看 |