利用ScriptX设置web打印格式

1.下载ScriptX控件,修改codebase的值,设置ScriptX控件存放的地址
http://www.meadroid.com/scriptx/sxdownload.asp

2.页面加载控件:
<object id="factory" viewastext  style="display:none"
  classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
  codebase="<c:out value="${pageContext.request.contextPath}" />/css/smsx.cab#Version=6,3,435,20">
</object>

3.使用控件
<script defer> 
       function SetPrintSettings() { 
              factory.printing.SetMarginMeasure(2)    // measure margins in inches 
              factory.SetPageRange(false, 1, 3)          // need pages from 1 to 3 
              factory.printing.printer = "HP DeskJet 870C" 
              factory.printing.copies = 2 
              factory.printing.collate = true 
              factory.printing.paperSize = "A4" 
              factory.printing.paperSource = "Manual feed" 

              // -- basic features  使用过
              factory.printing.header = "This is MeadCo" 
              factory.printing.footer = "Advanced Printing by ScriptX" 
              factory.printing.portrait = false     //方向,true
              factory.printing.leftMargin = 1.0 
              factory.printing.topMargin = 1.0 
              factory.printing.rightMargin = 1.0 
              factory.printing.bottomMargin = 1.0
    
             factory.printing.Print(false)     
             factory.printing.PageSetup()   //打印设置
             factory.printing.Preview()         //打印预览
       } 
</script>

4.页面中加载上述设置的属性  <body onLoad="SetPrintSettings() ">
 

你可能感兴趣的:(利用ScriptX设置web打印格式)