Generate EAN13 Standard Barcode ASP code example _ Application Tips

Source: Internet
Author: User

Copy Code code as follows:

<title> Barcode Generation </title>
<%
Rem =================================================================
Rem = function: Ean13
Rem = Description: Generate EAN13 standard barcode, with instance (ASP code)
Rem = version: 1.0.0
Rem = Author: Seventh kind of Right angle (7th/semico)
Rem = date:2005-08-08 11:57:06
Rem = qq:11110785
Rem = QQ Group: 3773360
Rem = apply: Generate EAN13 standard barcode as needed
Rem =================================================================
Function Ean13 (code,w,h)
Dim Guide,dict,lencode,rencode,cstart,cmid,cend,barcode,lmethod
Guide = Array ("AAAAAA", "Aababb", "Aabbab", "Abaabb", "Abbaab", "Abbbaa", "Ababab", "Ababba", "Abbaba")

Set Dict = CreateObject ("Scripting.Dictionary")
Dict.add "A", "0001101001100100100110111101010001101100010101111011101101101110001011"
Dict.add "B", "0100111011001100110110100001001110101110010000101001000100010010010111"

Rencode = Array ("1110010", "1100110", "1101100", "1000010", "1011100", "1001110", "1010000", "1000100", "1001000", "" 1110100 ")

cstart= "101"
Cmid= "01010"
Cend= "101"

If W<2 then w=2
If H<20 then h=20
Cwidth=w ' Barcode Unit width
Cheight=h ' Barcode height

' Check if bar code meets standard
If Len (code) <>13 then Response.Write "must be 13 bits!": Response.End

For I=1 to 12
If IsNumeric (Mid (code,i,1)) Then
If I mod 2 then
Rsum=rsum+int (Mid (code,i,1))
Else
Lsum=lsum+int (Mid (code,i,1))
End If
Else
Response.Write "must be numeric code!": Response.End
End If
Next
If 10-((lsum*3+rsum) mod <> int (right (code,1)) Then Response.Write "This barcode error!": Response.End

' Convert barcode
Barcode=cstart
Lmethod=left (code,1)
' If Lmethod=0 then lmethod=1
For i=2 to 7
Barcode = Barcode & Mid (Dict (mid Guide (Lmethod-1), i-1,1)), (7*mid (code,i,1) +1), 7)
Next
Barcode=barcode & CMid
For I=8 to 13
Barcode = barcode & Rencode (Mid (code,i,1))
Next
Barcode=barcode & Cend


fg= "#000000" ' barcode foreground color
bg= "#ffffff" ' Barcode background color
Response.Write "<div style= ' position:absolute;width:" &cWidth*95+60& "PX; Height: "&cHeight+30&" PX; Background: "&bg&"; ' > "
' Draw barcode
For X=1 to Len (barcode)
If X<5 or x>92 or (x>46 and x<51) then
sh=10
Else
Sh=0
End If

If mid (barcode,x,1) = "1" Then
Bcolor=fg
Else
Bcolor=bg
End If

Response.Write "<div style= ' Position:absolute;left:" & (X-1) *cwidth+30& "Px;top:5px;width:" &cWidth & "Px;height: &cHeight+5+sh&" px;background: "&bColor&"; ></div> "
Next
' Add a readable digital label
Response.Write "<div style= ' position:absolute;left:16px;top:" &cHeight+10& "Px;background:" &bg& "; color:" &fg& "; font:12px Verdana; ' > "&left (code,1) &" </div> "
For X=1 to 6
Response.Write "<div style= ' Position:absolute;left:" & (x*7+2) *cwidth+22& "px;top:" &cHeight+10& " Px;background: "&bg&"; color: "&fg&"; font:12px Verdana; ' > "&mid (code,x+1,1) &" </div> "
Response.Write "<div style= ' Position:absolute;left:" & (x*7+47) *cwidth+24& "Px;top:" &cHeight+10& "Px;background: &bg&"; color: "&fg&"; font:12px Verdana; ' > "&mid (code,x+7,1) &" </div> "
Next
Response.Write "<div style= ' Position:absolute; Left:30px;top: "&cHeight+25&" Px;width: "&cWidth*95&" Px;height:10px;text-align:center;background: #ffffff; border:solid 1px #e5e5e5; font:9px Verdana; >©2007 by Elbo </div> "
Response.Write "</div>"
End Function

%>
<p style= "font:12px Verdana" >
<span style= "Text-decoration:none" >
<font color= "#000000" > apply: Generate EAN13 Standard barcode </font></span><br as needed/>
You can test the following barcode: <br/>
9787900420206<br/>
9787894954947
</p>
<br/>
<form method= "POST" action= "ttt.asp" >
<label>
<input type= "" Name= "Bcode"/>
</label>
<input type= "Submit" value= "Generate barcode"/>
</form>
<p align= "center" ></p>

<p align= "center" >

<%
If Request ("Bcode") <> "then
Call Ean13 (Request ("Bcode"), 2,100)
Else
Call Ean13 ("1234567890128", 2,100)
End If

%>
</br></a> All rights reserved </p>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.