浏览器打印

  1、首先安装的插件  install_lodop32.exe或者install_lodop64.exe
2、引入 LodopFuncs.js


 
3、在html中引入   <object  id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0> 
       <embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0></embed>
               </object>
4.获取 
<script language="javascript"> 
var LODOP=getLodop(document.getElementById('LODOP'),document.getElementById('LODOP_EM')); 
</script> 
5.调用函数 
LODOP.函数名 
(1)打印初始化(PRINT_INIT) 
(2)设定纸张大小(SET_PRINT_PAGESIZE) 
(3)增加打印项 
---ADD_PRINT_HTM-增加超文本打印项(普通模式) 
---ADD_PRINT_TABLE-增加表格打印项(超文本模式) 
---ADD_PRINT_TEXT-增加纯文本打印项 
---ADD_PRINT_IMAGE-增加图片打印项 
---ADD_PRINT_BARCODE-增加条形码 
(4)设置打印项风格(SET_PRINT_STYLEA) 
(5)强制分页(NEWPAGEA) 
(6)打印 
---PREVIEW-打印预览 
---PRINT-直接打印 
---PRINT_SETUP-打印维护-目标使用者是最终用户 
---PRINT_DESIGN-目标使用者是软件开发者
例如:
 $scope.Data={piNo:'Abcd12345',batchNo:'KT-0020012',packing:'20',qty:'40',receivingDate:'04Apr2013',storageLocation:'B9-R12',description:'Soap Noodles 80:20(WILFARIN SN-8020)',barCode:'01220123'+'KT-0020012'}
 $scope.print=function(){
      try{
     LODOP=getLodop(document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM'));
     printPickData($scope.Data);
      }catch(err){
 alert(err);
   }
      }
 
 
 var LODOP;//全局的
//打印
function printPickData(data){
LODOP.PRINT_INIT("warehouse shipped");
var pagewith=135;
var pagelegth=75;
LODOP.SET_PRINT_PAGESIZE(1, pagewith+'mm', pagelegth+'mm','A4');
LODOP.SET_PRINT_STYLE("PenStyle",10);
LODOP.SET_PRINT_STYLE("FontSize",10);
var dataSize=10;
var leftLength = 2;
var topHeight=topHeightData = 2;
var Width=pagelegth/6;
 
LODOP.ADD_PRINT_TEXTA("L", topHeight+'mm', leftLength+'mm', 120+'mm', Width+'mm', "PI No:");
LODOP.ADD_PRINT_TEXTA("L", topHeight+'mm', pagewith/2+'mm', 120+'mm', Width+'mm', "Batch No:");
 
topHeight=topHeight+Width;
//LODOP.ADD_PRINT_TEXTA("L", topHeight+'mm', leftLength+'mm', 120+'mm', Width+'mm', "Pallet No:");
LODOP.ADD_PRINT_TEXTA("L", topHeight+'mm', leftLength+'mm', 120+'mm', Width+'mm', "Packing@KG:");
LODOP.ADD_PRINT_TEXTA("L", topHeight+'mm', pagewith/2+'mm', 120+'mm', Width+'mm', "Qty/Pallet:");
 
topHeight=topHeight+Width;
LODOP.ADD_PRINT_TEXTA("L", topHeight+'mm', leftLength+'mm', 120+'mm', Width+'mm', "Receiving Date:");
LODOP.ADD_PRINT_TEXTA("L", topHeight+'mm', pagewith/2+'mm', 120+'mm', Width+'mm', "Storage Location:");
 
topHeight=topHeight+Width;
LODOP.ADD_PRINT_TEXTA("L", topHeight+'mm', leftLength+'mm', 120+'mm', Width+'mm', "Description:");
 
LODOP.ADD_PRINT_TEXTA("D", topHeightData+'mm', leftLength+15+'mm', 120+'mm', Width+'mm', data.piNo);
LODOP.ADD_PRINT_TEXTA("D", topHeightData+'mm', pagewith/2+22+'mm', 120+'mm', Width+'mm', data.batchNo);
 
topHeightData=topHeightData+Width;
//LODOP.ADD_PRINT_TEXTA("D", topHeightData+'mm', leftLength+'mm', 120+'mm', Width+'mm', data.batchNo'KT-0020012');
LODOP.ADD_PRINT_TEXTA("D", topHeightData+'mm', leftLength+30+'mm', 120+'mm', Width+'mm', data.packing);
LODOP.ADD_PRINT_TEXTA("D", topHeightData+'mm', pagewith/2+24+'mm', 120+'mm', Width+'mm',data.qty);
//
topHeightData=topHeightData+Width;
LODOP.ADD_PRINT_TEXTA("D", topHeightData+'mm', leftLength+35+'mm', 120+'mm', Width+'mm', data.receivingDate);
LODOP.ADD_PRINT_TEXTA("D", topHeightData+'mm', pagewith/2+38+'mm', 120+'mm', Width+'mm', data.storageLocation);
//
topHeightData=topHeightData+Width;
LODOP.ADD_PRINT_TEXTA("L", topHeightData+'mm', leftLength+30+'mm', 120+'mm', Width+'mm', data.description);
topHeightData=topHeightData+Width;
//
LODOP.ADD_PRINT_BARCODE(topHeightData+'mm',leftLength+'mm',pagewith-2*leftLength+'mm',Width+'mm',"Code39",data.barCode);
LODOP.SET_PRINT_STYLEA(0,"ShowBarText",0);
 
LODOP.SET_PRINT_STYLEA("L","FontName","微软雅黑");
LODOP.SET_PRINT_STYLEA("L","FontSize",12);
LODOP.SET_PRINT_STYLEA("L","Bold",1);
LODOP.SET_PRINT_STYLEA("D","FontName","微软雅黑");
LODOP.SET_PRINT_STYLEA("D","FontSize",12);
//printdates(topHeight,leftLength,Width,data);
//LODOP.PRINT_DESIGN(); 
LODOP.PREVIEW();
//   LODOP.PRINT();
}
结果如下
浏览器打印_第1张图片
 

你可能感兴趣的:(浏览器)