Added missing initial NULL values for marc_subfield_structure.defaultvalue.
[koha.git] / misc / barcodes.pl
1 #!/usr/bin/perl
2
3
4
5 ####################
6 # Variable Section #
7 ####################
8
9 # Copyright 2000-2002 Katipo Communications
10 #
11 # This file is part of Koha.
12 #
13 # Koha is free software; you can redistribute it and/or modify it under the
14 # terms of the GNU General Public License as published by the Free Software
15 # Foundation; either version 2 of the License, or (at your option) any later
16 # version.
17 #
18 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
19 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
20 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License along with
23 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
24 # Suite 330, Boston, MA  02111-1307 USA
25
26 my $pretext='T ';
27 my $startnumber=1000;
28 my $pages=2;
29 my $libraryname='Copper Mountain Elementary';
30
31 # Shifts are given in millimeters. Positive numbers move up and to the right.
32 # These variables shift the whole page to account for printer differences.
33 my $shiftx=0;
34 my $shifty=0;
35
36 ####################
37
38
39
40 my $leftmargin=5;
41 my $rightmargin=3;
42 my $topmargin=18;
43 my $botmargin=10;
44
45
46 my $rightside=215;
47 my $topside=280;
48
49
50 my $barcodewidth=length("$pretext$startnumber")+2;
51
52 my $bcwidthfactor=8-$barcodewidth/2;
53 print STDERR "$barcodewidth $bcwidthfactor\n";
54
55 my $width=$rightside-($leftmargin+$rightmargin);
56 my $height=$topside-$topmargin-$botmargin;
57
58 print << "EOF";
59 %!PS-Adobe-2.0
60 %%Title: barcode.ps
61 %%Creator: Willem van Schaik
62 %%CreationDate: aug 1992
63 %%Pages: 1
64 %%DocumentFonts: Helvetica Code39
65 %%BoundingBox: 0 0 595 842
66 %%EndComments
67
68 /newfont 10 dict def
69 newfont begin
70 /FontType 3 def
71 /FontMatrix [0.01 0 0 0.01 0 0] def
72 /FontBBox [0 0 100 100] def
73
74 /Encoding 256 array def
75 0 1 255 {Encoding exch /.notdef put} for
76 Encoding 32 /barSpace put
77 Encoding 36 /barDollar put
78 Encoding 37 /barPercent put
79 Encoding 42 /barAsterisk put
80 Encoding 43 /barPlus put
81 Encoding 45 /barHyphen put
82 Encoding 46 /barPeriod put
83 Encoding 47 /barSlash put
84 Encoding 48 /bar0 put
85 Encoding 49 /bar1 put
86 Encoding 50 /bar2 put
87 Encoding 51 /bar3 put
88 Encoding 52 /bar4 put
89 Encoding 53 /bar5 put
90 Encoding 54 /bar6 put
91 Encoding 55 /bar7 put
92 Encoding 56 /bar8 put
93 Encoding 57 /bar9 put
94 Encoding 65 /barA put
95 Encoding 66 /barB put
96 Encoding 67 /barC put
97 Encoding 68 /barD put
98 Encoding 69 /barE put
99 Encoding 70 /barF put
100 Encoding 71 /barG put
101 Encoding 72 /barH put
102 Encoding 73 /barI put
103 Encoding 74 /barJ put
104 Encoding 75 /barK put
105 Encoding 76 /barL put
106 Encoding 77 /barM put
107 Encoding 78 /barN put
108 Encoding 79 /barO put
109 Encoding 80 /barP put
110 Encoding 81 /barQ put
111 Encoding 82 /barR put
112 Encoding 83 /barS put
113 Encoding 84 /barT put
114 Encoding 85 /barU put
115 Encoding 86 /barV put
116 Encoding 87 /barW put
117 Encoding 88 /barX put
118 Encoding 89 /barY put
119 Encoding 90 /barZ put
120
121 /CharProcs 45 dict def
122 CharProcs begin
123 /.notdef {} def
124 /barSpace {0 7 17 17 7 7 7 17 7 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
125 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
126 /barDollar {0 7 17 7 17 7 17 7 7 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
127 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
128 /barPercent {0 7 7 7 17 7 17 7 17 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
129 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
130 /barAsterisk {0 7 17 7 7 17 7 17 7 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
131 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
132 /barPlus {0 7 17 7 7 7 17 7 17 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
133 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
134 /barHyphen {0 7 17 7 7 7 7 17 7 17 newpath 93 0 moveto 5 {dup 0 100 rlineto
135 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
136 /barPeriod {0 17 17 7 7 7 7 17 7 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
137 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
138 /barSlash {0 7 17 7 17 7 7 7 17 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
139 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
140 /bar0 {0 7 7 7 17 17 7 17 7 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
141 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
142 /bar1 {0 17 7 7 17 7 7 7 7 17 newpath 93 0 moveto 5 {dup 0 100 rlineto
143 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
144 /bar2 {0 7 7 17 17 7 7 7 7 17 newpath 93 0 moveto 5 {dup 0 100 rlineto
145 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
146 /bar3 {0 17 7 17 17 7 7 7 7 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
147 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
148 /bar4 {0 7 7 7 17 17 7 7 7 17 newpath 93 0 moveto 5 {dup 0 100 rlineto
149 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
150 /bar5 {0 17 7 7 17 17 7 7 7 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
151 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
152 /bar6 {0 7 7 17 17 17 7 7 7 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
153 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
154 /bar7 {0 7 7 7 17 7 7 17 7 17 newpath 93 0 moveto 5 {dup 0 100 rlineto
155 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
156 /bar8 {0 17 7 7 17 7 7 17 7 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
157 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
158 /bar9 {0 7 7 17 17 7 7 17 7 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
159 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
160 /barA {0 17 7 7 7 7 17 7 7 17 newpath 93 0 moveto 5 {dup 0 100 rlineto
161 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
162 /barB {0 7 7 17 7 7 17 7 7 17 newpath 93 0 moveto 5 {dup 0 100 rlineto
163 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
164 /barC {0 17 7 17 7 7 17 7 7 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
165 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
166 /barD {0 7 7 7 7 17 17 7 7 17 newpath 93 0 moveto 5 {dup 0 100 rlineto
167 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
168 /barE {0 17 7 7 7 17 17 7 7 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
169 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
170 /barF {0 7 7 17 7 17 17 7 7 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
171 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
172 /barG {0 7 7 7 7 7 17 17 7 17 newpath 93 0 moveto 5 {dup 0 100 rlineto
173 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
174 /barH {0 17 7 7 7 7 17 17 7 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
175 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
176 /barI {0 7 7 17 7 7 17 17 7 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
177 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
178 /barJ {0 7 7 7 7 17 17 17 7 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
179 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
180 /barK {0 17 7 7 7 7 7 7 17 17 newpath 93 0 moveto 5 {dup 0 100 rlineto
181 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
182 /barL {0 7 7 17 7 7 7 7 17 17 newpath 93 0 moveto 5 {dup 0 100 rlineto
183 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
184 /barM {0 17 7 17 7 7 7 7 17 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
185 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
186 /barN {0 7 7 7 7 17 7 7 17 17 newpath 93 0 moveto 5 {dup 0 100 rlineto
187 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
188 /barO {0 17 7 7 7 17 7 7 17 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
189 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
190 /barP {0 7 7 17 7 17 7 7 17 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
191 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
192 /barQ {0 7 7 7 7 7 7 17 17 17 newpath 93 0 moveto 5 {dup 0 100 rlineto
193 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
194 /barR {0 17 7 7 7 7 7 17 17 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
195 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
196 /barS {0 7 7 17 7 7 7 17 17 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
197 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
198 /barT {0 7 7 7 7 17 7 17 17 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
199 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
200 /barU {0 17 17 7 7 7 7 7 7 17 newpath 93 0 moveto 5 {dup 0 100 rlineto
201 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
202 /barV {0 7 17 17 7 7 7 7 7 17 newpath 93 0 moveto 5 {dup 0 100 rlineto
203 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
204 /barW {0 17 17 17 7 7 7 7 7 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
205 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
206 /barX {0 7 17 7 7 17 7 7 7 17 newpath 93 0 moveto 5 {dup 0 100 rlineto
207 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
208 /barY {0 17 17 7 7 17 7 7 7 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
209 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
210 /barZ {0 7 17 17 7 17 7 7 7 7 newpath 93 0 moveto 5 {dup 0 100 rlineto
211 neg 0 rlineto 0 -100 rlineto closepath add neg 0 rmoveto} repeat fill} def
212 end
213
214 /BuildChar
215 { 100 0 0 0 93 100 setcachedevice
216   exch
217   begin
218     Encoding exch get
219     CharProcs exch get
220     end
221   exec
222 } def
223 end
224
225 /Code39 newfont definefont pop
226
227 %%EndProlog
228
229 EOF
230
231 my $number=$startnumber;
232 while ($page<$pages) {
233     my $data='';
234     for ($i=$leftmargin; $i<$rightside-$rightmargin; $i+=$width/4) {
235         for ($j=$botmargin; $j<$topside-$topmargin-$botmargin; $j+=$height/20) {
236             my $x=$i+$width/8;
237             my $y=$j+$height/40;
238             my $schooly=$y+5.8;
239             my $labely=$y-2.2;
240             my $lox=$x-2;
241             my $hix=$x+2;
242             my $loy=$y-2;
243             my $hiy=$y+2;
244             $data.=<<"EOF";
245 $x $y moveto
246 /Code39 findfont [$bcwidthfactor 0 0 5 0 0] makefont setfont
247 (*$pretext$number*) dup stringwidth pop 2 div neg 0 rmoveto show
248 /Helvetica findfont 1.7 scalefont setfont
249 $x $schooly moveto
250 ($schoolname) dup stringwidth pop 2 div neg 0 rmoveto show
251 /Helvetica findfont 2.3 scalefont setfont
252 $x $labely moveto
253 ($pretext$number) dup stringwidth pop 2 div neg 0 rmoveto show
254
255
256 EOF
257             $number++;
258         }
259     }
260
261
262     $page++;
263     print << "EOF";
264 %%Page: $page $page
265 %%PagerFonts:
266
267 $shiftx $shifty translate
268 72 25.4 div dup scale
269
270 /Code39 findfont [4 0 0 5 0 0] makefont setfont
271 /Times-Roman findfont
272 1 scalefont
273 setfont
274 $data
275
276
277
278
279
280 showpage
281
282
283 EOF
284 }
285 print "%%Trailer\n";