zoukankan      html  css  js  c++  java
  • web print

    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>The HTML5 Herald</title>
      <meta name="description" content="The HTML5 Herald">
      <meta name="author" content="SitePoint">
      <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
      <meta name="description" content="Responsive HTML5 and CSS3 site templates designed by @ajlkn." />
      <meta name="keywords" content="html5, css3, responsive, site template, website template" />
      <meta name="apple-mobile-web-app-title" content="HTML5 UP" />
      <style type="text/css" media="screen">
      #divPrint
      {
          background-color:#ffffff;
          font-size:20px;
          }
    #tab
     {
         height:100px;
         400px;
         border:5px solid #000000;
         }
    
          .style1
          {
              height: 50px;
              border:5px solid #000000;
          }
      </style>
    <script type="text/javascript">
        function CallPrint(strid) {
            var prtContent = document.getElementById(strid);
            var WinPrint = window.open('', '', 'letf=0,top=0,width=850,height=800,toolbar=0,scrollbars=1,status=0');
            WinPrint.document.write('<html><head><title>Popup 涂聚文</title>') //自定义标题
            WinPrint.document.write('</head><body>');
            WinPrint.document.write('</body></html>');
            WinPrint.document.write(prtContent.innerHTML);
            WinPrint.document.close();
            WinPrint.focus();
            WinPrint.print();  //没有网址内容
        }
    </script>  
    </head>
    <body>
     <form id="form1" runat="server">  
    <input id="btnPrint" type="button" value="Print" runat="server"  onclick="javascript:CallPrint('divPrint')"/>
        <div id="divPrint">
        <table id="tab">
        <tr id="tcss">
        <td class="style1">Your controls </td>
        <td class="style1"> 打印的内容</td>
        </tr>
            <tr id="tcss">
        <td class="style1">涂聚文<br /></td>
        <td class="style1">天下为公</td>
        </tr>
        </table>
      
    
      
      
    </div>
            </form>  
    </body>
    </html>
    

      

    function print1()
    {
    if (navigator.appname == "microsoft internet explore")
    {
    var printcommand = '<object id="printcommandobject" width=0 height=0 classid="clsid:8856f961-340a-11d0-a96b-00c04fd705a2"></object>';
    document.body.insertadjacenthtml('beforeend', printcommand);
     document.all.printcommandobject.execwb(6,-1);
    printcommandobject.outerhtml = "";
    }
    else {
    window.print();
    }
    }
    </script>
     
    <button onclick=print1()>Try it</button>
     
    2-this is second code which i tried
     
    <script>
    function btn_print_onclick() {
      factory.printing.header = "This is MeadCo";
      factory.printing.footer = "Printing by ScriptX";
      factory.printing.portrait = false;
      factory.printing.leftMargin = 1.0;
      factory.printing.topMargin = 1.0;
      factory.printing.rightMargin = 1.0;
      factory.printing.bottomMargin = 1.0;
      factory.printing.Print(false);
    }
    </script>
     
    
    </head>
    <body>
       <button onclick="btn_print_onclick()">Print report</button>
    </body>
    

      https://www.codeproject.com/questions/1013399/silent-print-from-client-side-ie

    https://www.codeproject.com/articles/24089/create-activex-in-net-step-by-step

  • 相关阅读:
    AGC037F Counting of Subarrays
    AGC025F Addition and Andition
    CF506C Mr. Kitayuta vs. Bamboos
    AGC032D Rotation Sort
    ARC101F Robots and Exits
    AGC032E Modulo Pairing
    CF559E Gerald and Path
    CF685C Optimal Point
    聊聊Mysql索引和redis跳表
    什么是线程安全
  • 原文地址:https://www.cnblogs.com/geovindu/p/7417652.html
Copyright © 2011-2022 走看看