Creating them is another matter, since fonts have to be installed on
the
or just use this code, which only requires 2 single-pixel GIFs to
implement.
formatting other things around the barcodes, like boxes and your
company
logo and address and other text things, is a simple exercise left to
the reader.
==========================================================
<%@ LANGUAGE="VBSCRIPT" %>
<%
Option Explicit
Response.Buffer = True
' *****************************************************
'
' alternatively, put this function into an include file
'
' *****************************************************
' The following subroutine can be used to generate Code 128 B barcodes.
Function WriteBarcode128B(ByVal inp)
Const MinValid = 32
Const MaxValid = 126
Const DEL = 195
Const FNC3 = 196
Const FNC2 = 197
Const SHIFT = 198
Const CODEC = 199
Const FNC4 = 200
Const CODEA = 201
Const FNC1 = 202
Const STARTA = 203
Const STARTB = 204
Const STARTC = 205
Const xSTOPx = 206
Dim cv(255)
cv(DEL) = 95
cv(FNC3) = 96
cv(FNC2) = 97
cv(SHIFT) = 98
cv(CODEC) = 99
cv(FNC4) = 100
cv(CODEA) = 101
cv(FNC1) = 102
cv(STARTA) = 103
cv(STARTB) = 104
cv(STARTC) = 105
cv(32) = 0 ' <SPACE>
cv(33) = 1 ' !
cv(34) = 2 ' "
cv(35) = 3 ' #
cv(36) = 4 ' $
cv(37) = 5 ' %
cv(38) = 6 ' &
cv(39) = 7 ' '
cv(40) = 8 ' (
cv(41) = 9 ' )
cv(42) = 10 ' *
cv(43) = 11 ' +
cv(44) = 12 ' ,
cv(45) = 13 ' -
cv(46) = 14 ' .
cv(47) = 15 ' /
cv(48) = 16 ' 0
cv(49) = 17 ' 1
cv(50) = 18 ' 2
cv(51) = 19 ' 3
cv(52) = 20 ' 4
cv(53) = 21 ' 5
cv(54) = 22 ' 6
cv(55) = 23 ' 7
cv(56) = 24 ' 8
cv(57) = 25 ' 9
cv(58) = 26 ' :
cv(59) = 27 ' ;
cv(60) = 28 ' <
cv(61) = 29 ' =
cv(62) = 30 ' >
cv(63) = 31 ' ?
cv(64) = 32 ' @
cv(65) = 33 ' A
cv(66) = 34 ' B
cv(67) = 35 ' C
cv(68) = 36 ' D
cv(69) = 37 ' E
cv(70) = 38 ' F
cv(71) = 39 ' G
cv(72) = 40 ' H
cv(73) = 41 ' I
cv(74) = 42 ' J
cv(75) = 43 ' K
cv(76) = 44 ' L
cv(77) = 45 ' M
cv(78) = 46 ' N
cv(79) = 47 ' O
cv(80) = 48 ' P
cv(81) = 49 ' Q
cv(82) = 50 ' R
cv(83) = 51 ' S
cv(84) = 52 ' T
cv(85) = 53 ' U
cv(86) = 54 ' V
cv(87) = 55 ' W
cv(88) = 56 ' X
cv(89) = 57 ' Y
cv(90) = 58 ' Z
cv(91) = 59 ' [
cv(92) = 60 ' /
cv(93) = 61 ' ]
cv(94) = 62 ' ^
cv(95) = 63 ' _
cv(96) = 64 ' `
cv(97) = 65 ' a
cv(98) = 66 ' b
cv(99) = 67 ' c
cv(100) = 68 ' d
cv(101) = 69 ' e
cv(102) = 70 ' f
cv(103) = 71 ' g
cv(104) = 72 ' h
cv(105) = 73 ' i
cv(106) = 74 ' j
cv(107) = 75 ' k
cv(108) = 76 ' l
cv(109) = 77 ' m
cv(110) = 78 ' n
cv(111) = 79 ' o
cv(112) = 80 ' p
cv(113) = 81 ' q
cv(114) = 82 ' r
cv(115) = 83 ' s
cv(116) = 84 ' t
cv(117) = 85 ' u
cv(118) = 86 ' v
cv(119) = 87 ' w
cv(120) = 88 ' x
cv(121) = 89 ' y
cv(122) = 90 ' z
cv(123) = 91 ' {
cv(124) = 92 ' |
cv(125) = 93 ' }
cv(126) = 94 ' ~
' Encode the input string
inp = trim(inp)
Dim cdv, pos, ca, icf
icf = false
cdv = cv(STARTB)
For pos = 1 To len(inp)
ca = asc(mid(inp, pos, 1))
if (ca < MinValid) OR (ca > MaxValid) then
ca = asc("?")
icf = true
end if
cdv = cdv + (cv(ca) * pos)
Next
cdv = (cdv Mod 103)
Dim cda
if cdv < 95 then
cda = cdv + 32
else
cda = cdv + 100
end if
Dim outp
outp = chr(STARTB) & inp & chr(cda) & chr(xSTOPx)
' Each Code 128 character consists of three black and three white
bars "BWBWBW"
' (except for the stop character which has an extra black bar).
' The bars have four different widths (1, 2, 3 and 4).
Dim bp(255)
bp(32) = "212222" ' <SPACE>
bp(33) = "222122" ' !
bp(34) = "222221" ' "
bp(35) = "121223" ' #
bp(36) = "121322" ' $
bp(37) = "131222" ' %
bp(38) = "122213" ' &
bp(39) = "122312" ' '
bp(40) = "132212" ' (
bp(41) = "221213" ' )
bp(42) = "221312" ' *
bp(43) = "231212" ' +
bp(44) = "112232" ' ,
bp(45) = "122132" ' -
bp(46) = "122231" ' .
bp(47) = "113222" ' /
bp(48) = "123122" ' 0
bp(49) = "123221" ' 1
bp(50) = "223211" ' 2
bp(51) = "221132" ' 3
bp(52) = "221231" ' 4
bp(53) = "213212" ' 5
bp(54) = "223112" ' 6
bp(55) = "312131" ' 7
bp(56) = "311222" ' 8
bp(57) = "321122" ' 9
bp(58) = "321221" ' :
bp(59) = "312212" ' ;
bp(60) = "322112" ' <
bp(61) = "322211" ' =
bp(62) = "212123" ' >
bp(63) = "212321" ' ?
bp(64) = "232121" ' @
bp(65) = "111323" ' A
bp(66) = "131123" ' B
bp(67) = "131321" ' C
bp(68) = "112313" ' D
bp(69) = "132113" ' E
bp(70) = "132311" ' F
bp(71) = "211313" ' G
bp(72) = "231113" ' H
bp(73) = "231311" ' I
bp(74) = "112133" ' J
bp(75) = "112331" ' K
bp(76) = "132131" ' L
bp(77) = "113123" ' M
bp(78) = "113321" ' N
bp(79) = "133121" ' O
bp(80) = "313121" ' P
bp(81) = "211331" ' Q
bp(82) = "231131" ' R
bp(83) = "213113" ' S
bp(84) = "213311" ' T
bp(85) = "213131" ' U
bp(86) = "311123" ' V
bp(87) = "311321" ' W
bp(88) = "331121" ' X
bp(89) = "312113" ' Y
bp(90) = "312311" ' Z
bp(91) = "332111" ' [
bp(92) = "314111" ' /
bp(93) = "221411" ' ]
bp(94) = "431111" ' ^
bp(95) = "111224" ' _
bp(96) = "111422" ' `
bp(97) = "121124" ' a
bp(98) = "121421" ' b
bp(99) = "141122" ' c
bp(100) = "141221" ' d
bp(101) = "112214" ' e
bp(102) = "112412" ' f
bp(103) = "122114" ' g
bp(104) = "122411" ' h
bp(105) = "142112" ' i
bp(106) = "142211" ' j
bp(107) = "241211" ' k
bp(108) = "221114" ' l
bp(109) = "413111" ' m
bp(110) = "241112" ' n
bp(111) = "134111" ' o
bp(112) = "111242" ' p
bp(113) = "121142" ' q
bp(114) = "121241" ' r
bp(115) = "114212" ' s
bp(116) = "124112" ' t
bp(117) = "124211" ' u
bp(118) = "411212" ' v
bp(119) = "421112" ' w
bp(120) = "421211" ' x
bp(121) = "212141" ' y
bp(122) = "214121" ' z
bp(123) = "412121" ' {
bp(124) = "111143" ' |
bp(125) = "111341" ' }
bp(126) = "131141" ' ~
bp(DEL) = "114113"
bp(FNC3) = "114311"
bp(FNC2) = "411113"
bp(SHIFT) = "411311"
bp(CODEC) = "113141"
bp(FNC4) = "114131"
bp(CODEA) = "311141"
bp(FNC1) = "411131"
bp(STARTA) = "211412"
bp(STARTB) = "211214"
bp(STARTC) = "211232"
bp(xSTOPx) = "2331112"
Dim o
o = ""
for pos = 1 to len(outp)
o = o & bp(asc(mid(outp, pos, 1)))
next
Const w = 1
Const h = 35
for pos = 1 to len(o) - 1 step 2
Response.Write("<img src='Black.gif' width=" & (w * cint(mid(o,
pos, 1))) & " height=" & h & " border=0>")
Response.Write("<img src='Blank.gif' width=" & (w * cint(mid(o, pos
+ 1, 1))) & " height=" & h & " border=0>")
next
if pos = len(o) then
Response.Write("<img src='Black.gif' width=" & (w * cint(mid(o,
pos, 1))) & " height=" & h & " border=0>")
end if
if icf then
WriteBarcode128B = false
else
WriteBarcode128B = true
end if
End Function
Dim s1, s2, s3, s4
s1 = "Vendor Part #"
s2 = "!@#$%^&*()_+=-`~{}[]|\/?><,." ' nothing is perfect
s3 = "1009876543210"
s4 = "ILS Stock #"
%><html>
<body bgcolor="#FFFFFF">
<table border=0 cellpadding=10 cellspacing=2>
<tr>
<td align=center>
<% Call WriteBarcode128B(s1) %><br>
<FONT FACE=Verdana size=2><B><%=s1%></B></FONT>
</td>
<td align=center>
<% Call WriteBarcode128B(s2) %><br>
<FONT FACE=Verdana size=2><B><%=s2%></B></FONT>
</td>
</tr>
<tr>
<td align=center>
<% Call WriteBarcode128B(s3) %><br>
<FONT FACE=Verdana size=2><B><%=s3%></B></FONT>
</td>
<td align=center>
<% Call WriteBarcode128B(s4) %><br>
<FONT FACE=Verdana size=2><B><%=s4%></B></FONT>
</td>
</tr>
</table>
</body>
</html>
==========================================================
swp