1. 程式人生 > >Web列印--Lodop 列印小票購物單

Web列印--Lodop 列印小票購物單


     <script src="../js/LodopFuncs.js" type="text/javascript"></script>
    <object   ID="LODOP" 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>
    <object classid="clsid:AF33188F-6656-4549-99A6-E394F0CE4EA4"
        codebase="

http://www.4fang.net/4ff/sc_setup.exe"
        id="pazu"
        name="pazu" >
        <param name="License" value="2AE816BA3A24A9BA3F01162E7BF420F4" />
    </object>
         <script language="javascript" type="text/javascript">
         function getNowDateTime()
         {
               var d = new Date();
             var vYear = d.getFullYear();
             var vMon = d.getMonth() + 1;
             var vDay = d.getDate()
             var h = d.getHours();
             var m = d.getMinutes();
           var se = d.getSeconds();
           s=vYear+"/"+(vMon<10 ? "0" + vMon : vMon)+"/"+(vDay<10 ? "0"+ vDay : vDay)+" "+(h<10 ? "0"+ h : h)+":"+(m<10 ? "0" + m : m)+":"+(se<10 ? "0" +se : se);
           return s;

         }
       

         //$("#Txt_Mfarm_Sn").val()
             var LODOP = getLodop(document.getElementById('LODOP'), document.getElementById('LODOP_EM'));
             function myPreview() {
                //必須列印初始化一下         
                LODOP.PRINT_INIT("");
                //設定頁面 ,10mm 頁面底部邊距 ,3和CreateCustomPage高度為自適應
                LODOP.SET_PRINT_PAGESIZE(3, "79mm","10mm","CreateCustomPage");
                LODOP.ADD_PRINT_TEXT("3.2mm","18.5mm","26.5mm","5.3mm","西堡紅酒歡迎您");
                LODOP.SET_PRINT_STYLEA(0,"Alignment",2);
                LODOP.ADD_PRINT_TEXT("9.8mm","2.4mm","31.5mm","5.3mm","編號:"+$("#Txt_Mfarm_Sn").val());
                LODOP.ADD_PRINT_TEXT("9.8mm","43.9mm","24.9mm","5.3mm","銷售員:"+$("#DDL_Xiaoshou").val());
                LODOP.ADD_PRINT_LINE("21.2mm","-63.8mm","20.9mm","68.5mm",2,0);
                LODOP.ADD_PRINT_LINE("22.2mm","-63.8mm","22mm","68.5mm",2,0);
                LODOP.ADD_PRINT_LINE("59mm","-63.8mm","58.7mm","68.5mm",2,0);
                LODOP.ADD_PRINT_LINE("60.3mm","-63.8mm","60.1mm","68.5mm",2,0);
                LODOP.ADD_PRINT_TEXT("15.6mm","2.4mm","21.4mm","5.3mm","品名規格");
                LODOP.ADD_PRINT_TEXT("15.6mm","40mm","11.4mm","5.3mm","數量");
                LODOP.ADD_PRINT_TEXT("15.6mm","54mm","14.8mm","5.3mm","金額");

               
               var listName=document.getElementsByName("Txt_Farm_Name");
               var listCount=document.getElementsByName("Txt_Farm_Count");
               var listMoney=document.getElementsByName("Txt_Mfarm_TotalMoney");
               var listSize=document.getElementsByName("Txt_Farm_Size");
               if(listName.length>0)
               {
                   var lineHeight=23.5;                
                   for(var i=0;i<listName.length;i++)
                   {
                        LODOP.ADD_PRINT_TEXT(""+lineHeight+"mm","2.4mm","36.8mm","5.3mm",""+listName[i].value+"/"+listSize[i].value);
                        LODOP.ADD_PRINT_TEXT(""+lineHeight+"mm","40.5mm","11.4mm","5.3mm",""+listCount[i].value);
                        LODOP.ADD_PRINT_TEXT(""+lineHeight+"mm","54mm","15.1mm","5.3mm",""+listMoney[i].value);
                        lineHeight+=5;
                   }
                }

                LODOP.ADD_PRINT_TEXT("61.9mm","2.6mm","26.5mm","5.3mm","總數量:"+$("#Txt_Mfarm_Cout").val());
                LODOP.ADD_PRINT_TEXT("62.4mm","38.6mm","31.8mm","5.3mm","總金額:"+$("#Txt_TotalMoney").val());
                LODOP.ADD_PRINT_TEXT("66.9mm","2.6mm","26.5mm","5.3mm","折扣率:"+$('#Txt_Money_Rate').numberbox('getValue'))+"%";//
                LODOP.ADD_PRINT_TEXT("67.5mm","38.6mm","31.8mm","5.3mm","折後金額:"+$('#Txt_Mfarm_DiscountMoney').numberbox('getValue'));//
                LODOP.ADD_PRINT_TEXT("73.6mm","2.9mm","33.3mm","5.3mm","付款金額:"+$('#Txt_Mfarm_BalanceMonye').numberbox('getValue'));//
                LODOP.ADD_PRINT_TEXT("78.6mm","2.9mm","59.3mm","5.3mm","列印日期:"+getNowDateTime());
               LODOP.ADD_PRINT_TEXT(585,10,100,20,".");
//                 LODOP.SET_PREVIEW_WINDOW(0, 0, 0,1024 , 700, "預覽檢視.開始列印");
                LODOP.SET_SHOW_MODE("LANDSCAPE_DEFROTATED",1);//橫向時的正向顯示
//  LODOP.SET_SHOW_MODE("SETUP_ENABLESS", 11111111000001);      
               // LODOP.PRINT_DESIGN(); //設定列印樣式
               // LODOP.PREVIEW();
                LODOP.PRINT();
             };