web print

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!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;
     width: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>

  

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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

posted @   ®Geovin Du Dream Park™  阅读(286)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
历史上的今天:
2009-08-23 css 表格和层的虚线的用法(兼容各浏览器IE8可以)
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示