File:
[LON-CAPA] /
doc /
build /
Attic /
barcode.html
Revision
1.2:
download - view:
text,
annotated -
select for diffs
Mon Apr 23 13:11:41 2001 UTC (23 years, 4 months ago) by
harris41
Branches:
MAIN
CVS tags:
version_1_0_3,
version_1_0_2,
version_1_0_1,
version_1_0_0,
version_0_99_5,
version_0_99_4,
version_0_99_3,
version_0_99_2,
version_0_99_1,
version_0_99_0,
version_0_6_2,
version_0_6,
version_0_5_1,
version_0_5,
version_0_4,
stable_2002_spring,
stable_2002_july,
stable_2002_april,
stable_2001_fall,
conference_2003,
STABLE,
HEAD
including sample code (written by authors of GD-Barcode.pm) -Scott
1: <pre>
2: * determing source build procedure for
3: LON-CAPA-barcode-3.1-1.i386.rpm
4: Components:
5: + gd library
6: + GD perl module
7: + GD Barcode perl module
8:
9: Looking
10: at things for a bit, I've decided to go with the newer,
11: more powerful GD-Barcode perl module as opposed to
12: the Barcode-Code128 perl module.
13:
14: These are the installation instructions and sample
15: png images in case you are interested. These instructions
16: work for the RedHat-6.2/LON-CAPA development distribution.
17:
18: wget http://www.boutell.com/gd/http/gd-1.8.4.tar.gz
19: tar xzvf gd-1.8.4.tar.gz
20: wget http://www.cpan.org/modules/by-module/GD/GD-1.33.tar.gz
21: tar xzvf GD-1.33.tar.gz
22: cd GD-1.33
23: cp patch_gd.pl ../gd-1.8.4
24: cd ../gd-1.8.4
25: perl patch_gd.pl
26: ./configure
27: make
28: make check
29: (as root)
30: make install
31: cd ../GD-1.33
32: perl Makefile.PL
33: Build JPEG support? [y] n
34: Build FreeType support? [y] n
35: Build XPM support? [y] n
36: make
37: make test
38: (as root)
39: make install
40: wget http://www.cpan.org/modules/by-module/GD/GD-Barcode-1.13.tar.gz
41: tar xzvf GD-Barcode-1.13.tar.gz
42: cd GD-Barcode-1.13
43: perl Makefile.PL
44: make
45: make test
46: (as root)
47: make install
48:
49: I am going to now calculate the installed files, ownerships, and
50: permissions, and make part of the LON-CAPA installation
51: (LON-CAPA-barcode-3.1-1.i386.rpm).
52:
53: -Scott
54: </pre>
55:
56: Example usage code #1 (from the GD-Barcode samples directory)
57: <pre>
58: use strict;
59: use GD::Barcode;
60:
61: my $oGdBar;
62: #1)EAN13
63: #1.1 NORMAL
64: print "=======================\nEAN13: NORMAL\n";
65: $oGdBar = GD::Barcode->new('EAN13', '123456789012');
66: print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
67: open(OUT, '>EAN13.png');
68: binmode OUT; #for Windows
69: print OUT $oGdBar->plot->png;
70: close OUT;
71: undef $oGdBar;
72:
73: #1.2 Error
74: print "EAN13: ERROR\n";
75: $oGdBar = GD::Barcode->new('EAN13', '12345678901');
76: print "ERROR:", $GD::Barcode::errStr, "\n";
77: undef $oGdBar;
78:
79: #2)EAN8
80: #2.1 NORMAL
81: print "=======================\nEAN8: NORMAL\n";
82: $oGdBar = GD::Barcode->new('EAN8', '1234567');
83: print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
84: open(OUT, '>EAN8.png');
85: binmode OUT; #for Windows
86: print OUT $oGdBar->plot->png;
87: close OUT;
88: undef $oGdBar;
89:
90: #2.2 Error
91: print "EAN8: ERROR\n";
92: $oGdBar = GD::Barcode->new('EAN8', 'A1234567');
93: print "ERROR:", $GD::Barcode::errStr, "\n";
94: undef $oGdBar;
95:
96: #3)UPC-A
97: #3.1 NORMAL
98: print "=======================\nUPCA: NORMAL\n";
99: $oGdBar = GD::Barcode->new('UPCA', '12345678901');
100: print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
101: open(OUT, '>UPCA.png');
102: binmode OUT; #for Windows
103: print OUT $oGdBar->plot->png;
104: close OUT;
105: undef $oGdBar;
106:
107: #3.2 Error
108: print "UPCA: ERROR\n";
109: $oGdBar = GD::Barcode->new('UPCA','12345678901132');
110: print "ERROR:", $GD::Barcode::errStr, "\n";
111: undef $oGdBar;
112:
113: #4)UPC-E
114: #4.1 NORMAL
115: print "=======================\nUPCE: NORMAL\n";
116: $oGdBar = GD::Barcode->new('UPCE', '1234567');
117: print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
118: open(OUT, '>UPCE.png');
119: binmode OUT; #for Windows
120: print OUT $oGdBar->plot->png;
121: close OUT;
122: undef $oGdBar;
123:
124: #4.2 Error
125: print "UPCE: ERROR\n";
126: $oGdBar = GD::Barcode->new('UPCE', '123456788');
127: print "ERROR:", $GD::Barcode::errStr, "\n";
128: undef $oGdBar;
129:
130: #5)NW7
131: #5.1 NORMAL
132: print "=======================\nNW7: NORMAL\n";
133: $oGdBar = GD::Barcode->new('NW7', '12345678');
134: print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
135: open(OUT, '>NW7.png');
136: binmode OUT; #for Windows
137: print OUT $oGdBar->plot->png;
138: close OUT;
139: undef $oGdBar;
140:
141: #5.2 Error
142: print "NW7: ERROR\n";
143: $oGdBar = GD::Barcode->new('NW7', 'NW7ERROR');
144: print "ERROR:", $GD::Barcode::errStr, "\n";
145: undef $oGdBar;
146:
147: #6)CODE-39
148: #6.1 NORMAL
149: print "=======================\nCode39: NORMAL\n";
150: $oGdBar = GD::Barcode->new('Code39', '*123456789012*');
151: print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
152: open(OUT, '>Code39.png');
153: binmode OUT; #for Windows
154: print OUT $oGdBar->plot->png;
155: close OUT;
156: undef $oGdBar;
157:
158: #6.2 Error
159: print "Code39: ERROR\n";
160: $oGdBar = GD::Barcode->new('Code39', '*12345678901;*');
161: print "ERROR:", $GD::Barcode::errStr, "\n";
162: undef $oGdBar;
163:
164: #7)ITF(Interleaved 2 of 5)
165: #7.1 NORMAL
166: print "=======================\nITF: NORMAL\n";
167: $oGdBar = GD::Barcode->new('ITF', '0123456789');
168: print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
169: open(OUT, '>ITF.png');
170: binmode OUT; #for Windows
171: print OUT $oGdBar->plot->png;
172: close OUT;
173: undef $oGdBar;
174:
175: #7.2 Error
176: print "ITF: ERROR\n";
177: $oGdBar = GD::Barcode->new('ITF', '123456788A');
178: print "ERROR:", $GD::Barcode::errStr, "\n";
179: undef $oGdBar;
180:
181: #8)Industrial2of5
182: #8.1 NORMAL
183: print "=======================\nIndustrial2of5: NORMAL\n";
184: $oGdBar = GD::Barcode->new('Industrial2of5', '0123456789');
185: print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
186: open(OUT, '>Industrial2of5.png');
187: binmode OUT; #for Windows
188: print OUT $oGdBar->plot->png;
189: close OUT;
190: undef $oGdBar;
191:
192: #8.2 Error
193: print "Industrial2of5: ERROR\n";
194: $oGdBar = GD::Barcode->new('Industrial2of5', '123456788A');
195: print "ERROR:", $GD::Barcode::errStr, "\n";
196: undef $oGdBar;
197:
198: #9)IATA2of5
199: #9.1 NORMAL
200: print "=======================\nIATA2of5: NORMAL\n";
201: $oGdBar = GD::Barcode->new('IATA2of5', '0123456789');
202: print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
203: open(OUT, '>IATA2of5.png');
204: binmode OUT; #for Windows
205: print OUT $oGdBar->plot->png;
206: close OUT;
207: undef $oGdBar;
208:
209: #9.2 Error
210: print "IATA2of5: ERROR\n";
211: $oGdBar = GD::Barcode->new('IATA2of5', '123456788A');
212: print "ERROR:", $GD::Barcode::errStr, "\n";
213: undef $oGdBar;
214:
215: #10)Matrix2of5
216: #10.1 NORMAL
217: print "=======================\nMatrix2of5: NORMAL\n";
218: $oGdBar = GD::Barcode->new('Matrix2of5', '0123456789');
219: print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
220: open(OUT, '>Matrix2of5.png');
221: binmode OUT; #for Windows
222: print OUT $oGdBar->plot->png;
223: close OUT;
224: undef $oGdBar;
225:
226: #10.2 Error
227: print "Matrix2of5: ERROR\n";
228: $oGdBar = GD::Barcode->new('Matrix2of5', '123456788A');
229: print "ERROR:", $GD::Barcode::errStr, "\n";
230: undef $oGdBar;
231:
232: #11)COOP2of5
233: #11.1 NORMAL
234: print "=======================\nCOOP2of5: NORMAL\n";
235: $oGdBar = GD::Barcode->new('COOP2of5', '0123456789');
236: print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
237: open(OUT, '>COOP2of5.png');
238: binmode OUT; #for Windows
239: print OUT $oGdBar->plot->png;
240: close OUT;
241: undef $oGdBar;
242:
243: #11.2 Error
244: print "COOP2of5: ERROR\n";
245: $oGdBar = GD::Barcode->new('COOP2of5', '123456788A');
246: print "ERROR:", $GD::Barcode::errStr, "\n";
247: undef $oGdBar;
248: </pre>
249:
250: Example usage code #2 (from the GD-Barcode samples directory)
251: <pre>
252: use strict;
253: use GD::Barcode::EAN8;
254: use GD::Barcode::EAN13;
255: use GD::Barcode::UPCA;
256: use GD::Barcode::UPCE;
257: use GD::Barcode::NW7;
258: use GD::Barcode::Code39;
259: use GD::Barcode::ITF;
260: use GD::Barcode::Industrial2of5;
261: use GD::Barcode::Matrix2of5;
262: use GD::Barcode::IATA2of5;
263: use GD::Barcode::COOP2of5;
264:
265: my $oGdBar;
266: #1)EAN13
267: #1.1 NORMAL
268: print "=======================\nEAN13: NORMAL\n";
269: $oGdBar = GD::Barcode::EAN13->new('123456789012');
270: print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
271: open(OUT, '>EAN13.png');
272: binmode OUT; #for Windows
273: print OUT $oGdBar->plot->png;
274: close OUT;
275: undef $oGdBar;
276:
277: #1.2 Error
278: print "EAN13: ERROR\n";
279: $oGdBar = GD::Barcode::EAN13->new('12345678901');
280: print "ERROR:", $GD::Barcode::EAN13::errStr, "\n";
281: undef $oGdBar;
282:
283: #2)EAN8
284: #2.1 NORMAL
285: print "=======================\nEAN8: NORMAL\n";
286: $oGdBar = GD::Barcode::EAN8->new('1234567');
287: print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
288: open(OUT, '>EAN8.png');
289: binmode OUT; #for Windows
290: print OUT $oGdBar->plot->png;
291: close OUT;
292: undef $oGdBar;
293:
294: #2.2 Error
295: print "EAN8: ERROR\n";
296: $oGdBar = GD::Barcode::EAN8->new('A1234567');
297: print "ERROR:", $GD::Barcode::EAN8::errStr, "\n";
298: undef $oGdBar;
299:
300: #3)UPC-A
301: #3.1 NORMAL
302: print "=======================\nUPCA: NORMAL\n";
303: $oGdBar = GD::Barcode::UPCA->new('12345678901');
304: print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
305: open(OUT, '>UPCA.png');
306: binmode OUT; #for Windows
307: print OUT $oGdBar->plot->png;
308: close OUT;
309: undef $oGdBar;
310:
311: #3.2 Error
312: print "UPCA: ERROR\n";
313: $oGdBar = GD::Barcode::UPCA->new('12345678901132');
314: print "ERROR:", $GD::Barcode::UPCA::errStr, "\n";
315: undef $oGdBar;
316:
317: #4)UPC-E
318: #4.1 NORMAL
319: print "=======================\nUPCE: NORMAL\n";
320: $oGdBar = GD::Barcode::UPCE->new('1234567');
321: print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
322: open(OUT, '>UPCE.png');
323: binmode OUT; #for Windows
324: print OUT $oGdBar->plot->png;
325: close OUT;
326: undef $oGdBar;
327:
328: #4.2 Error
329: print "UPCE: ERROR\n";
330: $oGdBar = GD::Barcode::UPCE->new('123456788');
331: print "ERROR:", $GD::Barcode::UPCE::errStr, "\n";
332: undef $oGdBar;
333:
334: #5)NW7
335: #5.1 NORMAL
336: print "=======================\nNW7: NORMAL\n";
337: $oGdBar = GD::Barcode::NW7->new('12345678');
338: print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
339: open(OUT, '>NW7.png');
340: binmode OUT; #for Windows
341: print OUT $oGdBar->plot->png;
342: close OUT;
343: undef $oGdBar;
344:
345: #5.2 Error
346: print "NW7: ERROR\n";
347: $oGdBar = GD::Barcode::NW7->new('NW7ERROR');
348: print "ERROR:", $GD::Barcode::NW7::errStr, "\n";
349: undef $oGdBar;
350:
351: #6)CODE-39
352: #6.1 NORMAL
353: print "=======================\nCode39: NORMAL\n";
354: $oGdBar = GD::Barcode::Code39->new('*123456789012*');
355: print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
356: open(OUT, '>Code39.png');
357: binmode OUT; #for Windows
358: print OUT $oGdBar->plot->png;
359: close OUT;
360: undef $oGdBar;
361:
362: #6.2 Error
363: print "Code39: ERROR\n";
364: $oGdBar = GD::Barcode::Code39->new('*12345678901;*');
365: print "ERROR:", $GD::Barcode::Code39::errStr, "\n";
366: undef $oGdBar;
367:
368: #7)ITF
369: #7.1 NORMAL
370: print "=======================\nITF: NORMAL\n";
371: $oGdBar = GD::Barcode::Code39->new('1234567890*');
372: print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
373: open(OUT, '>ITF.png');
374: binmode OUT; #for Windows
375: print OUT $oGdBar->plot->png;
376: close OUT;
377: undef $oGdBar;
378:
379: #7.2 Error
380: print "ITF: ERROR\n";
381: $oGdBar = GD::Barcode::ITF->new('*1234567');
382: print "ERROR:", $GD::Barcode::ITF::errStr, "\n";
383: undef $oGdBar;
384:
385: #8. Industrial2of5
386: #8.1 NORMAL
387: print "=======================\nIndustrial2of5: NORMAL\n";
388: $oGdBar = GD::Barcode::Industrial2of5->new('0123456789');
389: print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
390: open(OUT, '>Industrial2of5.png');
391: binmode OUT; #for Windows
392: print OUT $oGdBar->plot->png;
393: close OUT;
394: undef $oGdBar;
395:
396: #8.2 Error
397: print "Industrial2of5: ERROR\n";
398: $oGdBar = GD::Barcode::Industrial2of5->new('A12345678901');
399: print "ERROR:", $GD::Barcode::Industrial2of5::errStr, "\n";
400: undef $oGdBar;
401:
402: #9. IATA2of5
403: #9.1 NORMAL
404: print "=======================\nIATA2of5: NORMAL\n";
405: $oGdBar = GD::Barcode::IATA2of5->new('0123456789');
406: print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
407: open(OUT, '>IATA2of5.png');
408: binmode OUT; #for Windows
409: print OUT $oGdBar->plot->png;
410: close OUT;
411: undef $oGdBar;
412:
413: #10.2 Error
414: print "IATA2of5: ERROR\n";
415: $oGdBar = GD::Barcode::IATA2of5->new('A12345678901');
416: print "ERROR:", $GD::Barcode::IATA2of5::errStr, "\n";
417: undef $oGdBar;
418:
419: #10. Matrix2of5
420: #10.1 NORMAL
421: print "=======================\nMatrix2of5: NORMAL\n";
422: $oGdBar = GD::Barcode::Matrix2of5->new('0123456789');
423: print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
424: open(OUT, '>Matrix2of5.png');
425: binmode OUT; #for Windows
426: print OUT $oGdBar->plot->png;
427: close OUT;
428: undef $oGdBar;
429:
430: #10.2 Error
431: print "Matrix2of5: ERROR\n";
432: $oGdBar = GD::Barcode::Matrix2of5->new('A12345678901');
433: print "ERROR:", $GD::Barcode::Matrix2of5::errStr, "\n";
434: undef $oGdBar;
435:
436: #11. COOP2of5
437: #11.1 NORMAL
438: print "=======================\nCOOP2of5: NORMAL\n";
439: $oGdBar = GD::Barcode::COOP2of5->new('0123456789');
440: print "PTN:", $oGdBar->{text}, ":" ,$oGdBar->barcode, "\n";
441: open(OUT, '>COOP2of5.png');
442: binmode OUT; #for Windows
443: print OUT $oGdBar->plot->png;
444: close OUT;
445: undef $oGdBar;
446:
447: #11.2 Error
448: print "COOP2of5: ERROR\n";
449: $oGdBar = GD::Barcode::COOP2of5->new('A12345678901');
450: print "ERROR:", $GD::Barcode::COOP2of5::errStr, "\n";
451: undef $oGdBar;
452: </pre>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>