• 全部
  • C#综合技术
  • C#互联网桌面应用
  • AppLauncher
  • WinForm&WPF
  • C#开发新技术
  • 问答

C# 条码打印code39码高分求助!

tdskee 2009-04-19 11:04:07
我现在做的一个条码打印程序是code39码,20位数字。
应用的是一个科本的条码打印控件,这个控件中我没法修改条码的条宽比等东西。
现在打印出来的条码最小的有65mm宽,而我的标签纸要求是50mm宽。
请问大家有没其他的控件或者方式打印。
我试过划线的方式,结果发现也是很宽。
我的email:tdskee@126.com
qq:31605320
希望大家能给个例子或者能运行的程序
打印机是datamax i-4208
感谢,分不够另开贴给。
很急。。。
...全文
670 1 收藏 25
写回复
25 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
现在解决没有啊??我也是code39 用barcode 可以打印 但是条码枪识别不了。。你是怎么解决的??
回复
tdskee 2009-05-08
问题还是没解决。。。
搁置了一段时间,现在还是得想办法解决!!
回复
dont888 2009-04-27
我之前用CODE39编码做一个身份证号码的,自己画的,好像没那么长。
回复
hubofly 2009-04-27
顶一下,关注
回复
tdskee 2009-04-27
[Quote=引用 16 楼 liujiayu10 的回复:]
1,如果一定要用这个控件,那么,生成条码后,把它转化成位图再缩小显示
2,你用楼上几位的代码生成条码,一般扫描器都识的,CODE39还是比较普遍的
3,用条码字体,网上有的下的,MS也自带了一个

...
[/Quote]
用ms自带的那个msBarcode.ocx可以打印出来,但是扫不了。
回复
tdskee 2009-04-27
[Quote=引用 17 楼 goldxinx 的回复:]
BarcodeX
[/Quote]
这控件是要钱的啊!!!
回复
huwuling922 2009-04-24
顶一下..
回复
goldxinx 2009-04-24
BarcodeX
回复
liujiayu10 2009-04-24
1,如果一定要用这个控件,那么,生成条码后,把它转化成位图再缩小显示
2,你用楼上几位的代码生成条码,一般扫描器都识的,CODE39还是比较普遍的
3,用条码字体,网上有的下的,MS也自带了一个

...
回复
tdskee 2009-04-24
晕死了,现在又说20位不一定全是数字,还有字母。
code39打印出来太宽了。。
回复
tdskee 2009-04-24
我的要求是code39码,不是ean13。
回复
tdskee 2009-04-24
300点的打印机,
回复
xufzu123 2009-04-20
学习+up~
回复
我很懒 2009-04-20
不好意思,貌似那个链接是个骗子
回复
我很懒 2009-04-20
http://download.csdn.net/source/937943这里下载吧!
回复
zzxap 2009-04-20
[CODE=C#]
// Paint human readable left-side 6 symbol code
g.DrawString(barCode.Substring(1,6),font,new SolidBrush(Color.Black),x,drawBounds.Y + drawBounds.Height - 12);

char[] xxx = lines.ToCharArray();
for(int i=0;i<xxx.Length;i++){
if(xxx[i] == '1'){
g.DrawLine(new Pen(Color.Black,lineWidth),x,drawBounds.Y,x,drawBounds.Y + drawBounds.Height - 12);
}
else{
g.DrawLine(new Pen(Color.White,lineWidth),x,drawBounds.Y,x,drawBounds.Y + drawBounds.Height - 12);
}
x += lineWidth;
}

// Paint center 'guard bars', always same '01010'
g.DrawLine(new Pen(Color.White,lineWidth),x,drawBounds.Y,x,drawBounds.Y + drawBounds.Height);
x += lineWidth;
g.DrawLine(new Pen(Color.Black,lineWidth),x,drawBounds.Y,x,drawBounds.Y + drawBounds.Height);
x += lineWidth;
g.DrawLine(new Pen(Color.White,lineWidth),x,drawBounds.Y,x,drawBounds.Y + drawBounds.Height);
x += lineWidth;
g.DrawLine(new Pen(Color.Black,lineWidth),x,drawBounds.Y,x,drawBounds.Y + drawBounds.Height);
x += lineWidth;
g.DrawLine(new Pen(Color.White,lineWidth),x,drawBounds.Y,x,drawBounds.Y + drawBounds.Height);
x += lineWidth;

// 5 symbol product code + 1 symbol parity
lines = "";
for(int i=7;i<13;i++){
switch(symbols[i])
{
case '0':
lines += "1110010";
break;
case '1':
lines += "1100110";
break;
case '2':
lines += "1101100";
break;
case '3':
lines += "1000010";
break;
case '4':
lines += "1011100";
break;
case '5':
lines += "1001110";
break;
case '6':
lines += "1010000";
break;
case '7':
lines += "1000100";
break;
case '8':
lines += "1001000";
break;
case '9':
lines += "1110100";
break;
}
}
// Paint human readable left-side 6 symbol code
g.DrawString(barCode.Substring(7,6),font,new SolidBrush(Color.Black),x,drawBounds.Y + drawBounds.Height - 12);

xxx = lines.ToCharArray();
for(int i=0;i<xxx.Length;i++){
if(xxx[i] == '1'){
g.DrawLine(new Pen(Color.Black,lineWidth),x,drawBounds.Y,x,drawBounds.Y + drawBounds.Height - 12);
}
else{
g.DrawLine(new Pen(Color.White,lineWidth),x,drawBounds.Y,x,drawBounds.Y + drawBounds.Height - 12);
}
x += lineWidth;
}

// Paint right 'guard bars', always same '101'
g.DrawLine(new Pen(Color.Black,lineWidth),x,drawBounds.Y,x,drawBounds.Y + drawBounds.Height);
x += lineWidth;
g.DrawLine(new Pen(Color.White,lineWidth),x,drawBounds.Y,x,drawBounds.Y + drawBounds.Height);
x += lineWidth;
g.DrawLine(new Pen(Color.Black,lineWidth),x,drawBounds.Y,x,drawBounds.Y + drawBounds.Height);
}

}
}

