套打工具主要是为了与某些已经有个表格的报表或者统计表打印服务,页面常用一个简单的表格来表示,然后通过这个打印工具来完成页面的打印。当然不是把整个页面都打印在表格上,是按照特定的位置来打印。
1、首先下载SmartPrint
2、页面中引入cab包
<object id="printer" codebase="SmartPrint.cab" classid="clsid:40A878D3-4EAD-4C6D-8508-CE5C06501564"
width="547" height="284" align="center" hspace="0">
<param name="PaperHeight" value="500">
<param name="PaperWidth" value="500">
<param name="PrintOffSetX" value="0">
<param name="PrintOffSetY" value="0">
</object>
当然这个包的codebase是你的项目路径
3、简单的调用
var printer = document.getElementById("fpkj_printer"); var settingStr='{' settingStr +='"PaperWidth":"500",' +'"PaperHeight":"500",' +'"Title":"",' +'"OffsetX":"0",' +'"OffsetY":"0",' +'"ColumnSetting":[' +'{"Name":"KPRQ","FontSize":"10","X":"34","Y":"32"},' +'{"Name":"LSH","FontSize":"10","X":"86","Y":"86"}'; settingStr += ']}'; printer.init(settingStr); var recordSet = '{'+'"RecordSet":[{' recordSet+='"KPRQ":"'+1+'",'; recordSet+='"LSH":"'+8+'"'; recordSet+='}]}'; printer.print(recordSet);