-
-
Save Yamaha32088/e04792a9eaf81859d96830d09f81224a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- | |
Company : fusionZONE, Inc. | |
Application : barcodeZONE | |
Version : 4.0 | |
Build Date : 10/16/2007 | |
Copyright (c) 2007 fusionZONE, Inc. | |
All Rights Reserved | |
http://www.fusionzone.com | |
DO NOT REMOVE THIS NOTICE | |
CHANGE HISTORY: | |
Version Date Description of Change | |
1.1 9/2/2004 Fixed error in Code 39. | |
Modified barcode output file name to use UUID. | |
2.0 1/11/2005 Fixed error in Code 128B when using a "SPACE" Character | |
Fixed error in 2 of 5 Interleaved when using even numbers | |
Optimized barcodes for faster scanning | |
Added ability to set density on selected types | |
Added ability to turn text on and off | |
Removed option to modify bar color. | |
2.1 3/3/2005 Fixed error with Code 39 "-" | |
2.2 4/27/2005 Extensive rewrite of the EAN13 Code | |
2.3 8/22/2005 Added ability to specify output filename | |
Added ability to rotate output image | |
3.0 11/2005 UNIX Version | |
4.0 10/16/2007 Combined Windows and Unix version into one product that | |
supports the new CFIMAGE functionallity of CF8. This product | |
no longer requires the image.dll or java class file to be installed | |
on the ColdFusion server. | |
---> | |
<!--- | |
BARCODE TYPES | |
Some check digits are optional depending on the type of bar | |
code that is selected. If you require a check digit and it is | |
not required by the barcode standard, you (user) must supply the | |
check digit and include it in the data sting to be encoded. | |
Barcodes may require additional data for encoding that may not | |
be mentioned in this file. | |
BARCODE TYPE Check Digit Characters SET DENSITY | |
(1) CODE 128 B barcodeZONE N/A X | |
(2) 2 of 5 User N/A | |
(3) 2 of 5 Interleaved User EVEN NUMBER X | |
(4) Codabar N/A N/A X | |
(5) Postnet barcodeZONE 5,9 or 11 | |
(6) UPC (A) barcodeZONE 11 | |
(7) EAN 13 barcodeZONE 12 | |
(8) UPC (E) barcodeZONE 12 | |
*** BARCODEZONE WILL HANDLE THE CONVERSION OF THE 12 DIGIT UPC (A) TO THE 6 DIGIT UPC (E) | |
(9) Code 39 User N/A X | |
For more detailed information about barcodes, try one of these site: | |
http://www.barcodeisland.com/symbolgy.phtml | |
http://www.morovia.com/education/symbology/ | |
http://www.uc-council.org/ | |
Code Use Eample: | |
<cf_barcode | |
images_directory_path = "#ExpandPath('.\images\')#" \\ Physical Directory Path (REQUIRED) | |
**MUST INCLUDE TRAILING SLASH | |
data_to_encode = "TEST8052" \\ Data to encode (REQUIRED) | |
image_color_line = "000000" \\ Color of lines (HEX) **NO # SYMBOL# | |
image_color_background = "FFFFFF" \\ Color of background (HEX) **NO # SYMBOL# | |
image_height = "60" \\ Height of bars | |
image_quality = .75 \\ Valid values are fractions that range from 0 through 1 | |
barcode_type = "9" \\ Type of barcode as indicated above | |
density = "1" \\ Set the density of the barcode (1=density,2=NORMAL,3=SPARSE) | |
showtext = "1" \\ Displays text under barcode (1=YES,0=NO) | |
image_rotate = "0" \\ Rotates image specified number of degress (0,90,180,270) | |
output_location = "SCREEN" \\ Where to send image. DISK,SCREEN,BOTH | |
output_filename = ""> \\ Specify the filename of the outputed image. | |
Leave blank for autonaming GIF using UUID. | |
VALID FILE EXTENSION NAMES ARE: | |
- JPG | |
- GIF | |
- TIFF | |
- PNG | |
- | |
---> | |
<cfparam name="ATTRIBUTES.data_to_encode" default="barcodeZONE"> | |
<cfparam name="ATTRIBUTES.barcode_type" default="0"> | |
<cfparam name="ATTRIBUTES.images_directory_path" default=""> | |
<cfparam name="ATTRIBUTES.output_filename" default=""> | |
<cfparam name="ATTRIBUTES.output_location" default="BOTH"> | |
<cfparam name="ATTRIBUTES.font_size" default="12"> | |
<cfparam name="ATTRIBUTES.image_quality" default=".75"> | |
<cfparam name="ATTRIBUTES.image_height" default="40"> | |
<cfparam name="ATTRIBUTES.image_rotate" default="0"> | |
<cfparam name="ATTRIBUTES.image_color_background" default="FFFFFF"> | |
<cfparam name="ATTRIBUTES.image_color_line" default="000000"> | |
<cfparam name="ATTRIBUTES.density" default="1"> | |
<cfparam name="ATTRIBUTES.showtext" default="1"> | |
<cfscript> | |
data_to_encode = ATTRIBUTES.data_to_encode; | |
barcode_type = ATTRIBUTES.barcode_type; | |
images_directory_path = ATTRIBUTES.images_directory_path; | |
output_file = ATTRIBUTES.output_filename; | |
output_location = ATTRIBUTES.output_location; | |
image_height = ATTRIBUTES.image_height; | |
image_rotate = ATTRIBUTES.image_rotate; | |
image_quality = ATTRIBUTES.image_quality; | |
image_color_background = ATTRIBUTES.image_color_background; | |
image_color_line = ATTRIBUTES.image_color_line; | |
density = ATTRIBUTES.density; | |
human_readable = ATTRIBUTES.showtext; | |
position = 15; // HORIZONTAL START POSITION OF BARCODE (PIXELS) | |
bcindex = 0; | |
barcode_inital_width = 1500;// SET LARGE THEN CROPPED | |
barcode_final_height = image_height + 20; // SPACING FOR TEXT | |
barcode = ImageNew("",barcode_inital_width,barcode_final_height,"rgb",image_color_background); | |
ImageSetDrawingColor(barcode,image_color_line); | |
ImageSetAntialiasing(barcode,"on"); | |
</cfscript> | |
<cfswitch expression="#VARIABLES.barcode_type#"> | |
<cfcase value="1"> | |
<cfscript> | |
// Code 128 B | |
bcd = "Ì" & data_to_encode; | |
bc128 = ArrayNew(2); | |
bc128[1] = ListToArray("32,2,1,2,2,2,2"); | |
bc128[2] = ListToArray("33,2,2,2,1,2,2"); | |
bc128[3] = ListToArray("34,2,2,2,2,2,1"); | |
bc128[4] = ListToArray("35,1,2,1,2,2,2"); | |
bc128[5] = ListToArray("36,1,2,1,3,2,2"); | |
bc128[6] = ListToArray("37,1,3,1,2,2,2"); | |
bc128[7] = ListToArray("38,1,2,2,2,1,3"); | |
bc128[8] = ListToArray("39,1,2,2,3,1,2"); | |
bc128[9] = ListToArray("40,1,3,2,2,1,2"); | |
bc128[10] = ListToArray("41,2,2,1,2,1,3"); | |
bc128[11] = ListToArray("42,2,2,1,3,1,2"); | |
bc128[12] = ListToArray("43,2,3,1,2,1,2"); | |
bc128[13] = ListToArray("44,1,1,2,2,3,2"); | |
bc128[14] = ListToArray("45,1,2,2,1,3,2"); | |
bc128[15] = ListToArray("46,1,2,2,2,3,1"); | |
bc128[16] = ListToArray("47,1,1,3,2,2,2"); | |
bc128[17] = ListToArray("48,1,2,3,1,2,2"); | |
bc128[18] = ListToArray("49,1,2,3,2,2,1"); | |
bc128[19] = ListToArray("50,2,2,3,2,1,1"); | |
bc128[20] = ListToArray("51,2,2,1,1,3,2"); | |
bc128[21] = ListToArray("52,2,2,1,2,3,1"); | |
bc128[22] = ListToArray("53,2,1,3,2,1,2"); | |
bc128[23] = ListToArray("54,2,2,3,1,1,2"); | |
bc128[24] = ListToArray("55,3,1,2,1,3,1"); | |
bc128[25] = ListToArray("56,3,1,1,2,2,2"); | |
bc128[26] = ListToArray("57,3,2,1,1,2,2"); | |
bc128[27] = ListToArray("58,3,2,1,2,2,1"); | |
bc128[28] = ListToArray("59,3,1,2,2,1,2"); | |
bc128[29] = ListToArray("60,3,2,2,1,1,2"); | |
bc128[30] = ListToArray("61,3,2,2,2,1,1"); | |
bc128[31] = ListToArray("62,2,1,2,1,2,3"); | |
bc128[32] = ListToArray("63,2,1,2,3,2,1"); | |
bc128[33] = ListToArray("64,2,3,2,1,2,1"); | |
bc128[34] = ListToArray("65,1,1,1,3,2,3"); | |
bc128[35] = ListToArray("66,1,3,1,1,2,3"); | |
bc128[36] = ListToArray("67,1,3,1,3,2,1"); | |
bc128[37] = ListToArray("68,1,1,2,3,1,3"); | |
bc128[38] = ListToArray("69,1,3,2,1,1,3"); | |
bc128[39] = ListToArray("70,1,3,2,3,1,1"); | |
bc128[40] = ListToArray("71,2,1,1,3,1,3"); | |
bc128[41] = ListToArray("72,2,3,1,1,1,3"); | |
bc128[42] = ListToArray("73,2,3,1,3,1,1"); | |
bc128[43] = ListToArray("74,1,1,2,1,3,3"); | |
bc128[44] = ListToArray("75,1,1,2,3,3,1"); | |
bc128[45] = ListToArray("76,1,3,2,1,3,1"); | |
bc128[46] = ListToArray("77,1,1,3,1,2,3"); | |
bc128[47] = ListToArray("78,1,1,3,3,2,1"); | |
bc128[48] = ListToArray("79,1,3,3,1,2,1"); | |
bc128[49] = ListToArray("80,3,1,3,1,2,1"); | |
bc128[50] = ListToArray("81,2,1,1,3,3,1"); | |
bc128[51] = ListToArray("82,2,3,1,1,3,1"); | |
bc128[52] = ListToArray("83,2,1,3,1,1,3"); | |
bc128[53] = ListToArray("84,2,1,3,3,1,1"); | |
bc128[54] = ListToArray("85,2,1,3,1,3,1"); | |
bc128[55] = ListToArray("86,3,1,1,1,2,3"); | |
bc128[56] = ListToArray("87,3,1,1,3,2,1"); | |
bc128[57] = ListToArray("88,3,3,1,1,2,1"); | |
bc128[58] = ListToArray("89,3,1,2,1,1,3"); | |
bc128[59] = ListToArray("90,3,1,2,3,1,1"); | |
bc128[60] = ListToArray("91,3,3,2,1,1,1"); | |
bc128[61] = ListToArray("92,3,1,4,1,1,1"); | |
bc128[62] = ListToArray("93,2,2,1,4,1,1"); | |
bc128[63] = ListToArray("94,4,3,1,1,1,1"); | |
bc128[64] = ListToArray("95,1,1,1,2,2,4"); | |
bc128[65] = ListToArray("96,1,1,1,4,2,2"); | |
bc128[66] = ListToArray("97,1,2,1,1,2,4"); | |
bc128[67] = ListToArray("98,1,2,1,4,2,1"); | |
bc128[68] = ListToArray("99,1,4,1,1,2,2"); | |
bc128[69] = ListToArray("100,1,4,1,2,2,1"); | |
bc128[70] = ListToArray("101,1,1,2,2,1,4"); | |
bc128[71] = ListToArray("102,1,1,2,4,1,2"); | |
bc128[72] = ListToArray("103,1,2,2,1,1,4"); | |
bc128[73] = ListToArray("104,1,2,2,4,1,1"); | |
bc128[74] = ListToArray("105,1,4,2,1,1,2"); | |
bc128[75] = ListToArray("106,1,4,2,2,1,1"); | |
bc128[76] = ListToArray("107,2,4,1,2,1,1"); | |
bc128[77] = ListToArray("108,2,2,1,1,1,4"); | |
bc128[78] = ListToArray("109,4,1,3,1,1,1"); | |
bc128[79] = ListToArray("110,2,4,1,1,1,2"); | |
bc128[80] = ListToArray("111,1,3,4,1,1,1"); | |
bc128[81] = ListToArray("112,1,1,1,2,4,2"); | |
bc128[82] = ListToArray("113,1,2,1,1,4,2"); | |
bc128[83] = ListToArray("114,1,2,1,2,4,1"); | |
bc128[84] = ListToArray("115,1,1,4,2,1,2"); | |
bc128[85] = ListToArray("116,1,2,4,1,1,2"); | |
bc128[86] = ListToArray("117,1,2,4,2,1,1"); | |
bc128[87] = ListToArray("118,4,1,1,2,1,2"); | |
bc128[88] = ListToArray("119,4,2,1,1,1,2"); | |
bc128[89] = ListToArray("120,4,2,1,2,1,1"); | |
bc128[90] = ListToArray("121,2,1,2,1,4,1"); | |
bc128[91] = ListToArray("122,2,1,4,1,2,1"); | |
bc128[92] = ListToArray("123,4,1,2,1,2,1"); | |
bc128[93] = ListToArray("124,1,1,1,1,4,3"); | |
bc128[94] = ListToArray("125,1,1,1,3,4,1"); | |
bc128[95] = ListToArray("126,1,3,1,1,4,1"); | |
bc128[96] = ListToArray("195,1,1,4,1,1,3"); // <!--- DEL (ASCII 0195) ---> | |
bc128[97] = ListToArray("196,1,1,4,3,1,1"); // <!--- FNC 3 (ASCII 0196) ---> | |
bc128[98] = ListToArray("197,4,1,1,1,1,3"); // <!--- FNC 2 (ASCII 0197) ---> | |
bc128[99] = ListToArray("198,4,1,1,3,1,1"); // <!--- SHIFT (ASCII 0198) ---> | |
bc128[100] = ListToArray("199,1,1,3,1,4,1"); // <!--- CODE C (ASCII 0199) ---> | |
bc128[101] = ListToArray("200,1,1,4,1,3,1"); // <!--- FNC 4 (ASCII 0200) ---> | |
bc128[102] = ListToArray("201,3,1,1,1,4,1"); // <!--- CODE A (ASCII 0201) ---> | |
bc128[103] = ListToArray("202,4,1,1,1,3,1"); // <!--- FNC 1 (ASCII 0202) ---> | |
bc128[104] = ListToArray("203,2,1,1,4,1,2"); // <!--- Start Code A (ASCII 0203) ---> | |
bc128[105] = ListToArray("204,2,1,1,2,1,4"); // <!--- Start Code B (ASCII 0204) ---> | |
bc128[106] = ListToArray("205,2,1,1,2,3,2"); // <!--- Start Code C (ASCII 0205) ---> | |
bc128[107] = ListToArray("206,2,3,3,1,1,1,2"); // <!--- STOP (ASCII 0206) ---> | |
// START BAR CODE GENERATION SEQUENCE | |
for(fchr=1;fchr LTE Len(VARIABLES.bcd);fchr=fchr+1){ | |
thischr = ASC(MID(VARIABLES.bcd,fchr,1)); | |
for (i=1;i LTE 107;i=i+1){ | |
if (NOT Compare(bc128[i][1],thischr)){ | |
bcindex = i; | |
break; | |
} | |
} | |
// CALCULATE CHECKSUM AND GENERATE BAR DATA | |
if (fchr eq 1){ | |
bcchecksum = bcindex - 1; | |
}else{ | |
bcchecksum = bcchecksum + ((fchr-1) * (bcindex - 1)); | |
} | |
for (image_heightr=2;image_heightr LTE 7;image_heightr=image_heightr+1){ | |
if ((image_heightr MOD 2) eq 0){ | |
for (bcbar=1;bcbar LTE bc128[bcindex][image_heightr];bcbar=bcbar+1){ | |
for (r=1;r LTE VARIABLES.density;r=r+1){ | |
position = position + 1; | |
ImageDrawLine(barcode,position,0,position,image_height); | |
} | |
} | |
}else{ | |
for (bcspace=1;bcspace LTE bc128[bcindex][image_heightr];bcspace=bcspace+1){ | |
position = position + (1 * VARIABLES.density); | |
} | |
} | |
} | |
} | |
// GENERATE CHECKSUM CHARACTER | |
bcindex = (bcchecksum MOD 103) + 1; | |
for (image_heightr = 2; image_heightr LTE 7; image_heightr = image_heightr + 1){ | |
if ((image_heightr MOD 2) eq 0){ | |
for (r=1;r LTE VARIABLES.density;r=r+1){ | |
for (bcbar=1;bcbar LTE bc128[bcindex][image_heightr];bcbar=bcbar+1){ | |
position = position + 1; | |
ImageDrawLine(barcode,position,0,position,image_height); | |
} | |
} | |
}else{ | |
for (bcspace=1;bcspace LTE bc128[bcindex][image_heightr];bcspace=bcspace+1){ | |
position = position + (1 * VARIABLES.density); | |
} | |
} | |
} | |
// GENERATE STOP CHARACTER | |
for (image_heightr=2;image_heightr LTE 8;image_heightr=image_heightr+1){ | |
if ((image_heightr MOD 2) eq 0){ | |
for (r=1;r LTE VARIABLES.density;r=r+1){ | |
for (bcbar=1;bcbar LTE bc128[107][image_heightr];bcbar=bcbar+1){ | |
position = position + 1; | |
ImageDrawLine(barcode,position,0,position,image_height); | |
} | |
} | |
}else{ | |
for (bcspace=1;bcspace LTE bc128[107][image_heightr];bcspace=bcspace+1){ | |
position = position + (1 * VARIABLES.density); | |
} | |
} | |
} | |
bcd = MID(VARIABLES.bcd,2,(LEN(VARIABLES.bcd)-1)); | |
</cfscript> | |
</cfcase> | |
<cfcase value="2"> | |
<cfscript> | |
// 2 of 5 | |
if (VARIABLES.barcode_type eq 3 AND Len(data_to_encode) MOD 2){ | |
bcd = "0" & data_to_encode; | |
}else{ | |
bcd = data_to_encode; | |
} | |
bc2of5 = ArrayNew(2); | |
bc2of5[1] = ListToArray("0,0,1,1,0"); // Character 0 NNWWN | |
bc2of5[2] = ListToArray("1,0,0,0,1"); // Character 1 WNNNW | |
bc2of5[3] = ListToArray("0,1,0,0,1"); // Character 2 NWNNW | |
bc2of5[4] = ListToArray("1,1,0,0,0"); // Character 3 WWNNN | |
bc2of5[5] = ListToArray("0,0,1,0,1"); // Character 4 NNWNW | |
bc2of5[6] = ListToArray("1,0,1,0,0"); // Character 5 WNWNN | |
bc2of5[7] = ListToArray("0,1,1,0,0"); // Character 6 NWWNN | |
bc2of5[8] = ListToArray("0,0,0,1,1"); // Character 7 NNNWW | |
bc2of5[9] = ListToArray("1,0,0,1,0"); // Character 8 WNNWN | |
bc2of5[10] = ListToArray("0,1,0,1,0"); // Character 9 NWNWN | |
bc2of5Start = "11011010"; | |
bc2of5End = "1101011"; | |
// START CHARACTER | |
for (i=1;i LTE Len(bc2of5Start);i=i+1){ | |
a = MID(VARIABLES.bc2of5Start,i,1); | |
if (a eq 1){ | |
ImageDrawLine(barcode,position,0,position,image_height); | |
position = position + 1; | |
ImageDrawLine(barcode,position,0,position,image_height); | |
position = position + 1; | |
ImageDrawLine(barcode,position,0,position,image_height); | |
position = position + 1; | |
}else{ | |
position = position + 1; | |
} | |
} | |
// DATA CHARACTER | |
for (i=1; i LTE Len(VARIABLES.bcd);i=i+1){ | |
a = MID(VARIABLES.bcd,i,1)+1; | |
for (ii=1;ii LTE 5;ii=ii+1){ | |
if (bc2of5[a][ii] eq 0){ | |
barsize = 3; | |
}else{ | |
barsize = 6; | |
} | |
for (ibar=1;ibar LTE barsize;ibar=ibar+1){ | |
ImageDrawLine(barcode,position,0,position,image_height); | |
position = position + 1; | |
} | |
position = position + 1; | |
} | |
} | |
// END CHARACTER | |
for (i=1;i LTE Len(bc2of5End);i=i+1){ | |
a = MID(VARIABLES.bc2of5end,i,1); | |
if (a eq 1){ | |
ImageDrawLine(barcode,position,0,position,image_height); | |
position = position + 1; | |
ImageDrawLine(barcode,position,0,position,image_height); | |
position = position + 1; | |
ImageDrawLine(barcode,position,0,position,image_height); | |
position = position + 1; | |
}else{ | |
position = position + 1; | |
} | |
} | |
</cfscript> | |
</cfcase> | |
<cfcase value="3"> | |
<cfscript> | |
// (3) 2 of 5 Interleaved | |
if (VARIABLES.barcode_type eq 3 AND Len(data_to_encode) MOD 2){ | |
bcd = "0" & data_to_encode; | |
}else{ | |
bcd = data_to_encode; | |
} | |
//bcd = data_to_encode; | |
bc2of5 = ArrayNew(2); | |
bc2of5[1] = ListToArray("0,0,1,1,0"); // Character 0 NNWWN | |
bc2of5[2] = ListToArray("1,0,0,0,1"); // Character 1 WNNNW | |
bc2of5[3] = ListToArray("0,1,0,0,1"); // Character 2 NWNNW | |
bc2of5[4] = ListToArray("1,1,0,0,0"); // Character 3 WWNNN | |
bc2of5[5] = ListToArray("0,0,1,0,1"); // Character 4 NNWNW | |
bc2of5[6] = ListToArray("1,0,1,0,0"); // Character 5 WNWNN | |
bc2of5[7] = ListToArray("0,1,1,0,0"); // Character 6 NWWNN | |
bc2of5[8] = ListToArray("0,0,0,1,1"); // Character 7 NNNWW | |
bc2of5[9] = ListToArray("1,0,0,1,0"); // Character 8 WNNWN | |
bc2of5[10] = ListToArray("0,1,0,1,0"); // Character 9 NWNWN | |
// CALCULATE BAR LENGTH ( NOT USED ) | |
// cl = Len(VARIABLES.bcd); // Character length | |
// xd = 7.5 * .001; // X-Demension | |
// wr = 3; // Wide To Narrow Ration (2 - 3) | |
// barlength = (cl*(2 * wr + 3) + 6 + wr) * xd; | |
// START CHARACTER | |
for (i=1;i LTE 4;i=i+1){ | |
if ((NOT i MOD 2) eq 0){ | |
for (r=1;r LTE VARIABLES.density;r=r+1){ | |
ImageDrawLine(barcode,position,0,position,image_height); | |
position = position + 1; | |
} | |
}else{ | |
position = position + (1 * VARIABLES.density); | |
} | |
} | |
// DATA CHARACTER | |
for (i=1; i LTE Len(VARIABLES.bcd);i=i+2){ | |
a = MID(VARIABLES.bcd,i,1)+1; | |
b = MID(VARIABLES.bcd,i+1,1)+1; | |
for (ii = 1; ii LTE 5; ii = ii + 1){ | |
if (bc2of5[a][ii] eq 0){ | |
barsize = (1 * VARIABLES.density); | |
}else{ | |
barsize = (2 * VARIABLES.density); | |
} | |
for (ibar =1; ibar LTE barsize;ibar=ibar+1){ | |
ImageDrawLine(barcode,position,0,position,image_height); | |
position = position + 1; | |
} | |
if (bc2of5[b][ii] eq 0){ | |
spacesize = (1 * VARIABLES.density); | |
}else{ | |
spacesize = (2 * VARIABLES.density); | |
} | |
for (ispace=1;ispace LTE spacesize;ispace=ispace+1){ | |
position = position + 1; | |
} | |
} | |
} | |
// END CHARACTER | |
for (i=1; i LTE 4;i=i+1){ | |
if (NOT i eq 3){ | |
for (r=1;r LTE VARIABLES.density;r=r+1){ | |
ImageDrawLine(barcode,position,0,position,image_height); | |
position = position + 1; | |
} | |
} | |
else{ | |
position = position + (1 * VARIABLES.density); | |
} | |
} | |
</cfscript> | |
</cfcase> | |
<cfcase value="4"> | |
<cfscript> | |
// Codabar | |
bcd = data_to_encode; | |
bcCodabar = ArrayNew(2); | |
// ( C,B,S,B,S,B,S,B ) | |
bcCodabar[1] = ListToArray("0,0,0,0,0,0,1,1"); // Character 0 | |
bcCodabar[2] = ListToArray("1,0,0,0,0,1,1,0"); // Character 1 | |
bcCodabar[3] = ListToArray("2,0,0,0,1,0,0,1"); // Character 2 | |
bcCodabar[4] = ListToArray("3,1,1,0,0,0,0,0"); // Character 3 | |
bcCodabar[5] = ListToArray("4,0,0,1,0,0,1,0"); // Character 4 | |
bcCodabar[6] = ListToArray("5,1,0,0,0,0,1,0"); // Character 5 | |
bcCodabar[7] = ListToArray("6,0,1,0,0,0,0,1"); // Character 6 | |
bcCodabar[8] = ListToArray("7,0,1,0,0,1,0,0"); // Character 7 | |
bcCodabar[9] = ListToArray("8,0,1,1,0,0,0,0"); // Character 8 | |
bcCodabar[10] = ListToArray("9,1,0,0,1,0,0,0"); // Character 9 | |
bcCodabar[11] = ListToArray("-,0,0,0,1,1,0,0"); // Character - | |
bcCodabar[12] = ListToArray("$,0,0,1,1,0,0,0"); // Character $ | |
bcCodabar[13] = ListToArray(":,1,0,0,0,1,0,1"); // Character : | |
bcCodabar[14] = ListToArray("/,1,0,1,0,0,0,1"); // Character / | |
bcCodabar[15] = ListToArray(".,1,0,1,0,1,0,0"); // Character . | |
bcCodabar[16] = ListToArray("+,0,0,1,0,1,0,1"); // Character + | |
bcCodabar[17] = ListToArray("A,0,0,1,1,0,1,0"); // Character a | |
bcCodabar[18] = ListToArray("B,0,1,0,1,0,0,1"); // Character b | |
bcCodabar[19] = ListToArray("C,0,0,0,1,0,1,1"); // Character c | |
bcCodabar[20] = ListToArray("D,0,0,0,1,1,1,0"); // Character d | |
for (i=1; i LTE Len(VARIABLES.bcd);i=i+1){ | |
a = MID(VARIABLES.bcd,i,1); | |
for (ii=1; ii LTE 20;ii=ii+1){ | |
if (NOT CompareNoCase(bcCodabar[ii][1],a)){ | |
b = ii; | |
break; | |
} | |
} | |
for (iii=2;iii LTE 8;iii=iii+1){ | |
if (iii MOD 2 eq 1){ | |
if(bcCodabar[b][iii] eq 1){ | |
position = position + (2 * VARIABLES.density); | |
}else{ | |
position = position + (1 * VARIABLES.density); | |
} | |
}else{ | |
if(bcCodabar[b][iii] eq 1){ | |
for (r=1;r LTE VARIABLES.density;r=r+1){ | |
ImageDrawLine(barcode,position,0,position,image_height); | |
position = position + 1; | |
ImageDrawLine(barcode,position,0,position,image_height); | |
position = position + 1; | |
} | |
}else{ | |
for (r=1;r LTE VARIABLES.density;r=r+1){ | |
ImageDrawLine(barcode,position,0,position,image_height); | |
position = position + 1; | |
} | |
} | |
} | |
} | |
position = position + (1 * VARIABLES.density); | |
} | |
</cfscript> | |
</cfcase> | |
<cfcase value="5"> | |
<cfscript> | |
// Postnet | |
bcd = data_to_encode; | |
bcPostnet = ArrayNew(2); | |
bcPostnet[1] = ListToArray("1,1,0,0,0"); // Character 0 | |
bcPostnet[2] = ListToArray("0,0,0,1,1"); // Character 1 | |
bcPostnet[3] = ListToArray("0,0,1,0,1"); // character 2 | |
bcPostnet[4] = ListToArray("0,0,1,1,0"); // Character 3 | |
bcPostnet[5] = ListToArray("0,1,0,0,1"); // Character 4 | |
bcPostnet[6] = ListToArray("0,1,0,1,0"); // Character 5 | |
bcPostnet[7] = ListToArray("0,1,1,0,0"); // Character 6 | |
bcPostnet[8] = ListToArray("1,0,0,0,1"); // Character 7 | |
bcPostnet[9] = ListToArray("1,0,0,1,0"); // Character 8 | |
bcPostnet[10] = ListToArray("1,0,1,0,0"); // Character 9 | |
// Generate Checksum | |
// Checksum digit is a simple modulo 10 calculation of the sum of the all the digits that are being coded. | |
checktotal = 0; | |
for (i=1;i LTE LEN(bcd);i=i+1){ | |
checktotal = checktotal + MID(VARIABLES.bcd,i,1); | |
} | |
checksum = 10 - (checktotal MOD 10); | |
if (NOT checksum eq 10){ | |
bcd = VARIABLES.bcd & checksum; | |
}else{ | |
bcd = VARIABLES.bcd & 0; | |
} | |
writeoutput(checksum); | |
// Start Character | |
h = image_height; // Height of Start Character | |
p = 0; // Start position of Start Character | |
ImageDrawLine(barcode,position,p,position,h); | |
position = position + 1; | |
ImageDrawLine(barcode,position,p,position,h); | |
position = position + 1; | |
position = position + 2; | |
// Data Character | |
for (i=1;i LTE LEN(VARIABLES.bcd);i=i+1){ | |
a = MID(VARIABLES.bcd,i,1) + 1; | |
for (ii=1;ii LTE 5;ii=ii+1){ | |
if (bcPostnet[a][ii] eq 1){ | |
h = image_height; | |
p = 0; | |
}else{ | |
h = image_height/2; | |
p = image_height; | |
} | |
ImageDrawLine(barcode,position,p,position,h); | |
position = position + 1; | |
ImageDrawLine(barcode,position,p,position,h); | |
position = position + 1; | |
position = position + 2; | |
} | |
} | |
// End Character | |
h = image_height; // Height of Start Character | |
p = 0; // Start position of Start Character | |
ImageDrawLine(barcode,position,p,position,h); | |
position = position + 1; | |
ImageDrawLine(barcode,position,p,position,h); | |
position = position + 1; | |
</cfscript> | |
</cfcase> | |
<cfcase value="6"> | |
<cfscript> | |
// UPC(a) ---> | |
bcd = data_to_encode; | |
// Generate Checksum | |
a = 0; | |
for (i=1;i LTE 11;i=i+2){ | |
a = a + (MID(bcd,i,1) * 3); | |
} | |
for (i=2;i LTE 10;i=i+2){ | |
a = a + MID(bcd,i,1); | |
} | |
check_chr = (10-(a MOD 10)); | |
bcd = VARIABLES.bcd & check_chr; | |
bcUPCa=ArrayNew(2); | |
bcUPCa[1] = ListToArray("0,0,0,1,1,0,1,1,1,1,0,0,1,0"); | |
bcUPCa[2] = ListToArray("0,0,1,1,0,0,1,1,1,0,0,1,1,0"); | |
bcUPCa[3] = ListToArray("0,0,1,0,0,1,1,1,1,0,1,1,0,0"); | |
bcUPCa[4] = ListToArray("0,1,1,1,1,0,1,1,0,0,0,0,1,0"); | |
bcUPCa[5] = ListToArray("0,1,0,0,0,1,1,1,0,1,1,1,0,0"); | |
bcUPCa[6] = ListToArray("0,1,1,0,0,0,1,1,0,0,1,1,1,0"); | |
bcUPCa[7] = ListToArray("0,1,0,1,1,1,1,1,0,1,0,0,0,0"); | |
bcUPCa[8] = ListToArray("0,1,1,1,0,1,1,1,0,0,0,1,0,0"); | |
bcUPCa[9] = ListToArray("0,1,1,0,1,1,1,1,0,0,1,0,0,0"); | |
bcUPCa[10] = ListToArray("0,0,0,1,0,1,1,1,1,1,0,1,0,0"); | |
// Guard Bars | |
h2 = (ATTRIBUTES.image_height * 0.15)+ ATTRIBUTES.image_height; | |
if (VARIABLES.human_readable eq 1){ | |
ImageDrawText(barcode,Left(VARIABLES.bcd,1),5,barcode_final_height-6); | |
} | |
position = position + 1; | |
ImageDrawLine(barcode,position,0,position,h2); | |
position = position + 2; | |
ImageDrawLine(barcode,position,0,position,h2); | |
// Data Characters | |
for (i=1;i LTE 12;i=i+1){ | |
a = MID(VARIABLES.bcd,i,1)+1; | |
b = ( i \ 7 ) * 7; | |
if ((i eq 1) or (i eq 12)){ | |
h = (VARIABLES.image_height * 0.15) + VARIABLES.image_height; | |
}else{ | |
h = VARIABLES.image_height; | |
} | |
for (ii=1;ii LTE 7;ii=ii+1){ | |
if (bcUPCa[a][b+ii] eq 1){ | |
for (r=1;r LTE VARIABLES.density;r=r+1){ | |
position = position + 1; | |
ImageDrawLine(barcode,position,0,position,h); | |
} | |
}else{ | |
position = position + (1 * VARIABLES.density); | |
} | |
} | |
if (i eq 6){ | |
position = position + 2; | |
ImageDrawLine(barcode,position,0,position,h2); | |
position = position + 2; | |
ImageDrawLine(barcode,position,0,position,h2); | |
position = position + 1; | |
} | |
} | |
// code text | |
if (VARIABLES.human_readable eq 1){ | |
ImageDrawText(barcode,MID(VARIABLES.bcd,2,5),26,barcode_final_height-6); | |
ImageDrawText(barcode,MID(VARIABLES.bcd,7,5),65,barcode_final_height-6); | |
} | |
// Guard Bars | |
position = position + 1; | |
ImageDrawLine(barcode,position,0,position,h2); | |
position = position + 2; | |
ImageDrawLine(barcode,position,0,position,h2); | |
position = position + 1; | |
//end text | |
if (VARIABLES.human_readable eq 1){ | |
ImageDrawText(barcode,MID(VARIABLES.bcd,12,1),115,barcode_final_height-6); | |
} | |
// Clear String so it doesn't overlap | |
bcd = ""; | |
</cfscript> | |
</cfcase> | |
<cfcase value="7"> | |
<cfscript> | |
// EAN-13 ---> | |
bcd = data_to_encode; | |
a = 0; | |
for (i=2;i LTE 12;i=i+2){ | |
a = a + (MID(VARIABLES.bcd,i,1) * 3); | |
} | |
for (i=1;i LTE 11;i=i+2){ | |
a = a + MID(VARIABLES.bcd,i,1); | |
} | |
check_chr = (10-(a MOD 10)) MOD 10; | |
// check_chr = (10-(a MOD 10)); // This is the array position, actual character is -1 | |
bcd = VARIABLES.bcd & check_chr; | |
//writeoutput("a=" & a & "<br>"); | |
//writeoutput("check=" & check_chr & "<br>"); | |
//writeoutput("bcd=" & bcd & "<br>"); | |
bcPAR13=ArrayNew(2); | |
bcPAR13[1] = ListToArray("0,0,0,0,0,0,0,1,1,1,1,1,1"); // 0 | |
bcPAR13[2] = ListToArray("0,0,0,1,0,1,1,1,1,1,1,1,1"); // 1 | |
bcPAR13[3] = ListToArray("0,0,0,1,1,0,1,1,1,1,1,1,1"); // 2 | |
bcPAR13[4] = ListToArray("0,0,0,1,1,1,0,1,1,1,1,1,1"); // 3 | |
bcPAR13[5] = ListToArray("0,0,1,0,0,1,1,1,1,1,1,1,1"); // 4 | |
bcPAR13[6] = ListToArray("0,0,1,1,0,0,1,1,1,1,1,1,1"); // 5 | |
bcPAR13[7] = ListToArray("0,0,1,1,1,0,0,1,1,1,1,1,1"); // 6 | |
bcPAR13[8] = ListToArray("0,0,1,0,1,0,1,1,1,1,1,1,1"); // 7 | |
bcPAR13[9] = ListToArray("0,0,1,0,1,1,0,1,1,1,1,1,1"); // 8 | |
bcPAR13[10] = ListToArray("0,0,1,1,0,1,0,1,1,1,1,1,1"); // 9 | |
//0 = odd table | |
bcEAN130=ArrayNew(2); | |
bcEAN130[1] = ListToArray("0,0,0,1,1,0,1,1,1,1,0,0,1,0"); | |
bcEAN130[2] = ListToArray("0,0,1,1,0,0,1,1,1,0,0,1,1,0"); | |
bcEAN130[3] = ListToArray("0,0,1,0,0,1,1,1,1,0,1,1,0,0"); | |
bcEAN130[4] = ListToArray("0,1,1,1,1,0,1,1,0,0,0,0,1,0"); | |
bcEAN130[5] = ListToArray("0,1,0,0,0,1,1,1,0,1,1,1,0,0"); | |
bcEAN130[6] = ListToArray("0,1,1,0,0,0,1,1,0,0,1,1,1,0"); | |
bcEAN130[7] = ListToArray("0,1,0,1,1,1,1,1,0,1,0,0,0,0"); | |
bcEAN130[8] = ListToArray("0,1,1,1,0,1,1,1,0,0,0,1,0,0"); | |
bcEAN130[9] = ListToArray("0,1,1,0,1,1,1,1,0,0,1,0,0,0"); | |
bcEAN130[10] = ListToArray("0,0,0,1,0,1,1,1,1,1,0,1,0,0"); | |
//1 = even table | |
bcEAN131=ArrayNew(2); | |
bcEAN131[1] = ListToArray("0,1,0,0,1,1,1,1,1,1,0,0,1,0"); | |
bcEAN131[2] = ListToArray("0,1,1,0,0,1,1,1,1,0,0,1,1,0"); | |
bcEAN131[3] = ListToArray("0,0,1,1,0,1,1,1,1,0,1,1,0,0"); | |
bcEAN131[4] = ListToArray("0,1,0,0,0,0,1,1,0,0,0,0,1,0"); | |
bcEAN131[5] = ListToArray("0,0,1,1,1,0,1,1,0,1,1,1,0,0"); | |
bcEAN131[6] = ListToArray("0,1,1,1,0,0,1,1,0,0,1,1,1,0"); | |
bcEAN131[7] = ListToArray("0,0,0,0,1,0,1,1,0,1,0,0,0,0"); | |
bcEAN131[8] = ListToArray("0,0,1,0,0,0,1,1,0,0,0,1,0,0"); | |
bcEAN131[9] = ListToArray("0,0,0,1,0,0,1,1,0,0,1,0,0,0"); | |
bcEAN131[10] = ListToArray("0,0,1,0,1,1,1,1,1,1,0,1,0,0"); | |
// Guard Bars | |
h2 = (VARIABLES.image_height * 0.15) + VARIABLES.image_height; | |
if (VARIABLES.human_readable eq 1){ | |
ImageDrawText(barcode,MID(VARIABLES.bcd,1,1),5,barcode_final_height-15); | |
} | |
ImageDrawLine(barcode,position,0,position,h2); | |
position = position + 2; | |
ImageDrawLine(barcode,position,0,position,h2); | |
// Data Characters | |
fchr = MID(bcd,1,1); | |
//writeoutput("fchr=" & fchr & "<br>"); | |
for (i=2;i LTE 13;i=i+1){ | |
a = MID(VARIABLES.bcd,i,1)+1; | |
//writeoutput(a-1 & " = "); | |
// see if which partity to use (odd or even) | |
oddeven = bcPAR13[fchr+1][i]; | |
//writeoutput("i = " & i & "<br>"); | |
b = ( i \ 7 ) * 7; | |
if (i eq 7){ | |
b = 0; | |
} | |
//writeoutput("b = " & b & "<br>"); | |
h = VARIABLES.image_height; | |
for (ii=1;ii LTE 7;ii=ii+1){ | |
if (oddeven eq 1){ | |
//writeoutput(bcEAN131[a][b+ii]); | |
if (bcEAN131[a][b+ii] eq 1){ | |
for (r=1;r LTE VARIABLES.density;r=r+1){ | |
position = position + 1; | |
ImageDrawLine(barcode,position,0,position,h); | |
} | |
}else{ | |
position = position + (1 * VARIABLES.density); | |
} | |
}else{ | |
//writeoutput(bcEAN130[a][b+ii]); | |
if (bcEAN130[a][b+ii] eq 1){ | |
for (r=1;r LTE VARIABLES.density;r=r+1){ | |
position = position + 1; | |
ImageDrawLine(barcode,position,0,position,h); | |
} | |
}else{ | |
position = position + (1 * VARIABLES.density); | |
} | |
} | |
} | |
//writeoutput("<br><br>"); | |
if (i eq 7){ | |
position = position + 2; | |
ImageDrawLine(barcode,position,0,position,h2); | |
position = position + 2; | |
ImageDrawLine(barcode,position,0,position,h2); | |
position = position + 1; | |
} | |
} | |
// code text | |
if (VARIABLES.human_readable eq 1){ | |
ImageDrawText(barcode,MID(VARIABLES.bcd,2,6),19,barcode_final_height-6); | |
ImageDrawText(barcode,MID(VARIABLES.bcd,8,7),65,barcode_final_height-6); | |
} | |
// Guard Bars | |
position = position + 1; | |
ImageDrawLine(barcode,position,0,position,h2); | |
position = position + 2; | |
ImageDrawLine(barcode,position,0,position,h2); | |
position = position + 1; | |
if (VARIABLES.human_readable eq 1){ | |
ImageDrawText(barcode,MID(VARIABLES.bcd,13,1),250,barcode_final_height-6); | |
} | |
// end text | |
// | |
bcd = ""; | |
</cfscript> | |
</cfcase> | |
<cfcase value="8"> | |
<cfscript> | |
// UPC-E | |
function ConvertUPCA(UPCA) | |
{ | |
var csumTotal = 0; | |
if( Len(UPCA) LT 12 ){ | |
tmpString = NumberFormat(UPCA,"000000000000"); | |
UPCA = MID(tmpString,1, Len(tmpString)); | |
} | |
if( MID(UPCA,1,1) NEQ 0 and MID(UPCA,1,1) NEQ 1) | |
UPCE = '00000000000'; | |
else | |
{ | |
if( MID(UPCA,4,3) eq '000' or MID(UPCA,4,3) eq '100' or MID(UPCA,4,3) eq '200' ) | |
UPCE = MID(UPCA,2,2) & MID(UPCA,9,3) & MID(UPCA,4,1); | |
else if( MID(UPCA,5,2) eq '00' ) | |
UPCE = (MID(UPCA,2,3) & MID(UPCA,10,2)) & '3'; | |
else if( MID(UPCA,6,1) eq 0 ) | |
UPCE = (MID(UPCA,2,4) & MID(UPCA,11,1)) & '4'; | |
else if( MID(UPCA,11,1) GTE 5 ) | |
UPCE = MID(UPCA,2,5) & MID(UPCA,11,1); | |
else | |
UPCE = '000000000000'; | |
} | |
return UPCE; | |
} | |
bcd = ConvertUPCA(data_to_encode); // Calls ConvertUPCA function to 12 DIGIT UPCA to 6 DIGIT UPCE | |
// UPC-E PARITY ENCODING TABLE | |
upc_check = ArrayNew(2); | |
upc_check[1] = ListToArray("1,1,1,0,0,0"); // Character 0 | |
upc_check[2] = ListToArray("1,1,0,1,0,0"); // Character 1 | |
upc_check[3] = ListToArray("1,1,0,0,1,0"); // Character 2 | |
upc_check[4] = ListToArray("1,1,0,0,0,1"); // Character 3 | |
upc_check[5] = ListToArray("1,0,1,1,0,0"); // Character 4 | |
upc_check[6] = ListToArray("1,0,0,1,1,0"); // Character 5 | |
upc_check[7] = ListToArray("1,0,0,0,1,1"); // Character 6 | |
upc_check[8] = ListToArray("1,0,1,0,1,0"); // Character 7 | |
upc_check[9] = ListToArray("1,0,1,0,0,1"); // Character 8 | |
upc_check[10] = ListToArray("1,0,0,1,0,1"); // Character 9 | |
// UPC-E uses the "left-hand odd" and "left-hand even" | |
// encoding character sets from the EAN-13 encoding standard. | |
bcUPCe = ArrayNew(2); | |
bcUPCe[1] = ListToArray("0,0,0,1,1,0,1,0,1,0,0,1,1,1"); // Character 0 | |
bcUPCe[2] = ListToArray("0,0,1,1,0,0,1,0,1,1,0,0,1,1"); // Character 1 | |
bcUPCe[3] = ListToArray("0,0,1,0,0,1,1,0,0,1,1,0,1,1"); // Character 2 | |
bcUPCe[4] = ListToArray("0,1,1,1,1,0,1,0,1,0,0,0,0,1"); // Character 3 | |
bcUPCe[5] = ListToArray("0,1,0,0,0,1,1,0,0,1,1,1,0,1"); // Character 4 | |
bcUPCe[6] = ListToArray("0,1,1,0,0,0,1,0,1,1,1,0,0,1"); // Character 5 | |
bcUPCe[7] = ListToArray("0,1,0,1,1,1,1,0,0,0,0,1,0,1"); // Character 6 | |
bcUPCe[8] = ListToArray("0,1,1,1,0,1,1,0,0,1,0,0,0,1"); // Character 7 | |
bcUPCe[9] = ListToArray("0,1,1,0,1,1,1,0,0,0,1,0,0,1"); // Character 8 | |
bcUPCe[10] = ListToArray("0,0,0,1,0,1,1,0,0,1,0,1,1,1"); // Character 9 | |
// Convert to EAN13 (UPC_A with additional leading 0) to calculate check digit | |
last_chr = Right(VARIABLES.bcd,1); | |
if (ListFind("0,1,2",last_chr)){ | |
upc_code = "00" & MID(VARIABLES.bcd,1,2) & Right(VARIABLES.bcd,1) & "0000" & MID(VARIABLES.bcd,3,3); | |
}else if (last_chr eq 3){ | |
upc_code = "00" & Left(VARIABLES.bcd,3) & "00000" & MID(VARIABLES.bcd,4,2); | |
}else if (last_chr eq 4){ | |
upc_code = "00" & Left(VARIABLES.bcd,4) & "00000" & MID(VARIABLES.bcd,5,1); | |
}else if (ListFind("5,6,7,8,9",last_chr)){ | |
upc_code = "00" & Left(VARIABLES.bcd,5) & "0000" & Right(VARIABLES.bcd,1); | |
} | |
a = 0; | |
for (i=2;i LTE 12;i=i+2){ | |
a = a + (MID(upc_code,i,1) * 3); | |
} | |
for (i=1;i LTE 11;i=i+2){ | |
a = a + MID(upc_code,i,1); | |
} | |
check_chr = (10-(a MOD 10)) + 1; // This is the array position, actual character is -1 | |
check_txt = check_chr - 1; | |
// Guard Bars | |
h2 = (VARIABLES.image_height * 0.15) + VARIABLES.image_height; | |
if (VARIABLES.human_readable eq 1){ | |
ImageDrawText(barcode,"0",5,barcode_final_height-18); | |
} | |
ImageDrawLine(barcode,position,0,position,h2); | |
position = position + 2; | |
ImageDrawLine(barcode,position,0,position,h2); | |
// Data Characters | |
for (i=1;i LTE 6;i=i+1){ | |
b = MID(VARIABLES.bcd,i,1)+1; | |
c = upc_check[check_chr][i] * 7; | |
for (ii=1;ii LTE 7;ii=ii+1){ | |
if (bcUPCe[b][c+ii] eq 1){ | |
position = position + 1; | |
ImageDrawLine(barcode,position,0,position,image_height); | |
}else{ | |
position = position + 1; | |
} | |
} | |
} | |
// Guard Bars | |
position = position + 2; | |
ImageDrawLine(barcode,position,0,position,h2); | |
position = position + 2; | |
ImageDrawLine(barcode,position,0,position,h2); | |
position = position + 2; | |
ImageDrawLine(barcode,position,0,position,h2); | |
if (VARIABLES.human_readable eq 1){ | |
ImageDrawText(barcode,check_txt,position+4,barcode_final_height-18); | |
} | |
</cfscript> | |
</cfcase> | |
<cfcase value="9"> | |
<cfscript> | |
// Code 39, Code 3 of 9 | |
bcd = data_to_encode; | |
bcLookup = ArrayNew(2); | |
bcLookup[01] = ListToArray("!,2,42,11"); | |
bcLookup[02][01] = ""; | |
bcLookup[02][02] = 2; | |
bcLookup[02][03] = 42; | |
bcLookup[02][04] = 12; | |
bcLookup[03][01] = ""; | |
bcLookup[03][02] = 2; | |
bcLookup[03][03] = 42; | |
bcLookup[03][04] = 13; | |
bcLookup[04] = ListToArray("$,2,42,14"); | |
bcLookup[05] = ListToArray("%,2,42,15"); | |
bcLookup[06] = ListToArray("&,2,42,16"); | |
bcLookup[07] = ListToArray("',2,42,17"); | |
bcLookup[08] = ListToArray("(,2,42,18"); | |
bcLookup[09] = ListToArray("),2,42,19"); | |
bcLookup[10] = ListToArray("*,2,42,20"); | |
bcLookup[11] = ListToArray("+,2,42,21"); | |
bcLookup[12] = ListToArray(",|2|42|22","|"); | |
bcLookup[13] = ListToArray("-,1,37"); | |
bcLookup[14] = ListToArray(".,2,38"); | |
bcLookup[15] = ListToArray("/,2,42,25"); | |
bcLookup[16] = ListToArray("0,1,10"); | |
bcLookup[17] = ListToArray("1,1,1"); | |
bcLookup[18] = ListToArray("2,1,2"); | |
bcLookup[19] = ListToArray("3,1,3"); | |
bcLookup[20] = ListToArray("4,1,4"); | |
bcLookup[21] = ListToArray("5,1,5"); | |
bcLookup[22] = ListToArray("6,1,6"); | |
bcLookup[23] = ListToArray("7,1,7"); | |
bcLookup[24] = ListToArray("8,1,8"); | |
bcLookup[25] = ListToArray("9,1,9"); | |
bcLookup[26] = ListToArray(":,2,42,36"); | |
bcLookup[27] = ListToArray(";,2,44,16"); | |
bcLookup[28] = ListToArray("<,2,44,17"); | |
bcLookup[29] = ListToArray("=,2,44,18"); | |
bcLookup[30] = ListToArray(">,2,44,19"); | |
bcLookup[31] = ListToArray("?,2,44,20"); | |
bcLookup[32] = ListToArray("@,2,44,32"); | |
bcLookup[33] = ListToArray("A,1,11"); | |
bcLookup[34] = ListToArray("B,1,12"); | |
bcLookup[35] = ListToArray("C,1,13"); | |
bcLookup[36] = ListToArray("D,1,14"); | |
bcLookup[37] = ListToArray("E,1,15"); | |
bcLookup[38] = ListToArray("F,1,16"); | |
bcLookup[39] = ListToArray("G,1,17"); | |
bcLookup[40] = ListToArray("H,1,18"); | |
bcLookup[41] = ListToArray("I,1,19"); | |
bcLookup[42] = ListToArray("J,1,20"); | |
bcLookup[43] = ListToArray("K,1,21"); | |
bcLookup[44] = ListToArray("L,1,22"); | |
bcLookup[45] = ListToArray("M,1,23"); | |
bcLookup[46] = ListToArray("N,1,24"); | |
bcLookup[47] = ListToArray("O,1,25"); | |
bcLookup[48] = ListToArray("P,1,26"); | |
bcLookup[49] = ListToArray("Q,1,27"); | |
bcLookup[50] = ListToArray("R,1,28"); | |
bcLookup[51] = ListToArray("S,1,29"); | |
bcLookup[52] = ListToArray("T,1,30"); | |
bcLookup[53] = ListToArray("U,1,31"); | |
bcLookup[54] = ListToArray("V,1,32"); | |
bcLookup[55] = ListToArray("W,1,33"); | |
bcLookup[56] = ListToArray("X,1,34"); | |
bcLookup[57] = ListToArray("Y,1,35"); | |
bcLookup[58] = ListToArray("Z,1,36"); | |
bcLookup[59] = ListToArray("[,2,44,21"); | |
bcLookup[60] = ListToArray("\,2,44,22"); | |
bcLookup[61] = ListToArray("],2,44,23"); | |
bcLookup[62] = ListToArray("^,2,44,24"); | |
bcLookup[63] = ListToArray("_,2,44,25"); | |
bcLookup[64] = ListToArray("`,2,44,33"); | |
bcLookup[65] = ListToArray("{,2,44,26"); | |
bcLookup[66] = ListToArray("|,2,44,27"); | |
bcLookup[67] = ListToArray("},2,44,28"); | |
bcLookup[68] = ListToArray("~,2,44,29"); | |
bcLookup[69] = ListToArray("[,2,44,21"); | |
bcLookup[70][1] = " "; | |
bcLookup[70][2] = 1; | |
bcLookup[70][3] = 39; | |
//Encoding Table | |
bc3of9 = ArrayNew(2); | |
bc3of9[01] = ListToArray("1,0,0,1,0,0,0,0,1"); // Character 1 | |
bc3of9[02] = ListToArray("0,0,1,1,0,0,0,0,1"); // Character 2 | |
bc3of9[03] = ListToArray("1,0,1,1,0,0,0,0,0"); // Character 3 | |
bc3of9[04] = ListToArray("0,0,0,1,1,0,0,0,1"); // Character 4 | |
bc3of9[05] = ListToArray("1,0,0,1,1,0,0,0,0"); // Character 5 | |
bc3of9[06] = ListToArray("0,0,1,1,1,0,0,0,0"); // Character 6 | |
bc3of9[07] = ListToArray("0,0,0,1,0,0,1,0,1"); // Character 7 | |
bc3of9[08] = ListToArray("1,0,0,1,0,0,1,0,0"); // Character 8 | |
bc3of9[09] = ListToArray("0,0,1,1,0,0,1,0,0"); // Character 9 | |
bc3of9[10] = ListToArray("0,0,0,1,1,0,1,0,0"); // Character 0 | |
bc3of9[11] = ListToArray("1,0,0,0,0,1,0,0,1"); // Character A | |
bc3of9[12] = ListToArray("0,0,1,0,0,1,0,0,1"); // Character B | |
bc3of9[13] = ListToArray("1,0,1,0,0,1,0,0,0"); // Character C | |
bc3of9[14] = ListToArray("0,0,0,0,1,1,0,0,1"); // Character D | |
bc3of9[15] = ListToArray("1,0,0,0,1,1,0,0,0"); // Character E | |
bc3of9[16] = ListToArray("0,0,1,0,1,1,0,0,0"); // Character F | |
bc3of9[17] = ListToArray("0,0,0,0,0,1,1,0,1"); // Character G | |
bc3of9[18] = ListToArray("1,0,0,0,0,1,1,0,0"); // Character H | |
bc3of9[19] = ListToArray("0,0,1,0,0,1,1,0,0"); // Character I | |
bc3of9[20] = ListToArray("0,0,0,0,1,1,1,0,0"); // Character J | |
bc3of9[21] = ListToArray("1,0,0,0,0,0,0,1,1"); // Character K | |
bc3of9[22] = ListToArray("0,0,1,0,0,0,0,1,1"); // Character L | |
bc3of9[23] = ListToArray("1,0,1,0,0,0,0,1,0"); // Character M | |
bc3of9[24] = ListToArray("0,0,0,0,1,0,0,1,1"); // Character N | |
bc3of9[25] = ListToArray("1,0,0,0,1,0,0,1,0"); // Character O | |
bc3of9[26] = ListToArray("0,0,1,0,1,0,0,1,0"); // Character P | |
bc3of9[27] = ListToArray("0,0,0,0,0,0,1,1,1"); // Character Q | |
bc3of9[28] = ListToArray("1,0,0,0,0,0,1,1,0"); // Character R | |
bc3of9[29] = ListToArray("0,0,1,0,0,0,1,1,0"); // Character S | |
bc3of9[30] = ListToArray("0,0,0,0,1,0,1,1,0"); // Character T | |
bc3of9[31] = ListToArray("1,1,0,0,0,0,0,0,1"); // Character U | |
bc3of9[32] = ListToArray("0,1,1,0,0,0,0,0,1"); // Character V | |
bc3of9[33] = ListToArray("1,1,1,0,0,0,0,0,0"); // Character W | |
bc3of9[34] = ListToArray("0,1,0,0,1,0,0,0,1"); // Character X | |
bc3of9[35] = ListToArray("1,1,0,1,0,0,0,0,0"); // Character Y | |
bc3of9[36] = ListToArray("0,1,1,0,1,0,0,0,0"); // Character Z | |
bc3of9[37] = ListToArray("0,1,0,0,0,0,1,0,1"); // Character - | |
bc3of9[38] = ListToArray("1,1,0,0,0,0,1,0,0"); // Character . | |
bc3of9[39] = ListToArray("0,1,1,0,0,0,1,0,0"); // Character (Space) | |
bc3of9[40] = ListToArray("0,1,0,0,1,0,1,0,0"); // Code39 Start/Stop Character | |
bc3of9[41] = ListToArray("0,1,0,1,0,1,0,0,0"); // Character $ | |
bc3of9[42] = ListToArray("0,1,0,1,0,0,0,1,0"); // Character / | |
bc3of9[43] = ListToArray("0,1,0,0,0,1,0,1,0"); // Character + (Lower Case) | |
bc3of9[44] = ListToArray("0,0,0,1,0,1,0,1,0"); // Character % | |
// Start Character (*) | |
for (i=1;i LTE 9;i=i+1){ | |
if (i MOD 2 eq 1){ | |
if (bc3of9[40][i] eq 1){ | |
for (ii=1;ii LTE 2;ii=ii+1){ | |
for (r=1;r LTE VARIABLES.density;r=r+1){ | |
ImageDrawLine(barcode,position,0,position,image_height); | |
position = position + 1; | |
} | |
} | |
}else{ | |
for (ii=1;ii LTE 1;ii=ii+1){ | |
for (r=1;r LTE VARIABLES.density;r=r+1){ | |
ImageDrawLine(barcode,position,0,position,image_height); | |
position = position + 1; | |
} | |
} | |
} | |
}else{ | |
if (bc3of9[40][i] eq 1){ | |
position = position + (2 * VARIABLES.density); | |
}else{ | |
position = position + (1 * VARIABLES.density); | |
} | |
} | |
} | |
// GAP | |
position = position + (1 * VARIABLES.density); | |
for (i=1;i LTE LEN(VARIABLES.bcd);i=i+1){ | |
a = MID(VARIABLES.bcd,i,1); | |
for (ii=1;ii LTE 70;ii=ii+1){ | |
if (bcLookup[ii][1] eq UCase(a)){ | |
c = ii; | |
break; | |
} | |
} | |
if (ASC(a) GTE ASC("a") and ASC(a) LTE ASC("z")){ | |
for (z=1;z LTE 9;z=z+1){ | |
if (i MOD 2 eq 1){ | |
if (bc3of9[40][z] eq 1){ | |
for (ii=1;ii LTE 2;ii=ii+1){ | |
for (r=1;r LTE VARIABLES.density;r=r+1){ | |
ImageDrawLine(barcode,position,0,position,image_height); | |
position = position + 1; | |
} | |
} | |
}else{ | |
for (ii=1;ii LTE 1;ii=ii+1){ | |
for (r=1;r LTE VARIABLES.density;r=r+1){ | |
ImageDrawLine(barcode,position,0,position,image_height); | |
position = position + 1; | |
} | |
} | |
} | |
}else{ | |
if (bc3of9[40][z] eq 1){ | |
position = position + (2 * VARIABLES.density); | |
}else{ | |
position = position + (1 * VARIABLES.density); | |
} | |
} | |
} | |
// Insert gap between characters | |
position = position + (1 * VARIABLES.density); | |
} | |
for (zz=1;zz LTE bcLookup[c][2];zz=zz+1){ | |
d = zz + 2; | |
for (ii=1;ii LTE 9;ii=ii+1){ | |
if (ii MOD 2 eq 1){ | |
if (bc3of9[bcLookup[c][d]][ii] eq 1){ | |
for (iii=1;iii LTE 2;iii=iii+1){ | |
for (r=1;r LTE VARIABLES.density;r=r+1){ | |
ImageDrawLine(barcode,position,0,position,image_height); | |
position = position + 1; | |
} | |
} | |
}else{ | |
for (iii=1;iii LTE 1;iii=iii+1){ | |
for (r=1;r LTE VARIABLES.density;r=r+1){ | |
ImageDrawLine(barcode,position,0,position,image_height); | |
position = position + 1; | |
} | |
} | |
} | |
}else{ | |
if (bc3of9[bcLookup[c][d]][ii] eq 1){ | |
position = position + (2 * VARIABLES.density); | |
}else{ | |
position = position + (1 * VARIABLES.density); | |
} | |
} | |
} | |
// Insert gap between characters | |
position = position + (1 * VARIABLES.density); | |
} | |
} | |
// Stop Character (*) | |
for (i=1;i LTE 9;i=i+1){ | |
if (i MOD 2 eq 1){ | |
if (bc3of9[40][i] eq 1){ | |
for (ii=1;ii LTE 2;ii=ii+1){ | |
for (r=1;r LTE VARIABLES.density;r=r+1){ | |
ImageDrawLine(barcode,position,0,position,image_height); | |
position = position + 1; | |
} | |
} | |
}else{ | |
for (ii=1;ii LTE 1;ii=ii+1){ | |
for (r=1;r LTE VARIABLES.density;r=r+1){ | |
ImageDrawLine(barcode,position,0,position,image_height); | |
position = position + 1; | |
} | |
} | |
} | |
}else{ | |
if (bc3of9[40][i] eq 1){ | |
position = position + (2 * VARIABLES.density); | |
}else{ | |
position = position + (1 * VARIABLES.density); | |
} | |
} | |
} | |
</cfscript> | |
</cfcase> | |
</cfswitch> | |
<cfscript> | |
barcode_final_width = position + 15; // BAR CODE FINAL WIDTH | |
ImageCrop(barcode,0,0,barcode_final_width,barcode_final_height); | |
if(VARIABLES.human_readable){ | |
txt_count = Len(Trim(BCD)); | |
txt_height = barcode_final_height - 5; | |
txt_position = (barcode_final_width/2) - ((txt_count/2)*7); | |
ImageDrawText(barcode,bcd,txt_position,txt_height,{ size = ATTRIBUTES.font_size}); | |
} | |
if(VARIABLES.image_rotate){ | |
ImageRotate(barcode,image_rotate); | |
} | |
if(Len(Trim(output_file))){ | |
barfile = output_file; | |
}else{ | |
barfile = CreateUUID() & '.gif'; | |
} | |
if(ListFindNoCase("DISK,BOTH",output_location)){ | |
ImageWrite(barcode,"#images_directory_path##barfile#",image_quality); | |
} | |
</cfscript> | |
<cfif ListFindNoCase("SCREEN,BOTH",output_location)> | |
<cfimage source=#barcode# action="writeToBrowser"> | |
</cfif> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment