最近用smsx做了一个web打印合同的小程序,觉得还是有点用,这里把代码存下来,说不定以后能用的上。
HTML(添加smsx控件,打印按钮调用打印方法):
<OBJECT id="factory" style="DISPLAY: none" codeBase="js/smsx.cab#VVersion=6,3,435,20" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" viewastext></OBJECT> <input id="print" type="button" value="打印" name="${cd.lsApplSeq }" class="btn" οnclick="printPage()"/>JS方法(设置打印样式):
function printPage(){ //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" factory.printing.header = "&b&b" ; factory.printing.footer = "&b"; factory.printing.portrait = true; factory.printing.leftMargin =27.00; factory.printing.topMargin =28.00; factory.printing.rightMargin =27.00; factory.printing.bottomMargin =28.00; print(); }