|
楼主 |
发表于 2011-8-15 17:25:27
|
显示全部楼层
回复【楼主位】zhq0571
-----------------------------------------------------------------------
条码打印使用范例
public void tmprint(string RF,String intm, String dm, String dispp, bool debug)
{
/*
^Q19,3 标签高度、标签间距
^W54 宽度
^E12 停歇点设定
^H12 打印明暗度
^P1 打印张数
^S2 速度
^C1 复印张数
^R1 左边界起印点
^O0 自动剥纸
^D0 裁刀
~Rx 将整张标签转向180,x为标签宽度(1-104),x>104时为转回原处
^L 标签起始符,说明以下开始标签,内容。
Dy2-me-dd
Th:m:s
BA,26,13,2,5,100,0,1,a01000001
B标签种类,左下角水平位,左下角垂直位,条码窄度,条码宽度,条码高度,条码旋转度,
码文是否显示,条码数据。
E
new:
9. ecTextOutR(x,y,b,c,d,e,f,g)
功能說明: 指定True Type字型作為輸出文字的字型,並提供字型旋轉角度的
設定
輸入參數: x:(數值)設定文字所在位置的X軸座標(dots)
y:(數值)設定文字所在位置的Y軸座標(dots)
b:(數值)設定文字的高度
c:(字串)指定所使用的字型名稱
d:(字串)所要列印的文字資料
e:(數值)設定文字寬度(預設值=0)
f :(數值)設定文字線條粗細(預設值=40,容許調整值為 0~100)
g : (數值)輸出文字的旋轉角度:
0(旋轉零度), 90(旋轉90度), 180 (旋轉180度)和 270(旋轉270
度)
4
傳回值: 1 = (數值) 成功
0 = (數值) 失敗
*/
string disp = ""; ;
string[] tm ;
tm = new string[20];
tm[0] = "^Q" + this.numericUpDown_标签高度.Value.ToString() + "," + numericUpDown_标签间距.Value.ToString();
tm[1] = "^W" + this.numericUpDown_标签宽度.Value.ToString() ;
tm[2] = "^E" + this.numericUpDown_停歇点.Value.ToString();
tm[3] = "^H" + this.numericUpDown_明暗度.Value.ToString();
tm[4] = "^P" + this.numericUpDown_打印张数.Value.ToString();
tm[5] = "^S" + this.numericUpDown_打印速度.Value.ToString();
tm[6] = "^C" + this.numericUpDown_复制张数.Value.ToString() ;
tm[7] = "^R" + this.numericUpDown_左边界.Value.ToString() ;
tm[8] = "^O0";
tm[9] = "^D0";
tm[10] = "~R200";
tm[11] = "^L";
tm[12] = "BA," + this.numericUpDown_条码坐标X.Value.ToString() + "," + this.numericUpDown_条码坐标Y.Value.ToString() + "," + this.numericUpDown_条码细线宽.Value.ToString() + "," + this.numericUpDown_条码粗线宽.Value.ToString();
tm[12] += "," + this.numericUpDown_条码高度.Value.ToString() + ",0,0," + intm;
tm[13] = this.numericUpDown_题名坐标X.Value.ToString();
tm[14] = this.numericUpDown_题名坐标Y.Value.ToString();
tm[15] = this.numericUpDown_题名高度.Value.ToString();
if (this.comboBox_题名字体.SelectedIndex < 0) comboBox_题名字体.SelectedIndex = 0;
tm[16] = comboBox_题名字体.Text;
if (this.comboBox_输出方式.SelectedIndex < 0) comboBox_输出方式.SelectedIndex = 2;
if (debug) MessageBox.Show("输出类别:" + comboBox_输出方式.SelectedIndex.ToString());
switch (comboBox_TMJ_SW.SelectedIndex)
{
case 0:
apps.BASE.TM_OF863.openport_of863(comboBox_输出方式.SelectedIndex.ToString());
break;
default:
case 1: apps.BASE.TM_OF863.openport_EZ1100(comboBox_输出方式.SelectedIndex.ToString());
break;
}
if (apps.BASE.TM_OF863.isready() == 0)
{
MessageBox.Show("打印机未准备好!请重试。");
}
else
{
for (int i = 0; i < 13; i++)
{
apps.BASE.TM_OF863.sendcommand(tm);
disp = disp + tm + "\n";
}
//String tmdm = "条码" + intm + " 档号" + dm;
string tmdm = "" + intm + " " + dm;
if (checkBox_档号在题名前.Checked)
{
tmdm = "" + intm;// + " " + dm;
dispp = dm + " " + dispp;
}
else
{
tmdm = "" + intm + " " + dm;
}
//apps.BASE.TM_OF863.ecTextOut(2, 2, int.Parse(tm[15]), tm[16], tmdm);
int tmdm_x = int.Parse(this.numericUpDown_条码坐标X.Value.ToString());
int tmdm_y = int.Parse(this.numericUpDown_条码坐标Y.Value.ToString())-30;
if (tmdm_y < 5) tmdm_y = 5;
apps.BASE.TM_OF863.ecTextOut(tmdm_x, tmdm_y, 25, tm[16], tmdm + " [" + RF + "]");
//int tmdh_y =int.Parse( this.numericUpDown_条码坐标Y.Value.ToString()) + int.Parse(this.numericUpDown_条码高度.Value.ToString()) + 10;
//apps.BASE.TM_OF863.ecTextOut(int.Parse(this.numericUpDown_条码坐标X.Value.ToString()), tmdh_y, 25, tm[16], tmdm);//条码与档号
//apps.BASE.TM_OF863.ecTextOut(int.Parse(tm[13]), int.Parse(tm[14]), int.Parse(tm[15]), tm[16], dispp);
} |
|