100分求救!C#打印39条形码的问题!
C#打印39条形码的问题
如何搞定!
刚从WEBFORM转到WINFORM有些问题不会,问问,100分
[解决办法]
用GDI+慢慢画吧!
[解决办法]
用条码字体设置好你要打的东西,下满和打印一般文档一样,定义好纸张大小就ok了,
[解决办法]
http://www.cobainsoft.com/downloads/downloaddetail.aspx?id=12
[解决办法]
Private Sub PrintBarCode( _
ByVal strBarCode As String, _
Optional ByVal intXPos As Integer = 0, _
Optional ByVal intYPos As Integer = 0, _
Optional ByVal intPrintHeight As Integer = 10, _
Optional ByVal bolPrintText As Boolean = True _
)
' 参数说明:
' strBarCode - 要打印的条形码字符串
' intXPos, intYPos - 打印条形码的左上角坐标(缺省为(0,0),坐标刻度为:毫米)
' intHeight - 打印高度(缺省为一厘米,坐标刻度为:毫米)
' bolPrintText - 是否打印人工识别字符(缺省为true)
' "0 "- "9 ", "A-Z ", "- ", "% ", "$ "和 "* " 的条码编码格式,总共 40 个字符
Static strBarTable(39) As String
' 初始化条码编码格式表
strBarTable(0) = "001100100 " ' 0
strBarTable(1) = "100010100 " ' 1
strBarTable(2) = "010010100 " ' 2
strBarTable(3) = "110000100 " ' 3
strBarTable(4) = "001010100 " ' 4
strBarTable(5) = "101000100 " ' 5
strBarTable(6) = "011000100 " ' 6
strBarTable(7) = "000110100 " ' 7
strBarTable(8) = "100100100 " ' 8
strBarTable(9) = "010100100 " ' 9
strBarTable(10) = "100010010 " ' A
strBarTable(11) = "010010010 " ' B
strBarTable(12) = "110000010 " ' C
strBarTable(13) = "001010010 " ' D
strBarTable(14) = "101000010 " ' E
strBarTable(15) = "011000010 " ' F
strBarTable(16) = "000110010 " ' G
strBarTable(17) = "100100010 " ' H
strBarTable(18) = "010100010 " ' I
strBarTable(19) = "001100010 " ' J
strBarTable(20) = "100010001 " ' K
strBarTable(21) = "010010001 " ' L
strBarTable(22) = "110000001 " ' M
strBarTable(23) = "001010001 " ' N
strBarTable(24) = "101000001 " ' O
strBarTable(25) = "011000001 " ' P
strBarTable(26) = "000110001 " ' Q
strBarTable(27) = "100100001 " ' R
strBarTable(28) = "010100001 " ' S
strBarTable(29) = "001100001 " ' T
strBarTable(30) = "100011000 " ' U
strBarTable(31) = "010011000 " ' V
strBarTable(32) = "110001000 " ' W
strBarTable(33) = "001011000 " ' X
strBarTable(34) = "101001000 " ' Y
strBarTable(35) = "011001000 " ' Z
strBarTable(36) = "000111000 " ' -
strBarTable(37) = "100101000 " ' %
strBarTable(38) = "010101000 " ' $
strBarTable(39) = "001101000 " ' *
[解决办法]
For j = 1 To 5
' 画细线
If Mid(strBarTable(intIndex), j, 1) = "0 " Then
For k = 0 To intWidthXI - 1
Printer.Line (x + k, y)-Step(0, intHeight)
Next k
x = x + intWidthXI
' 画宽线
Else
For k = 0 To intWidthCU - 1
Printer.Line (x + k, y)-Step(0, intHeight)
Next k
x = x + intWidthCU
End If
' 每个字符条码之间为窄间隙
If j = 5 Then
x = x + intWidthXI * 3
Exit For
End If
' 窄间隙
If Mid(strBarTable(intIndex), j + 5, 1) = "0 " Then
x = x + intWidthXI * 3
' 宽间隙
Else
x = x + intWidthCU * 2
End If
Next j
Next i
' 恢复打印机 ScaleMode
Printer.ScaleMode = intOldScaleMode
' 恢复打印机 DrawWidth
Printer.DrawWidth = intOldDrawWidth
' 恢复打印机 Font
Set Printer.Font = fntOldFont
End Sub
[解决办法]
做个条码组件
[解决办法]
请问你在Web里面是如何实现打印条形码?
[解决办法]
mark
[解决办法]
將0123456789abcdefghijklmnopqrstuvwxyz每個編碼成圖型,再加上39碼的前後綴.每個條碼用前面的組成就好.直接打印圖形.
[解决办法]
学习