[/code]
回复
zzxap 2009-04-20
[CODE=C#]
/// <summary>
/// Paint EAN13 barcode to specified graphics into specified draw rectangle.
/// </summary>
/// <param name="barCode">BarCode value.</param>
/// <param name="g">Graphics where to draw.</param>
/// <param name="drawBounds">Draw bounds.</param>
public static void Paint_EAN13(string Numbers12bit,Graphics g,Rectangle drawBounds)
{
string barCode = getENA13Code(Numbers12bit);

char[] symbols = barCode.ToCharArray();

//--- Validate barCode -------------------------------------------------------------------//
if(barCode.Length != 13){
return;
}
foreach(char c in symbols){
if(!Char.IsDigit(c)){
return;
}
}

//--- Check barcode checksum ------------------------//
int checkSum = Convert.ToInt32(symbols[12].ToString());
int calcSum = 0;
bool one_three = true;
for(int i=0;i<12;i++){
if(one_three){
calcSum += (Convert.ToInt32(symbols[i].ToString()) * 1);
one_three = false;
}
else{
calcSum += (Convert.ToInt32(symbols[i].ToString()) * 3);
one_three = true;
}
}

char[] calcSumChar = calcSum.ToString().ToCharArray();
if(checkSum !=0 && checkSum != (10 - Convert.ToInt32(calcSumChar[calcSumChar.Length - 1].ToString()))){
return;
}
//--------------------------------------------------//
//---------------------------------------------------------------------------------------//

Font font = new Font("Microsoft Sans Serif",8);

// Fill backround with white color
// g.Clear(Color.White);

int lineWidth = 1;
int x = drawBounds.X;

// Paint human readable 1 system symbol code
g.DrawString(symbols[0].ToString(),font,new SolidBrush(Color.Black),x,drawBounds.Y + drawBounds.Height - 16);
x += 10;

// Paint left 'guard bars', always same '101'
g.DrawLine(new Pen(Color.Black,lineWidth),x,drawBounds.Y,x,drawBounds.Y + drawBounds.Height);
x += lineWidth;
g.DrawLine(new Pen(Color.White,lineWidth),x,drawBounds.Y,x,drawBounds.Y + drawBounds.Height);
x += lineWidth;
g.DrawLine(new Pen(Color.Black,lineWidth),x,drawBounds.Y,x,drawBounds.Y + drawBounds.Height);
x += lineWidth;

// First number of barcode specifies how to encode each character in the left-hand
// side of the barcode should be encoded.
bool[] leftSideParity = new bool[6];
switch(symbols[0])
{
case '0':
leftSideParity[0] = true; // Odd
leftSideParity[1] = true; // Odd
leftSideParity[2] = true; // Odd
leftSideParity[3] = true; // Odd
leftSideParity[4] = true; // Odd
leftSideParity[5] = true; // Odd
break;
case '1':
leftSideParity[0] = true; // Odd
leftSideParity[1] = true; // Odd
leftSideParity[2] = false; // Even
leftSideParity[3] = true; // Odd
leftSideParity[4] = false; // Even
leftSideParity[5] = false; // Even
break;
case '2':
leftSideParity[0] = true; // Odd
leftSideParity[1] = true; // Odd
leftSideParity[2] = false; // Even
leftSideParity[3] = false; // Even
leftSideParity[4] = true; // Odd
leftSideParity[5] = false; // Even
break;
case '3':
leftSideParity[0] = true; // Odd
leftSideParity[1] = true; // Odd
leftSideParity[2] = false; // Even
leftSideParity[3] = false; // Even
leftSideParity[4] = false; // Even
leftSideParity[5] = true; // Odd
break;
case '4':
leftSideParity[0] = true; // Odd
leftSideParity[1] = false; // Even
leftSideParity[2] = true; // Odd
leftSideParity[3] = true; // Odd
leftSideParity[4] = false; // Even
leftSideParity[5] = false; // Even
break;
case '5':
leftSideParity[0] = true; // Odd
leftSideParity[1] = false; // Even
leftSideParity[2] = false; // Even
leftSideParity[3] = true; // Odd
leftSideParity[4] = true; // Odd
leftSideParity[5] = false; // Even
break;
case '6':
leftSideParity[0] = true; // Odd
leftSideParity[1] = false; // Even
leftSideParity[2] = false; // Even
leftSideParity[3] = false; // Even
leftSideParity[4] = true; // Odd
leftSideParity[5] = true; // Odd
break;
case '7':
leftSideParity[0] = true; // Odd
leftSideParity[1] = false; // Even
leftSideParity[2] = true; // Odd
leftSideParity[3] = false; // Even
leftSideParity[4] = true; // Odd
leftSideParity[5] = false; // Even
break;
case '8':
leftSideParity[0] = true; // Odd
leftSideParity[1] = false; // Even
leftSideParity[2] = true; // Odd
leftSideParity[3] = false; // Even
leftSideParity[4] = false; // Even
leftSideParity[5] = true; // Odd
break;
case '9':
leftSideParity[0] = true; // Odd
leftSideParity[1] = false; // Even
leftSideParity[2] = false; // Even
leftSideParity[3] = true; // Odd
leftSideParity[4] = false; // Even
leftSideParity[5] = true; // Odd
break;
}

// second number system digit + 5 symbol manufacter code
string lines = "";
for(int i=0;i<6;i++){
bool oddParity = leftSideParity[i];
if(oddParity){
switch(symbols[i + 1])
{
case '0':
lines += "0001101";
break;
case '1':
lines += "0011001";
break;
case '2':
lines += "0010011";
break;
case '3':
lines += "0111101";
break;
case '4':
lines += "0100011";
break;
case '5':
lines += "0110001";
break;
case '6':
lines += "0101111";
break;
case '7':
lines += "0111011";
break;
case '8':
lines += "0110111";
break;
case '9':
lines += "0001011";
break;
}
}
// Even parity
else{
switch(symbols[i + 1])
{
case '0':
lines += "0100111";
break;
case '1':
lines += "0110011";
break;
case '2':
lines += "0011011";
break;
case '3':
lines += "0100001";
break;
case '4':
lines += "0011101";
break;
case '5':
lines += "0111001";
break;
case '6':
lines += "0000101";
break;
case '7':
lines += "0010001";
break;
case '8':
lines += "0001001";
break;
case '9':
lines += "0010111";
break;
}
}
}


[/CODE]
回复
zzxap 2009-04-20
[code=C#]
假设将EAN的内容从右到左的顺序编号:N13、N12、N11、N10、N9、N8、N7、N6、N5、N4、N3、N2、N1,其中N1是准备要求的校验位:
1、C1=(N2+N4+N6+N8+N10+N12)*3;
2、C2=N3+N5+N7+N9+N11+N13;
3、将C1与C2相加,取其个位数,设为C3;4、校验位N1=10-C3

using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace BarCodeEAN13
{
/// <summary>
/// Barcode control.
/// </summary>
public class wctrl_BarCode
{

private static string getENA13Code(string Numbers12bit)
{
int c1 = 0;
int c2 = 0;

for (int i=0; i<11; i= i+2)
{
c1 += int.Parse(Numbers12bit[i].ToString());
c2 += int.Parse(Numbers12bit[i+1].ToString());
}

int c3 = c1 + c2 *3;

c3 = c3 - c3/10 *10;

if (c3 == 0)
{
return Numbers12bit + 0;
}
else
{
int N = 10 - c3;

return Numbers12bit + N;
}
}


[/CODE]
回复
zgke 2009-04-20
你的看你打印机多少DPI的
.真不行知己画

http://blog.csdn.net/zgke/archive/2008/12/12/3503845.aspx



回复
xupeihuagudulei 2009-04-20
[Quote=引用 5 楼 itcrazyman 的回复:]
mark up 顶起
[/Quote]
回复
加载更多回复
相关推荐
发帖
C#
创建于2007-09-28

10.5w+

社区成员

.NET技术 C#
申请成为版主
帖子事件
创建了帖子
2009-04-19 11:04
社区公告

让您成为最强悍的C#开发者