Debian Codegraph @

texmf-dist/doc/latex/barcodes/eandoc.tex

raw
1 %%
2 %% This is file `eandoc.tex',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% barcodes.dtx (with options: `eandoc')
8 %% As this is a generated file, you may perhaps not want to edit it.
9 %% This file belongs to the barcode package.
10 %% It may be of no great use without the rest of the barcode package.
11 %% \CharacterTable
12 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
13 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
14 %% Digits \0\1\2\3\4\5\6\7\8\9
15 %% Exclamation \! Double quote \" Hash (number) \#
16 %% Dollar \$ Percent \% Ampersand \&
17 %% Acute accent \' Left paren \( Right paren \)
18 %% Asterisk \* Plus \+ Comma \,
19 %% Minus \- Point \. Solidus \/
20 %% Colon \: Semicolon \; Less than \<
21 %% Equals \= Greater than \> Question mark \?
22 %% Commercial at \@ Left bracket \[ Backslash \\
23 %% Right bracket \] Circumflex \^ Underscore \_
24 %% Grave accent \` Left brace \{ Vertical bar \|
25 %% Right brace \} Tilde \~}
26 %%
27 \documentclass{article}
28 \begin{document}
29 \author{Peter Willadt}
30 \title{EAN Barcodes by \TeX{} an Metafont}
31 \date{1998-01-24}
32 \maketitle
33 \begin{abstract}
34 This article documents the use of the font {\tt wlean.mf}. With the font,
35 there also comes an auxiliary Perl file for preprocessing TeX source.
36 Its use is also documented here.
37 \end{abstract}
38
39 \section{Legal Restrictions and Introduction}
40
41 All the files in this package are subject to the \LaTeX\ Project Public
42 License. Also I got a special wish: If you find this package useful,
43 support TUG or your local \TeX\ user group.
44
45 The complete contents of this package is
46 described in the file {\tt README}. That file also contains some
47 information about the use of the other barcode fonts that are
48 contained. For more information about these other files you may want
49 to read an article that has appeared in the december, 1997 issue of
50 {\em TUGboat}. Please see also the remarks in the section {\em
51 Address} later in this file.
52
53 \section{About {\sc ean}}
54
55 In stores, {\sc upc} and {\sc ean} codes are widely used for automatic
56 identification, pricing etc. {\sc ean} consist of either eight or
57 thirteen digits. Twelve digit {\sc upc} codes are like thirteen digit
58 {\sc ean} with the first digit equal to zero. {\sc ean} specifications
59 do not only
60 require bars, also the encoded number has to be written in plain text,
61 in case a reader is defective or the code is too hard to read. {\sc
62 ean} is a high-density code, and so it is highly vulnerable.
63
64 \subsection{Coding}
65
66 The last digit of an {\sc ean} is a weighted mod 10 checksum. Digits
67 are alternatingly multiplied by 1 or 3. The so calculated sum over all
68 digits has to be divisible by ten without any remainder.
69
70 There are three different {\sc ean} character sets labeled A, B, and
71 C. Eight digit {\sc ean} codes use character sets A and C, {\sc ean}
72 codes with thirteen digits use all three character sets---see below.
73
74 \begin{verse}
75 {\sc ean} with eight digits consists of:\\
76 a sidebar\\
77 the first four digits (coded in character set A),\\
78 the middle separator,\\
79 the other four digits (coded in character set C)\\
80 another sidebar.
81 \end{verse}
82
83 The first half of an {\sc ean} code with thirteen digits is coded in
84 the character sets A and B, the second half in character set C. The
85 coding of the very first digit is hidden in the varying use of the
86 character sets A and B. A C programmer might use the following table
87 and algorithm to decide which character set to use for digits 2--7:
88
89 \begin{verbatim}
90 static UBYTE abtab[10][6]={
91 {0,0,0,0,0,0}, /* 0 */
92 {0,0,1,0,1,1}, /* 1 */
93 {0,0,1,1,0,1}, /* 2 */
94 {0,0,1,1,1,0}, /* 3 */
95 {0,1,0,0,1,1}, /* 4 */
96 {0,1,1,0,0,1}, /* 5 */
97 {0,1,1,1,0,0}, /* 6 */
98 {0,1,0,1,0,1}, /* 7 */
99 {0,1,0,1,1,0}, /* 8 */
100 {0,1,1,0,1,0} /* 9 */
101 };
102
103 char eancode[18];
104 char eansource[14]="4025700001030";
105
106 eancode[0]=eansource[0];
107 eancode[1]=' ';
108 eancode[2]='+';
109 for(i=1;i<7;i++)
110 eancode[i+2]='A'+eansource[i]-'0'
111 +abtab[eansource[0]-'0'][i-1]*('a'-'A');
112 /* then the middle separator, digits 7--13,
113 * and the final + sign */
114 \end{verbatim}
115
116 A zero means to use character set A and a one means to use character
117 set B for the respective digit. The printed code of an {\sc ean} 13
118 consist of the following elements, from left to right:
119
120 \begin{verse}
121 The first digit in human-readable form\\
122 an {\sc ean} sidebar\\
123 six digits in character sets A or B\\
124 the {\sc ean} middle separator\\
125 six digits in character set C\\
126 another {\sc ean} sidebar
127 \end{verse}
128
129 Magazines or codes with pricing have a so called extension following
130 the main code with some fixed distance. This extension consists of one
131 sidebar and two or five digits. As I have no full {\sc ean}
132 documentation at hand at the time of this writing, I am sorry that I
133 am not able to tell you more about this.
134
135 The {\sc ean} digits themselves obey to the following rules: Each
136 digit takes seven units of space. Some of the seven elements are
137 white, others are black. Digits from character set A always are white
138 at the left edge and black at the right, and they always have an odd numer
139 of black elements. Digits from character set B are quit similiar, but
140 they have an even number of black elements. Digits from Character set C
141 always start with a black element and have an even number of
142 black elements. The rightmost element in character set C is always white.
143 The sidebars are three elements wide, the middle separator takes five
144 elements.
145
146 \subsection{What {\sc ean} numbers may I use?}
147
148 For inhouse use, you may use any 13-digit {\sc ean} that starts with a
149 2. If you want to have your products sold elsewhere, you have to buy a
150 set of {\sc ean} numbers from the organisation in your country that
151 holds these numbers. For germany, this organisation is the {\em
152 Zentrale f\"ur Coorganisation} in Cologne. Almost any country has a
153 similiar organisation.
154
155 The first digit or sometimes the first two digits code the country of
156 origin, the next five to six digits code the manufacturer, the eigth
157 to twelfth digits are for free use by the manufacturer. The
158 thirteenth digit is, as explained above, a checksum. {\sc ean} do not
159 contain any qualifiers, so if you get an {\sc ean} from somewhere, you
160 may find out about the country of origin and about the manufacturer of
161 the product, but if you want to know more, you have to contact the
162 manufacturer.
163
164 \section{Using {\tt wlean.mf}}
165
166 {\tt wlean.mf} is rather raw. It contains all three {\sc ean}
167 character sets within one single font, but at different places.
168 The character sets A, B, C, and the digits are
169 featured through the following characters:
170
171 \begin{verse}
172 0 to 9 yield the digits from 0 to 9\\
173 A to J yield the codes from character set A\\
174 a to j yield the codes from character set B\\
175 K to T yield the codes from character set C\\
176 + makes the left and right sidebar and\\
177 - makes the middle sign
178 \end{verse}
179
180 So, to code the number {\tt 2099993098253}, you have to write\\
181 \verb*|{\eanfont2 +AJjjJd-KTSMPN+}|. The space is necessary to separate
182 the leading 2 from the barcode.
183
184 {\tt wlean.mf} does not use true {\sc ocr} digits, as it should. As
185 the digits will not be used for {\sc ocr}, I do not consider this as
186 a serious restriction. If you really need {\sc ocr} digits, there is
187 an {\sc ocr} font on {\sc ctan}. And in {\em TUGboat}, there has been
188 a publication about {\sc ean}, where \TeX{} draws the bars and
189 the {\sc ocr} font prints the digits, see [1].
190
191 {\tt wlean.mf} uses the normal {\sc ean} dimensions. If you would like
192 lower bars---in contradiction to the {\sc ean} rules---you have to edit
193 the source. The rules also make recommendations about the scaling. To
194 be fully compatible, this font may be scaled 0.8, 0.9, 1, 1.2, 1.4,
195 1.5, 1.7, 1.85, or 2 times the original size. With a 300 dpi printer,
196 I do not recommend using sizes$<1.0$.
197
198 \subsection{Installation}
199
200 The installation itself is pretty mundane, like with any plain font.
201 Just copy {\tt wlean.mf} to a location where Metafont can find
202 it. Then invoke Metafont to create a {\sc tfm} file. Move this {\sc
203 tfm} file where \TeX{} can find it. Type in the example at the end of
204 this file and run it through \TeX{}. Then call Metafont again to
205 produce a font suitable for your printer or previewer and move this
206 font to an appropriate location. You may also want to edit {\tt
207 codean.pl} to run on your shell. For this purpose you have to read
208 your system's documentation or the documentation that comes with Perl.
209
210 \subsection{Making readable output}
211
212 Don't make {\sc ean} too small. With a 300 dpi printer, you should not
213 use this font with magnification$<1$; {\tt scaled 1200} will be okay.
214 If you want to do mass production, go to somebody with a barcode
215 reader and check your output, {\em before} you loose money. You also
216 should consider changes in the blackness that may be caused by
217 production printing devices. And, of course, you should only use
218 colours that can be used with barcode reading devices. Especially, do
219 not use red and watch for much contrast between the colour you print
220 and the colour of the paper.
221
222 \subsection{Coding the numbers}
223
224 You will perhaps not want to write something as ugly and error-prone
225 as \verb*|{\eanfont2 +AJjjJd-KTSMPN+}| manually. So you have to use a
226 preprocessor\footnote{See bcfaq.tex for \TeX{} code to go without
227 preprocessing. It is very fine.}. With {\tt wlean.mf} there comes a
228 tiny Perl program ({\tt codean.pl}) that does preprocessing within
229 your \TeX{} sources\footnote{codean.pl in the meantime also handles
230 code 128. See bcfaq.tex}.
231
232 The \TeX{} file to be filtered may contain any number of lines
233 that have one of the following commands starting at the leftmost position.
234
235 \begin{itemize}
236 \item \verb|\ean{|{\em12 or 13 digit number}\verb|}|
237 The number will be coded as {\sc ean}. If it is only 12 digits long, the
238 checksum will be calculated, too.
239
240 \item \verb|\embed{|{\em12 or 13 digit number}\verb|}|
241 The number is used as a base for embedding article numbers \&c.\
242 within an {\sc ean}.
243
244 \item \verb|\eean{|{\em number with at most 11 digits}\verb|}|
245 This number is to be embedded within an {\sc ean}.
246
247 \item \verb|\isbn{|{\em valid ISBN}\verb|}| An {\sc isbn} to
248 make an embedded {\sc ean} of.
249 \end{itemize}
250
251 Let's look at an example: You want the {\sc isbn} {\tt0-201-13448-9}
252 to be embedded. So you write \verb|\isbn{0201134489}|, but you might
253 also use the embedding method and write
254 \verb|\embed{9780000000000}| and, somewhere later in the file,
255 \verb|\eean{020113448}|. In this latter case you have to omit the last digit,
256 as {\sc isbn} loose their check digit in favour of the {\sc ean} check digit.
257 Anyway you do it, you get your command replaced by
258 \verb|\EAN{|{\em13-digit-number-coded-strange}\verb|}| in the output
259 file.
260
261 But embedding is especially useful if you also write the program that
262 reads the barcodes. This program might then extract your article
263 number from an {\sc ean} starting with {\tt20}, eg.
264
265 What you have to do is, of course, to use stub definitions for the
266 three macros mentioned above---as they shall never actually be
267 typeset---and to use a valid definition for \verb|\EAN|. Then you run
268 your \TeX{} source through {\tt codean.pl}. This program takes as
269 first parameter the name of your original file and as second parameter
270 the name of your destination file. If you omit the parameters, you will
271 be asked for them.
272
273 You may of course also peek the source of {\tt codean.pl} to see how
274 {\sc ean} checksums are calculated, and so on.
275
276 \subsection{Example}
277
278 Here is a full example.
279 Use this \TeX{} source:
280
281 \begin{verbatim}
282 \font\eanfont=WLEAN
283 \def\ean#1{\message{Call codean.pl}}
284 \def\eean#1{\message{Call codean.pl}}
285 \def\isbn#1{\message{Call codean.pl}}
286 \def\embed#1{}
287 \def\EAN#1{\vbox{\vskip10pt\eanfont#1\vskip10pt}}
288 Now, something to do:
289 \ean{4025700001030} % or, without checksum:
290 \ean{402570000103}
291 \embed{2500000000000}
292 \eean{123}
293 \isbn{0201134489}
294 \end{verbatim}
295
296 Having run your file through {\tt codean.pl}, the lines after the percent
297 sign look like this:
298
299 \begin{verbatim}
300 Now, something to do:
301 \EAN{4 +AcFHaa-KKLKNK+} % or, without checksum: %(4025700001030)
302 \EAN{4 +AcFHaa-KKLKNK+} %(402570000103)
303 \embed{2500000000000}
304 \EAN{2 +FAaaAa-KKLMNT+} % embedded(123)
305 \EAN{9 +HiaCaB-LNOOSN+} % ISBN(0201134489)
306 \end{verbatim}
307
308 Running this file through \TeX{}, you get {\sc dvi} output containig
309 {\sc ean} barcodes. Perhaps you wonder why there is not even a
310 single {\sc ean} contained within this documentation. The reason is
311 quite simple: You should be able to read the docs {\em before} you
312 have installed the font. But now is the right time to try the example
313 on your own. Better yet, you may code an {\sc ean} where you have
314 taken the number from something like your favourite candy and then,
315 having printed it, you may compare the bars. This is a nice way to
316 spend your evenings. I actually started deciphering {\sc ean} codes in
317 this way, several years ago.
318
319 \section{The End}
320
321 \subsection{Address}
322
323 Just in case you want to write to me, here is my address---but
324 please note: I am not the {\sc ean} guru.
325
326 \begin{verbatim}
327 Peter Willadt
328 75177 Pforzheim
329 Germany
330 email: [email protected]
331 \end{verbatim}
332
333 I also would appreciate if only one version of the material contained
334 in this package is distributed. So if you have any corrections,
335 suggestions, \&c., please do not hesitate to send them to me to
336 incorporate them within this package.
337
338 \subsection{Acknowledgement}
339
340 I want to express my special thanks to Barbara Beeton for proofreading
341 and making valuable suggestions. If there are still any typos or
342 illegibilities, that is due to the fact that I had to change some
343 things later on.
344
345 \begin{thebibliography}{1}
346
347 \bibitem{bc:ean}
348 Peter Ol{\v{s}}ak.
349 \newblock The {\sc ean} barcodes by {\TeX}.
350 \newblock {\em TUGboat}, 15(4):459--464, 1994.
351
352 \end{thebibliography}
353
354 \end{document}
355 \endinput
356 %%
357 %% End of file `eandoc.tex'.