Codice PHP:
this.EAN13=function EAN13(xx,xy,xbarcode,xh,xw)
{
if (!xh) {xh=16};
if (!xw) {xw=.35};
this.Barcode(xx,xy,xbarcode,xh,xw,13);
}
this.UPC_A=function UPC_A(xx , xy , xbarcode , xh , xw)
{
if (!xh) {xh=16};
if (!xw) {xw=.35};
this.Barcode(xx,xy,xbarcode,xh,xw,12);
}
this.GetCheckDigit=function GetCheckDigit(xbarcode)
{
xsum=0;
for(xi=1;xi<=11;xi+=2)xsum+=3*xbarcode.charAt(xi);
for(xi=0;xi<=10;xi+=2)xsum+=xbarcode.charAt(xi);
xr=xsum%10;
if(xr>0)xr=10-xr;
return xr;
}
this.TestCheckDigit=function TestCheckDigit(xbarcode)
{
xsum=0;
for(xi=1;xi<=11;xi+=2)xsum+=3*xbarcode.charAt(xi);
for(xi=0;xi<=10;xi+=2)xsum+=xbarcode.charAt(xi);
return (xsum+xbarcode.charAt(12))%10==0;
}
this.Barcode=function Barcode(xx , xy , xbarcode , xh , xw , xlen)
{
//xbarcode=str_pad(xbarcode,xlen-1,"0",STR_PAD_LEFT);
while(xbarcode.length<=xlen-1) xbarcode += "0" + xbarcode
if(xlen==12)xbarcode="0" + xbarcode;
if(lib.strlen(xbarcode)==12)xbarcode+=this.GetCheckDigit(xbarcode);
else if(!this.TestCheckDigit(xbarcode))this.Error("Incorrect check digit");
xcodes=lib.newArray("A" , lib.newArray("0" , "0001101","1" , "0011001","2" , "0010011","3" , "0111101","4" , "0100011","5" , "0110001","6" , "0101111","7" , "0111011","8" , "0110111","9" , "0001011"),"B" , lib.newArray("0" , "0100111","1" , "0110011","2" , "0011011","3" , "0100001","4" , "0011101","5" , "0111001","6" , "0000101","7" , "0010001","8" , "0001001","9" , "0010111"),"C" , lib.newArray("0" , "1110010","1" , "1100110","2" , "1101100","3" , "1000010","4" , "1011100","5" , "1001110","6" , "1010000","7" , "1000100","8" , "1001000","9" , "1110100"));
xparities=lib.newArray("0" ,Array("A","A","A","A","A","A"),"1",Array("A","A","B","A","B","B"),"2" , Array("A","A","B","B","A","B"),"3" , Array("A","A","B","B","B","A"),"4" , Array("A","B","A","A","B","B"),"5" , Array("A","B","B","A","A","B"),"6" , Array("A","B","B","B","A","A"),"7" , Array("A","B","A","B","A","B"),"8" , Array("A","B","A","B","B","A"),"9" , Array("A","B","B","A","B","A"));
xcode="101";
xp=xparities[xbarcode.charAt(0)];
for(xi=1;xi<=6;xi++)xcode+=xcodes[xp[xi-1]][xbarcode.charAt(xi)];
xcode+="01010";
for(xi=7;xi<=12;xi++)xcode+=xcodes["C"][xbarcode.charAt(xi)];
xcode+="101";
for(xi=0;xi<lib.strlen(xcode);xi++)
{
if(xcode.charAt(xi)=="1")this.Rect(xx+xi*xw,xy,xw,xh,"F");
}
this.SetFont("Arial","",12);
//Response.Write(lib.substr(xbarcode,-xlen));
// REsponse.End;
this.Text(xx,xy+xh+11/this.k,lib.substr(xbarcode,-xlen));
}
e questo il mio: