C# 使用指令打印条形码
求打印机高人进来指点。我被这个问题困扰很久了。厂商给的技术手册,我是没大看明白,自己摸索了一周,见效甚微。 --------------------编程问答-------------------- 试试水晶报表之类的吧,指令集记得是输出流特别麻烦,而且针对的是对套打,屏蔽操作系统之类采用的 --------------------编程问答-------------------- 用字体不好么 --------------------编程问答-------------------- Code93的条形码
class Code93
{
List<int> indexs = new List<int>(20);
char[] chars = {'0','1','2','3','4','5','6','7','8','9',
'A','B','C','D','E','F','G','H','I','J',
'K','L','M','N','O','P','Q','R','S','T',
'U','V','W','X','Y','Z','-','.',' ','$',
'/','+','%'};
string[] codes = {"100010100","101001000","101000100","101000010","100101000",
"100100100","100100010","101010000","100010010","100001010" ,
"110101000","110100100","110100010","110010100","110010010",
"110001010","101101000","101100100","101100010","100110100",
"100011010","101011000","101001100","101000110","100101100",
"100010110","110110100","110110010","110101100","110100110" ,
"110010110","110011010","101101100","101100110","100110110" ,
"100111010","100101110","111010100","111010010","111001010" ,
"101101110","101101110","110101110","100100110","111011010" ,
"111010110","100110010","101011110","1010111101"};
public string EndodingCode93(string s)
{
string code = codes[47];
for (int i = 0; i < s.Length; i++)
{
if (s[i] == '+')
return null;
int y = -1;
for (int x = 0; x < chars.Length; x++)
if (chars[x] == s[i])
{
y = x;
break;
}
if (y == -1)
return null;
code += codes[y];
indexs.Add(y);
}
int m = 0;
for (int i = indexs.Count - 1; i >= 0; i--)
m += (((indexs.Count - 1 - i) % 20) + 1) * indexs[i];
indexs.Add(m % 47);
int n = 0;
for (int i = indexs.Count - 1; i >= 0; i--)
n += (((indexs.Count - 1 - i) % 15) + 1) * indexs[i];
code += codes[m % 47];
code += codes[n % 47];
code += codes[48];
indexs.Clear();
return code;
}
}
生成条形码图片
Image TiaomaImage(string tiaoma, double wid, double het)--------------------编程问答-------------------- 生产图片
{
if (tiaoma == null)
return;
if (tiaoma == "")
return;
string s = new Code93().EndodingCode93(tiaoma);
int k = 2;
if (wid < 2 * s.Length)
wid = 2 * s.Length;
Image bp = new Bitmap((int)wid + 1, (int)het + 1);
Graphics g = Graphics.FromImage(bp);
for (int i = 0; i < s.Length; i++)
{
if (s[i] != '0')
g.FillRectangle(Brushes.Black, i * k, 0, k, (int)het - 8);
}
g.DrawString(tiaoma, new Font("宋体", 8), Brushes.Black, 5, (int)het - 8);
g.Dispose();
return bp;
}
或者用sliverlight打 --------------------编程问答--------------------
什么类型的条码打印机,使用什么端口打印,支持什么样的条码语言(ZPL,EPL之类的)
补充:.NET技术 , 非技术区