WEB打印ScriptX控件smsx.cab使用方法


利用smsx.cab控件进行WEB打印,可以控制"纵打"、 横打”和“页面的边距。打印代码如下:

<!-- MeadCo ScriptX -->
<object id="factory" style="display:none"
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
codebase="smsx.cab#Version=6,3,435,20">
</object>

<script defer>
function window.onload() {
  if (!factory.object) {
    alert("打印控件没有正确安装!");
    return;
  } else {
    // -- 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
   
    // -- basic features
    factory.printing.header = "This is MeadCo";
    factory.printing.footer = "Printing by ScriptX";
    factory.printing.portrait = true;
    factory.printing.leftMargin = 1.0;
    factory.printing.topMargin = 1.0;
    factory.printing.rightMargin = 1.0;
    factory.printing.bottomMargin = 1.0;
  }
}

</script>

<script language="javascript">
function printTure() //打印函数
{
document.all("dayinDiv").style.display="none";//隐藏按钮
factory.printing.Print(false); //调用控件打印
document.all("dayinDiv").style.display="";//显示
}

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

<DIV align="center" id="dayinDiv" name="dayinDiv">
<input type=button value="打印本页" onclick="printTure()">
<input type=button value="页面设置" onclick="factory.printing.PageSetup()">
<input type=button value="打印预览" onclick="factory.printing.Preview()"><br>
</DIV>


关于ScriptX的下载和该控件的使用方法请登陆 http://www.meadroid.com/scriptx/index.asp 查看.

你可能感兴趣的:(Web,asp,HP)