zoukankan      html  css  js  c++  java
  • 使用MeadCo's ScriptX控件做WEB打印

     官方网址:http://www.meadroid.com/scriptx/index.asp

    MeadCo's ScriptX控件有两种使用方式,一种是做为免费版本使用,一种是做为收费版本使用,免费版本支持的功能要少些,不过最重要也是最常用的页面设置,它还是提供的,因此使用免费版本即可。不过这两个版本用的都是同一个cab文件,只不过在代码设置中有一些不同。

    http://www.meadroid.com/scriptx/sxdownload.asp这里下载smsx.cab文件。

    页面调用示例:

    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <object id=factory viewastext style="display:none" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" codebase="smsx.cab#Version=6,5,439,12"></object>
    <title></title>
    <style media="print">
    .noprint {
    display:none;
    }
    </style>
    <script type="text/javascript">
    <!--
    function SetPrintSettings() {
    // -- advanced features
    //factory.printing.SetMarginMeasure(2); // measure margins in inches
    //factory.printing.printer = "HP DeskJet 870C";
    //factory.printing.paperSize = "A4";
    //factory.printing.paperSource = "Manual feed";
    //factory.printing.collate = true;
    //factory.printing.copies = 2;
    //factory.printing.SetPageRange(false, 1, 3); // need pages from 1 to 3

    //注意,如果页面报了JS错误,可以先将以上advanced features全部去掉,只留下面的basic features,这里我将上面的全部注释掉

    // -- basic features
    factory.printing.header = "";
    factory.printing.footer = "";
    factory.printing.portrait = false;
    factory.printing.leftMargin = 1.0;
    factory.printing.topMargin = 1.0;
    factory.printing.rightMargin = 1.0;
    factory.printing.bottomMargin = 1.0;
    }

    function Print(frame) {
    factory.printing.Print(true, frame) // print with prompt
    }

    //-->
    </script>
    </head>

    <body onload="SetPrintSettings()">
    <table border="1" width="100%">
    <tr>
    <td>a</td>
    <td>b</td>
    </tr>
    <tr>
    <td>c</td>
    <td>d</td>
    </tr>
    </table>
    <center class="noprint">
    <input type=button value="打印本页" onclick="factory.printing.print(false)"> 
    <input type=button value="页面设置" onclick="factory.printing.PageSetup()"> 
    <input type=button value="打印预览" onclick="factory.printing.Preview()">
    </center>
    </body>
    </html>

    官方说明文档:http://www.meadroid.com/scriptx/docs/printdoc.asp,建议看看这个。

  • 相关阅读:
    python中filter(),map()和reduce()的用法及区别
    Python中的单例模式的几种实现方式的及优化
    python标准库和第三方库的区别
    django和flask的区别
    wtforms
    protobuf学习
    人物FSM
    策略模式
    虚函数调用机制
    虚析构函数
  • 原文地址:https://www.cnblogs.com/bdqczhl/p/11153542.html
Copyright © 2011-2022 走看看