WebBrowser 打印

Posted bkin的笔记

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了WebBrowser 打印相关的知识,希望对你有一定的参考价值。

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RTMInterViewInfo.aspx.cs" Inherits="RTM_NewOperate_RTMInterViewInfo" %>


<%@ Register Assembly="DropDownCheckList" Namespace="UNLV.IAP.WebControls" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <link href="../../images/ui_css/table.css" type="text/css" rel="stylesheet">
    <title>
        <%=this.GetCompanyName()%>
        <%this.GetResouseValue("rtm.requiremaster.print");%>
    </title>
    <style media="print" type="text/css">
            .Noprint{display:none;}
            .PageNext{page-break-after: always;}
        </style>
    <style type="text/css">
            .Noprint
            {    
                font-family: "新細明體";
                font-size: 9pt;
            }
            .td
            {
            BORDER-RIGHT: #000000 0px solid; BORDER-TOP: #000000 0px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid
            }
            .td1{BORDER-RIGHT: #000000 0px solid; BORDER-TOP: #000000 0px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid;}
            .td2{BORDER-RIGHT: #000000 0px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid;}
            .td3{BORDER-RIGHT: #000000 0px solid; BORDER-TOP: #000000 0px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 0px solid;}
            .td4{BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 0px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid;}
            .td21{BORDER-RIGHT: #000000 0px solid; BORDER-TOP: #000000 0px solid; BORDER-LEFT: #000000 0px solid; BORDER-BOTTOM: #000000 1px solid;}
            .td22{BORDER-RIGHT: #000000 0px solid; BORDER-TOP: #000000 0px solid; BORDER-LEFT: #000000 0px solid; BORDER-BOTTOM: #000000 1px solid;}
            .td23{BORDER-RIGHT: #000000 0px solid; BORDER-TOP: #000000 0px solid; BORDER-LEFT: #000000 0px solid; BORDER-BOTTOM: #000000 0px solid;}
            .ttd1{BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 0px solid; BORDER-LEFT: #000000 0px solid; BORDER-BOTTOM: #000000 1px solid;}
            .ttd2{BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 0px solid; BORDER-LEFT: #000000 0px solid; BORDER-BOTTOM: #000000 0px solid;}
            .ttd3{BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 2px solid; BORDER-LEFT: #000000 2px solid; BORDER-BOTTOM: #000000 1px solid;}
                    .input{border-width: 1;width:10pt;height:10pt;color:#000000;border-style:solid;border-color:#FFFFFF";}  

</style>
    <style type="text/css">
        input{border-width: 1;width:10pt;height:10pt;color:#000000;border-style:solid;border-color:#FFFFFF"}  
  </style>

    <script language="javascript" type="text/javascript">
function printClick(type)
{
//    document.getElementById("NoPrintContent").style.display="none";
    switch(type)
    {
        case 0:
        document.all.WebBrowser.ExecWB(6,1);
        break;
        case 1:
        document.all.WebBrowser.ExecWB(8,1);
        break;
        case 2:
        document.all.WebBrowser.ExecWB(7,1);
        break;
    }
    
}
function setAuditManPrin()
{
 document.getElementById("DIVMAuditMan1").innerText= GetLabelCheckbox("ddlAudit1");
 document.getElementById("DIVMAuditMan2").innerText= GetLabelCheckbox("ddlAudit2");
 document.getElementById("DIVMAuditMan3").innerText= GetLabelCheckbox("ddlAudit3");
 document.getElementById("DIVMAuditMan4").innerText= GetLabelCheckbox("ddlAudit4");
 document.getElementById("DIVMAuditMan5").innerText= GetLabelCheckbox("ddlAudit5");
 document.getElementById("DIVMAuditMan6").innerText= GetLabelCheckbox("ddlAudit6");
 document.getElementById("DIVMAuditMan7").innerText= GetLabelCheckbox("ddlAudit7");
 document.getElementById("DIVMAuditMan8").innerText= GetLabelCheckbox("ddlAudit8");
 document.getElementById("DIVMAuditManA").innerText= GetLabelCheckbox("ddlAuditA");
 document.getElementById("DIVMAuditManB").innerText= GetLabelCheckbox("ddlAuditB");
 document.getElementById("DIVMAuditManC").innerText= GetLabelCheckbox("ddlAuditC");
}
function GetLabelCheckbox(id)
 {
   this.divCheckboxes=document.getElementById(id + "_checkboxes");
   var e = this.divCheckboxes.getElementsByTagName("label");
   var el = this.divCheckboxes.getElementsByTagName("input");
    
       var rstr="";
       for (var i=0; i<e.length; i++)
       {
           if (el[i].type == "checkbox" && el[i].checked)
           {
//             if (e[i].htmlFor == (id+"_"+i))
//             {
//                for (var j=0; j<e[i].childNodes.length; j++)
//                {
//                    if (e[i].childNodes[j].nodeType == 3) //text type
//                    {
//                        rstr += e[i].childNodes[j].nodeValue + ",";
//                    }
//                }
//             }
                rstr += el[i].value + "
";
           }
       }
   
   // still here?  no <label> for this checkbox then
   return rstr;
 }
    </script>

</head>
<body class="css_body">
    <form id="form1" runat="server">
        <table id="NoPrintContent" class="Noprint" cellspacing="0" cellpadding="0" width="740px"
            align="center" border="0">
            <tbody>
                <tr>
                    <td align="left">
                        <span style="color: Red">
                            <%=this.GetResouseValue("common.print.notice")%></span><%=this.GetResouseValue("common.print.noticeconfig")%>
                    </td>
                    <td align="right">
                        <object id="WebBrowser" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height="0"
                            width="0">
                        </object>
                        <input type="button" style="height: 14pt; width: auto" value="列    印" onclick="printClick(0)" />
                        <input type="button" style="height: 14pt; width: auto" value="頁面設定" onclick="printClick(1)" />
                        <input type="button" style="height: 14pt; width: auto" value="列印預覽" onclick="printClick(2)" />
                        <input type="button" style="height: 14pt; width: auto" value="關閉窗口" onclick="window.close()" />
                    </td>
                </tr>
                <tr>
                    <td align="center" colspan="2">
                        <hr align="center" width="100%" noshade="noshade" size="1">
                    </td>
                </tr>
            </tbody>
        </table>
        <table width="740px" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td width="158">
                    &nbsp;</td>
                <td class="headsize1" height="30" width="454" align="center">
                    <strong><span style="font-family: 華康粗黑體">富 士 康 科 技 集 团</span></strong></td>
            </tr>
            <tr>
                <td width="158">
                    &nbsp;</td>
                <td class="headsize1" width="454" height="30" align="center">
                    <strong><span style="font-family: 華康粗黑體">应聘人员基本资料表</span></strong>
                </td>
                <td width="138">
                    &nbsp;</td>
            </tr>
            <tr>
                <td align="left" colspan="2">
                </td>
                <td align="left">
                    <strong><span>填表日期:<asp:Label ID="LabelDate" runat="server" Text="Label"></asp:Label></span></strong>
                </td>
            </tr>
        </table>
        <table width="740" border="1" align="center" cellpadding="0" cellspacing="0" class="ttd3">
            <tr>
                <td width="50" rowspan="2" align="center" class="ttd1">姓名</td>
                <td width="50" height="25" align="center" class="ttd1">中文</td>
                <td width="540" class="ttd1">&nbsp;</td>
                <td width="100" rowspan="2" align="center" class="ttd1">&nbsp;</td>
            </tr>
            <tr>
                <td width="50" height="25" align="center" class="ttd1">英文</td>
                <td class="ttd1">&nbsp;</td>
            </tr>
            <tr>
                <td class="ttd1" colspan="4">
                    <table width="100%" border="1" cellpadding="0" cellspacing="0" class="td23">
                        <tr>
                            <td width="80" height="25" rowspan="2" align="center" class="ttd1">国籍(选填)</td>
                            <td width="90" class="ttd1">□中国(大陆)</td>
                            <td width="120" align="center" class="ttd1">身份证号码</td>
                            <td class="ttd1">&nbsp;</td>
                        </tr>
                        <tr>
                            <td align="center" class="ttd2">&nbsp;</td>
                            <td align="center" class="ttd2">护照号码</td>
                            <td class="td23">&nbsp;</td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td class="ttd1" colspan="4">
                    <table width="100%" border="1" cellpadding="0" cellspacing="0" class="td23">
                        <tr>
                            <td width="100" align="center" class="ttd1">户 籍 地 址</td>
                            <td width="250" class="ttd1">&nbsp;</td>
                            <td width="100" align="center" class="ttd1">个人联系电话</td>
                            <td class="ttd1">&nbsp;</td>
                        </tr>
                        <tr>
                            <td width="100" align="center" class="ttd1">身份证地址</td>
                            <td width="250" class="ttd1">&nbsp;</td>
                            <td width="100" align="center" class="ttd1">E-mail</td>
                            <td class="ttd1">&nbsp;</td>
                        </tr>
                        <tr>
                            <td width="100" align="center" class="ttd1">目前居住地址</td>
                            <td width="250" class="ttd1">&nbsp;</td>
                            <td width="100" align="center" class="ttd1">紧急联络人</td>
                            <td class="ttd1">&nbsp;</td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="4" class="ttd1">二、学历/经历/家庭</td>
            </tr>
            <tr>
                <td class="ttd1" colspan="4">
                    <table width="100%" border="1" cellpadding="0" cellspacing="0" class="td23">
                        <tr>
                            <td width="20" rowspan="7" class="ttd1">学历(由高到低)</td>
                            <td width="80" class="ttd1">学历</td>
                            <td width="128" class="ttd1">学校名称</td>
                            <td width="128" class="ttd1">专业</td>
                            <td width="128" class="ttd1">起止年月</td>
                            <td width="128" class="ttd1">教育形式</td>
                            <td width="128" class="ttd1">学校地址</td>
                        </tr>
                        <tr>
                            <td width="80" class="ttd1">博士</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                        </tr>
                        <tr>
                            <td width="80" class="ttd1">硕士</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                        </tr>
                        <tr>
                            <td width="80" class="ttd1">本科</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                        </tr>
                        <tr>
                            <td width="80" class="ttd1">大专</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                        </tr>
                        <tr>
                            <td width="80" class="ttd1">中专/高中/技校</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                        </tr>
                        <tr>
                            <td width="80" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                            <td width="128" class="ttd1">&nbsp;</td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td class="ttd1" colspan="4">
                    <table width="100%" border="1" cellpadding="0" cellspacing="0" class="td23">
                        <tr>
                            <td class="ttd1" >工作经历(由近至远)</td>
                            <td >起止年月(近到远)</td>
                            <td >服务单位名称(时间须连续)</td>
                            <td >企业性质</td>
                            <td >产品种类</td>
                            <td >员工人数</td>
                            <td >部门及职位</td>
                            <td >离职工资</td>
                            <td >离职原因</td>
                            <td >主管/同事电话</td>
                        </tr>
                        <tr>
                            <td width="100" align="center" class="ttd1">身份证地址</td>
                            <td width="250" class="ttd1">&nbsp;</td>
                            <td width="100" align="center" class="ttd1">E-mail</td>
                            <td class="ttd1">&nbsp;</td>
                        </tr>
                        <tr>
                            <td width="100" align="center" class="ttd1">目前居住地址</td>
                            <td width="250" class="ttd1">&nbsp;</td>
                            <td width="100" align="center" class="ttd1">紧急联络人</td>
                            <td class="ttd1">&nbsp;</td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <p>
            &nbsp;</p>
    </form>
</body>
</html>

 

以上是关于WebBrowser 打印的主要内容,如果未能解决你的问题,请参考以下文章

打印 WPF WebBrowser 的内容

WebBrowser 打印

argparse 代码片段只打印部分日志

我的Android进阶之旅NDK开发之在C++代码中使用Android Log打印日志,打印出C++的函数耗时以及代码片段耗时详情

WebBrowser控件是浏览器啥版本

怎样用delphi 获取网页html源代码(网页需登录)