玄铁剑

成功的途径:抄,创造,研究,发明...
posts - 128, comments - 42, trackbacks - 0, articles - 174

LabelView/Codesoft 條碼打印范例

Posted on 2007-09-11 17:52 玄铁剑 阅读(4156) 评论(4)  编辑 收藏 引用 所属分类: C# Winform

LabelView Sample:

private   void   Form1_Load(object   sender,   System.EventArgs   e)  
  {  
  LabelApp=new   LabelApplicationClass();  
  doc=(LabelView.LabelDocument)LabelApp.ActiveDocument();  
  doc.Open("c:\\worklog\\label.lbl",true);  
  }  
   
  private   void   PrintLabel(string   result)  
  {  
  try  
  {  
   
  LabelView.LabelField   snLabel=(LabelView.LabelField)((LabelView.LabelFields)doc.LabelFields).Item("SN");  
  snLabel.Value=result;  
  doc.LabelSetup();  
  doc.PrintLabel(2,null,null,null,null,null,null);  
   
   
  }  
  catch(Exception   err)  
  {  
  MessageBox.Show(err.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);  
  }  
  }  
   
   
   
   
  private   void   Form1_Closing(object   sender,   System.ComponentModel.CancelEventArgs   e)  
  {  
  LabelApp.Quit();  
  LabelApp   =   null;  
  System.GC.Collect();  
   
  } 

Zebra-ZPL Sample:
先用Bar-One做成Barcode文檔,再通過File-->Down formatter to print生成zpl文檔,通過編程對zpl文檔中特定數據進行替換,最後輸出到指定端口即可.
  ofstream   fout;                             //declare   file-stream   handle  
  fout.open("lpt1:",   ios::out);             //open   out   to   lpt1:  
  fout<<"^XA";                                //   start   ZPL   command  
  fout<<"^FO11,19^A0N,17,16^FDYXX^FS";        //   define   the   locate   of   the   printout   and   the   size   of   the   font   is   17   x   16  
  fout<<"^FO45,19^A0N,17,16^FDXXXXX^FS";     
  fout<<"^FO95,19^A0N,17,16^FDAA^FS";  
  fout<<"^FO121,19^A0N,17,16^FDB^FS";  
  fout<<"^FO11,40^A0N,13,12^FDMM/DD/YY^FS";     //   define   the   locate   of   the   printout   and   the   size   of   the   font   is   13   x   12  
  fout<<"^FO81,40^A0N,13,12^FDC^FS";  
  fout<<"^FO103,40^A0N,13,12^FDD^FS";  
  fout<<"^FO11,59^A0N,13,12^FDPF^FS";  
  fout<<"^FO45,60^A0N,13,12^FDKF^FS";  
  fout<<"^FO73,60^A0N,13,12^FDDD^FS";  
  fout<<"^FO95,61^A0N,13,12^FDI^FS";  
  fout<<"^BY1,3,15^FO11,80^BCN,,Y,N^FD0705610065^FS";    //   print   barcode   128   with   human   readable  
  fout<<"^PQ1";                                             //print   one   label  
  fout<<"^XZ";                       //sending   end   of   zpl   Print   one  
  fout.close();                       


///////////////////////////////////////Codesoft Delphi
Var
    BarApp,BarDoc:Variant;
Begin
  BarApp := CreateOleObject('lppx.Application');
  BarApp.Visible:=True;
  BarDoc:=BarApp.ActiveDocument;
  BarVars:=BarDoc.Variables;
  BarDoc.Open('T018S1.Lab');
  BarDoc.Variables.Item('Data1').Value:='ABCD';
  BarDoc.Variables.Item('Data2').Value:='111';
  BarDoc.Variables.Item('Data3').Value:='111ABCD';
  Bardoc.Printlabel(1);
  BarDoc.FormFeed;
  Bardoc.Close;
  BarApp.Quit;
End;

///////////////////////////////////////Codesoft C#
using LabelManager2;
ApplicationClass lbl = new ApplicationClass();
try
{
    lbl.Documents.Open(@"D:\Temp\TEMP.Lab", false);
    Document doc = lbl.ActiveDocument;
    //foreach(...)
    //{
    doc.Variables.FormVariables.Item("Var0").Value = "12399999";
    //doc.Variables.FreeVariables
    //doc.Variables.Formulas
    //doc.Variables.TableLookups
    //doc.Variables.DatabaseVariables
    //doc.Variables.Dates
    //doc.Variables.Counters
    doc.PrintDocument(1);
    //}
    doc.Close(false);
}
catch (Exception ex)
{
    lbl.Quit();
}

SAMPLE CODESOFT 8 APPLICATIONS

Click a link below to download a sample ActiveX application:

Feedback

# re: LabelView/Codesoft 條碼打印范例  回复  更多评论   

2008-06-06 17:40 by wolaiye320
有沒有Codesoft java的例子。本人正在研究,但是一直找不到資料,不知怎麽入手。

# re: LabelView/Codesoft 條碼打印范例[未登录]  回复  更多评论   

2008-06-06 20:03 by 玄铁剑
上面点击Java有个范例的压缩包...

# re: LabelView/Codesoft 條碼打印范例  回复  更多评论   

2009-04-10 14:10 by 郑文娟
你好
Borland C++ 哪个例子有可以直接运行的吗?
谢谢!

# re: LabelView/Codesoft 條碼打印范例  回复  更多评论   

2010-01-11 13:42 by
LabelApplicationClass LabelView.LabelDocument
请问这些对象那里来的?
只有注册用户登录后才能发表评论。