Debian Codegraph @

texmf-dist/dvips/pst-barcode/pst-barcode.pro

raw
1 %!PS
2
3 %% $Id: pst-barcode.pro 1253 2026-05-18 05:37:49Z herbert $
4 % Barcode Writer in Pure PostScript - Version 2026-05-18
5 % https://bwipp.terryburton.co.uk
6 %
7 % Copyright (c) 2004-2026 Terry Burton
8 %
9 % Permission is hereby granted, free of charge, to any
10 % person obtaining a copy of this software and associated
11 % documentation files (the "Software"), to deal in the
12 % Software without restriction, including without
13 % limitation the rights to use, copy, modify, merge,
14 % publish, distribute, sublicense, and/or sell copies of
15 % the Software, and to permit persons to whom the Software
16 % is furnished to do so, subject to the following
17 % conditions:
18 %
19 % The above copyright notice and this permission notice
20 % shall be included in all copies or substantial portions
21 % of the Software.
22 %
23 % THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
24 % KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
25 % THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
26 % PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 % THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
28 % DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
29 % CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 % CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
31 % IN THE SOFTWARE.
32
33 % --BEGIN TEMPLATE--
34
35 % --BEGIN RESOURCE preamble--
36 %%BeginResource: Category uk.co.terryburton.bwipp 0.0 2025111800 29733 32838
37 %%BeginData: 6 ASCII Lines
38 currentglobal
39 true setglobal
40 /Generic /Category findresource dup length 1 add dict copy dup
41 /InstanceType /setpacking where {pop /packedarraytype} {/arraytype} ifelse put
42 /uk.co.terryburton.bwipp exch /Category defineresource pop
43 setglobal
44 %%EndData
45 %%EndResource
46 % --END RESOURCE preamble--
47
48 % --BEGIN RESOURCE loadctx--
49 % --REQUIRES preamble--
50 %%BeginResource: uk.co.terryburton.bwipp loadctx 0.0 2025111800 41297 40927
51 %%BeginData: 30 ASCII Lines
52 /setpacking where {pop currentpacking true setpacking} if
53 1 dict
54 begin
55 /loadctx {
56 % Place a context dictionary just below the current dictionary, which can
57 % be populated with static data on the first run and then carried between
58 % invocations of the encoder
59 /ctxname exch def
60 /uk.co.terryburton.bwipp.global_ctx dup where {exch get /ctx exch def} {pop} ifelse
61 ctx null ne {
62 1 { % Common exit
63 ctx ctxname known {
64 ctx ctxname get /_FINALIZED known {
65 /ctxdef {pop} def % No need to redefine within the existing context
66 exit
67 } if
68 } if
69 ctx ctxname 10 dict put
70 /ctxdef {ctx ctxname get begin exec end} def
71 } repeat
72 currentdict ctx ctxname get end begin begin
73 } {
74 /ctxdef {exec} def % No context provided, so define ephemerally
75 } ifelse
76 }
77 [/barcode] {null def} forall
78 bind def
79 /loadctx dup load /uk.co.terryburton.bwipp defineresource pop
80 end
81 /setpacking where {pop setpacking} if
82 %%EndData
83 %%EndResource
84 % --END RESOURCE loadctx--
85
86 % --BEGIN RESOURCE unloadctx--
87 % --REQUIRES preamble--
88 %%BeginResource: uk.co.terryburton.bwipp unloadctx 0.0 2025111800 38938 38741
89 %%BeginData: 14 ASCII Lines
90 /setpacking where {pop currentpacking true setpacking} if
91 1 dict
92 begin
93 /unloadctx {
94 % Finalize and remove the context, which is expected to be just underneath currentdict
95 ctx null ne {
96 currentdict end /_FINALIZED true def end begin
97 } if
98 }
99 [/barcode] {null def} forall
100 bind def
101 /unloadctx dup load /uk.co.terryburton.bwipp defineresource pop
102 end
103 /setpacking where {pop setpacking} if
104 %%EndData
105 %%EndResource
106 % --END RESOURCE unloadctx--
107
108 % --BEGIN RESOURCE raiseerror--
109 % --REQUIRES preamble--
110 %%BeginResource: uk.co.terryburton.bwipp raiseerror 0.0 2025111800 39029 38860
111 %%BeginData: 17 ASCII Lines
112 /setpacking where {pop currentpacking true setpacking} if
113 10 dict
114 begin
115 /raiseerror {
116 % $error exch /errorinfo exch put
117 % $error exch /errorname exch put
118 % $error /command null put
119 % $error /newerror true put
120 (error)
121 (%stderr)(w)file (string) writestring %%%%% hv
122 % stop
123 }
124 [/barcode] {null def} forall
125 bind def
126 /raiseerror dup load /uk.co.terryburton.bwipp defineresource pop
127 end
128 /setpacking where {pop setpacking} if
129 %%EndData
130 %%EndResource
131 % --END RESOURCE raiseerror--
132
133 % --BEGIN RESOURCE processoptions--
134 % --REQUIRES preamble raiseerror--
135 %%BeginResource: uk.co.terryburton.bwipp processoptions 0.0 2025111800 48428 48479
136 %%BeginData: 50 ASCII Lines
137 /setpacking where {pop currentpacking true setpacking} if
138 10 dict
139 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
140 begin
141 /processoptions {
142
143 % Convert string to dict
144 dup type /stringtype eq {
145 << exch
146 {
147 dup () eq {pop exit} if
148 ( ) search not { () exch null exch } if exch pop
149 (=) search not { true exch null exch } if exch pop % k => k = true
150 exch 3 -1 roll
151 } loop
152 >>
153 } if
154
155 % Apply options that exist in currentdict, converting values to existing types
156 mark exch dup
157 {
158 exch dup currentdict exch known {
159 dup load type 3 -1 roll exch <<
160 /booleantype { false or } % Force a type error if not boolean value
161 /stringtype { dup length string cvs } % Conversion to string to force a boolean to fail
162 /nametype 1 index % Conversion original nametype to string is fine
163 /realtype { dup cvr exch pop }
164 /nulltype 1 index % We define "null" as the sentinal value of a realtype
165 /integertype { dup cvr dup cvi ne {dup not} if cvi } % Force type error when precision is lost or boolean is given
166 >> exch get stopped {
167 pop pop
168 dup length string cvs dup length 24 add string
169 dup 0 (Invalid type for option ) putinterval
170 dup 24 4 -1 roll putinterval
171 counttomark {exch pop} repeat
172 /bwipp.invalidOptionType exch //raiseerror exec
173 } if
174 def
175 } {
176 pop pop % Ignore unknown options
177 } ifelse
178 } forall
179 exch pop
180
181 }
182 [/barcode] {null def} forall
183 bind def
184 /processoptions dup load /uk.co.terryburton.bwipp defineresource pop
185 end
186 /setpacking where {pop setpacking} if
187 %%EndData
188 %%EndResource
189 % --END RESOURCE processoptions--
190
191 % --BEGIN RESOURCE parseinput--
192 % --REQUIRES preamble loadctx unloadctx raiseerror--
193 %%BeginResource: uk.co.terryburton.bwipp parseinput 0.0 2025111800 73998 69831
194 %%BeginData: 178 ASCII Lines
195 /setpacking where {pop currentpacking true setpacking} if
196 10 dict
197 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
198 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
199 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
200 begin
201 /parseinput {
202
203 20 dict begin
204
205 /parseinput //loadctx exec
206
207 /fncvals exch def
208 /barcode exch def
209
210 /parse dup dup fncvals exch get def fncvals exch undef
211 /parsefnc dup dup fncvals exch get def fncvals exch undef
212 /parseonly dup dup fncvals exch known def fncvals exch undef
213 /eci dup dup fncvals exch known def fncvals exch undef
214
215 % Control character names to ordinals
216 {
217 <<
218 [
219 /NUL /SOH /STX /ETX /EOT /ENQ /ACK /BEL
220 /BS /TAB /LF /VT /FF /CR () () % SO and SI prefix clash with SOH
221 /DLE /DC1 /DC2 /DC3 /DC4 /NAK /SYN /ETB
222 /CAN /EM /SUB /ESC /FS /GS /RS /US
223 ]
224 0 exch {
225 1 index 1 add 3 1 roll exch 3 -1 roll
226 } forall pop
227 >> /ctrl exch def
228 } ctxdef
229
230 /msg barcode length array def
231 /j 0 def
232 barcode { % loop
233 (^) search exch
234 % Copy characters up to a "^"
235 dup length exch
236 msg exch j exch [ exch {} forall ] putinterval
237 j add /j exch def
238 { % Found a "^" escape character
239 pop
240 1 { % common exit
241
242 parse not parsefnc not and { % "^" as is
243 msg j 94 put
244 /j j 1 add def
245 exit
246 } if
247
248 % Encode "^" to start with
249 msg j 94 put
250 /j j 1 add def
251
252 % parse
253 parse {
254 dup length 3 ge { % "^XXX" byte
255 dup 0 3 getinterval ctrl exch
256 2 copy known {
257 /j j 1 sub def % Replace "^" with ordinal
258 get msg exch j exch put
259 /j j 1 add def
260 dup length 3 sub 3 exch getinterval
261 exit
262 } {
263 pop pop
264 } ifelse
265 } if
266 dup length 2 ge { % "^XX" to byte
267 dup 0 2 getinterval ctrl exch
268 2 copy known {
269 /j j 1 sub def % Replace "^" with ordinal
270 get msg exch j exch put
271 /j j 1 add def
272 dup length 2 sub 2 exch getinterval
273 exit
274 } {
275 pop pop
276 } ifelse
277 } if
278 dup length 3 ge { % "^NNN" to byte
279 dup 0 3 getinterval true exch {
280 dup 48 lt exch 57 gt or { pop false } if
281 } forall
282 {
283 dup 0 3 getinterval cvi dup 255 gt {
284 pop pop
285 /bwipp.invalidOrdinal (Ordinal must be 000 to 255) //raiseerror exec
286 } if
287 /j j 1 sub def % Replace "^" with ordinal
288 msg exch j exch put
289 /j j 1 add def
290 dup length 3 sub 3 exch getinterval
291 } if
292 } if
293 } if
294
295 parseonly
296 parsefnc not or
297 msg j 1 sub get 94 ne % Carat was substituted away
298 or {exit} if
299
300 % parsefnc
301 /j j 1 sub def
302 dup length 1 lt {
303 pop
304 /bwipp.truncatedCaret (Caret character truncated) //raiseerror exec
305 } if
306 dup 0 get 94 eq { % "^^" -> "^"
307 msg j 94 put
308 /j j 1 add def
309 dup length 1 sub 1 exch getinterval
310 exit
311 } if
312 dup length 3 lt {
313 pop
314 /bwipp.truncatedFNC (Function character truncated) //raiseerror exec
315 } if
316 dup 0 3 getinterval (ECI) eq eci and { % "^ECInnnnnn" -> -1nnnnnn
317 dup length 9 lt {
318 pop
319 /bwipp.truncatedECI (ECI truncated) //raiseerror exec
320 } if
321 dup 3 6 getinterval
322 dup {
323 dup 48 lt exch 57 gt or {
324 pop pop
325 /bwipp.invalidECI (ECI must be 000000 to 999999) //raiseerror exec
326 } if
327 } forall
328 0 exch {48 sub sub 10 mul} forall 10 idiv 1000000 sub
329 msg exch j exch put
330 /j j 1 add def
331 dup length 9 sub 9 exch getinterval
332 exit
333 } if
334 dup length 4 lt { % "^FNCx" -> fncvals{FNCx}
335 pop
336 /bwipp.truncatedFNC (Function character truncated) //raiseerror exec
337 } if
338 dup 0 4 getinterval dup fncvals exch known not {
339 dup length 28 add string dup 28 4 -1 roll putinterval
340 dup 0 (Unknown function character: ) putinterval
341 exch pop
342 /bwipp.unknownFNC exch //raiseerror exec
343 } if
344 fncvals exch get
345 msg exch j exch put
346 /j j 1 add def
347 dup length 4 sub 4 exch getinterval
348 exit
349
350 } repeat
351 } { % No more "^" characters
352 exit
353 } ifelse
354 } loop
355
356 parseonly not {
357 msg 0 j getinterval
358 } {
359 j string
360 0 1 j 1 sub { 1 index exch dup msg exch get put } for
361 } ifelse
362
363 //unloadctx exec
364
365 end
366
367 }
368 [/barcode] {null def} forall
369 bind def
370 /parseinput dup load /uk.co.terryburton.bwipp defineresource pop
371 end
372 /setpacking where {pop setpacking} if
373 %%EndData
374 %%EndResource
375 % --END RESOURCE parseinput--
376
377 % --BEGIN RESOURCE gs1process--
378 % --REQUIRES preamble loadctx unloadctx parseinput raiseerror--
379 %%BeginResource: uk.co.terryburton.bwipp gs1process 0.0 2025111800 684317 715053
380 %%BeginData: 3307 ASCII Lines
381 /setpacking where {pop currentpacking true setpacking} if
382 10 dict
383 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
384 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
385 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
386 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
387 begin
388 /gs1process {
389
390 20 dict begin
391
392 /gs1process //loadctx exec
393
394 {
395 % Extracted from the GS1 Syntax Dictionary
396 /gs1syntax <<
397
398 <<
399 /parts [
400 << /cset /N /min 18 /max 18 /opt false /linters [ /lintcsum /lintgcppos2 ] >>
401 ]
402 /dlpkey [ ]
403 >>
404 (00) exch dup
405 pop
406
407 <<
408 /parts [
409 << /cset /N /min 14 /max 14 /opt false /linters [ /lintcsum /lintgcppos2 ] >>
410 ]
411 /ex [ (255) (37) ]
412 /dlpkey [ [ (22) (10) (21) ] [ (235) ] ]
413 >>
414 (01) exch dup
415 pop
416
417 <<
418 /parts [
419 << /cset /N /min 14 /max 14 /opt false /linters [ /lintcsum /lintgcppos2 ] >>
420 ]
421 /ex [ (01) (03) ]
422 /req [ [ [ (37) ] ] ]
423 >>
424 (02) exch dup
425 pop
426
427 <<
428 /parts [
429 << /cset /N /min 14 /max 14 /opt false /linters [ /lintcsum /lintgcppos2 ] >>
430 ]
431 /ex [ (01) (02) (37) ]
432 /dlattr false
433 >>
434 (03) exch dup
435 pop
436
437 <<
438 /parts [
439 << /cset /X /min 1 /max 20 /opt false /linters [] >>
440 ]
441 /req [ [ [ (01) ] [ (02) ] [ (03) ] [ (8006) ] [ (8026) ] ] ]
442 >>
443 (10) exch dup
444 pop
445
446 <<
447 /parts [
448 << /cset /N /min 6 /max 6 /opt false /linters [ /lintyymmd0 ] >>
449 ]
450 /req [ [ [ (01) ] [ (02) ] [ (03) ] [ (8006) ] [ (8026) ] ] ]
451 >>
452 (11) exch dup
453 pop
454
455 <<
456 /parts [
457 << /cset /N /min 6 /max 6 /opt false /linters [ /lintyymmd0 ] >>
458 ]
459 /req [ [ [ (8020) ] ] ]
460 >>
461 (12) exch dup
462 pop
463
464 <<
465 /parts [
466 << /cset /N /min 6 /max 6 /opt false /linters [ /lintyymmd0 ] >>
467 ]
468 /req [ [ [ (01) ] [ (02) ] [ (03) ] [ (8006) ] [ (8026) ] ] ]
469 >>
470 (13) exch dup
471 (15) exch dup
472 (16) exch dup
473 pop
474
475 <<
476 /parts [
477 << /cset /N /min 6 /max 6 /opt false /linters [ /lintyymmd0 ] >>
478 ]
479 /req [ [ [ (01) ] [ (02) ] [ (03) ] [ (255) ] [ (8006) ] [ (8026) ] ] ]
480 >>
481 (17) exch dup
482 pop
483
484 <<
485 /parts [
486 << /cset /N /min 2 /max 2 /opt false /linters [] >>
487 ]
488 /req [ [ [ (01) ] [ (02) ] [ (8006) ] [ (8026) ] ] ]
489 >>
490 (20) exch dup
491 pop
492
493 <<
494 /parts [
495 << /cset /X /min 1 /max 20 /opt false /linters [] >>
496 ]
497 /ex [ (235) ]
498 /req [ [ [ (01) ] [ (03) ] [ (8006) ] ] ]
499 /dlattr false
500 >>
501 (21) exch dup
502 pop
503
504 <<
505 /parts [
506 << /cset /X /min 1 /max 20 /opt false /linters [] >>
507 ]
508 /req [ [ [ (01) ] ] ]
509 /dlattr false
510 >>
511 (22) exch dup
512 pop
513
514 <<
515 /parts [
516 << /cset /X /min 1 /max 28 /opt false /linters [] >>
517 ]
518 /req [ [ [ (01) ] ] ]
519 /dlattr false
520 >>
521 (235) exch dup
522 pop
523
524 <<
525 /parts [
526 << /cset /X /min 1 /max 30 /opt false /linters [] >>
527 ]
528 /req [ [ [ (01) ] [ (02) ] [ (8006) ] [ (8026) ] ] ]
529 >>
530 (240) exch dup
531 (241) exch dup
532 pop
533
534 <<
535 /parts [
536 << /cset /N /min 1 /max 6 /opt false /linters [] >>
537 ]
538 /req [ [ [ (01) ] [ (02) ] [ (8006) ] [ (8026) ] ] ]
539 >>
540 (242) exch dup
541 pop
542
543 <<
544 /parts [
545 << /cset /X /min 1 /max 20 /opt false /linters [] >>
546 ]
547 /req [ [ [ (01) ] ] ]
548 >>
549 (243) exch dup
550 pop
551
552 <<
553 /parts [
554 << /cset /X /min 1 /max 30 /opt false /linters [] >>
555 ]
556 /req [ [ [ (01) ] [ (8006) ] ] [ [ (21) ] ] ]
557 >>
558 (250) exch dup
559 pop
560
561 <<
562 /parts [
563 << /cset /X /min 1 /max 30 /opt false /linters [] >>
564 ]
565 /req [ [ [ (01) ] [ (8006) ] ] ]
566 >>
567 (251) exch dup
568 pop
569
570 <<
571 /parts [
572 << /cset /N /min 13 /max 13 /opt false /linters [ /lintcsum /lintgcppos1 ] >>
573 << /cset /X /min 1 /max 17 /opt true /linters [] >>
574 ]
575 /dlpkey [ ]
576 >>
577 (253) exch dup
578 pop
579
580 <<
581 /parts [
582 << /cset /X /min 1 /max 20 /opt false /linters [] >>
583 ]
584 /req [ [ [ (414) ] ] ]
585 /dlattr false
586 >>
587 (254) exch dup
588 pop
589
590 <<
591 /parts [
592 << /cset /N /min 13 /max 13 /opt false /linters [ /lintcsum /lintgcppos1 ] >>
593 << /cset /N /min 1 /max 12 /opt true /linters [] >>
594 ]
595 /ex [ (01) (02) (415) (8006) (8020) (8026) ]
596 /dlpkey [ ]
597 >>
598 (255) exch dup
599 pop
600
601 <<
602 /parts [
603 << /cset /N /min 1 /max 8 /opt false /linters [] >>
604 ]
605 /req [ [ [ (01) ] [ (02) ] ] ]
606 >>
607 (30) exch dup
608 pop
609
610 <<
611 /parts [
612 << /cset /N /min 6 /max 6 /opt false /linters [] >>
613 ]
614 /ex [ (310n) ]
615 /req [ [ [ (01) ] [ (02) ] ] ]
616 >>
617 (3100) exch dup
618 (3101) exch dup
619 (3102) exch dup
620 (3103) exch dup
621 (3104) exch dup
622 (3105) exch dup
623 pop
624
625 <<
626 /parts [
627 << /cset /N /min 6 /max 6 /opt false /linters [] >>
628 ]
629 /ex [ (311n) ]
630 /req [ [ [ (01) ] [ (02) ] ] ]
631 >>
632 (3110) exch dup
633 (3111) exch dup
634 (3112) exch dup
635 (3113) exch dup
636 (3114) exch dup
637 (3115) exch dup
638 pop
639
640 <<
641 /parts [
642 << /cset /N /min 6 /max 6 /opt false /linters [] >>
643 ]
644 /ex [ (312n) ]
645 /req [ [ [ (01) ] [ (02) ] ] ]
646 >>
647 (3120) exch dup
648 (3121) exch dup
649 (3122) exch dup
650 (3123) exch dup
651 (3124) exch dup
652 (3125) exch dup
653 pop
654
655 <<
656 /parts [
657 << /cset /N /min 6 /max 6 /opt false /linters [] >>
658 ]
659 /ex [ (313n) ]
660 /req [ [ [ (01) ] [ (02) ] ] ]
661 >>
662 (3130) exch dup
663 (3131) exch dup
664 (3132) exch dup
665 (3133) exch dup
666 (3134) exch dup
667 (3135) exch dup
668 pop
669
670 <<
671 /parts [
672 << /cset /N /min 6 /max 6 /opt false /linters [] >>
673 ]
674 /ex [ (314n) ]
675 /req [ [ [ (01) ] [ (02) ] ] ]
676 >>
677 (3140) exch dup
678 (3141) exch dup
679 (3142) exch dup
680 (3143) exch dup
681 (3144) exch dup
682 (3145) exch dup
683 pop
684
685 <<
686 /parts [
687 << /cset /N /min 6 /max 6 /opt false /linters [] >>
688 ]
689 /ex [ (315n) ]
690 /req [ [ [ (01) ] [ (02) ] ] ]
691 >>
692 (3150) exch dup
693 (3151) exch dup
694 (3152) exch dup
695 (3153) exch dup
696 (3154) exch dup
697 (3155) exch dup
698 pop
699
700 <<
701 /parts [
702 << /cset /N /min 6 /max 6 /opt false /linters [] >>
703 ]
704 /ex [ (316n) ]
705 /req [ [ [ (01) ] [ (02) ] ] ]
706 >>
707 (3160) exch dup
708 (3161) exch dup
709 (3162) exch dup
710 (3163) exch dup
711 (3164) exch dup
712 (3165) exch dup
713 pop
714
715 <<
716 /parts [
717 << /cset /N /min 6 /max 6 /opt false /linters [] >>
718 ]
719 /ex [ (320n) ]
720 /req [ [ [ (01) ] [ (02) ] ] ]
721 >>
722 (3200) exch dup
723 (3201) exch dup
724 (3202) exch dup
725 (3203) exch dup
726 (3204) exch dup
727 (3205) exch dup
728 pop
729
730 <<
731 /parts [
732 << /cset /N /min 6 /max 6 /opt false /linters [] >>
733 ]
734 /ex [ (321n) ]
735 /req [ [ [ (01) ] [ (02) ] ] ]
736 >>
737 (3210) exch dup
738 (3211) exch dup
739 (3212) exch dup
740 (3213) exch dup
741 (3214) exch dup
742 (3215) exch dup
743 pop
744
745 <<
746 /parts [
747 << /cset /N /min 6 /max 6 /opt false /linters [] >>
748 ]
749 /ex [ (322n) ]
750 /req [ [ [ (01) ] [ (02) ] ] ]
751 >>
752 (3220) exch dup
753 (3221) exch dup
754 (3222) exch dup
755 (3223) exch dup
756 (3224) exch dup
757 (3225) exch dup
758 pop
759
760 <<
761 /parts [
762 << /cset /N /min 6 /max 6 /opt false /linters [] >>
763 ]
764 /ex [ (323n) ]
765 /req [ [ [ (01) ] [ (02) ] ] ]
766 >>
767 (3230) exch dup
768 (3231) exch dup
769 (3232) exch dup
770 (3233) exch dup
771 (3234) exch dup
772 (3235) exch dup
773 pop
774
775 <<
776 /parts [
777 << /cset /N /min 6 /max 6 /opt false /linters [] >>
778 ]
779 /ex [ (324n) ]
780 /req [ [ [ (01) ] [ (02) ] ] ]
781 >>
782 (3240) exch dup
783 (3241) exch dup
784 (3242) exch dup
785 (3243) exch dup
786 (3244) exch dup
787 (3245) exch dup
788 pop
789
790 <<
791 /parts [
792 << /cset /N /min 6 /max 6 /opt false /linters [] >>
793 ]
794 /ex [ (325n) ]
795 /req [ [ [ (01) ] [ (02) ] ] ]
796 >>
797 (3250) exch dup
798 (3251) exch dup
799 (3252) exch dup
800 (3253) exch dup
801 (3254) exch dup
802 (3255) exch dup
803 pop
804
805 <<
806 /parts [
807 << /cset /N /min 6 /max 6 /opt false /linters [] >>
808 ]
809 /ex [ (326n) ]
810 /req [ [ [ (01) ] [ (02) ] ] ]
811 >>
812 (3260) exch dup
813 (3261) exch dup
814 (3262) exch dup
815 (3263) exch dup
816 (3264) exch dup
817 (3265) exch dup
818 pop
819
820 <<
821 /parts [
822 << /cset /N /min 6 /max 6 /opt false /linters [] >>
823 ]
824 /ex [ (327n) ]
825 /req [ [ [ (01) ] [ (02) ] ] ]
826 >>
827 (3270) exch dup
828 (3271) exch dup
829 (3272) exch dup
830 (3273) exch dup
831 (3274) exch dup
832 (3275) exch dup
833 pop
834
835 <<
836 /parts [
837 << /cset /N /min 6 /max 6 /opt false /linters [] >>
838 ]
839 /ex [ (328n) ]
840 /req [ [ [ (01) ] [ (02) ] ] ]
841 >>
842 (3280) exch dup
843 (3281) exch dup
844 (3282) exch dup
845 (3283) exch dup
846 (3284) exch dup
847 (3285) exch dup
848 pop
849
850 <<
851 /parts [
852 << /cset /N /min 6 /max 6 /opt false /linters [] >>
853 ]
854 /ex [ (329n) ]
855 /req [ [ [ (01) ] [ (02) ] ] ]
856 >>
857 (3290) exch dup
858 (3291) exch dup
859 (3292) exch dup
860 (3293) exch dup
861 (3294) exch dup
862 (3295) exch dup
863 pop
864
865 <<
866 /parts [
867 << /cset /N /min 6 /max 6 /opt false /linters [] >>
868 ]
869 /ex [ (330n) ]
870 /req [ [ [ (00) ] [ (01) ] ] ]
871 >>
872 (3300) exch dup
873 (3301) exch dup
874 (3302) exch dup
875 (3303) exch dup
876 (3304) exch dup
877 (3305) exch dup
878 pop
879
880 <<
881 /parts [
882 << /cset /N /min 6 /max 6 /opt false /linters [] >>
883 ]
884 /ex [ (331n) ]
885 /req [ [ [ (00) ] [ (01) ] ] ]
886 >>
887 (3310) exch dup
888 (3311) exch dup
889 (3312) exch dup
890 (3313) exch dup
891 (3314) exch dup
892 (3315) exch dup
893 pop
894
895 <<
896 /parts [
897 << /cset /N /min 6 /max 6 /opt false /linters [] >>
898 ]
899 /ex [ (332n) ]
900 /req [ [ [ (00) ] [ (01) ] ] ]
901 >>
902 (3320) exch dup
903 (3321) exch dup
904 (3322) exch dup
905 (3323) exch dup
906 (3324) exch dup
907 (3325) exch dup
908 pop
909
910 <<
911 /parts [
912 << /cset /N /min 6 /max 6 /opt false /linters [] >>
913 ]
914 /ex [ (333n) ]
915 /req [ [ [ (00) ] [ (01) ] ] ]
916 >>
917 (3330) exch dup
918 (3331) exch dup
919 (3332) exch dup
920 (3333) exch dup
921 (3334) exch dup
922 (3335) exch dup
923 pop
924
925 <<
926 /parts [
927 << /cset /N /min 6 /max 6 /opt false /linters [] >>
928 ]
929 /ex [ (334n) ]
930 /req [ [ [ (00) ] [ (01) ] ] ]
931 >>
932 (3340) exch dup
933 (3341) exch dup
934 (3342) exch dup
935 (3343) exch dup
936 (3344) exch dup
937 (3345) exch dup
938 pop
939
940 <<
941 /parts [
942 << /cset /N /min 6 /max 6 /opt false /linters [] >>
943 ]
944 /ex [ (335n) ]
945 /req [ [ [ (00) ] [ (01) ] ] ]
946 >>
947 (3350) exch dup
948 (3351) exch dup
949 (3352) exch dup
950 (3353) exch dup
951 (3354) exch dup
952 (3355) exch dup
953 pop
954
955 <<
956 /parts [
957 << /cset /N /min 6 /max 6 /opt false /linters [] >>
958 ]
959 /ex [ (336n) ]
960 /req [ [ [ (00) ] [ (01) ] ] ]
961 >>
962 (3360) exch dup
963 (3361) exch dup
964 (3362) exch dup
965 (3363) exch dup
966 (3364) exch dup
967 (3365) exch dup
968 pop
969
970 <<
971 /parts [
972 << /cset /N /min 6 /max 6 /opt false /linters [] >>
973 ]
974 /ex [ (337n) ]
975 /req [ [ [ (01) ] ] ]
976 >>
977 (3370) exch dup
978 (3371) exch dup
979 (3372) exch dup
980 (3373) exch dup
981 (3374) exch dup
982 (3375) exch dup
983 pop
984
985 <<
986 /parts [
987 << /cset /N /min 6 /max 6 /opt false /linters [] >>
988 ]
989 /ex [ (340n) ]
990 /req [ [ [ (00) ] [ (01) ] ] ]
991 >>
992 (3400) exch dup
993 (3401) exch dup
994 (3402) exch dup
995 (3403) exch dup
996 (3404) exch dup
997 (3405) exch dup
998 pop
999
1000 <<
1001 /parts [
1002 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1003 ]
1004 /ex [ (341n) ]
1005 /req [ [ [ (00) ] [ (01) ] ] ]
1006 >>
1007 (3410) exch dup
1008 (3411) exch dup
1009 (3412) exch dup
1010 (3413) exch dup
1011 (3414) exch dup
1012 (3415) exch dup
1013 pop
1014
1015 <<
1016 /parts [
1017 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1018 ]
1019 /ex [ (342n) ]
1020 /req [ [ [ (00) ] [ (01) ] ] ]
1021 >>
1022 (3420) exch dup
1023 (3421) exch dup
1024 (3422) exch dup
1025 (3423) exch dup
1026 (3424) exch dup
1027 (3425) exch dup
1028 pop
1029
1030 <<
1031 /parts [
1032 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1033 ]
1034 /ex [ (343n) ]
1035 /req [ [ [ (00) ] [ (01) ] ] ]
1036 >>
1037 (3430) exch dup
1038 (3431) exch dup
1039 (3432) exch dup
1040 (3433) exch dup
1041 (3434) exch dup
1042 (3435) exch dup
1043 pop
1044
1045 <<
1046 /parts [
1047 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1048 ]
1049 /ex [ (344n) ]
1050 /req [ [ [ (00) ] [ (01) ] ] ]
1051 >>
1052 (3440) exch dup
1053 (3441) exch dup
1054 (3442) exch dup
1055 (3443) exch dup
1056 (3444) exch dup
1057 (3445) exch dup
1058 pop
1059
1060 <<
1061 /parts [
1062 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1063 ]
1064 /ex [ (345n) ]
1065 /req [ [ [ (00) ] [ (01) ] ] ]
1066 >>
1067 (3450) exch dup
1068 (3451) exch dup
1069 (3452) exch dup
1070 (3453) exch dup
1071 (3454) exch dup
1072 (3455) exch dup
1073 pop
1074
1075 <<
1076 /parts [
1077 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1078 ]
1079 /ex [ (346n) ]
1080 /req [ [ [ (00) ] [ (01) ] ] ]
1081 >>
1082 (3460) exch dup
1083 (3461) exch dup
1084 (3462) exch dup
1085 (3463) exch dup
1086 (3464) exch dup
1087 (3465) exch dup
1088 pop
1089
1090 <<
1091 /parts [
1092 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1093 ]
1094 /ex [ (347n) ]
1095 /req [ [ [ (00) ] [ (01) ] ] ]
1096 >>
1097 (3470) exch dup
1098 (3471) exch dup
1099 (3472) exch dup
1100 (3473) exch dup
1101 (3474) exch dup
1102 (3475) exch dup
1103 pop
1104
1105 <<
1106 /parts [
1107 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1108 ]
1109 /ex [ (348n) ]
1110 /req [ [ [ (00) ] [ (01) ] ] ]
1111 >>
1112 (3480) exch dup
1113 (3481) exch dup
1114 (3482) exch dup
1115 (3483) exch dup
1116 (3484) exch dup
1117 (3485) exch dup
1118 pop
1119
1120 <<
1121 /parts [
1122 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1123 ]
1124 /ex [ (349n) ]
1125 /req [ [ [ (00) ] [ (01) ] ] ]
1126 >>
1127 (3490) exch dup
1128 (3491) exch dup
1129 (3492) exch dup
1130 (3493) exch dup
1131 (3494) exch dup
1132 (3495) exch dup
1133 pop
1134
1135 <<
1136 /parts [
1137 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1138 ]
1139 /ex [ (350n) ]
1140 /req [ [ [ (01) ] [ (02) ] ] ]
1141 >>
1142 (3500) exch dup
1143 (3501) exch dup
1144 (3502) exch dup
1145 (3503) exch dup
1146 (3504) exch dup
1147 (3505) exch dup
1148 pop
1149
1150 <<
1151 /parts [
1152 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1153 ]
1154 /ex [ (351n) ]
1155 /req [ [ [ (01) ] [ (02) ] ] ]
1156 >>
1157 (3510) exch dup
1158 (3511) exch dup
1159 (3512) exch dup
1160 (3513) exch dup
1161 (3514) exch dup
1162 (3515) exch dup
1163 pop
1164
1165 <<
1166 /parts [
1167 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1168 ]
1169 /ex [ (352n) ]
1170 /req [ [ [ (01) ] [ (02) ] ] ]
1171 >>
1172 (3520) exch dup
1173 (3521) exch dup
1174 (3522) exch dup
1175 (3523) exch dup
1176 (3524) exch dup
1177 (3525) exch dup
1178 pop
1179
1180 <<
1181 /parts [
1182 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1183 ]
1184 /ex [ (353n) ]
1185 /req [ [ [ (00) ] [ (01) ] ] ]
1186 >>
1187 (3530) exch dup
1188 (3531) exch dup
1189 (3532) exch dup
1190 (3533) exch dup
1191 (3534) exch dup
1192 (3535) exch dup
1193 pop
1194
1195 <<
1196 /parts [
1197 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1198 ]
1199 /ex [ (354n) ]
1200 /req [ [ [ (00) ] [ (01) ] ] ]
1201 >>
1202 (3540) exch dup
1203 (3541) exch dup
1204 (3542) exch dup
1205 (3543) exch dup
1206 (3544) exch dup
1207 (3545) exch dup
1208 pop
1209
1210 <<
1211 /parts [
1212 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1213 ]
1214 /ex [ (355n) ]
1215 /req [ [ [ (00) ] [ (01) ] ] ]
1216 >>
1217 (3550) exch dup
1218 (3551) exch dup
1219 (3552) exch dup
1220 (3553) exch dup
1221 (3554) exch dup
1222 (3555) exch dup
1223 pop
1224
1225 <<
1226 /parts [
1227 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1228 ]
1229 /ex [ (356n) ]
1230 /req [ [ [ (01) ] [ (02) ] ] ]
1231 >>
1232 (3560) exch dup
1233 (3561) exch dup
1234 (3562) exch dup
1235 (3563) exch dup
1236 (3564) exch dup
1237 (3565) exch dup
1238 pop
1239
1240 <<
1241 /parts [
1242 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1243 ]
1244 /ex [ (357n) ]
1245 /req [ [ [ (01) ] [ (02) ] ] ]
1246 >>
1247 (3570) exch dup
1248 (3571) exch dup
1249 (3572) exch dup
1250 (3573) exch dup
1251 (3574) exch dup
1252 (3575) exch dup
1253 pop
1254
1255 <<
1256 /parts [
1257 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1258 ]
1259 /ex [ (360n) ]
1260 /req [ [ [ (01) ] [ (02) ] ] ]
1261 >>
1262 (3600) exch dup
1263 (3601) exch dup
1264 (3602) exch dup
1265 (3603) exch dup
1266 (3604) exch dup
1267 (3605) exch dup
1268 pop
1269
1270 <<
1271 /parts [
1272 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1273 ]
1274 /ex [ (361n) ]
1275 /req [ [ [ (01) ] [ (02) ] ] ]
1276 >>
1277 (3610) exch dup
1278 (3611) exch dup
1279 (3612) exch dup
1280 (3613) exch dup
1281 (3614) exch dup
1282 (3615) exch dup
1283 pop
1284
1285 <<
1286 /parts [
1287 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1288 ]
1289 /ex [ (362n) ]
1290 /req [ [ [ (00) ] [ (01) ] ] ]
1291 >>
1292 (3620) exch dup
1293 (3621) exch dup
1294 (3622) exch dup
1295 (3623) exch dup
1296 (3624) exch dup
1297 (3625) exch dup
1298 pop
1299
1300 <<
1301 /parts [
1302 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1303 ]
1304 /ex [ (363n) ]
1305 /req [ [ [ (00) ] [ (01) ] ] ]
1306 >>
1307 (3630) exch dup
1308 (3631) exch dup
1309 (3632) exch dup
1310 (3633) exch dup
1311 (3634) exch dup
1312 (3635) exch dup
1313 pop
1314
1315 <<
1316 /parts [
1317 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1318 ]
1319 /ex [ (364n) ]
1320 /req [ [ [ (01) ] [ (02) ] ] ]
1321 >>
1322 (3640) exch dup
1323 (3641) exch dup
1324 (3642) exch dup
1325 (3643) exch dup
1326 (3644) exch dup
1327 (3645) exch dup
1328 pop
1329
1330 <<
1331 /parts [
1332 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1333 ]
1334 /ex [ (365n) ]
1335 /req [ [ [ (01) ] [ (02) ] ] ]
1336 >>
1337 (3650) exch dup
1338 (3651) exch dup
1339 (3652) exch dup
1340 (3653) exch dup
1341 (3654) exch dup
1342 (3655) exch dup
1343 pop
1344
1345 <<
1346 /parts [
1347 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1348 ]
1349 /ex [ (366n) ]
1350 /req [ [ [ (01) ] [ (02) ] ] ]
1351 >>
1352 (3660) exch dup
1353 (3661) exch dup
1354 (3662) exch dup
1355 (3663) exch dup
1356 (3664) exch dup
1357 (3665) exch dup
1358 pop
1359
1360 <<
1361 /parts [
1362 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1363 ]
1364 /ex [ (367n) ]
1365 /req [ [ [ (00) ] [ (01) ] ] ]
1366 >>
1367 (3670) exch dup
1368 (3671) exch dup
1369 (3672) exch dup
1370 (3673) exch dup
1371 (3674) exch dup
1372 (3675) exch dup
1373 pop
1374
1375 <<
1376 /parts [
1377 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1378 ]
1379 /ex [ (368n) ]
1380 /req [ [ [ (00) ] [ (01) ] ] ]
1381 >>
1382 (3680) exch dup
1383 (3681) exch dup
1384 (3682) exch dup
1385 (3683) exch dup
1386 (3684) exch dup
1387 (3685) exch dup
1388 pop
1389
1390 <<
1391 /parts [
1392 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1393 ]
1394 /ex [ (369n) ]
1395 /req [ [ [ (00) ] [ (01) ] ] ]
1396 >>
1397 (3690) exch dup
1398 (3691) exch dup
1399 (3692) exch dup
1400 (3693) exch dup
1401 (3694) exch dup
1402 (3695) exch dup
1403 pop
1404
1405 <<
1406 /parts [
1407 << /cset /N /min 1 /max 8 /opt false /linters [] >>
1408 ]
1409 /req [ [ [ (00) ] ] [ [ (02) ] [ (8026) ] ] ]
1410 >>
1411 (37) exch dup
1412 pop
1413
1414 <<
1415 /parts [
1416 << /cset /N /min 1 /max 15 /opt false /linters [] >>
1417 ]
1418 /ex [ (390n) (391n) (394n) (8111) ]
1419 /req [ [ [ (255) ] [ (8020) ] ] ]
1420 >>
1421 (3900) exch dup
1422 (3901) exch dup
1423 (3902) exch dup
1424 (3903) exch dup
1425 (3904) exch dup
1426 (3905) exch dup
1427 (3906) exch dup
1428 (3907) exch dup
1429 (3908) exch dup
1430 (3909) exch dup
1431 pop
1432
1433 <<
1434 /parts [
1435 << /cset /N /min 3 /max 3 /opt false /linters [ /lintiso4217 ] >>
1436 << /cset /N /min 1 /max 15 /opt false /linters [] >>
1437 ]
1438 /ex [ (391n) ]
1439 /req [ [ [ (8020) ] ] ]
1440 >>
1441 (3910) exch dup
1442 (3911) exch dup
1443 (3912) exch dup
1444 (3913) exch dup
1445 (3914) exch dup
1446 (3915) exch dup
1447 (3916) exch dup
1448 (3917) exch dup
1449 (3918) exch dup
1450 (3919) exch dup
1451 pop
1452
1453 <<
1454 /parts [
1455 << /cset /N /min 1 /max 15 /opt false /linters [] >>
1456 ]
1457 /ex [ (392n) (393n) ]
1458 /req [ [ [ (01) ] ] [ [ (30) ] [ (31nn) ] [ (32nn) ] [ (35nn) ] [ (36nn) ] ] ]
1459 >>
1460 (3920) exch dup
1461 (3921) exch dup
1462 (3922) exch dup
1463 (3923) exch dup
1464 (3924) exch dup
1465 (3925) exch dup
1466 (3926) exch dup
1467 (3927) exch dup
1468 (3928) exch dup
1469 (3929) exch dup
1470 pop
1471
1472 <<
1473 /parts [
1474 << /cset /N /min 3 /max 3 /opt false /linters [ /lintiso4217 ] >>
1475 << /cset /N /min 1 /max 15 /opt false /linters [] >>
1476 ]
1477 /ex [ (393n) ]
1478 /req [ [ [ (30) ] [ (31nn) ] [ (32nn) ] [ (35nn) ] [ (36nn) ] ] ]
1479 >>
1480 (3930) exch dup
1481 (3931) exch dup
1482 (3932) exch dup
1483 (3933) exch dup
1484 (3934) exch dup
1485 (3935) exch dup
1486 (3936) exch dup
1487 (3937) exch dup
1488 (3938) exch dup
1489 (3939) exch dup
1490 pop
1491
1492 <<
1493 /parts [
1494 << /cset /N /min 4 /max 4 /opt false /linters [] >>
1495 ]
1496 /ex [ (394n) (8111) ]
1497 /req [ [ [ (255) ] ] ]
1498 >>
1499 (3940) exch dup
1500 (3941) exch dup
1501 (3942) exch dup
1502 (3943) exch dup
1503 pop
1504
1505 <<
1506 /parts [
1507 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1508 ]
1509 /ex [ (392n) (393n) (395n) (8005) ]
1510 /req [ [ [ (30) ] [ (31nn) ] [ (32nn) ] [ (35nn) ] [ (36nn) ] ] ]
1511 >>
1512 (3950) exch dup
1513 (3951) exch dup
1514 (3952) exch dup
1515 (3953) exch dup
1516 (3954) exch dup
1517 (3955) exch dup
1518 pop
1519
1520 <<
1521 /parts [
1522 << /cset /X /min 1 /max 30 /opt false /linters [] >>
1523 ]
1524 >>
1525 (400) exch dup
1526 pop
1527
1528 <<
1529 /parts [
1530 << /cset /X /min 1 /max 30 /opt false /linters [ /lintgcppos1 ] >>
1531 ]
1532 /dlpkey [ ]
1533 >>
1534 (401) exch dup
1535 pop
1536
1537 <<
1538 /parts [
1539 << /cset /N /min 17 /max 17 /opt false /linters [ /lintcsum /lintgcppos1 ] >>
1540 ]
1541 /dlpkey [ ]
1542 >>
1543 (402) exch dup
1544 pop
1545
1546 <<
1547 /parts [
1548 << /cset /X /min 1 /max 30 /opt false /linters [] >>
1549 ]
1550 /req [ [ [ (00) ] ] ]
1551 >>
1552 (403) exch dup
1553 pop
1554
1555 <<
1556 /parts [
1557 << /cset /N /min 13 /max 13 /opt false /linters [ /lintcsum /lintgcppos1 ] >>
1558 ]
1559 >>
1560 (410) exch dup
1561 (411) exch dup
1562 (412) exch dup
1563 (413) exch dup
1564 pop
1565
1566 <<
1567 /parts [
1568 << /cset /N /min 13 /max 13 /opt false /linters [ /lintcsum /lintgcppos1 ] >>
1569 ]
1570 /dlpkey [ [ (254) ] [ (7040) ] ]
1571 >>
1572 (414) exch dup
1573 pop
1574
1575 <<
1576 /parts [
1577 << /cset /N /min 13 /max 13 /opt false /linters [ /lintcsum /lintgcppos1 ] >>
1578 ]
1579 /req [ [ [ (8020) ] ] ]
1580 /dlpkey [ [ (8020) ] ]
1581 >>
1582 (415) exch dup
1583 pop
1584
1585 <<
1586 /parts [
1587 << /cset /N /min 13 /max 13 /opt false /linters [ /lintcsum /lintgcppos1 ] >>
1588 ]
1589 >>
1590 (416) exch dup
1591 pop
1592
1593 <<
1594 /parts [
1595 << /cset /N /min 13 /max 13 /opt false /linters [ /lintcsum /lintgcppos1 ] >>
1596 ]
1597 /dlpkey [ [ (7040) ] ]
1598 >>
1599 (417) exch dup
1600 pop
1601
1602 <<
1603 /parts [
1604 << /cset /X /min 1 /max 20 /opt false /linters [] >>
1605 ]
1606 /ex [ (421) ]
1607 >>
1608 (420) exch dup
1609 pop
1610
1611 <<
1612 /parts [
1613 << /cset /N /min 3 /max 3 /opt false /linters [ /lintiso3166 ] >>
1614 << /cset /X /min 1 /max 9 /opt false /linters [] >>
1615 ]
1616 /ex [ (4307) ]
1617 >>
1618 (421) exch dup
1619 pop
1620
1621 <<
1622 /parts [
1623 << /cset /N /min 3 /max 3 /opt false /linters [ /lintiso3166 ] >>
1624 ]
1625 /ex [ (426) ]
1626 /req [ [ [ (01) ] [ (02) ] [ (8006) ] [ (8026) ] ] ]
1627 >>
1628 (422) exch dup
1629 pop
1630
1631 <<
1632 /parts [
1633 << /cset /N /min 3 /max 3 /opt false /linters [ /lintiso3166 ] >>
1634 << /cset /N /min 3 /max 3 /opt true /linters [ /lintiso3166 ] >>
1635 << /cset /N /min 3 /max 3 /opt true /linters [ /lintiso3166 ] >>
1636 << /cset /N /min 3 /max 3 /opt true /linters [ /lintiso3166 ] >>
1637 << /cset /N /min 3 /max 3 /opt true /linters [ /lintiso3166 ] >>
1638 ]
1639 /ex [ (426) ]
1640 /req [ [ [ (01) ] [ (02) ] ] ]
1641 >>
1642 (423) exch dup
1643 pop
1644
1645 <<
1646 /parts [
1647 << /cset /N /min 3 /max 3 /opt false /linters [ /lintiso3166 ] >>
1648 ]
1649 /ex [ (426) ]
1650 /req [ [ [ (01) ] [ (02) ] ] ]
1651 >>
1652 (424) exch dup
1653 pop
1654
1655 <<
1656 /parts [
1657 << /cset /N /min 3 /max 3 /opt false /linters [ /lintiso3166 ] >>
1658 << /cset /N /min 3 /max 3 /opt true /linters [ /lintiso3166 ] >>
1659 << /cset /N /min 3 /max 3 /opt true /linters [ /lintiso3166 ] >>
1660 << /cset /N /min 3 /max 3 /opt true /linters [ /lintiso3166 ] >>
1661 << /cset /N /min 3 /max 3 /opt true /linters [ /lintiso3166 ] >>
1662 ]
1663 /ex [ (426) ]
1664 /req [ [ [ (01) ] [ (02) ] ] ]
1665 >>
1666 (425) exch dup
1667 pop
1668
1669 <<
1670 /parts [
1671 << /cset /N /min 3 /max 3 /opt false /linters [ /lintiso3166 ] >>
1672 ]
1673 /req [ [ [ (01) ] [ (02) ] ] ]
1674 >>
1675 (426) exch dup
1676 pop
1677
1678 <<
1679 /parts [
1680 << /cset /X /min 1 /max 3 /opt false /linters [] >>
1681 ]
1682 /req [ [ [ (01) ] [ (02) ] ] [ [ (422) ] ] ]
1683 >>
1684 (427) exch dup
1685 pop
1686
1687 <<
1688 /parts [
1689 << /cset /X /min 1 /max 35 /opt false /linters [ /lintpcenc ] >>
1690 ]
1691 /req [ [ [ (00) ] ] ]
1692 >>
1693 (4300) exch dup
1694 (4301) exch dup
1695 pop
1696
1697 <<
1698 /parts [
1699 << /cset /X /min 1 /max 70 /opt false /linters [ /lintpcenc ] >>
1700 ]
1701 /req [ [ [ (00) ] ] ]
1702 >>
1703 (4302) exch dup
1704 pop
1705
1706 <<
1707 /parts [
1708 << /cset /X /min 1 /max 70 /opt false /linters [ /lintpcenc ] >>
1709 ]
1710 /req [ [ [ (4302) ] ] ]
1711 >>
1712 (4303) exch dup
1713 pop
1714
1715 <<
1716 /parts [
1717 << /cset /X /min 1 /max 70 /opt false /linters [ /lintpcenc ] >>
1718 ]
1719 /req [ [ [ (00) ] ] ]
1720 >>
1721 (4304) exch dup
1722 (4305) exch dup
1723 (4306) exch dup
1724 pop
1725
1726 <<
1727 /parts [
1728 << /cset /X /min 2 /max 2 /opt false /linters [ /lintiso3166alpha2 ] >>
1729 ]
1730 /req [ [ [ (00) ] ] ]
1731 >>
1732 (4307) exch dup
1733 pop
1734
1735 <<
1736 /parts [
1737 << /cset /X /min 1 /max 30 /opt false /linters [] >>
1738 ]
1739 /req [ [ [ (00) ] ] ]
1740 >>
1741 (4308) exch dup
1742 pop
1743
1744 <<
1745 /parts [
1746 << /cset /N /min 10 /max 10 /opt false /linters [ /lintlatitude ] >>
1747 << /cset /N /min 10 /max 10 /opt false /linters [ /lintlongitude ] >>
1748 ]
1749 /req [ [ [ (00) ] ] ]
1750 >>
1751 (4309) exch dup
1752 pop
1753
1754 <<
1755 /parts [
1756 << /cset /X /min 1 /max 35 /opt false /linters [ /lintpcenc ] >>
1757 ]
1758 /req [ [ [ (00) ] ] ]
1759 >>
1760 (4310) exch dup
1761 (4311) exch dup
1762 pop
1763
1764 <<
1765 /parts [
1766 << /cset /X /min 1 /max 70 /opt false /linters [ /lintpcenc ] >>
1767 ]
1768 /req [ [ [ (00) ] ] ]
1769 >>
1770 (4312) exch dup
1771 pop
1772
1773 <<
1774 /parts [
1775 << /cset /X /min 1 /max 70 /opt false /linters [ /lintpcenc ] >>
1776 ]
1777 /req [ [ [ (4312) ] ] ]
1778 >>
1779 (4313) exch dup
1780 pop
1781
1782 <<
1783 /parts [
1784 << /cset /X /min 1 /max 70 /opt false /linters [ /lintpcenc ] >>
1785 ]
1786 /req [ [ [ (00) ] ] ]
1787 >>
1788 (4314) exch dup
1789 (4315) exch dup
1790 (4316) exch dup
1791 pop
1792
1793 <<
1794 /parts [
1795 << /cset /X /min 2 /max 2 /opt false /linters [ /lintiso3166alpha2 ] >>
1796 ]
1797 /req [ [ [ (00) ] ] ]
1798 >>
1799 (4317) exch dup
1800 pop
1801
1802 <<
1803 /parts [
1804 << /cset /X /min 1 /max 20 /opt false /linters [] >>
1805 ]
1806 /req [ [ [ (00) ] ] ]
1807 >>
1808 (4318) exch dup
1809 pop
1810
1811 <<
1812 /parts [
1813 << /cset /X /min 1 /max 30 /opt false /linters [] >>
1814 ]
1815 /req [ [ [ (00) ] ] ]
1816 >>
1817 (4319) exch dup
1818 pop
1819
1820 <<
1821 /parts [
1822 << /cset /X /min 1 /max 35 /opt false /linters [ /lintpcenc ] >>
1823 ]
1824 /req [ [ [ (00) ] ] ]
1825 >>
1826 (4320) exch dup
1827 pop
1828
1829 <<
1830 /parts [
1831 << /cset /N /min 1 /max 1 /opt false /linters [ /lintyesno ] >>
1832 ]
1833 /req [ [ [ (00) ] ] ]
1834 >>
1835 (4321) exch dup
1836 (4322) exch dup
1837 (4323) exch dup
1838 pop
1839
1840 <<
1841 /parts [
1842 << /cset /N /min 6 /max 6 /opt false /linters [ /lintyymmd0 ] >>
1843 << /cset /N /min 4 /max 4 /opt false /linters [ /linthhmi ] >>
1844 ]
1845 /req [ [ [ (00) ] ] ]
1846 >>
1847 (4324) exch dup
1848 (4325) exch dup
1849 pop
1850
1851 <<
1852 /parts [
1853 << /cset /N /min 6 /max 6 /opt false /linters [ /lintyymmdd ] >>
1854 ]
1855 /req [ [ [ (00) ] ] ]
1856 >>
1857 (4326) exch dup
1858 pop
1859
1860 <<
1861 /parts [
1862 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1863 << /cset /X /min 1 /max 1 /opt true /linters [ /linthyphen ] >>
1864 ]
1865 /ex [ (4331) ]
1866 /req [ [ [ (00) ] ] ]
1867 >>
1868 (4330) exch dup
1869 pop
1870
1871 <<
1872 /parts [
1873 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1874 << /cset /X /min 1 /max 1 /opt true /linters [ /linthyphen ] >>
1875 ]
1876 /ex [ (4330) ]
1877 /req [ [ [ (00) ] ] ]
1878 >>
1879 (4331) exch dup
1880 pop
1881
1882 <<
1883 /parts [
1884 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1885 << /cset /X /min 1 /max 1 /opt true /linters [ /linthyphen ] >>
1886 ]
1887 /ex [ (4333) ]
1888 /req [ [ [ (00) ] ] ]
1889 >>
1890 (4332) exch dup
1891 pop
1892
1893 <<
1894 /parts [
1895 << /cset /N /min 6 /max 6 /opt false /linters [] >>
1896 << /cset /X /min 1 /max 1 /opt true /linters [ /linthyphen ] >>
1897 ]
1898 /ex [ (4332) ]
1899 /req [ [ [ (00) ] ] ]
1900 >>
1901 (4333) exch dup
1902 pop
1903
1904 <<
1905 /parts [
1906 << /cset /N /min 13 /max 13 /opt false /linters [] >>
1907 ]
1908 /req [ [ [ (01) ] [ (02) ] [ (8006) ] [ (8026) ] ] ]
1909 >>
1910 (7001) exch dup
1911 pop
1912
1913 <<
1914 /parts [
1915 << /cset /X /min 1 /max 30 /opt false /linters [] >>
1916 ]
1917 /req [ [ [ (01) ] [ (02) ] ] ]
1918 >>
1919 (7002) exch dup
1920 pop
1921
1922 <<
1923 /parts [
1924 << /cset /N /min 6 /max 6 /opt false /linters [ /lintyymmdd ] >>
1925 << /cset /N /min 4 /max 4 /opt false /linters [ /linthhmi ] >>
1926 ]
1927 /req [ [ [ (01) ] [ (02) ] ] ]
1928 >>
1929 (7003) exch dup
1930 pop
1931
1932 <<
1933 /parts [
1934 << /cset /N /min 1 /max 4 /opt false /linters [] >>
1935 ]
1936 /req [ [ [ (01) ] ] [ [ (10) ] ] ]
1937 >>
1938 (7004) exch dup
1939 pop
1940
1941 <<
1942 /parts [
1943 << /cset /X /min 1 /max 12 /opt false /linters [] >>
1944 ]
1945 /req [ [ [ (01) ] [ (02) ] ] ]
1946 >>
1947 (7005) exch dup
1948 pop
1949
1950 <<
1951 /parts [
1952 << /cset /N /min 6 /max 6 /opt false /linters [ /lintyymmdd ] >>
1953 ]
1954 /req [ [ [ (01) ] [ (02) ] ] ]
1955 >>
1956 (7006) exch dup
1957 pop
1958
1959 <<
1960 /parts [
1961 << /cset /N /min 6 /max 6 /opt false /linters [ /lintyymmdd ] >>
1962 << /cset /N /min 6 /max 6 /opt true /linters [ /lintyymmdd ] >>
1963 ]
1964 /req [ [ [ (01) ] [ (02) ] ] ]
1965 >>
1966 (7007) exch dup
1967 pop
1968
1969 <<
1970 /parts [
1971 << /cset /X /min 1 /max 3 /opt false /linters [] >>
1972 ]
1973 /req [ [ [ (01) ] [ (02) ] ] ]
1974 >>
1975 (7008) exch dup
1976 pop
1977
1978 <<
1979 /parts [
1980 << /cset /X /min 1 /max 10 /opt false /linters [] >>
1981 ]
1982 /req [ [ [ (01) ] [ (02) ] ] ]
1983 >>
1984 (7009) exch dup
1985 pop
1986
1987 <<
1988 /parts [
1989 << /cset /X /min 1 /max 2 /opt false /linters [] >>
1990 ]
1991 /req [ [ [ (01) ] [ (02) ] ] ]
1992 >>
1993 (7010) exch dup
1994 pop
1995
1996 <<
1997 /parts [
1998 << /cset /N /min 6 /max 6 /opt false /linters [ /lintyymmdd ] >>
1999 << /cset /N /min 4 /max 4 /opt true /linters [ /linthhmi ] >>
2000 ]
2001 /req [ [ [ (01) ] [ (02) ] ] ]
2002 >>
2003 (7011) exch dup
2004 pop
2005
2006 <<
2007 /parts [
2008 << /cset /X /min 1 /max 20 /opt false /linters [] >>
2009 ]
2010 /req [ [ [ (01) ] [ (8006) ] ] [ [ (416) ] ] ]
2011 >>
2012 (7020) exch dup
2013 pop
2014
2015 <<
2016 /parts [
2017 << /cset /X /min 1 /max 20 /opt false /linters [] >>
2018 ]
2019 /req [ [ [ (01) ] [ (8006) ] ] ]
2020 >>
2021 (7021) exch dup
2022 pop
2023
2024 <<
2025 /parts [
2026 << /cset /X /min 1 /max 20 /opt false /linters [] >>
2027 ]
2028 /req [ [ [ (7021) ] ] ]
2029 >>
2030 (7022) exch dup
2031 pop
2032
2033 <<
2034 /parts [
2035 << /cset /X /min 1 /max 30 /opt false /linters [ /lintgcppos1 ] >>
2036 ]
2037 >>
2038 (7023) exch dup
2039 pop
2040
2041 <<
2042 /parts [
2043 << /cset /N /min 3 /max 3 /opt false /linters [ /lintiso3166999 ] >>
2044 << /cset /X /min 1 /max 27 /opt false /linters [] >>
2045 ]
2046 /req [ [ [ (01) ] [ (02) ] ] ]
2047 >>
2048 (7030) exch dup
2049 (7031) exch dup
2050 (7032) exch dup
2051 (7033) exch dup
2052 (7034) exch dup
2053 (7035) exch dup
2054 (7036) exch dup
2055 (7037) exch dup
2056 (7038) exch dup
2057 (7039) exch dup
2058 pop
2059
2060 <<
2061 /parts [
2062 << /cset /N /min 1 /max 1 /opt false /linters [] >>
2063 << /cset /X /min 1 /max 1 /opt false /linters [] >>
2064 << /cset /X /min 1 /max 1 /opt false /linters [] >>
2065 << /cset /X /min 1 /max 1 /opt false /linters [ /lintimporteridx ] >>
2066 ]
2067 /dlattr false
2068 >>
2069 (7040) exch dup
2070 pop
2071
2072 <<
2073 /parts [
2074 << /cset /X /min 1 /max 4 /opt false /linters [ /lintpackagetype ] >>
2075 ]
2076 /req [ [ [ (00) ] ] ]
2077 /dlattr false
2078 >>
2079 (7041) exch dup
2080 pop
2081
2082 <<
2083 /parts [
2084 << /cset /X /min 1 /max 20 /opt false /linters [] >>
2085 ]
2086 /req [ [ [ (01) ] ] ]
2087 >>
2088 (710) exch dup
2089 (711) exch dup
2090 (712) exch dup
2091 (713) exch dup
2092 (714) exch dup
2093 (715) exch dup
2094 (716) exch dup
2095 pop
2096
2097 <<
2098 /parts [
2099 << /cset /X /min 2 /max 2 /opt false /linters [] >>
2100 << /cset /X /min 1 /max 28 /opt false /linters [] >>
2101 ]
2102 /req [ [ [ (01) ] [ (8004) ] ] ]
2103 >>
2104 (7230) exch dup
2105 (7231) exch dup
2106 (7232) exch dup
2107 (7233) exch dup
2108 (7234) exch dup
2109 (7235) exch dup
2110 (7236) exch dup
2111 (7237) exch dup
2112 (7238) exch dup
2113 (7239) exch dup
2114 pop
2115
2116 <<
2117 /parts [
2118 << /cset /X /min 1 /max 20 /opt false /linters [] >>
2119 ]
2120 /req [ [ [ (01) ] [ (8006) ] ] ]
2121 >>
2122 (7240) exch dup
2123 pop
2124
2125 <<
2126 /parts [
2127 << /cset /N /min 2 /max 2 /opt false /linters [ /lintmediatype ] >>
2128 ]
2129 /req [ [ [ (8017) ] [ (8018) ] ] ]
2130 >>
2131 (7241) exch dup
2132 pop
2133
2134 <<
2135 /parts [
2136 << /cset /X /min 1 /max 25 /opt false /linters [] >>
2137 ]
2138 /req [ [ [ (8017) ] [ (8018) ] ] ]
2139 >>
2140 (7242) exch dup
2141 pop
2142
2143 <<
2144 /parts [
2145 << /cset /N /min 8 /max 8 /opt false /linters [ /lintyyyymmdd ] >>
2146 ]
2147 /ex [ (7251) ]
2148 /req [ [ [ (8018) ] ] ]
2149 >>
2150 (7250) exch dup
2151 pop
2152
2153 <<
2154 /parts [
2155 << /cset /N /min 8 /max 8 /opt false /linters [ /lintyyyymmdd ] >>
2156 << /cset /N /min 4 /max 4 /opt false /linters [ /linthhmi ] >>
2157 ]
2158 /ex [ (7250) ]
2159 /req [ [ [ (8018) ] ] ]
2160 >>
2161 (7251) exch dup
2162 pop
2163
2164 <<
2165 /parts [
2166 << /cset /N /min 1 /max 1 /opt false /linters [ /lintiso5218 ] >>
2167 ]
2168 /req [ [ [ (8018) ] ] ]
2169 >>
2170 (7252) exch dup
2171 pop
2172
2173 <<
2174 /parts [
2175 << /cset /X /min 1 /max 40 /opt false /linters [ /lintpcenc ] >>
2176 ]
2177 /ex [ (7256) (7259) ]
2178 /req [ [ [ (8017) ] [ (8018) ] ] ]
2179 >>
2180 (7253) exch dup
2181 (7254) exch dup
2182 pop
2183
2184 <<
2185 /parts [
2186 << /cset /X /min 1 /max 10 /opt false /linters [] >>
2187 ]
2188 /ex [ (7256) (7259) ]
2189 /req [ [ [ (8017) ] [ (8018) ] ] ]
2190 >>
2191 (7255) exch dup
2192 pop
2193
2194 <<
2195 /parts [
2196 << /cset /X /min 1 /max 90 /opt false /linters [ /lintpcenc ] >>
2197 ]
2198 /req [ [ [ (8017) ] [ (8018) ] ] ]
2199 >>
2200 (7256) exch dup
2201 pop
2202
2203 <<
2204 /parts [
2205 << /cset /X /min 1 /max 70 /opt false /linters [ /lintpcenc ] >>
2206 ]
2207 /req [ [ [ (8018) ] ] ]
2208 >>
2209 (7257) exch dup
2210 pop
2211
2212 <<
2213 /parts [
2214 << /cset /X /min 3 /max 3 /opt false /linters [ /lintposinseqslash ] >>
2215 ]
2216 /req [ [ [ (8018) (7259) ] ] ]
2217 >>
2218 (7258) exch dup
2219 pop
2220
2221 <<
2222 /parts [
2223 << /cset /X /min 1 /max 40 /opt false /linters [ /lintpcenc ] >>
2224 ]
2225 /ex [ (7256) ]
2226 /req [ [ [ (8018) ] ] ]
2227 >>
2228 (7259) exch dup
2229 pop
2230
2231 <<
2232 /parts [
2233 << /cset /N /min 4 /max 4 /opt false /linters [ /lintnonzero ] >>
2234 << /cset /N /min 5 /max 5 /opt false /linters [ /lintnonzero ] >>
2235 << /cset /N /min 3 /max 3 /opt false /linters [ /lintnonzero ] >>
2236 << /cset /N /min 1 /max 1 /opt false /linters [ /lintwinding ] >>
2237 << /cset /N /min 1 /max 1 /opt false /linters [] >>
2238 ]
2239 /req [ [ [ (01) ] ] ]
2240 >>
2241 (8001) exch dup
2242 pop
2243
2244 <<
2245 /parts [
2246 << /cset /X /min 1 /max 20 /opt false /linters [] >>
2247 ]
2248 >>
2249 (8002) exch dup
2250 pop
2251
2252 <<
2253 /parts [
2254 << /cset /N /min 1 /max 1 /opt false /linters [ /lintzero ] >>
2255 << /cset /N /min 13 /max 13 /opt false /linters [ /lintcsum /lintgcppos1 ] >>
2256 << /cset /X /min 1 /max 16 /opt true /linters [] >>
2257 ]
2258 /dlpkey [ ]
2259 >>
2260 (8003) exch dup
2261 pop
2262
2263 <<
2264 /parts [
2265 << /cset /X /min 1 /max 30 /opt false /linters [ /lintgcppos1 ] >>
2266 ]
2267 /dlpkey [ [ (7040) ] ]
2268 >>
2269 (8004) exch dup
2270 pop
2271
2272 <<
2273 /parts [
2274 << /cset /N /min 6 /max 6 /opt false /linters [] >>
2275 ]
2276 /req [ [ [ (01) ] [ (02) ] ] ]
2277 >>
2278 (8005) exch dup
2279 pop
2280
2281 <<
2282 /parts [
2283 << /cset /N /min 14 /max 14 /opt false /linters [ /lintcsum /lintgcppos2 ] >>
2284 << /cset /N /min 4 /max 4 /opt false /linters [ /lintpieceoftotal ] >>
2285 ]
2286 /ex [ (01) (37) ]
2287 /dlpkey [ [ (22) (10) (21) ] ]
2288 >>
2289 (8006) exch dup
2290 pop
2291
2292 <<
2293 /parts [
2294 << /cset /X /min 1 /max 34 /opt false /linters [ /lintiban ] >>
2295 ]
2296 /req [ [ [ (415) ] ] ]
2297 >>
2298 (8007) exch dup
2299 pop
2300
2301 <<
2302 /parts [
2303 << /cset /N /min 6 /max 6 /opt false /linters [ /lintyymmdd ] >>
2304 << /cset /N /min 2 /max 2 /opt false /linters [ /linthh ] >>
2305 << /cset /N /min 2 /max 2 /opt true /linters [ /lintmi ] >>
2306 << /cset /N /min 2 /max 2 /opt true /linters [ /lintss ] >>
2307 ]
2308 /req [ [ [ (01) ] [ (02) ] ] ]
2309 >>
2310 (8008) exch dup
2311 pop
2312
2313 <<
2314 /parts [
2315 << /cset /X /min 1 /max 50 /opt false /linters [] >>
2316 ]
2317 /req [ [ [ (00) ] [ (01) ] ] ]
2318 >>
2319 (8009) exch dup
2320 pop
2321
2322 <<
2323 /parts [
2324 << /cset /Y /min 1 /max 30 /opt false /linters [ /lintgcppos1 ] >>
2325 ]
2326 /dlpkey [ [ (8011) ] ]
2327 >>
2328 (8010) exch dup
2329 pop
2330
2331 <<
2332 /parts [
2333 << /cset /N /min 1 /max 12 /opt false /linters [ /lintnozeroprefix ] >>
2334 ]
2335 /req [ [ [ (8010) ] ] ]
2336 /dlattr false
2337 >>
2338 (8011) exch dup
2339 pop
2340
2341 <<
2342 /parts [
2343 << /cset /X /min 1 /max 20 /opt false /linters [] >>
2344 ]
2345 /req [ [ [ (01) ] [ (8006) ] ] ]
2346 >>
2347 (8012) exch dup
2348 pop
2349
2350 <<
2351 /parts [
2352 << /cset /X /min 1 /max 25 /opt false /linters [ /lintcsumalpha /lintgcppos1 ] >>
2353 ]
2354 /dlpkey [ ]
2355 >>
2356 (8013) exch dup
2357 pop
2358
2359 <<
2360 /parts [
2361 << /cset /X /min 1 /max 25 /opt false /linters [ /lintcsumalpha /lintgcppos1 /linthasnondigit ] >>
2362 ]
2363 /req [ [ [ (01) ] ] ]
2364 /dlattr false
2365 >>
2366 (8014) exch dup
2367 pop
2368
2369 <<
2370 /parts [
2371 << /cset /N /min 18 /max 18 /opt false /linters [ /lintcsum /lintgcppos1 ] >>
2372 ]
2373 /ex [ (8018) ]
2374 /dlpkey [ [ (8019) ] ]
2375 >>
2376 (8017) exch dup
2377 pop
2378
2379 <<
2380 /parts [
2381 << /cset /N /min 18 /max 18 /opt false /linters [ /lintcsum /lintgcppos1 ] >>
2382 ]
2383 /ex [ (8017) ]
2384 /dlpkey [ [ (8019) ] ]
2385 >>
2386 (8018) exch dup
2387 pop
2388
2389 <<
2390 /parts [
2391 << /cset /N /min 1 /max 10 /opt false /linters [] >>
2392 ]
2393 /req [ [ [ (8017) ] [ (8018) ] ] ]
2394 /dlattr false
2395 >>
2396 (8019) exch dup
2397 pop
2398
2399 <<
2400 /parts [
2401 << /cset /X /min 1 /max 25 /opt false /linters [] >>
2402 ]
2403 /req [ [ [ (415) ] ] ]
2404 /dlattr false
2405 >>
2406 (8020) exch dup
2407 pop
2408
2409 <<
2410 /parts [
2411 << /cset /N /min 14 /max 14 /opt false /linters [ /lintcsum /lintgcppos2 ] >>
2412 << /cset /N /min 4 /max 4 /opt false /linters [ /lintpieceoftotal ] >>
2413 ]
2414 /ex [ (02) (8006) ]
2415 /req [ [ [ (37) ] ] ]
2416 >>
2417 (8026) exch dup
2418 pop
2419
2420 <<
2421 /parts [
2422 << /cset /Z /min 1 /max 90 /opt false /linters [] >>
2423 ]
2424 /req [ [ [ (00) ] [ (01) (21) ] [ (253) ] [ (255) ] [ (8003) ] [ (8004) ] [ (8006) (21) ] [ (8010) (8011) ] [ (8017) ] [ (8018) ] ] ]
2425 >>
2426 (8030) exch dup
2427 pop
2428
2429 <<
2430 /parts [
2431 << /cset /X /min 1 /max 70 /opt false /linters [ /lintcouponcode ] >>
2432 ]
2433 >>
2434 (8110) exch dup
2435 pop
2436
2437 <<
2438 /parts [
2439 << /cset /N /min 4 /max 4 /opt false /linters [] >>
2440 ]
2441 /req [ [ [ (255) ] ] ]
2442 >>
2443 (8111) exch dup
2444 pop
2445
2446 <<
2447 /parts [
2448 << /cset /X /min 1 /max 70 /opt false /linters [ /lintcouponposoffer ] >>
2449 ]
2450 >>
2451 (8112) exch dup
2452 pop
2453
2454 <<
2455 /parts [
2456 << /cset /X /min 1 /max 70 /opt false /linters [] >>
2457 ]
2458 /req [ [ [ (01) ] ] ]
2459 /dlattr false
2460 >>
2461 (8200) exch dup
2462 pop
2463
2464 <<
2465 /parts [
2466 << /cset /X /min 1 /max 30 /opt false /linters [] >>
2467 ]
2468 >>
2469 (90) exch dup
2470 pop
2471
2472 <<
2473 /parts [
2474 << /cset /X /min 1 /max 90 /opt false /linters [] >>
2475 ]
2476 >>
2477 (91) exch dup
2478 (92) exch dup
2479 (93) exch dup
2480 (94) exch dup
2481 (95) exch dup
2482 (96) exch dup
2483 (97) exch dup
2484 (98) exch dup
2485 (99) exch dup
2486 pop
2487
2488 >> def
2489 } ctxdef
2490
2491 % Extract AIs and vals from provided GS1 data in the indicated format
2492
2493 /ai eq { % Bracketed AI element string
2494
2495 % Parse out AIs and values
2496 (\() anchorsearch not {
2497 pop /bwipp.GS1aiMissingOpenParen (AIs must start with '\(') //raiseerror exec
2498 } if
2499 pop
2500 mark exch { % loop
2501 dup () eq {pop exit} if
2502 (\)) search not {
2503 cleartomark /bwipp.GS1aiMissingCloseParen (AIs must end with '\)') //raiseerror exec
2504 } if
2505 exch pop exch
2506 (\() search { exch pop exch } { () } ifelse
2507 } loop
2508 counttomark dup 0 gt {dup 2 idiv 1 add -1 exch {-1 roll} for} {pop} ifelse
2509 counttomark 2 idiv array astore /ais exch def
2510 counttomark array astore [ exch { % Expand ordinals of the form ^NNN to ASCII
2511 << /parse parse /parseonly true /parsefnc false >> //parseinput exec
2512 } forall ] /vals exch def
2513 pop
2514
2515 } { % Digital Link URI
2516
2517 % Validate and strip the scheme
2518 (http://) anchorsearch not {
2519 (HTTP://) anchorsearch not {
2520 (https://) anchorsearch not {
2521 (HTTPS://) anchorsearch not {
2522 pop /bwipp.GS1dlURIbadScheme (Scheme must be http:// HTTP:// https:// or HTTPS://) //raiseerror exec
2523 } if} if} if} if
2524 pop
2525
2526 % Strip the domain
2527 (/) search not {
2528 pop /bwipp.GS1dlMissingDomainOrPathInfo (URI must contain a domain and path info) //raiseerror exec
2529 } if
2530 pop pop
2531
2532 % Fragment delimits end of data
2533 (#) search {
2534 exch pop exch pop
2535 } if
2536
2537 % Query parameter marker splits path info and query parameters
2538 (?) search not {
2539 () exch null exch
2540 } if
2541 /pp exch def
2542 pop
2543 /qp exch def
2544
2545 % Find positions of character immediately following "/" in the path info
2546 mark 0
2547 0 pp {
2548 (/) search not {pop exit} if
2549 length 1 add exch pop 2 index add exch
2550 } loop
2551 counttomark 1 sub array astore /pipos exch def pop pop
2552 pipos length 1 le {
2553 /bwipp.GS1dlNoAIinfo (The path was too short to contain AI info) //raiseerror exec
2554 } if
2555
2556 % Walk backwards to find the right-most path element that is a valid dlpkey
2557 false
2558 pipos length 2 sub -2 0 {
2559 dup
2560 dup pipos exch get
2561 exch pipos exch 1 add get 1 index sub 1 sub pp 3 1 roll getinterval
2562 dup gs1syntax exch known {
2563 gs1syntax exch get /dlpkey known {
2564 exch pop true exit
2565 } if
2566 } {
2567 pop
2568 } ifelse
2569 pop
2570 } for
2571 not {
2572 /bwipp.GS1dlNoAIinfo (The path does not contain a valid primary key) //raiseerror exec
2573 } if
2574 pipos exch get dup pp length exch sub pp 3 1 roll getinterval /pp exch def
2575
2576 /uriunescape {
2577 /qq exch def % Is query parameter
2578 /in exch def
2579 /out in length string def
2580 0 0 {
2581 1 index in length ge {exit} if
2582 in 2 index get
2583 dup 43 eq qq and { % "+" -> " " in query params
2584 pop out 1 index 32 put
2585 1 add exch 1 add exch
2586 } {
2587 dup 37 eq 3 index in length 2 sub lt and { % "%nn" -> ord
2588 pop
2589 in 2 index 1 add 2 getinterval 0 exch {
2590 dup dup 48 ge exch 57 le and {48 sub} { % 0-9
2591 dup dup 65 ge exch 70 le and {55 sub} { % A-F
2592 dup dup 97 ge exch 102 le and {87 sub} { % a-f
2593 pop pop /bwipp.GS1dlBadHexCharacter (Invalid hex character) //raiseerror exec
2594 } ifelse } ifelse } ifelse
2595 exch 16 mul add
2596 } forall
2597 out exch 2 index exch put
2598 1 add exch 3 add exch
2599 } {
2600 out exch 2 index exch put
2601 1 add exch 1 add exch
2602 } ifelse } ifelse
2603 } loop
2604 out exch 0 exch getinterval /out exch def
2605 pop
2606 out
2607 } def
2608
2609 /isvaliddlpkeyseq {
2610 /in exch def
2611 false
2612 gs1syntax in 0 get get /dlpkey get {
2613 /seq exch def
2614 /i 1 def /j 0 def
2615 {
2616 i in length ge {exit} if
2617 j seq length ge {exit} if
2618 in i get seq j get eq {
2619 /i i 1 add def
2620 } if
2621 /j j 1 add def
2622 } loop
2623 i in length eq {pop true exit} if
2624 } forall
2625 } def
2626
2627 /ais 99 array def
2628 /vals 99 array def
2629 0
2630
2631 % Extract AIs from the path components
2632 pp {
2633 (/) search {
2634 ais exch 4 index exch put
2635 pop
2636 (/) search {exch pop} {() exch} ifelse
2637 vals exch 3 index exch false uriunescape put
2638 } {
2639 pop exit
2640 } ifelse
2641 exch 1 add exch
2642 } loop
2643 dup /plen exch def
2644
2645 % Validate the key-qualifiers in the path info sequence
2646 dup 1 gt {
2647 ais 0 plen getinterval isvaliddlpkeyseq not {
2648 pop /bwipp.GS1dlBadPathInfo (The AIs in the path are not a valid key-qualifier sequence for the key) //raiseerror exec
2649 } if
2650 } if
2651
2652 % Extract AIs from the query parameters
2653 qp {
2654 dup () eq {pop exit} if
2655 (&) search {exch pop} {() exch} ifelse
2656 (=) search {
2657 true 1 index {dup 48 ge exch 57 le and and} forall {
2658 ais exch 5 index exch put
2659 pop
2660 vals exch 3 index exch true uriunescape put
2661 exch 1 add exch
2662 } { % Ignore non-numeric parameters
2663 pop pop pop
2664 } ifelse
2665 } { % Ignore singletons and empty parameters
2666 pop
2667 } ifelse
2668 } loop
2669
2670 % Check for invalid DL data attributes in the query params
2671 ais plen 2 index plen sub getinterval {
2672 gs1syntax 1 index known {
2673 gs1syntax 1 index get /dlattr 2 copy known { get } { pop pop true } ifelse
2674 } {
2675 dontlint
2676 } ifelse
2677 not {
2678 dup length dup 46 add string
2679 dup 0 (AI \() putinterval
2680 dup 4 4 index putinterval
2681 dup 2 index 4 add (\) is not a valid GS1 DL URI data attribute) putinterval
2682 exch pop exch pop /bwipp.GS1dlInvalidDataAttribute exch //raiseerror exec
2683 } if
2684 pop
2685 } forall
2686
2687 % Check for valid path info attributes in query params
2688 ais plen 2 index plen sub getinterval {
2689 plen -1 1 { % Trial the query param at each non-initial path info position
2690 1 index [
2691 ais 0 plen getinterval aload pop
2692 counttomark 3 add -2 roll exch 1 roll
2693 ] isvaliddlpkeyseq {
2694 exch pop
2695 dup length dup 50 add string
2696 dup 0 (AI \() putinterval
2697 dup 4 4 index putinterval
2698 dup 2 index 4 add (\) from query params should be in the path info) putinterval
2699 exch pop exch pop /bwipp.GS1dlAttributeMustBeQualifier exch //raiseerror exec
2700 } if
2701 } for
2702 pop
2703 } forall
2704
2705 /ais ais 0 3 index getinterval def
2706 /vals vals 0 3 index getinterval def
2707 pop
2708
2709 % Expand any extracted GTINs
2710 0 1 ais length 1 sub {
2711 dup ais exch get (01) eq {
2712 dup vals exch get
2713 dup length dup 8 eq exch dup 12 eq exch 13 eq or or {
2714 (00000000000000) 14 string copy dup 3 -1 roll dup length 14 exch sub exch putinterval
2715 vals exch 2 index exch put
2716 } {
2717 pop
2718 } ifelse
2719 } if
2720 pop
2721 } for
2722
2723 } ifelse
2724
2725 % Two-digit AI prefixes not requiring FNC1 separation
2726 {
2727 /aifixed << [
2728 (00) (01) (02) (03) (04)
2729 (11) (12) (13) (14) (15) (16) (17) (18) (19) (20)
2730 % (23) % Reassigned to variable-length AI (235)!
2731 (31) (32) (33) (34) (35) (36)
2732 (41)
2733 ] {dup} forall >> def
2734 } ctxdef
2735
2736 /fncs [
2737 ais {
2738 true exch
2739 dup length 2 ge {
2740 0 2 getinterval aifixed exch known {pop false} if
2741 } {
2742 pop
2743 } ifelse
2744 } forall
2745 ] def
2746
2747
2748 % Linter routines for validating AI components
2749 {
2750 /cset82 <<
2751 0 (!"%&'\(\)*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz)
2752 { exch dup 1 add } forall pop
2753 >> def
2754
2755 /cset39 <<
2756 0 (#-/0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ)
2757 { exch dup 1 add } forall pop
2758 >> def
2759
2760 /cset32 <<
2761 0 (23456789ABCDEFGHJKLMNPQRSTUVWXYZ)
2762 { exch dup 1 add } forall pop
2763 >> def
2764
2765 /cset64 <<
2766 0 (ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_)
2767 { exch dup 1 add } forall pop
2768 >> def
2769 } ctxdef
2770
2771 /lintnumeric {
2772 true exch { dup 48 lt exch 57 gt or { pop false exit } if } forall
2773 not { pop /bwipp.GS1notNumeric (Not numeric) false exit } if
2774 } def
2775
2776 /lintcset82 {
2777 true exch { cset82 exch known not { pop false exit } if } forall
2778 not { pop /bwipp.GS1badCSET82character (Invalid CSET 82 character) false exit } if
2779 } def
2780
2781 /lintcset39 {
2782 true exch { cset39 exch known not { pop false exit } if } forall
2783 not { pop /bwipp.GS1badCSET39character (Invalid CSET 39 character) false exit } if
2784 } def
2785
2786 /lintcset64 {
2787 % Trim and validate any padding. Padding is not compulsory.
2788 dup (=) search {
2789 exch pop dup length 3 mod exch 3 1 roll false
2790 1 index 1 eq 3 index (=) eq and {pop true} if
2791 1 index 2 eq 3 index () eq and {pop true} if
2792 not { pop pop pop pop pop /bwipp.GS1badCSET64padding (Invalid CSET 64 padding) false exit } if
2793 pop pop exch
2794 } if
2795 pop
2796 % Verify the character set of the remainder
2797 true exch { cset64 exch known not { pop false exit } if } forall
2798 not { pop /bwipp.GS1badCSET64character (Invalid CSET 64 character) false exit } if
2799 } def
2800
2801 /lintgcppos1 {
2802 dup length 2 lt { pop pop /bwipp.GS1gcpTooShort (Value is too short to contain a GS1 Company Prefix) false exit } if
2803 dup 0 get dup 48 lt exch 57 gt or exch
2804 1 get dup 48 lt exch 57 gt or or {
2805 pop /bwipp.GS1badGCP (Non-numeric GS1 Company Prefix) false exit
2806 } if
2807 } def
2808
2809 /lintgcppos2 {
2810 dup length 1 lt { pop pop /bwipp.GS1valueTooShortForOffsetGCP (Value is too short to contain an offset GS1 Company Prefix) false exit } if
2811 dup length 1 sub 1 exch getinterval lintgcppos1
2812 } def
2813
2814 /lintimporteridx {
2815 (-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz)
2816 exch search not {pop pop /bwipp.GS1badImporterIndex (Invalid importer index) false exit} if
2817 pop pop pop
2818 } def
2819
2820 /lintcsum {
2821 mark exch
2822 dup length 2 mod 0 eq {3} {1} ifelse
2823 exch { 48 sub 1 index mul exch 4 exch sub } forall pop
2824 0 counttomark 1 sub {add} repeat exch pop
2825 10 mod 0 ne { pop /bwipp.GS1badChecksum (Bad checksum) false exit } if
2826 } def
2827
2828 /lintcsumalpha {
2829 dup length 2 lt { pop pop /bwipp.GS1alphaTooShort (Alphanumeric string is too short to check) false exit} if
2830 dup length 2 sub
2831 2 copy
2832 0 exch getinterval mark exch {
2833 dup cset82 exch known { cset82 exch get } { -1 exit } ifelse
2834 } forall
2835 dup -1 eq { cleartomark pop pop pop /bwipp.GS1UnknownCSET82Character (Unknown CSET 82 character) false exit} if
2836 counttomark array astore exch pop
2837 3 1 roll
2838 2 getinterval mark exch {
2839 dup cset32 exch known { cset32 exch get } { -1 exit } ifelse
2840 } forall
2841 dup -1 eq { cleartomark pop pop /bwipp.GS1UnknownCSET32Character (Unknown CSET 32 character) false exit} if
2842 counttomark array astore exch pop
2843 dup 0 get 5 bitshift exch 1 get add exch
2844 [ 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 ]
2845 1 index length
2846 dup 2 index length gt { pop pop pop pop pop /bwipp.GS1alphaTooLong (Alphanumeric string is too long to check) false exit} if
2847 0 exch getinterval {exch} forall
2848 0 exch { 3 -1 roll exch mul add } forall 1021 mod
2849 ne { pop /bwipp.GS1badAlphaCheckCharacters (Bad alphanumeric check characters) false exit} if
2850 } def
2851
2852 {
2853 /iso3166 << [
2854 /004 /008 /010 /012 /016 /020 /024 /028 /031 /032 /036 /040 /044 /048
2855 /050 /051 /052 /056 /060 /064 /068 /070 /072 /074 /076 /084 /086 /090 /092 /096
2856 /100 /104 /108 /112 /116 /120 /124 /132 /136 /140 /144 /148
2857 /152 /156 /158 /162 /166 /170 /174 /175 /178 /180 /184 /188 /191 /192 /196
2858 /203 /204 /208 /212 /214 /218 /222 /226 /231 /232 /233 /234 /238 /239 /242 /246 /248
2859 /250 /254 /258 /260 /262 /266 /268 /270 /275 /276 /288 /292 /296
2860 /300 /304 /308 /312 /316 /320 /324 /328 /332 /334 /336 /340 /344 /348
2861 /352 /356 /360 /364 /368 /372 /376 /380 /384 /388 /392 /398
2862 /400 /404 /408 /410 /414 /417 /418 /422 /426 /428 /430 /434 /438 /440 /442 /446
2863 /450 /454 /458 /462 /466 /470 /474 /478 /480 /484 /492 /496 /498 /499
2864 /500 /504 /508 /512 /516 /520 /524 /528 /531 /533 /534 /535 /540 /548
2865 /554 /558 /562 /566 /570 /574 /578 /580 /581 /583 /584 /585 /586 /591 /598
2866 /600 /604 /608 /612 /616 /620 /624 /626 /630 /634 /638 /642 /643 /646
2867 /652 /654 /659 /660 /662 /663 /666 /670 /674 /678 /682 /686 /688 /690 /694
2868 /702 /703 /704 /705 /706 /710 /716 /724 /728 /729 /732 /740 /744 /748
2869 /752 /756 /760 /762 /764 /768 /772 /776 /780 /784 /788 /792 /795 /796 /798
2870 /800 /804 /807 /818 /826 /831 /832 /833 /834 /840
2871 /850 /854 /858 /860 /862 /876 /882 /887 /894
2872 ] {dup} forall >> def
2873 } ctxdef
2874
2875 /lintiso3166 {
2876 iso3166 exch known not { pop /bwipp.GS1UnknownCountry (Unknown country code) false exit } if
2877 } def
2878
2879 /lintiso3166999 {
2880 dup /999 ne {
2881 iso3166 exch known not { pop /bwipp.GS1UnknownCountryOr999 (Unknown country code or not 999) false exit } if
2882 } {
2883 pop
2884 } ifelse
2885 } def
2886
2887 {
2888 /iso3166alpha2 << [
2889 /AD /AE /AF /AG /AI /AL /AM /AO /AQ /AR /AS /AT /AU /AW /AX /AZ
2890 /BA /BB /BD /BE /BF /BG /BH /BI /BJ /BL /BM /BN /BO /BQ /BR /BS /BT /BV /BW /BY /BZ
2891 /CA /CC /CD /CF /CG /CH /CI /CK /CL /CM /CN /CO /CR /CU /CV /CW /CX /CY /CZ
2892 /DE /DJ /DK /DM /DO /DZ
2893 /EC /EE /EG /EH /ER /ES /ET
2894 /FI /FJ /FK /FM /FO /FR
2895 /GA /GB /GD /GE /GF /GG /GH /GI /GL /GM /GN /GP /GQ /GR /GS /GT /GU /GW /GY
2896 /HK /HM /HN /HR /HT /HU
2897 /ID /IE /IL /IM /IN /IO /IQ /IR /IS /IT /JE /JM /JO /JP
2898 /KE /KG /KH /KI /KM /KN /KP /KR /KW /KY /KZ
2899 /LA /LB /LC /LI /LK /LR /LS /LT /LU /LV /LY
2900 /MA /MC /MD /ME /MF /MG /MH /MK /ML /MM /MN /MO /MP /MQ /MR /MS /MT /MU /MV /MW /MX /MY /MZ
2901 /NA /NC /NE /NF /NG /NI /NL /NO /NP /NR /NU /NZ
2902 /OM
2903 /PA /PE /PF /PG /PH /PK /PL /PM /PN /PR /PS /PT /PW /PY
2904 /QA
2905 /RE /RO /RS /RU /RW
2906 /SA /SB /SC /SD /SE /SG /SH /SI /SJ /SK /SL /SM /SN /SO /SR /SS /ST /SV /SX /SY /SZ
2907 /TC /TD /TF /TG /TH /TJ /TK /TL /TM /TN /TO /TR /TT /TV /TW /TZ
2908 /UA /UG /UM /US /UY /UZ
2909 /VA /VC /VE /VG /VI /VN /VU
2910 /WF /WS
2911 /YE /YT
2912 /ZA /ZM /ZW
2913 ] {dup} forall >> def
2914 } ctxdef
2915
2916 /lintiso3166alpha2 {
2917 iso3166alpha2 exch known not { pop /bwipp.GS1UnknownCountryAlpha (Unknown country alpha code) false exit } if
2918 } def
2919
2920 {
2921 /iso4217 << [
2922 /008 /012 /032 /036 /044 /048
2923 /050 /051 /052 /060 /064 /068 /072 /084 /090 /096
2924 /104 /108 /116 /124 /132 /136 /144
2925 /152 /156 /170 /174 /188 /191 /192
2926 /203 /208 /214 /222 /230 /232 /238 /242 /262 /270 /292
2927 /320 /324 /328 /332 /340 /344 /348
2928 /352 /356 /360 /364 /368 /376 /388 /392 /396 /398
2929 /400 /404 /408 /410 /414 /417 /418
2930 /422 /426 /430 /434 /446
2931 /454 /458 /462 /480 /484 /496 /498
2932 /504 /512 /516 /524 /532 /533 /548
2933 /554 /558 /566 /578 /586 /590 /598
2934 /600 /604 /608 /634 /643 /646 /654 /682 /690 /694
2935 /702 /704 /706 /710 /728 /748
2936 /752 /756 /760 /764 /776 /780 /784 /788
2937 /800 /807 /818 /826 /834 /840 /858 /860 /882 /886
2938 /901 /925 /927 /928 /929 /930 /931 /932 /933 /934 /936 /938
2939 /940 /941 /943 /944 /946 /947 /948 /949
2940 /950 /951 /952 /953 /955 /956 /957 /958 /959
2941 /960 /961 /962 /963 /964 /965 /967 /968 /969
2942 /970 /971 /972 /973 /975 /976 /977 /978 /979
2943 /980 /981 /984 /985 /986 /990 /994 /997 /999
2944 ] {dup} forall >> def
2945 } ctxdef
2946
2947 /lintiso4217 {
2948 iso4217 exch known not { pop /bwipp.GS1UnknownCurrency (Unknown currency code) false exit } if
2949 } def
2950
2951 /lintiso5218 {
2952 dup (0) ne exch dup (1) ne exch dup (2) ne exch (9) ne and and and {
2953 pop /bwipp.GS1biologicalSexCode (Invalid biological sex code) false exit
2954 } if
2955 } def
2956
2957 /lintiban {
2958 dup length 4 le { pop pop /bwipp.GS1tooShort (IBAN too short) false exit } if
2959 dup true exch {
2960 1 string dup 0 4 -1 roll put
2961 (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ)
2962 exch search not { pop pop false exit } if
2963 pop pop pop
2964 } forall
2965 not { pop /bwipp.GS1badIBANcharacter (Invalid IBAN character) false exit } if
2966 dup mark exch mark exch {} forall counttomark -4 roll counttomark array astore exch pop {
2967 48 sub dup 9 gt {7 sub dup 10 idiv exch 10 mod} if
2968 } forall counttomark array astore exch pop
2969 0 exch {exch 10 mul add 97 mod} forall
2970 1 ne { pop pop /bwipp.GS1badIBANchecksum (IBAN checksum incorrect) false exit } if
2971 0 2 getinterval lintiso3166alpha2
2972 } def
2973
2974 /lintzero {
2975 (0) ne { pop /bwipp.GS1zeroRequired (Zero is required) false exit } if
2976 } def
2977
2978 /lintnonzero {
2979 false exch { 48 ne {pop true} if } forall
2980 not { pop /bwipp.GS1zeroNotPermitted (Zero not permitted) false exit } if
2981 } def
2982
2983 /lintnozeroprefix {
2984 dup length 1 gt exch 0 get 48 eq and {
2985 pop /bwipp.GS1badZeroPrefix (Zero prefix is not permitted) false exit
2986 } if
2987 } def
2988
2989 /linthasnondigit {
2990 false exch { dup 48 lt exch 57 gt or {pop true exit} if } forall
2991 not { /bwipp.GS1requiresNonDigit (A non-digit character is required) false exit } if
2992 } def
2993
2994 /linthyphen {
2995 (-) ne { pop /bwipp.GS1hyphenRequired (A hyphen is required) false exit } if
2996 } def
2997
2998 /lintyyyymmd0 {
2999 dup 4 2 getinterval cvi dup 1 lt exch 12 gt or { pop /bwipp.GS1badMonth (Invalid month) false exit } if
3000 dup 0 4 getinterval cvi dup 400 mod 0 eq exch dup 4 mod 0 eq exch 100 mod 0 ne and or % Leap year?
3001 [ 31 3 -1 roll {29} {28} ifelse 31 30 31 30 31 31 30 31 30 31 ]
3002 1 index 4 2 getinterval cvi 1 sub get
3003 exch 6 2 getinterval cvi lt { pop /bwipp.GS1badDay (Invalid day of month) false exit } if
3004 } def
3005
3006 /lintyyyymmdd {
3007 dup length 8 ne { pop /bwipp.GS1badDateLength (Invalid length for yyyymmdd date) false exit } if
3008 dup 6 2 getinterval cvi 1 lt { pop /bwipp.GS1badDay (Invalid day of month) false exit } if
3009 lintyyyymmd0
3010 } def
3011
3012 /lintyymmd0 {
3013 dup 0 2 getinterval cvi dup 21 sub % Update 20YY periodically for century calculation
3014 dup 51 ge {pop (19)} { -50 le {(21)} {(20)} ifelse} ifelse exch pop % Century prefix
3015 8 string dup 0 4 -1 roll putinterval dup 2 4 -1 roll putinterval
3016 lintyyyymmd0
3017 } def
3018
3019 /lintyymmdd {
3020 dup length 6 ne { pop /bwipp.GS1badDateLength (Invalid length for yymmdd date) false exit } if
3021 dup 4 2 getinterval cvi 1 lt { pop /bwipp.GS1badDay (Invalid day of month) false exit } if
3022 lintyymmd0
3023 } def
3024
3025 /linthh {
3026 0 2 getinterval cvi 23 gt { pop pop /bwipp.GS1badHour (Invalid hour of day) false exit } if
3027 } def
3028
3029 /lintmi {
3030 0 2 getinterval cvi 59 gt { pop /bwipp.GS1badMinute (Invalid minute in the hour) false exit } if
3031 } def
3032
3033 /lintss {
3034 0 2 getinterval cvi 59 gt { pop /bwipp.GS1badSecond (Invalid second in the minute) false exit } if
3035 } def
3036
3037 /linthhmi {
3038 dup 0 2 getinterval cvi 23 gt { pop pop /bwipp.GS1badHour (Invalid hour of day) false exit } if
3039 2 2 getinterval cvi 59 gt { pop /bwipp.GS1badMinute (Invalid minute in the hour) false exit } if
3040 } def
3041
3042 /lintmmoptss {
3043 dup length dup 2 ne exch 4 ne and {
3044 pop /bwipp.GS1badTimeLength (Invalid length for optional minutes and seconds) false exit
3045 } if
3046 dup 0 2 getinterval cvi 59 gt { pop pop /bwipp.GS1badMinute (Invalid minute in the hour) false exit } if
3047 dup length 4 ge {
3048 dup 2 2 getinterval cvi 59 gt { pop pop /bwipp.GS1badSecond (Invalid second in the minute) false exit } if
3049 } if
3050 pop
3051 } def
3052
3053 /lintyesno {
3054 dup (0) ne exch (1) ne and {
3055 pop /bwipp.GS1badBoolean (Neither 0 nor 1 for yes or no) false exit
3056 } if
3057 } def
3058
3059 /lintwinding {
3060 dup (0) ne exch dup (1) ne exch (9) ne and and {
3061 pop /bwipp.GS1badWinding (Invalid winding direction) false exit
3062 } if
3063 } def
3064
3065 /lintpieceoftotal {
3066 dup length 2 mod 0 ne { pop pop /bwipp.GS1badPieceTotalLength (Invalid piece/total length) false exit } if
3067 dup dup length 2 idiv 0 exch getinterval cvi
3068 dup 0 eq { pop pop pop /bwipp.GS1badPieceNumber (Invalid piece number) false exit } if
3069 exch dup length 2 idiv dup getinterval cvi
3070 dup 0 eq { pop pop pop /bwipp.GS1badPieceTotal (Invalid total number) false exit } if
3071 gt { pop /bwipp.GS1pieceExceedsTotal (Piece number exceeds total) false exit } if
3072 } def
3073
3074 /lintposinseqslash {
3075 (/) search not {
3076 pop /bwipp.invalidPosInSeqFormat (Invalid <pos>/<end> format) false exit
3077 } if
3078 exch pop
3079 dup length 0 eq {
3080 pop pop /bwipp.invalidPosInSeqFormat (Invalid <pos>/<end> format) false exit
3081 } if
3082 1 index length 0 eq {
3083 pop pop /bwipp.invalidPosInSeqFormat (Invalid <pos>/<end> format) false exit
3084 } if
3085 dup true exch {
3086 dup 48 lt exch 57 gt or { pop false exit } if
3087 } forall
3088 not { pop pop /bwipp.positionNotNumeric (Position is not numeric) false exit } if
3089 1 index true exch {
3090 dup 48 lt exch 57 gt or { pop false exit } if
3091 } forall
3092 not { pop pop /bwipp.endNotNumeric (End is not numeric) false exit } if
3093 dup 0 get 48 eq {pop pop /bwipp.positionZeroPrefix (Position cannot have zero prefix) false exit} if
3094 1 index 0 get 48 eq {pop pop /bwipp.endZeroPrefix (End cannot have zero prefix) false exit} if
3095 cvi exch cvi exch
3096 lt {/bwipp.positionExceedsEnd (Position exceeds end) false exit} if
3097 } def
3098
3099 /lintpcenc {
3100 {
3101 (%) search not {pop exit} if
3102 pop pop dup length 2 lt { pop pop /bwipp.GS1badPercentEscape (Invalid % escape) false exit } if
3103 dup 0 2 getinterval true exch {
3104 1 string dup 0 4 -1 roll put
3105 (0123456789ABCDEFabcdef)
3106 exch search not { pop pop false exit } if
3107 pop pop pop
3108 } forall
3109 not { pop pop /bwipp.GS1badPercentChars (Invalid characters for percent encoding) false exit } if
3110 } loop
3111 } def
3112
3113 /lintcouponcode {
3114 dup true exch {
3115 dup 48 lt exch 57 gt or { pop false exit } if
3116 } forall
3117 not { pop pop /bwipp.GS1couponNotNumeric (Coupon not numeric) false exit } if
3118
3119 % GCP VLI and value
3120 dup length 1 lt {
3121 pop pop /bwipp.GS1couponTooShortGCPVLI (Coupon too short: Missing GCP VLI) false exit
3122 } if
3123 dup 0 1 getinterval cvi dup 6 gt {
3124 pop pop /bwipp.GS1couponBadGCPVLI (Coupon GCP length indicator must be 0-6) false exit
3125 } if
3126 6 add 1 add
3127 2 copy exch length gt {
3128 pop pop pop /bwipp.GS1couponTooShortGCP (Coupon too short: GCP truncated) false exit
3129 } if
3130 dup 2 index length exch sub getinterval
3131
3132 % Offer Code
3133 dup length 6 lt {
3134 pop pop /bwipp.GS1couponTooShortOfferCode (Coupon too short: Offer Code truncated) false exit
3135 } if
3136 dup length 6 sub 6 exch getinterval
3137
3138 % Save Value VLI and value
3139 dup length 1 lt {
3140 pop pop /bwipp.GS1couponTooShortSaveValueVLI (Coupon too short: Missing Save Value VLI) false exit
3141 } if
3142 dup 0 1 getinterval cvi dup dup 1 lt exch 5 gt or {
3143 pop pop /bwipp.GS1couponBadSaveValueVLI (Coupon Save Value length indicator must be 1-5) false exit
3144 } if
3145 1 add
3146 2 copy exch length gt {
3147 pop pop pop /bwipp.GS1couponTooShortSaveValue (Coupon too short: Save Value truncated) false exit
3148 } if
3149 dup 2 index length exch sub getinterval
3150
3151 % 1st Purchase Requirement VLI and value
3152 dup length 1 lt {
3153 pop pop /bwipp.GS1couponTooShort1stPurchaseRequirementVLI (Coupon too short: Missing 1st Purchase Requirement VLI) false exit
3154 } if
3155 dup 0 1 getinterval cvi dup dup 1 lt exch 5 gt or {
3156 pop pop /bwipp.GS1couponBad1stPurchaseRequirementVLI (Coupon 1st Purchase Requirement length indicator must be 1-5) false exit
3157 } if
3158 1 add
3159 2 copy exch length gt {
3160 pop pop pop /bwipp.GS1couponTooShort1stPurchaseRequirement (Coupon too short: 1st Purchase Requirement truncated) false exit
3161 } if
3162 dup 2 index length exch sub getinterval
3163
3164 % 1st Purchase Requirement Code
3165 dup length 1 lt {
3166 pop pop /bwipp.GS1couponTooShort1stPurchaseRequirementCode (Coupon too short: Missing 1st Purchase Requirement Code) false exit
3167 } if
3168 dup 0 1 getinterval cvi dup 4 gt exch 9 ne and {
3169 pop pop /bwipp.GS1couponBad1stPurchaseRequirementCode (Coupon 1st Purchase Requirement Code must be 0-4 or 9) false exit
3170 } if
3171 dup length 1 sub 1 exch getinterval
3172
3173 % 1st Purchase Family Code
3174 dup length 3 lt {
3175 pop pop /bwipp.GS1couponTooShort1stPurchaseFamilyCode (Coupon too short: 1st Purchase Family Code truncated) false exit
3176 } if
3177 dup length 3 sub 3 exch getinterval
3178
3179 % Optional field 1
3180 dup length 1 ge { dup 0 1 getinterval cvi 1 eq {
3181 1 dup 2 index length exch sub getinterval
3182
3183 % Additional Purchase Rules Code
3184 dup length 1 lt {
3185 pop pop /bwipp.GS1couponTooShortAdditionalPurchaseRulesCode (Coupon too short: Missing Additional Purchase Rules Code) false exit
3186 } if
3187 dup 0 1 getinterval cvi 3 gt {
3188 pop pop /bwipp.GS1couponBadAdditionalPurchaseRulesCode (Coupon Additional Purchase Rules Code must be 0-3) false exit
3189 } if
3190 dup length 1 sub 1 exch getinterval
3191
3192 % 2nd Purchase RequirementVLI and value
3193 dup length 1 lt {
3194 pop pop /bwipp.GS1couponTooShort2ndPurchaseRequirementVLI (Coupon too short: Missing 2nd Purchase Requirement VLI) false exit
3195 } if
3196 dup 0 1 getinterval cvi dup dup 1 lt exch 5 gt or {
3197 pop pop /bwipp.GS1couponBad2ndPurchaseRequirementVLI (Coupon 2nd Purchase Requirement length indicator must be 1-5) false exit
3198 } if
3199 1 add
3200 2 copy exch length gt {
3201 pop pop pop /bwipp.GS1couponTooShort2ndPurchaseRequirement (Coupon too short: 2nd Purchase Requirement truncated) false exit
3202 } if
3203 dup 2 index length exch sub getinterval
3204
3205 % 2nd Purchase Requirement Code
3206 dup length 1 lt {
3207 pop pop /bwipp.GS1couponTooShort2ndPurchaseRequirementCode (Coupon too short: Missing 2nd Purchase Requirement Code) false exit
3208 } if
3209 dup 0 1 getinterval cvi dup 4 gt exch 9 ne and {
3210 pop pop /bwipp.GS1couponBad2ndPurchaseRequirementCode (Coupon 2nd Purchase Requirement Code must be 0-4 or 9) false exit
3211 } if
3212 dup length 1 sub 1 exch getinterval
3213
3214 % 2nd Purchase Family Code
3215 dup length 3 lt {
3216 pop pop /bwipp.GS1couponTooShort2ndPurchaseFamilyCode (Coupon too short: 2nd Purchase Family Code truncated) false exit
3217 } if
3218 dup length 3 sub 3 exch getinterval
3219
3220 % 2nd Purchase GCP VLI and value
3221 dup length 1 lt {
3222 pop pop /bwipp.GS1couponTooShort2ndPurchaseGCPVLI (Coupon too short: Missing 2nd Purchase GCP VLI) false exit
3223 } if
3224 dup 0 1 getinterval cvi dup dup 6 gt exch 9 ne and {
3225 pop pop /bwipp.GS1couponBad2ndPurchaseGCPVLI (Coupon 2nd Purchase GCP length indicator must be 0-6 or 9) false exit
3226 } if
3227 dup 9 ne {6 add} {pop 0} ifelse 1 add
3228 2 copy exch length gt {
3229 pop pop pop /bwipp.GS1couponTooShort2ndPurchaseGCP (Coupon too short: 2nd Purchase GCP truncated) false exit
3230 } if
3231 dup 2 index length exch sub getinterval
3232
3233 } if } if
3234
3235 % Optional field 2
3236 dup length 1 ge { dup 0 1 getinterval cvi 2 eq {
3237 1 dup 2 index length exch sub getinterval
3238
3239 % 3rd Purchase RequirementVLI and value
3240 dup length 1 lt {
3241 pop pop /bwipp.GS1couponTooShort3rdPurchaseRequirementVLI (Coupon too short: Missing 3rd Purchase Requirement VLI) false exit
3242 } if
3243 dup 0 1 getinterval cvi dup dup 1 lt exch 5 gt or {
3244 pop pop /bwipp.GS1couponBad3rdPurchaseRequirementVLI (Coupon 3rd Purchase Requirement length indicator must be 1-5) false exit
3245 } if
3246 1 add
3247 2 copy exch length gt {
3248 pop pop pop /bwipp.GS1couponTooShort3rdPurchaseRequirement (Coupon too short: 3rd Purchase Requirement truncated) false exit
3249 } if
3250 dup 2 index length exch sub getinterval
3251
3252 % 3rd Purchase Requirement Code
3253 dup length 1 lt {
3254 pop pop /bwipp.GS1couponTooShort3rdPurchaseRequirementCode (Coupon too short: Missing 3rd Purchase Requirement Code) false exit
3255 } if
3256 dup 0 1 getinterval cvi dup 4 gt exch 9 ne and {
3257 pop pop /bwipp.GS1couponBad3rdPurchaseRequirementCode (Coupon 3rd Purchase Requirement Code must be 0-4 or 9) false exit
3258 } if
3259 dup length 1 sub 1 exch getinterval
3260
3261 % 3rd Purchase Family Code
3262 dup length 3 lt {
3263 pop pop /bwipp.GS1couponTooShort3rdPurchaseFamilyCode (Coupon too short: 3rd Purchase Family Code truncated) false exit
3264 } if
3265 dup length 3 sub 3 exch getinterval
3266
3267 % 3rd Purchase GCP VLI and value
3268 dup length 1 lt {
3269 pop pop /bwipp.GS1couponTooShort3rdPurchaseGCPVLI (Coupon too short: Missing 3rd Purchase GCP VLI) false exit
3270 } if
3271 dup 0 1 getinterval cvi dup dup 6 gt exch 9 ne and {
3272 pop pop /bwipp.GS1couponBad3rdPurchaseGCPVLI (Coupon 3rd Purchase GCP length indicator must be 0-6 or 9) false exit
3273 } if
3274 dup 9 ne {6 add} {pop 0} ifelse 1 add
3275 2 copy exch length gt {
3276 pop pop pop /bwipp.GS1couponTooShort3rdPurchaseGCP (Coupon too short: 3rd Purchase GCP truncated) false exit
3277 } if
3278 dup 2 index length exch sub getinterval
3279
3280 } if } if
3281
3282 % Optional field 3
3283 /couponexpire -1 def
3284 dup length 1 ge { dup 0 1 getinterval cvi 3 eq {
3285 1 dup 2 index length exch sub getinterval
3286
3287 % Expiration date
3288 dup length 6 lt {
3289 pop pop /bwipp.GS1couponTooShortExpirationDate (Coupon too short: Expiration date) false exit
3290 } if
3291 dup 2 2 getinterval cvi dup 1 lt exch 12 gt or { pop pop /bwipp.GS1couponExpirationDateBadMonth (Invalid month in expiration date) false exit } if
3292 dup 0 2 getinterval cvi dup 21 sub % Update 20YY periodically for century calculation
3293 dup 51 ge {pop 1900 add} { -50 le {2100 add} {2000 add} ifelse} ifelse % YYYY
3294 dup 400 mod 0 eq exch dup 4 mod 0 eq exch 100 mod 0 ne and or % Leap year?
3295 [ 31 3 -1 roll {29} {28} ifelse 31 30 31 30 31 31 30 31 30 31 ]
3296 1 index 2 2 getinterval cvi 1 sub get
3297 1 index 4 2 getinterval cvi dup 3 1 roll lt
3298 exch 1 lt or { pop pop /bwipp.GS1couponExpirationDateBadDay (Invalid day of month in expiration date) false exit } if
3299 dup 0 6 getinterval cvi /couponexpire exch def
3300 dup length 6 sub 6 exch getinterval
3301
3302 } if } if
3303
3304 % Optional field 4
3305 dup length 1 ge { dup 0 1 getinterval cvi 4 eq {
3306 1 dup 2 index length exch sub getinterval
3307
3308 % Start date
3309 dup length 6 lt {
3310 pop pop /bwipp.GS1couponTooShortStartDate (Coupon too short: Start date) false exit
3311 } if
3312 dup 2 2 getinterval cvi dup 1 lt exch 12 gt or { pop pop /bwipp.GS1couponStartDateBadMonth (Invalid month in start date) false exit } if
3313 dup 0 2 getinterval cvi dup 21 sub % Update 20YY periodically for century calculation
3314 dup 51 ge {pop 1900 add} { -50 le {2100 add} {2000 add} ifelse} ifelse % YYYY
3315 dup 400 mod 0 eq exch dup 4 mod 0 eq exch 100 mod 0 ne and or % Leap year?
3316 [ 31 3 -1 roll {29} {28} ifelse 31 30 31 30 31 31 30 31 30 31 ]
3317 1 index 2 2 getinterval cvi 1 sub get
3318 1 index 4 2 getinterval cvi dup 3 1 roll lt
3319 exch 1 lt or { pop pop /bwipp.GS1couponStartDateBadDay (Invalid day of month in start date) false exit } if
3320 dup 0 6 getinterval cvi /couponstart exch def
3321 couponexpire -1 ne couponexpire couponstart lt and {
3322 pop pop /bwipp.GS1couponExpireDateBeforeStartDate (Coupon expires before it starts) false exit
3323 } if
3324 dup length 6 sub 6 exch getinterval
3325
3326 } if } if
3327
3328 % Optional field 5
3329 dup length 1 ge { dup 0 1 getinterval cvi 5 eq {
3330 1 dup 2 index length exch sub getinterval
3331
3332 % Serial Number VLI and value
3333 dup length 1 lt {
3334 pop pop /bwipp.GS1couponTooShortSerialNumberVLI (Coupon too short: Missing Serial Number VLI) false exit
3335 } if
3336 dup 0 1 getinterval cvi 6 add 1 add
3337 2 copy exch length gt {
3338 pop pop pop /bwipp.GS1couponTooShortSerialNumber (Coupon too short: Serial Number truncated) false exit
3339 } if
3340 dup 2 index length exch sub getinterval
3341
3342 } if } if
3343
3344 % Optional field 6
3345 dup length 1 ge { dup 0 1 getinterval cvi 6 eq {
3346 1 dup 2 index length exch sub getinterval
3347
3348 % Retailer GCP/GLN VLI and value
3349 dup length 1 lt {
3350 pop pop /bwipp.GS1couponTooShortRetailerGCPGLNVLI (Coupon too short: Missing Retailer GCP/GLN VLI) false exit
3351 } if
3352 dup 0 1 getinterval cvi dup dup 1 lt exch 7 gt or {
3353 pop pop /bwipp.GS1couponBadRetailerGCPGLNVLI (Coupon Retailer GCP/GLN length indicator must be 1-7) false exit
3354 } if
3355 6 add 1 add
3356 2 copy exch length gt {
3357 pop pop pop /bwipp.GS1couponTooShortRetailerGCPGLN (Coupon too short: Retailer GCP/GLN truncated) false exit
3358 } if
3359 dup 2 index length exch sub getinterval
3360
3361 } if } if
3362
3363 % Optional field 9
3364 dup length 1 ge { dup 0 1 getinterval cvi 9 eq {
3365 1 dup 2 index length exch sub getinterval
3366
3367 % Save Value Code
3368 dup length 1 lt {
3369 pop pop /bwipp.GS1couponTooShortSaveValueCode (Coupon too short: Missing Save Value Code) false exit
3370 } if
3371 dup 0 1 getinterval cvi dup 6 gt exch dup 3 eq exch 4 eq or or {
3372 pop pop /bwipp.GS1couponBadSaveValueCode (Coupon Save Value Code must be 0,1,2,5 or 6) false exit
3373 } if
3374 dup length 1 sub 1 exch getinterval
3375
3376 % Save Value Applies to Item
3377 dup length 1 lt {
3378 pop pop /bwipp.GS1couponTooShortSaveValueAppliesToItem (Coupon too short: Missing Save Value Applies to Item) false exit
3379 } if
3380 dup 0 1 getinterval cvi 2 gt {
3381 pop pop /bwipp.GS1couponBadSaveValueAppliesToItem (Coupon Save Value Applies to Item must be 0-2) false exit
3382 } if
3383 dup length 1 sub 1 exch getinterval
3384
3385 % Store Coupon Flag
3386 dup length 1 lt {
3387 pop pop /bwipp.GS1couponTooShortStoreCouponFlag (Coupon too short: Missing Store Coupon Flag) false exit
3388 } if
3389 dup length 1 sub 1 exch getinterval
3390
3391 % Don't Multiply Flag
3392 dup length 1 lt {
3393 pop pop /bwipp.GS1couponTooShortDontMultiplyFlag (Coupon too short: Missing Don't Multiply Flag) false exit
3394 } if
3395 dup 0 1 getinterval cvi 1 gt {
3396 pop pop /bwipp.GS1couponBadDontMultiplyFlag (Don't Multiply Flag must be 0 or 1) false exit
3397 } if
3398 dup length 1 sub 1 exch getinterval
3399
3400 } if } if
3401
3402 dup length 0 ne {
3403 pop pop /bwipp.GS1couponUnrecognisedOptionalField (Coupon fields must be 1,2,3,4,5,6 or 9, increasing order) false exit
3404 } if
3405 pop
3406 } def
3407
3408 /lintcouponposoffer {
3409 dup true exch {
3410 dup 48 lt exch 57 gt or { pop false exit } if
3411 } forall
3412 not { pop pop /bwipp.GS1couponNotNumeric (Coupon not numeric) false exit } if
3413 % Format Code
3414 dup length 1 lt {
3415 pop pop /bwipp.GS1couponTooShortFormatCode (Coupon too short: Missing Format Code) false exit
3416 } if
3417 dup 0 1 getinterval dup (0) ne exch (1) ne and {
3418 pop pop /bwipp.GS1couponBadFormatCode (Coupon format must be 0 or 1) false exit
3419 } if
3420 dup length 1 sub 1 exch getinterval
3421 % Funder ID VLI and Funder ID
3422 dup length 1 lt {
3423 pop pop /bwipp.GS1couponTooShortFunderVLI (Coupon too short: Missing Funder VLI) false exit
3424 } if
3425 dup 0 1 getinterval cvi dup 6 gt {
3426 pop pop pop /bwipp.GS1couponBadFunderVLI (Coupon Funder length indicator must be 0-6) false exit
3427 } if
3428 6 add 1 add
3429 2 copy exch length gt {
3430 pop pop pop /bwipp.GS1couponTooShortFunder (Coupon too short: Truncated Funder ID) false exit
3431 } if
3432 dup 2 index length exch sub getinterval
3433 % Offer Code
3434 dup length 6 lt {
3435 pop pop /bwipp.GS1couponTooShortOfferCode (Coupon too short: Truncated Offer Code) false exit
3436 } if
3437 dup length 6 sub 6 exch getinterval
3438 % Serial Number VLI and Serial Number
3439 dup length 1 lt {
3440 pop pop /bwipp.GS1couponTooShortSnVLI (Coupon too short: Missing SN VLI) false exit
3441 } if
3442 dup 0 1 getinterval cvi
3443 6 add 1 add
3444 2 copy exch length gt {
3445 pop pop pop /bwipp.GS1couponTooShortSn (Coupon too short: Truncated SN) false exit
3446 } if
3447 dup 2 index length exch sub getinterval
3448 dup length 0 ne {
3449 pop pop /bwipp.GS1couponTooLong (Coupon too long) false exit
3450 } if
3451 pop
3452 } def
3453
3454 /lintlatitude {
3455 dup length 10 ne {
3456 pop /bwipp.GS1badLatitudeLength (Invalid length for a latitude) false exit
3457 } if
3458 cvi
3459 (1800000000) cvi % Workaround issue with packager
3460 gt { pop /bwipp.GS1badLatitude (Invalid value for latitude) false exit } if
3461 } def
3462
3463 /lintlongitude {
3464 dup length 10 ne {
3465 pop /bwipp.GS1badLongitudeLength (Invalid length for a longitude) false exit
3466 } if
3467 % Workaround issue with packager
3468 cvi
3469 (3600000000) cvi % Workaround issue with packager
3470 gt { pop /bwipp.GS1badLongitude (Invalid value for longitude) false exit } if
3471 } def
3472
3473 {
3474 /aidcmediatype << [
3475 /01 /02 /03 /04 /05 /06 /07 /08 /09 /10
3476 /80 /81 /82 /83 /84 /85 /86 /87 /88 /89
3477 /90 /91 /92 /93 /94 /95 /96 /97 /98 /99
3478 ] {dup} forall >> def
3479 } ctxdef
3480
3481 /lintmediatype {
3482 aidcmediatype exch known not { pop /bwipp.GS1UnknownMediaType (Unknown AIDC media type) false exit } if
3483 } def
3484
3485 {
3486 /packagetype << [
3487 /1A /1B /1D /1F /1G /1W
3488 /200 /201 /202 /203 /204 /205 /206 /210 /211 /212 /2C
3489 /3A /3H
3490 /43 /44 /4A /4B /4C /4D /4F /4G /4H
3491 /5H /5L /5M
3492 /6H /6P
3493 /7A /7B
3494 /8 /8A /8B /8C
3495 /9
3496 /AA /AB /AC /AD /AF /AG /AH /AI /AJ /AL /AM /AP /APE/AT /AV
3497 /B4 /BB /BC /BD /BE /BF /BG /BGE /BH /BI /BJ /BK /BL /BM /BME /BN /BO /BP /BQ /BR /BRI /BS /BT /BU /BV /BW /BX /BY /BZ
3498 /CA /CB /CBL /CC /CCE /CD /CE /CF /CG /CH /CI /CJ /CK /CL /CM /CN /CO /CP /CQ /CR /CS /CT /CU /CV /CW /CX /CY /CZ
3499 /DA /DB /DC /DG /DH /DI /DJ /DK /DL /DM /DN /DP /DPE /DR /DS /DT /DU /DV /DW /DX /DY
3500 /E1 /E2 /E3 /EC /ED /EE /EF /EG /EH /EI /EN
3501 /FB /FC /FD /FE /FI /FL /FO /FOB /FP /FPE /FR /FT /FW /FX
3502 /GB /GI /GL /GR /GU /GY /GZ
3503 /HA /HB /HC /HG /HN /HR
3504 /IA /IB /IC /ID /IE /IF /IG /IH /IK /IL /IN /IZ
3505 /JB /JC /JG /JR /JT /JY
3506 /KG /KI
3507 /LAB /LE /LG /LT /LU /LV /LZ
3508 /MA /MB /MC /ME /MPE /MR /MS /MT /MW /MX
3509 /NA /NE /NF /NG /NS /NT /NU /NV
3510 /OA /OB /OC /OD /OE /OF /OK /OPE /OT /OU
3511 /P2 /PA /PAE /PB /PC /PD /PE /PF /PG /PH /PI /PJ /PK /PL /PLP /PN /PO /POP /PP /PPE /PR /PT /PU /PUE /PV /PX /PY /PZ
3512 /QA /QB /QC /QD /QF /QG /QH /QJ /QK /QL /QM /QN /QP /QQ /QR /QS
3513 /RB1 /RB2 /RB3 /RCB /RD /RG /RJ /RK /RL /RO /RT /RZ
3514 /S1 /SA /SB /SC /SD /SE /SEC /SH /SI /SK /SL /SM /SO /SP /SS /ST /STL /SU /SV /SW /SX /SY /SZ
3515 /T1 /TB /TC /TD /TE /TEV /TG /THE /TI /TK /TL /TN /TO /TR /TRE /TS /TT /TTE /TU /TV /TW /TWE /TY /TZ
3516 /UC /UN /UUE
3517 /VA /VG /VI /VK /VL /VN /VO /VP /VQ /VR /VS /VY
3518 /WA /WB /WC /WD /WF /WG /WH /WJ /WK /WL /WM /WN /WP /WQ /WR /WRP /WS /WT /WU /WV /WW /WX /WY /WZ
3519 /X11 /X12 /X15 /X16 /X17 /X18 /X19 /X20 /X3 /XA /XB /XC /XD /XF /XG /XH /XJ /XK
3520 /YA /YB /YC /YD /YF /YG /YH /YJ /YK /YL /YM /YN /YP /YQ /YR /YS /YT /YV /YW /YX /YY /YZ
3521 /ZA /ZB /ZC /ZD /ZF /ZG /ZH /ZJ /ZK /ZL /ZM /ZN /ZP /ZQ /ZR /ZS /ZT /ZU /ZV /ZW /ZX /ZY /ZZ
3522 ] {dup} forall >> def
3523 } ctxdef
3524
3525 /lintpackagetype {
3526 packagetype exch known not { pop /bwipp.GS1unknownPackageType (Unknown package type) false exit } if
3527 } def
3528
3529 dontlint not {
3530
3531 % Validate AI contents
3532 true
3533 0 1 vals length 1 sub {
3534 dup ais exch get /ai exch def
3535 vals exch get /val exch def
3536 gs1syntax ai known {
3537 gs1syntax ai get /parts get
3538 % Overall length checks, e.g. to report "too long", not "checksum failure"
3539 dup 0 exch {dup /opt get {pop 0} {/min get} ifelse add} forall val length gt {
3540 pop /bwipp.GS1valueTooShort (Too short) false exit
3541 } if
3542 dup 0 exch {/max get add} forall val length lt {
3543 pop /bwipp.GS1valueTooLong (Too long) false exit
3544 } if
3545 { % Checks for each component of the AI
3546 /props exch def
3547 props /max get val length 2 copy gt {exch} if pop
3548 val exch 0 exch getinterval /eval exch def
3549 /val val eval length dup val length exch sub getinterval def
3550 eval length 0 eq {
3551 props /opt get not {
3552 pop /bwipp.GS1valueTooShort (Too short) false exit
3553 } if
3554 } {
3555 eval length props /min get lt {
3556 pop /bwipp.GS1valueTooShort (Too short) false exit
3557 } if
3558 << /N /lintnumeric /X /lintcset82 /Y /lintcset39 /Z /lintcset64 >>
3559 props /cset get get eval exch load exec
3560 props /linters get { eval exch load exec } forall
3561 } ifelse
3562 } forall
3563 dup not {exit} if
3564 val length 0 ne { % Not all data consumed by components
3565 pop /bwipp.GS1valueTooLong (Too long) false exit
3566 } if
3567 } {
3568 pop /bwipp.GS1unknownAI (Unrecognised AI) false exit
3569 } ifelse
3570 } for
3571 not {
3572 dup length ai length add 5 add string
3573 dup 0 (AI ) putinterval
3574 dup 3 ai putinterval
3575 dup 3 ai length add (: ) putinterval
3576 dup 5 ai length add 4 -1 roll putinterval
3577 //raiseerror exec
3578 } if
3579
3580 % Search for "patt" matching an AIs, excluding "this" AI
3581 /aiexists {
3582 /this exch def
3583 /patt exch def
3584 1 { % common exit
3585 aivals patt known {true exit} if % Fast path
3586 patt length 4 eq {
3587 patt 3 1 getinterval (n) eq {
3588 /pfxlen patt 2 1 getinterval (n) eq {2} {3} ifelse def
3589 false
3590 ais {
3591 dup dup this ne exch length 4 eq and {
3592 0 pfxlen getinterval patt 0 pfxlen getinterval eq {
3593 pop true
3594 } if
3595 } {
3596 pop
3597 } ifelse
3598 } forall
3599 exit
3600 } if
3601 false exit
3602 } if
3603 false exit
3604 } repeat
3605 } def
3606
3607 % Build AI dict and validate repeats
3608 /aivals vals length dict def
3609 0 1 vals length 1 sub {
3610 dup ais exch get /ai exch def
3611 vals exch get /val exch def
3612 aivals ai known {
3613 aivals ai get val ne {
3614 ai length 40 add string
3615 dup 0 (Repeated AIs \() putinterval
3616 dup 14 ai putinterval
3617 dup 14 ai length add (\) must have the same value) putinterval
3618 /bwipp.GS1repeatedDifferingAIs exch //raiseerror exec
3619 } if
3620 } {
3621 aivals ai val put
3622 } ifelse
3623 } for
3624
3625 % Validate ex and req pairings
3626 0 1 vals length 1 sub {
3627 ais exch get /ai exch def
3628 gs1syntax ai get /ex 2 copy known {
3629 get {
3630 /patt exch def
3631 patt ai aiexists {
3632 ai length patt length add 36 add string
3633 dup 0 (AIs \() putinterval
3634 dup 5 ai putinterval
3635 dup 5 ai length add (\) and \() putinterval
3636 dup 12 ai length add patt putinterval
3637 dup 12 ai length add patt length add (\) are mutually exclusive) putinterval
3638 /bwipp.GS1exclusiveAIs exch //raiseerror exec
3639 } if
3640 } forall
3641 } {
3642 pop pop
3643 } ifelse
3644 lintreqs {
3645 gs1syntax ai get /req 2 copy known {
3646 get { % For each req attribute instance
3647 false exch { % And each AI sequence alternative
3648 true exch { % Check whether all AIs in the sequence are present
3649 ai aiexists not {pop false} if
3650 } forall
3651 { pop true exit } if % Wholly matching any of the alternatives is sufficient
3652 } forall
3653 not {
3654 [
3655 gs1syntax ai get /req get
3656 { { { (+) } forall pop ( OR ) } forall pop ( WITH ) } forall pop
3657 ] dup 0 exch {length add} forall
3658 ai length 49 add dup 3 -1 roll add string exch 3 -1 roll {
3659 dup length 2 index add
3660 3 index 4 2 roll putinterval
3661 } forall pop
3662 dup 0 (One of more requisite AIs for AI \() putinterval
3663 dup 34 ai putinterval
3664 dup 34 ai length add (\) are missing: ) putinterval
3665 /bwipp.GS1missingAIs exch //raiseerror exec
3666 } if
3667 } forall
3668 } {
3669 pop pop
3670 } ifelse
3671 } if
3672 } for
3673
3674 } if % dontlint
3675
3676 ais vals fncs
3677
3678 //unloadctx exec
3679
3680 end
3681
3682 }
3683 [/barcode] {null def} forall
3684 bind def
3685 /gs1process dup load /uk.co.terryburton.bwipp defineresource pop
3686 end
3687 /setpacking where {pop setpacking} if
3688 %%EndData
3689 %%EndResource
3690 % --END RESOURCE gs1process--
3691
3692 % --BEGIN RESOURCE rendertext--
3693 % --REQUIRES preamble raiseerror--
3694 %%BeginResource: uk.co.terryburton.bwipp rendertext 0.0 2025111800 83190 81883
3695 %%BeginData: 256 ASCII Lines
3696 /setpacking where {pop currentpacking true setpacking} if
3697 10 dict
3698 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
3699 begin
3700
3701 /rendertextpositions <<
3702 % direction
3703 % x-align y-align
3704 (forward) <<
3705 (offleft) { tw neg nudge sub } (below) { th neg nudge sub }
3706 (left) { 0 } (bottom) { 0 }
3707 (xcenter) { pixx tw sub 2 div } (ycenter) { pixy th sub 2 div }
3708 (right) { pixx tw sub } (top) { pixy th sub }
3709 (offright) { pixx nudge add } (above) { pixy nudge add }
3710 >>
3711 (backward) <<
3712 (offleft) { 0 nudge sub } (below) { 0 nudge sub }
3713 (left) { tw } (bottom) { th }
3714 (xcenter) { pixx tw add 2 div } (ycenter) { pixy th add 2 div }
3715 (right) { pixx } (top) { pixy }
3716 (offright) { pixx tw add nudge add } (above) { pixy th add nudge add }
3717 >>
3718 (upward) <<
3719 (offleft) { 0 nudge sub } (below) { tw neg nudge sub }
3720 (left) { th } (bottom) { 0 }
3721 (xcenter) { pixx th add 2 div } (ycenter) { pixy tw sub 2 div }
3722 (right) { pixx } (top) { pixy tw sub }
3723 (offright) { pixx th add nudge add } (above) { pixy nudge add }
3724 >>
3725 (downward) <<
3726 (offleft) { th neg nudge sub } (below) { 0 nudge sub }
3727 (left) { 0 } (bottom) { tw }
3728 (xcenter) { pixx th sub 2 div } (ycenter) { pixy tw add 2 div }
3729 (right) { pixx th sub } (top) { pixy }
3730 (offright) { pixx nudge add } (above) { pixy tw add nudge add }
3731 >>
3732 >> def
3733
3734 % x-align y-align direction text-width text-height
3735 /rendertextpositiontext {
3736 /th exch def
3737 /tw exch def
3738 /nudge 1 def
3739 //rendertextpositions exch get dup
3740 4 -1 roll dup (center) eq {pop (xcenter)} if get exec exch
3741 3 -1 roll dup (center) eq {pop (ycenter)} if get exec
3742 } bind def
3743
3744 /rendertext {
3745
3746 % Display the text for elements in the text array
3747 includetext {
3748
3749 textcolor (unset) ne { textcolor setanycolor } if
3750
3751 textxalign (unset) eq textyalign (unset) eq and alttext () eq and {
3752 /s 0 def /fn () def
3753 txt {
3754 aload pop
3755 2 copy s ne exch fn ne or {
3756 dup 0 le {
3757 pop pop pop pop pop
3758 /bwipp.fontTooSmall (The font size is too small) //raiseerror exec
3759 } if
3760 2 copy /s exch def /fn exch def
3761 selectfont
3762 } {
3763 pop pop
3764 } ifelse
3765 moveto show
3766 } forall
3767 } {
3768
3769 alttext () eq {
3770 /txt [ txt { 0 get {} forall } forall ] def
3771 /tstr txt length string def
3772 0 1 txt length 1 sub { dup txt exch get tstr 3 1 roll put } for
3773 } {
3774 /tstr alttext def
3775 0 1 alttext length 1 sub {
3776 dup
3777 alttext exch 1 getinterval alttextsubspace exch search {
3778 alttext 4 index 32 put pop pop
3779 } if
3780 pop pop
3781 } for
3782 } ifelse
3783
3784 alttext () ne alttextsplit () ne and {
3785 alttextsplit length 1 ne {
3786 /bwipp.alttextsplitBad (The alttextsplit option must be a single character) //raiseerror exec
3787 } if
3788 /textlines [
3789 tstr { alttextsplit search { exch pop exch } { exit } ifelse } loop
3790 ] def
3791 } {
3792 /textlines [ tstr ] def
3793 } ifelse
3794
3795 textfont textsize selectfont
3796
3797 % Find true ascent of font
3798 tstr length 0 eq {
3799 0
3800 } {
3801 gsave
3802 newpath 0 0 moveto (0) false charpath pathbbox
3803 4 1 roll pop pop pop
3804 grestore
3805 currentfont /PaintType known {currentfont /PaintType get 2 eq} {false} ifelse
3806 currentfont /StrokeWidth known and {
3807 currentfont /StrokeWidth get 2 div 0 exch
3808 currentfont /FontMatrix get dtransform
3809 dup mul exch dup mul add sqrt
3810 add
3811 } if
3812 } ifelse
3813 /textascent exch def
3814
3815 /textwidth 0 textlines { stringwidth pop 2 copy lt {exch} if pop } forall tstr length 1 sub textgaps mul add def
3816 /textheight textlines length dup textascent mul exch 1 sub textlinegaps mul add def
3817
3818 textxalign (unset) eq { /textxalign (center) def } if
3819 textyalign (unset) eq { /textyalign (below) def } if
3820
3821 textxalign (justify) eq {
3822 textdirection (forward) ne textdirection (backward) ne and {
3823 /bwipp.textxjustify (textxalign=justify requires forward or backward text) //raiseerror exec
3824 } if
3825 textwidth pixx lt {
3826 /textgaps pixx textwidth sub tstr length 1 sub div def
3827 /textxalign textdirection (forward) eq { (left) } { (right) } ifelse def
3828 } {
3829 /textgaps 0.0 def
3830 /textxalign (center) def
3831 } ifelse
3832 } if
3833
3834 textyalign (justify) eq {
3835 textdirection (upward) ne textdirection (downward) ne and {
3836 /bwipp.textyjustify (textyalign=justify requires upward or downward text) //raiseerror exec
3837 } if
3838 textwidth pixy lt {
3839 /textgaps pixy textwidth sub tstr length 1 sub div def
3840 /textyalign textdirection (upward) eq { (bottom) } { (top) } ifelse def
3841 } {
3842 /textgaps 0.0 def
3843 /textyalign (center) def
3844 } ifelse
3845 } if
3846
3847 textxalign textyalign textdirection textwidth textheight //rendertextpositiontext exec moveto
3848 textxoffset textyoffset rmoveto
3849 gsave
3850 << (forward) 0 (upward) 90 (backward) 180 (downward) 270 >> textdirection get rotate
3851 currentpoint translate
3852 0 1 textlines length 1 sub {
3853 /i exch def
3854 0 0 textascent textlinegaps add i mul add moveto
3855 textgaps 0 textlines dup length i sub 1 sub get ashow
3856 } for
3857 grestore
3858
3859 } ifelse
3860
3861 } if
3862
3863 % Render any extratext
3864 extratext () ne {
3865
3866 0 1 extratext length 1 sub {
3867 dup
3868 extratext exch 1 getinterval extratextsubspace exch search {
3869 extratext 4 index 32 put pop pop
3870 } if
3871 pop pop
3872 } for
3873
3874 extratextsplit () ne {
3875 extratextsplit length 1 ne {
3876 /bwipp.extratextsplitBad (The extratextsplit option must be a single character) //raiseerror exec
3877 } if
3878 /textlines [
3879 extratext { extratextsplit search { exch pop exch } { exit } ifelse } loop
3880 ] def
3881 } {
3882 /textlines [ extratext ] def
3883 } ifelse
3884
3885 extratextcolor (unset) ne { extratextcolor setanycolor } if
3886 extratextfont extratextsize selectfont
3887
3888 % Find true ascent of font
3889 gsave
3890 newpath 0 0 moveto (0) false charpath pathbbox
3891 4 1 roll pop pop pop
3892 grestore
3893 currentfont /PaintType known {currentfont /PaintType get 2 eq} {false} ifelse
3894 currentfont /StrokeWidth known and {
3895 currentfont /StrokeWidth get 2 div 0 exch
3896 currentfont /FontMatrix get dtransform
3897 dup mul exch dup mul add sqrt
3898 add
3899 } if
3900 /textascent exch def
3901
3902 /textwidth 0 textlines { stringwidth pop 2 copy lt {exch} if pop } forall extratext length 1 sub extratextgaps mul add def
3903 /textheight textlines length dup textascent mul exch 1 sub extratextlinegaps mul add def
3904
3905 extratextxalign (justify) eq {
3906 extratextdirection (forward) ne extratextdirection (backward) ne and {
3907 /bwipp.extratextxjustify (extratextxalign=justify requires forward or backward text) //raiseerror exec
3908 } if
3909 textwidth pixx lt {
3910 /extratextgaps pixx textwidth sub extratext length 1 sub div def
3911 /extratextxalign extratextdirection (forward) eq { (left) } { (right) } ifelse def
3912 } {
3913 /extratextgaps 0.0 def
3914 /extratextxalign (center) def
3915 } ifelse
3916 } if
3917
3918 extratextyalign (justify) eq {
3919 extratextdirection (upward) ne extratextdirection (downward) ne and {
3920 /bwipp.extratextyjustify (extratextyalign=justify requires upward or downward text) //raiseerror exec
3921 } if
3922 textwidth pixy lt {
3923 /extratextgaps pixy textwidth sub extratext length 1 sub div def
3924 /extratextyalign extratextdirection (upward) eq { (bottom) } { (top) } ifelse def
3925 } {
3926 /extratextgaps 0.0 def
3927 /extratextyalign (center) def
3928 } ifelse
3929 } if
3930
3931 extratextxalign extratextyalign extratextdirection textwidth textheight //rendertextpositiontext exec moveto
3932 extratextxoffset extratextyoffset rmoveto
3933 gsave
3934 << (forward) 0 (upward) 90 (backward) 180 (downward) 270 >> extratextdirection get rotate
3935 currentpoint translate
3936 0 1 textlines length 1 sub {
3937 /i exch def
3938 0 0 textascent extratextlinegaps add i mul add moveto
3939 extratextgaps 0 textlines dup length i sub 1 sub get ashow
3940 } for
3941 grestore
3942
3943 } if
3944
3945 }
3946 [/barcode] {null def} forall
3947 bind def
3948 /rendertext dup load /uk.co.terryburton.bwipp defineresource pop
3949
3950 end
3951 /setpacking where {pop setpacking} if
3952 %%EndData
3953 %%EndResource
3954 % --END RESOURCE rendertext--
3955
3956 % --BEGIN RENDERER renlinear--
3957 % --REQUIRES preamble raiseerror processoptions rendertext--
3958 %%BeginResource: uk.co.terryburton.bwipp renlinear 0.0 2025111800 90830 89617
3959 %%BeginData: 269 ASCII Lines
3960 /setpacking where {pop currentpacking true setpacking} if
3961 10 dict
3962 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
3963 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
3964 dup /rendertext dup /uk.co.terryburton.bwipp findresource put
3965 begin
3966 /renlinear {
3967
3968 20 dict begin % Confine variables to local scope
3969
3970 % Default options
3971 /sbs [] def
3972 /bhs [] def
3973 /bbs [] def
3974 /txt [] def
3975 /includetext false def
3976 /textcolor (unset) def
3977 /textxalign (unset) def
3978 /textyalign (unset) def
3979 /textdirection (forward) def
3980 /textfont (Courier) def
3981 /textsize 10.0 def
3982 /textxoffset 0.0 def
3983 /textyoffset 0.0 def
3984 /textgaps 0.0 def
3985 /textlinegaps 1.2 def
3986 /alttext () def
3987 /alttextsplit () def
3988 /alttextsubspace () def
3989 /extratext () def
3990 /extratextsubspace () def
3991 /extratextsplit () def
3992 /extratextlinegaps 1.2 def
3993 /extratextcolor (unset) def
3994 /extratextxalign (left) def
3995 /extratextyalign (above) def
3996 /extratextdirection (forward) def
3997 /extratextfont (Courier) def
3998 /extratextsize 10.0 def
3999 /extratextxoffset 0.0 def
4000 /extratextyoffset 0.0 def
4001 /extratextgaps 0.0 def
4002 /barcolor (unset) def
4003 /backgroundcolor (unset) def
4004 /bordercolor (unset) def
4005 /inkspread 0.15 def
4006 /width 0.0 def
4007 /barratio 1.0 def
4008 /spaceratio 1.0 def
4009 /showborder false def
4010 /showbearer false def
4011 /borderleft 10.0 def
4012 /borderright 10.0 def
4013 /bordertop 0.0 def
4014 /borderbottom 0.0 def
4015 /borderwidth 0.5 def
4016 /guardwhitespace false def
4017 /guardleftpos 0.0 def
4018 /guardleftypos 0.0 def
4019 /guardrightpos 0.0 def
4020 /guardrightypos 0.0 def
4021 /guardwidth 5.0 def
4022 /guardheight 7.0 def
4023
4024 {def} forall
4025 opt currentdict /opt undef //processoptions exec pop
4026
4027 /uk.co.terryburton.bwipp.global_ctx dup where {
4028 exch get /ctx exch def
4029 barcolor (unset) eq { ctx /default_barcolor 2 copy known {get /barcolor exch def} {pop pop} ifelse } if
4030 backgroundcolor (unset) eq { ctx /default_backgroundcolor 2 copy known {get /backgroundcolor exch def} {pop pop} ifelse } if
4031 bordercolor (unset) eq { ctx /default_bordercolor 2 copy known {get /bordercolor exch def} {pop pop} ifelse } if
4032 } { pop } ifelse
4033
4034 % Input validation
4035
4036 textxalign (unset) ne {
4037 << /offleft dup /left dup /center dup /right dup /offright dup >> textxalign known not {
4038 /bwipp.renmatrixBadTextxalign (textxalign must be offleft, left, center, right or offright) //raiseerror exec
4039 } if
4040 } if
4041
4042 textyalign (unset) ne {
4043 << /above dup /top dup /center dup /bottom dup /below dup >> textyalign known not {
4044 /bwipp.renmatrixBadTextyalign (textyalign must be above, top, center, bottom or below) //raiseerror exec
4045 } if
4046 } if
4047
4048 << /forward dup /backward dup /upward dup /downward dup >> textdirection known not {
4049 /bwipp.renmatrixBadTextdirection (textdirection must be forward, backward, upward or downward) //raiseerror exec
4050 } if
4051
4052 textsize 0 le textsize 25 ge or {
4053 /bwipp.renmatrixBadTextsize (textsize must be greater than zero and less that 25) //raiseerror exec
4054 } if
4055
4056 << /offleft dup /left dup /center dup /right dup /offright dup >> extratextxalign known not {
4057 /bwipp.renmatrixBadExtratextxalign (extratextxalign must be offleft, left, center, right or offright) //raiseerror exec
4058 } if
4059
4060 << /above dup /top dup /center dup /bottom dup /below dup >> extratextyalign known not {
4061 /bwipp.renmatrixBadExtratextyalign (extratextyalign must be above, top, center, bottom or below) //raiseerror exec
4062 } if
4063
4064 << /forward dup /backward dup /upward dup /downward dup >> extratextdirection known not {
4065 /bwipp.renmatrixBadExtratextdirection (extratextdirection must be forward, backward, upward or downward) //raiseerror exec
4066 } if
4067
4068 extratextsize 0 le extratextsize 25 ge or {
4069 /bwipp.renmatrixBadTextsize (extratextsize must be greater than zero and less that 25) //raiseerror exec
4070 } if
4071
4072 % Create bar elements and put them into the bars array
4073 /bars sbs length 1 add 2 idiv array def
4074 /pixx 0 def /pixy 0 def
4075 0 1 sbs length 1 add 2 idiv 2 mul 2 sub {
4076 /i exch def
4077 i 2 mod 0 eq { % i is even
4078 /d sbs i get barratio mul barratio sub 1 add def % d = digit*r-r+1
4079 sbs i get 0 ne {
4080 /h bhs i 2 idiv get 72 mul def % Height from bhs
4081 /c d 2 div pixx add def % Centre of the bar = pixx + d/2
4082 /y bbs i 2 idiv get 72 mul def % Baseline from bbs
4083 /w d inkspread sub def % bar width = digit - inkspread
4084 bars i 2 idiv [h c y w] put % Add the bar entry
4085 h y add pixy gt {/pixy h y add def} if
4086 } {
4087 bars i 2 idiv -1 put % Dummy entry
4088 } ifelse
4089 } {
4090 /d sbs i get spaceratio mul spaceratio sub 1 add def % d = digit*r-r+1
4091 } ifelse
4092 /pixx pixx d add def % pixx += d
4093 } for
4094
4095 gsave
4096
4097 currentpoint translate
4098
4099 % Force symbol to given width
4100 width 0 ne {
4101 width 72 mul pixx div 1 scale
4102 } if
4103
4104 % Set RGB or CMYK color, or some other color by name
4105 /setanycolor {
4106 /anycolor exch def
4107 anycolor length 1 lt {
4108 /bwipp.colorEnpty (Colors must not be empty) //raiseerror exec
4109 } if
4110 anycolor 0 get 95 ne { % RGB or CMYK
4111 anycolor length dup 6 ne exch 8 ne and {
4112 /bwipp.colorBadLength (Colors must be 6 or 8 hexadecimal characters or a defined name beginning with underscore) //raiseerror exec
4113 } if
4114 mark
4115 0 2 anycolor length 1 sub {
4116 anycolor exch 2 getinterval 0 exch {
4117 dup dup 48 ge exch 57 le and {48 sub} { % 0-9
4118 dup dup 65 ge exch 70 le and {55 sub} { % A-F
4119 dup dup 97 ge exch 102 le and {87 sub} { % a-f
4120 cleartomark /bwipp.colorBadCharacter (RGB and CMYK Colors must be in hexadecimal notation) //raiseerror exec
4121 } ifelse } ifelse } ifelse
4122 exch 16 mul add
4123 } forall
4124 255 div
4125 } for
4126 counttomark
4127 dup 3 eq { /DeviceRGB } { /DeviceCMYK } ifelse
4128 exch 2 add -1 roll pop % clear mark
4129 } { % Named color beginning "_..."
4130 /uk.co.terryburton.bwipp.global_ctx dup where {exch get} {0 dict} ifelse
4131 /named_colors 2 copy known {get} {pop pop 0 dict} ifelse
4132 anycolor 2 copy known not {
4133 pop pop /bwipp.colorUnknown (Color is not defined) //raiseerror exec
4134 } if
4135 get mark exch aload pop counttomark 1 add -2 roll exch pop
4136 } ifelse
4137 { setcolorspace setcolor } stopped {
4138 /bwipp.colorFailedToSet (Failed to set color) //raiseerror exec
4139 } if
4140 } def
4141
4142 % Display the border and background
4143 showborder showbearer or {
4144 /tl [ borderleft borderwidth 2 div add neg pixy bordertop add borderwidth 2 div add ] def
4145 /tr [ pixx borderright add borderwidth 2 div add pixy bordertop add borderwidth 2 div add ] def
4146 /bl [ borderleft borderwidth 2 div add neg borderbottom borderwidth 2 div add neg ] def
4147 /br [ pixx borderright add borderwidth 2 div add borderbottom borderwidth 2 div add neg ] def
4148 } { % No need to extend background when there is no border or bearer
4149 /tl [ borderleft neg inkspread add pixy bordertop add ] def
4150 /tr [ pixx borderright add inkspread sub pixy bordertop add ] def
4151 /bl [ borderleft neg inkspread add borderbottom neg ] def
4152 /br [ pixx borderright add inkspread sub borderbottom neg ] def
4153 } ifelse
4154 backgroundcolor (unset) ne {
4155 gsave
4156 newpath bl aload pop moveto [ br tr tl ] { aload pop lineto } forall closepath
4157 backgroundcolor setanycolor fill
4158 grestore
4159 } if
4160 showbearer { % Overrides showborder
4161 gsave
4162 newpath
4163 bl aload pop moveto br aload pop lineto
4164 tl aload pop moveto tr aload pop lineto
4165 bordercolor (unset) ne { bordercolor setanycolor } if
4166 borderwidth inkspread 2 mul sub setlinewidth stroke
4167 grestore
4168 } {
4169 showborder {
4170 gsave
4171 newpath bl aload pop moveto [ br tr tl ] { aload pop lineto } forall closepath
4172 bordercolor (unset) ne { bordercolor setanycolor } if
4173 borderwidth inkspread 2 mul sub setlinewidth stroke
4174 grestore
4175 } if } ifelse
4176
4177 % Display the bars for elements in the bars array
4178 gsave
4179 barcolor (unset) ne { barcolor setanycolor } if
4180 newpath
4181 bars {
4182 dup -1 ne {
4183 aload pop % h x y w
4184 2 index 1 index 2 div sub 2 index moveto
4185 0 4 index rlineto
4186 dup 0 rlineto
4187 0 4 index neg rlineto
4188 closepath
4189 pop pop pop pop
4190 } {
4191 pop
4192 } ifelse
4193 } forall
4194 fill
4195 grestore
4196
4197 % Display the text
4198 //rendertext exec
4199
4200 % Display the guard elements
4201 guardwhitespace {
4202 0.75 setlinewidth
4203 guardleftpos 0 ne {
4204 newpath
4205 guardleftpos neg guardwidth add guardleftypos guardheight 2 div add moveto
4206 guardwidth neg guardheight -2 div rlineto
4207 guardwidth guardheight -2 div rlineto
4208 stroke
4209 } if
4210 guardrightpos 0 ne {
4211 newpath
4212 guardrightpos pixx add guardwidth sub guardrightypos guardheight 2 div add moveto
4213 guardwidth guardheight -2 div rlineto
4214 guardwidth neg guardheight -2 div rlineto
4215 stroke
4216 } if
4217 } if
4218
4219 grestore
4220
4221 end
4222
4223 }
4224 [/barcode] {null def} forall
4225 bind def
4226 /renlinear dup load /uk.co.terryburton.bwipp defineresource pop
4227 end
4228 /setpacking where {pop setpacking} if
4229 %%EndData
4230 %%EndResource
4231 % --END RENDERER renlinear--
4232
4233 % --BEGIN RENDERER renmatrix--
4234 % --REQUIRES preamble raiseerror processoptions rendertext--
4235 %%BeginResource: uk.co.terryburton.bwipp renmatrix 0.0 2025111800 107570 106302
4236 %%BeginData: 355 ASCII Lines
4237 /setpacking where {pop currentpacking true setpacking} if
4238 10 dict
4239 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
4240 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
4241 dup /rendertext dup /uk.co.terryburton.bwipp findresource put
4242 begin
4243 /renmatrix {
4244
4245 20 dict begin
4246
4247 % Default options
4248 /width 1.0 def
4249 /height 1.0 def
4250 /barcolor (unset) def
4251 /backgroundcolor (unset) def
4252 /bordercolor (unset) def
4253 /colormap (unset) def
4254 /dotty false def
4255 /inkspread null def % real sentinal
4256 /inkspreadh null def % real sentinal
4257 /inkspreadv null def % real sentinal
4258 /txt [] def
4259 /includetext false def
4260 /textcolor (unset) def
4261 /textxalign (unset) def
4262 /textyalign (unset) def
4263 /textdirection (forward) def
4264 /textfont (Courier) def
4265 /textsize 10.0 def
4266 /textxoffset 0.0 def
4267 /textyoffset 0.0 def
4268 /textgaps 0.0 def
4269 /textlinegaps 1.2 def
4270 /alttext () def
4271 /alttextsplit () def
4272 /alttextsubspace () def
4273 /extratext () def
4274 /extratextsubspace () def
4275 /extratextsplit () def
4276 /extratextlinegaps 1.2 def
4277 /extratextcolor (unset) def
4278 /extratextxalign (left) def
4279 /extratextyalign (above) def
4280 /extratextdirection (forward) def
4281 /extratextfont (Courier) def
4282 /extratextsize 10.0 def
4283 /extratextxoffset 0.0 def
4284 /extratextyoffset 0.0 def
4285 /extratextgaps 0.0 def
4286 /showborder false def
4287 /borderleft 0.0 def
4288 /borderright 0.0 def
4289 /bordertop 0.0 def
4290 /borderbottom 0.0 def
4291 /borderwidth 0.25 def
4292
4293 {def} forall
4294 opt currentdict /opt undef //processoptions exec pop
4295
4296 inkspread null eq {/inkspread 0.15 def} if
4297 inkspreadh null eq {/inkspreadh inkspread def} if
4298 inkspreadv null eq {/inkspreadv inkspread def} if
4299
4300 /uk.co.terryburton.bwipp.global_ctx dup where {
4301 exch get /ctx exch def
4302 barcolor (unset) eq { ctx /default_barcolor 2 copy known {get /barcolor exch def} {pop pop} ifelse } if
4303 backgroundcolor (unset) eq { ctx /default_backgroundcolor 2 copy known {get /backgroundcolor exch def} {pop pop} ifelse } if
4304 bordercolor (unset) eq { ctx /default_bordercolor 2 copy known {get /bordercolor exch def} {pop pop} ifelse } if
4305 } { pop } ifelse
4306
4307 % Input validation
4308
4309 textxalign (unset) ne {
4310 << /offleft dup /left dup /center dup /right dup /offright dup >> textxalign known not {
4311 /bwipp.renmatrixBadTextxalign (textxalign must be offleft, left, center, right or offright) //raiseerror exec
4312 } if
4313 } if
4314
4315 textyalign (unset) ne {
4316 << /above dup /top dup /center dup /bottom dup /below dup >> textyalign known not {
4317 /bwipp.renmatrixBadTextyalign (textyalign must be above, top, center, bottom or below) //raiseerror exec
4318 } if
4319 } if
4320
4321 << /forward dup /backward dup /upward dup /downward dup >> textdirection known not {
4322 /bwipp.renmatrixBadTextdirection (textdirection must be forward, backward, upward or downward) //raiseerror exec
4323 } if
4324
4325 textsize 0 le textsize 25 ge or {
4326 /bwipp.renmatrixBadTextsize (textsize must be greater than zero and less that 25) //raiseerror exec
4327 } if
4328
4329 << /offleft dup /left dup /center dup /right dup /offright dup >> extratextxalign known not {
4330 /bwipp.renmatrixBadExtratextxalign (extratextxalign must be offleft, left, center, right or offright) //raiseerror exec
4331 } if
4332
4333 << /above dup /top dup /center dup /bottom dup /below dup >> extratextyalign known not {
4334 /bwipp.renmatrixBadExtratextyalign (extratextyalign must be above, top, center, bottom or below) //raiseerror exec
4335 } if
4336
4337 << /forward dup /backward dup /upward dup /downward dup >> extratextdirection known not {
4338 /bwipp.renmatrixBadExtratextdirection (extratextdirection must be forward, backward, upward or downward) //raiseerror exec
4339 } if
4340
4341 extratextsize 0 le extratextsize 25 ge or {
4342 /bwipp.renmatrixBadTextsize (extratextsize must be greater than zero and less that 25) //raiseerror exec
4343 } if
4344
4345 /xyget { pixx mul add pixs exch get} def
4346 /cget { pixx mul add cache exch get and} def
4347 /cput { % Optimise by only storing "stem" corners
4348 dup 4 mod 0 eq { % dir is up or left
4349 3 1 roll pixx mul add cache exch 2 copy get 4 -1 roll or put
4350 } {
4351 pop pop pop
4352 } ifelse
4353 } def
4354
4355 /abcd {
4356 4 string 0 [
4357 5 -2 roll
4358 pixx mul add dup
4359 pixs exch 2 getinterval aload pop 3 -1 roll % A B
4360 pixs exch pixx add 2 getinterval aload pop % C D
4361 ] {3 copy 48 add put pop 1 add} forall pop
4362 } def
4363
4364 /right {dir 1 ne {x y dir cput [x y]} if /x x 1 add def /dir 1 def} def
4365 /down {dir 2 ne {x y dir cput [x y]} if /y y 1 add def /dir 2 def} def
4366 /left {dir 4 ne {x y dir cput [x y]} if /x x 1 sub def /dir 4 def} def
4367 /up {dir 8 ne {x y dir cput [x y]} if /y y 1 sub def /dir 8 def} def
4368
4369 /trace {
4370 % Walk the outline of a region emitting edge coordinates of the path
4371 /y exch def /x exch def
4372 % dir 1:right 2:down 4:left 8:up
4373 /dir x 1 add y 1 add xyget 1 eq {8} {4} ifelse def
4374 /sx x def /sy y def /sdir dir def
4375
4376 % A B
4377 % C D
4378 mark {
4379 x y abcd
4380 1 { % Common exit
4381 dup dup (0001) eq exch dup (0011) eq exch (1011) eq or or {pop right exit} if
4382 dup dup (0010) eq exch dup (1010) eq exch (1110) eq or or {pop down exit} if
4383 dup dup (1000) eq exch dup (1100) eq exch (1101) eq or or {pop left exit} if
4384 dup dup (0100) eq exch dup (0101) eq exch (0111) eq or or {pop up exit} if
4385 dup (1001) eq {
4386 dir 2 eq {pop left exit} {pop right exit} ifelse
4387 } { % 0110
4388 dir 1 eq {pop down exit} {pop up exit} ifelse
4389 } ifelse
4390 } repeat
4391 x sx eq y sy eq and dir sdir eq and {exit} if
4392 } loop
4393 counttomark array astore exch pop
4394
4395 } def
4396
4397 % Set RGB or CMYK color, or some other color by name
4398 /setanycolor {
4399 /anycolor exch def
4400 anycolor length 1 lt {
4401 /bwipp.colorEnpty (Colors must not be empty) //raiseerror exec
4402 } if
4403 anycolor 0 get 95 ne { % RGB or CMYK
4404 anycolor length dup 6 ne exch 8 ne and {
4405 /bwipp.colorBadLength (Colors must be 6 or 8 hexadecimal characters or a defined name beginning with underscore) //raiseerror exec
4406 } if
4407 mark
4408 0 2 anycolor length 1 sub {
4409 anycolor exch 2 getinterval 0 exch {
4410 dup dup 48 ge exch 57 le and {48 sub} { % 0-9
4411 dup dup 65 ge exch 70 le and {55 sub} { % A-F
4412 dup dup 97 ge exch 102 le and {87 sub} { % a-f
4413 cleartomark /bwipp.colorBadCharacter (RGB and CMYK Colors must be in hexadecimal notation) //raiseerror exec
4414 } ifelse } ifelse } ifelse
4415 exch 16 mul add
4416 } forall
4417 255 div
4418 } for
4419 counttomark
4420 dup 3 eq { /DeviceRGB } { /DeviceCMYK } ifelse
4421 exch 2 add -1 roll pop % clear mark
4422 } { % Named color beginning "_..."
4423 /uk.co.terryburton.bwipp.global_ctx dup where {exch get} {0 dict} ifelse
4424 /named_colors 2 copy known {get} {pop pop 0 dict} ifelse
4425 anycolor 2 copy known not {
4426 pop pop /bwipp.colorUnknown (Color is not defined) //raiseerror exec
4427 } if
4428 get mark exch aload pop counttomark 1 add -2 roll exch pop
4429 } ifelse
4430 { setcolorspace setcolor } stopped {
4431 /bwipp.colorFailedToSet (Failed to set color) //raiseerror exec
4432 } if
4433 } def
4434
4435 % Plot a layer of single colour
4436 /drawlayer {
4437
4438 /pixsorig pixs def
4439 /pixs exch def
4440
4441 % Pad the bitmap on all sides
4442 /pixs [
4443 pixx 2 add {0} repeat
4444 0 pixx pixs length 1 sub {
4445 0 exch
4446 pixs exch pixx getinterval aload pop
4447 0
4448 } for
4449 pixx 2 add {0} repeat
4450 ] def
4451 /pixx pixx 2 add def
4452 /pixy pixy 2 add def
4453
4454 % Cache of visited corners for each direction
4455 /cache [ pixs length {0} repeat ] def
4456
4457 % Construct paths by tracing regions avoiding duplication by using the cache
4458 /paths [
4459 0 1 pixy 2 sub {
4460 /j exch def
4461 0 1 pixx 2 sub {
4462 /i exch def
4463 /k i j abcd def
4464 k (0001) eq k (1001) eq or { % Black region stem corners
4465 8 i j cget 0 eq {
4466 i j trace
4467 } if
4468 } if
4469 k (1110) eq { % White region stem corner
4470 4 i j cget 0 eq {
4471 i j trace
4472 } if
4473 } if
4474 } for
4475 } for
4476 ] def
4477
4478 % Revert the bitmap size
4479 /pixx pixx 2 sub def
4480 /pixy pixy 2 sub def
4481
4482 % Draw the image
4483 newpath
4484 paths {
4485 /p exch def
4486 /len p length def
4487 p len 1 sub get aload pop
4488 p 0 get aload pop
4489 0 1 len 1 sub { % x1 y1 x2 y2
4490 /i exch def
4491 p i 1 add len mod get aload pop 6 -2 roll % x3 y3 x1 y1 x2 y2
4492 5 index inkspreadh
4493 4 index 4 -1 roll lt {add} {sub} ifelse % y3<y1 ? x2+i : x2-i
4494 4 1 roll
4495 4 index inkspreadv
4496 4 index 4 -1 roll gt {add} {sub} ifelse % x3>x1 ? y2+i : y2-i
4497 4 -1 roll exch pixy exch sub
4498 i 0 eq {moveto} {lineto} ifelse
4499 } for % x2 y2 x3 y3
4500 closepath
4501 pop pop pop pop
4502 } forall
4503 fill
4504
4505 /pixs pixsorig def
4506
4507 } def
4508
4509 /drawlayerdots {
4510
4511 /pixsorig pixs def
4512 /pixs exch def
4513
4514 newpath
4515 0 1 pixs length 1 sub {
4516 dup pixx mod /x exch def
4517 pixx idiv /y exch def
4518 x y xyget 1 eq {
4519 x 0.5 add pixy y sub 0.5 sub moveto
4520 x 0.5 add pixy y sub 0.5 sub 0.5 inkspread sub 0 360 arc
4521 } if
4522 } for
4523 fill
4524
4525 /pixs pixsorig def
4526
4527 } def
4528
4529 gsave
4530
4531 currentpoint translate
4532
4533 /inkspread inkspread 2 div def
4534 /inkspreadh inkspreadh 2 div def
4535 /inkspreadv inkspreadv 2 div def
4536
4537 % Force symbol to given width
4538 width pixx div 72 mul height pixy div 72 mul scale
4539
4540 % Display the border and background
4541 showborder {
4542 /tl [ borderleft borderwidth 2 div add neg pixy bordertop add borderwidth 2 div add ] def
4543 /tr [ pixx borderright add borderwidth 2 div add pixy bordertop add borderwidth 2 div add ] def
4544 /bl [ borderleft borderwidth 2 div add neg borderbottom borderwidth 2 div add neg ] def
4545 /br [ pixx borderright add borderwidth 2 div add borderbottom borderwidth 2 div add neg ] def
4546 } { % No need to extend background when there is no border
4547 /tl [ borderleft neg inkspread add pixy bordertop add inkspread sub ] def
4548 /tr [ pixx borderright add inkspread sub pixy bordertop add inkspread sub ] def
4549 /bl [ borderleft neg inkspread add borderbottom neg inkspread add ] def
4550 /br [ pixx borderright add inkspread sub borderbottom neg inkspread add ] def
4551 } ifelse
4552 backgroundcolor (unset) ne {
4553 gsave
4554 newpath bl aload pop moveto [ br tr tl ] { aload pop lineto } forall closepath
4555 backgroundcolor setanycolor fill
4556 grestore
4557 } if
4558 showborder {
4559 gsave
4560 newpath bl aload pop moveto [ br tr tl ] { aload pop lineto } forall closepath
4561 bordercolor (unset) ne { bordercolor setanycolor } if
4562 borderwidth inkspread 2 mul sub setlinewidth stroke
4563 grestore
4564 } if
4565
4566 % Display the matrix
4567 colormap (unset) eq {
4568 /colormap << 1 barcolor >> def
4569 } if
4570
4571 colormap {
4572 dup (unset) ne { setanycolor } { pop } ifelse
4573 /key exch def
4574 [
4575 pixs { key eq {1} {0} ifelse } forall
4576 ] dotty {drawlayerdots} {drawlayer} ifelse
4577 } forall
4578
4579 % Display the text
4580 //rendertext exec
4581
4582 grestore
4583
4584 end
4585
4586 }
4587 [/barcode] {null def} forall
4588 bind def
4589 /renmatrix dup load /uk.co.terryburton.bwipp defineresource pop
4590 end
4591 /setpacking where {pop setpacking} if
4592 %%EndData
4593 %%EndResource
4594 % --END RENDERER renmatrix--
4595
4596 % --BEGIN RENDERER renmaximatrix--
4597 % --REQUIRES preamble raiseerror processoptions--
4598 %%BeginResource: uk.co.terryburton.bwipp renmaximatrix 0.0 2025111800 71333 70630
4599 %%BeginData: 144 ASCII Lines
4600 /setpacking where {pop currentpacking true setpacking} if
4601 10 dict
4602 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
4603 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
4604 begin
4605 /renmaximatrix {
4606
4607 20 dict begin
4608
4609 % Default options
4610 /barcolor (unset) def
4611 /backgroundcolor (unset) def
4612 /bordercolor (unset) def
4613 /inkspread 0.15 def
4614 /showborder false def
4615 /borderleft 0.0 def
4616 /borderright 0.0 def
4617 /bordertop 0.0 def
4618 /borderbottom 0.0 def
4619 /borderwidth 0.25 def
4620
4621 {def} forall
4622 opt currentdict /opt undef //processoptions exec pop
4623
4624 /uk.co.terryburton.bwipp.global_ctx dup where {
4625 exch get /ctx exch def
4626 barcolor (unset) eq { ctx /default_barcolor 2 copy known {get /barcolor exch def} {pop pop} ifelse } if
4627 backgroundcolor (unset) eq { ctx /default_backgroundcolor 2 copy known {get /backgroundcolor exch def} {pop pop} ifelse } if
4628 bordercolor (unset) eq { ctx /default_bordercolor 2 copy known {get /bordercolor exch def} {pop pop} ifelse } if
4629 } { pop } ifelse
4630
4631 % Set RGB or CMYK color, or some other color by name
4632 /setanycolor {
4633 /anycolor exch def
4634 anycolor length 1 lt {
4635 /bwipp.colorEnpty (Colors must not be empty) //raiseerror exec
4636 } if
4637 anycolor 0 get 95 ne { % RGB or CMYK
4638 anycolor length dup 6 ne exch 8 ne and {
4639 /bwipp.colorBadLength (Colors must be 6 or 8 hexadecimal characters or a defined name beginning with underscore) //raiseerror exec
4640 } if
4641 mark
4642 0 2 anycolor length 1 sub {
4643 anycolor exch 2 getinterval 0 exch {
4644 dup dup 48 ge exch 57 le and {48 sub} { % 0-9
4645 dup dup 65 ge exch 70 le and {55 sub} { % A-F
4646 dup dup 97 ge exch 102 le and {87 sub} { % a-f
4647 cleartomark /bwipp.colorBadCharacter (RGB and CMYK Colors must be in hexadecimal notation) //raiseerror exec
4648 } ifelse } ifelse } ifelse
4649 exch 16 mul add
4650 } forall
4651 255 div
4652 } for
4653 counttomark
4654 dup 3 eq { /DeviceRGB } { /DeviceCMYK } ifelse
4655 exch 2 add -1 roll pop % clear mark
4656 } { % Named color beginning "_..."
4657 /uk.co.terryburton.bwipp.global_ctx dup where {exch get} {0 dict} ifelse
4658 /named_colors 2 copy known {get} {pop pop 0 dict} ifelse
4659 anycolor 2 copy known not {
4660 pop pop /bwipp.colorUnknown (Color is not defined) //raiseerror exec
4661 } if
4662 get mark exch aload pop counttomark 1 add -2 roll exch pop
4663 } ifelse
4664 { setcolorspace setcolor } stopped {
4665 /bwipp.colorFailedToSet (Failed to set color) //raiseerror exec
4666 } if
4667 } def
4668
4669 gsave
4670
4671 currentpoint translate
4672
4673 2.4945 dup scale % from 1pt to 0.88mm
4674
4675 % Display the border and background
4676 showborder {
4677 /tl [ borderleft borderwidth 2 div add neg 29 bordertop add borderwidth 2 div add ] def
4678 /tr [ 30 borderright add borderwidth 2 div add 29 bordertop add borderwidth 2 div add ] def
4679 /bl [ borderleft borderwidth 2 div add neg borderbottom borderwidth 2 div add neg ] def
4680 /br [ 30 borderright add borderwidth 2 div add borderbottom borderwidth 2 div add neg ] def
4681 } { % No need to extend background when there is no border
4682 /tl [ borderleft neg inkspread add 29 bordertop add inkspread sub ] def
4683 /tr [ 30 borderright add inkspread sub 29 bordertop add inkspread sub ] def
4684 /bl [ borderleft neg inkspread add borderbottom neg inkspread add ] def
4685 /br [ 30 borderright add inkspread sub borderbottom neg inkspread add ] def
4686 } ifelse
4687 backgroundcolor (unset) ne {
4688 gsave
4689 newpath bl aload pop moveto [ br tr tl ] { aload pop lineto } forall closepath
4690 backgroundcolor setanycolor fill
4691 grestore
4692 } if
4693 showborder {
4694 gsave
4695 newpath bl aload pop moveto [ br tr tl ] { aload pop lineto } forall closepath
4696 bordercolor (unset) ne { bordercolor setanycolor } if
4697 borderwidth inkspread 2 mul sub setlinewidth stroke
4698 grestore
4699 } if
4700
4701 barcolor (unset) ne { barcolor setanycolor } if
4702
4703 /g 0.06 inkspread add def
4704
4705 0.5 0.5774 translate
4706
4707 newpath
4708 pixs {
4709 dup
4710 /x exch 30 mod def
4711 /y exch 30 idiv def
4712 y 2 mod 0 eq {x} {x 0.5 add} ifelse
4713 32 y sub 0.8661 mul
4714 moveto
4715 0 0.5774 g sub rmoveto
4716 -0.5 g add -0.2887 g 2 div add rlineto
4717 0 -0.5774 g add rlineto
4718 0.5 g sub -0.2887 g 2 div add rlineto
4719 0.5 g sub 0.2887 g 2 div sub rlineto
4720 0 0.5774 g sub rlineto
4721 -0.5 g add 0.2887 g 2 div sub rlineto
4722 closepath
4723 } forall
4724 fill
4725
4726 % Plot the locator symbol
4727 newpath 14 13.8576 0.5774 inkspread add 0 360 arc closepath
4728 14 13.8576 1.3359 inkspread sub 360 0 arcn closepath fill
4729 newpath 14 13.8576 2.1058 inkspread add 0 360 arc closepath
4730 14 13.8576 2.8644 inkspread sub 360 0 arcn closepath fill
4731 newpath 14 13.8576 3.6229 inkspread add 0 360 arc closepath
4732 14 13.8576 4.3814 inkspread sub 360 0 arcn closepath fill
4733
4734 grestore
4735
4736 end
4737
4738 }
4739 [/barcode] {null def} forall
4740 bind def
4741 /renmaximatrix dup load /uk.co.terryburton.bwipp defineresource pop
4742 end
4743 /setpacking where {pop setpacking} if
4744 %%EndData
4745 %%EndResource
4746 % --END RENDERER renmaximatrix--
4747
4748 % --BEGIN ENCODER ean5--
4749 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear--
4750 % --DESC: EAN-5 (5 digit addon)
4751 % --EXAM: 90200
4752 % --EXOP: includetext guardwhitespace
4753 % --RNDR: renlinear
4754 %%BeginResource: uk.co.terryburton.bwipp ean5 0.0 2025111800 70507 70249
4755 %%BeginData: 133 ASCII Lines
4756 /setpacking where {pop currentpacking true setpacking} if
4757 10 dict
4758 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
4759 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
4760 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
4761 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
4762 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
4763 begin
4764 /ean5 {
4765
4766 20 dict begin
4767
4768 /ctx null def
4769 /dontdraw false def
4770 /includetext false def
4771 /textfont /Helvetica def
4772 /textsize 12.0 def
4773 /textxoffset 0.0 def
4774 /textyoffset null def % realtype sentinal
4775 /height 0.7 def
4776
4777 //processoptions exec /options exch def
4778 /barcode exch def
4779
4780 textyoffset null eq {
4781 /textyoffset height 72 mul 1 add def
4782 } if
4783
4784 /ean5 //loadctx exec
4785
4786 % Validate input
4787 barcode length 5 ne {
4788 /bwipp.ean5badLength (EAN-5 add-on must be 5 digits) //raiseerror exec
4789 } if
4790 barcode {
4791 dup 48 lt exch 57 gt or {
4792 /bwipp.ean5badCharacter (EAN-5 add-on must contain only digits) //raiseerror exec
4793 } if
4794 } forall
4795
4796 {
4797 % Create an array containing the character mappings
4798 /encs
4799 [ (3211) (2221) (2122) (1411) (1132)
4800 (1231) (1114) (1312) (1213) (3112)
4801 (112) (11)
4802 ] def
4803
4804 % Create a string of the available characters
4805 /barchars (0123456789) def
4806
4807 % Determine the mirror map based on mod 10 checksum
4808 /mirrormaps
4809 [ (11000) (10100) (10010) (10001) (01100)
4810 (00110) (00011) (01010) (01001) (00101)
4811 ] def
4812 } ctxdef
4813
4814 /checksum 0 def
4815 0 1 4 {
4816 /i exch def
4817 /barchar barcode i get 48 sub def
4818 i 2 mod 0 eq {
4819 /checksum barchar 3 mul checksum add def
4820 } {
4821 /checksum barchar 9 mul checksum add def
4822 } ifelse
4823 } for
4824 /checksum checksum 10 mod def
4825 /mirrormap mirrormaps checksum get def
4826
4827 /sbs 31 string def
4828 /txt 5 array def
4829
4830 0 1 4 {
4831 /i exch def
4832
4833 % Prefix with either a start character or separator character
4834 i 0 eq {
4835 sbs 0 encs 10 get putinterval
4836 } {
4837 sbs i 1 sub 6 mul 7 add encs 11 get putinterval
4838 } ifelse
4839
4840 % Lookup the encoding for the barcode character
4841 barcode i 1 getinterval barchars exch search
4842 pop % Discard true leaving pre
4843 length /indx exch def % indx is the length of pre
4844 pop pop % Discard seek and post
4845 /enc encs indx get def % Get the indxth encoding
4846 mirrormap i get 49 eq { % Reverse enc if 1 in this position in mirrormap
4847 /enclen enc length def
4848 /revenc enclen string def
4849 0 1 enclen 1 sub {
4850 /j exch def
4851 /char enc j get def
4852 revenc enclen j sub 1 sub char put
4853 } for
4854 /enc revenc def
4855 } if
4856 sbs i 6 mul 3 add enc putinterval % Put encoded digit into sbs
4857 txt i [barcode i 1 getinterval i 1 sub 9 mul 10 add textxoffset add textyoffset textfont textsize] put
4858 } for
4859
4860 % Return the arguments
4861 <<
4862 /ren /renlinear
4863 /sbs [sbs {48 sub} forall]
4864 /bhs [16{height}repeat]
4865 /bbs [16{0}repeat]
4866 includetext {
4867 /txt txt
4868 } if
4869 /opt options
4870 /guardrightpos 5.0
4871 /guardrightypos textyoffset 4 add
4872 /borderleft 12.0
4873 /borderright 5.0
4874 /bordertop 10.0
4875 >>
4876
4877 dontdraw not //renlinear if
4878
4879 //unloadctx exec
4880
4881 end
4882
4883 }
4884 [/barcode] {null def} forall
4885 bind def
4886 /ean5 dup load /uk.co.terryburton.bwipp defineresource pop
4887 end
4888 /setpacking where {pop setpacking} if
4889 %%EndData
4890 %%EndResource
4891 % --END ENCODER ean5--
4892
4893 % --BEGIN ENCODER ean2--
4894 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear--
4895 % --DESC: EAN-2 (2 digit addon)
4896 % --EXAM: 05
4897 % --EXOP: includetext guardwhitespace
4898 % --RNDR: renlinear
4899 %%BeginResource: uk.co.terryburton.bwipp ean2 0.0 2025111800 69170 68815
4900 %%BeginData: 119 ASCII Lines
4901 /setpacking where {pop currentpacking true setpacking} if
4902 10 dict
4903 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
4904 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
4905 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
4906 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
4907 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
4908 begin
4909 /ean2 {
4910
4911 20 dict begin
4912
4913 /ctx null def
4914 /dontdraw false def
4915 /includetext false def
4916 /textfont /Helvetica def
4917 /textsize 12.0 def
4918 /textxoffset 0.0 def
4919 /textyoffset null def % sentinal realtype
4920 /height 0.7 def
4921
4922 //processoptions exec /options exch def
4923 /barcode exch def
4924
4925 textyoffset null eq {
4926 /textyoffset height 72 mul 1 add def
4927 } if
4928
4929 /ean2 //loadctx exec
4930
4931 % Validate input
4932 barcode length 2 ne {
4933 /bwipp.ean2badLength (EAN-2 add-on must be 2 digits) //raiseerror exec
4934 } if
4935 barcode {
4936 dup 48 lt exch 57 gt or {
4937 /bwipp.ean2badCharacter (EAN-2 add-on must contain only digits) //raiseerror exec
4938 } if
4939 } forall
4940
4941 {
4942 % Create an array containing the character mappings
4943 /encs
4944 [ (3211) (2221) (2122) (1411) (1132)
4945 (1231) (1114) (1312) (1213) (3112)
4946 (112) (11)
4947 ] def
4948
4949 % Create a string of the available characters
4950 /barchars (0123456789) def
4951
4952 % Determine the mirror map based on mod 4 checksum
4953 /mirrormaps [(00) (01) (10) (11)] def
4954 } ctxdef
4955
4956 /mirrormap mirrormaps barcode 0 2 getinterval cvi 4 mod get def
4957
4958 /sbs 13 string def
4959 /txt 2 array def
4960
4961 0 1 1 {
4962 /i exch def
4963
4964 % Prefix with either a start character or separator character
4965 i 0 eq {
4966 sbs 0 encs 10 get putinterval
4967 } {
4968 sbs i 1 sub 6 mul 7 add encs 11 get putinterval
4969 } ifelse
4970
4971 % Lookup the encoding for the barcode character
4972 barcode i 1 getinterval barchars exch search
4973 pop % Discard true leaving pre
4974 length /indx exch def % indx is the length of pre
4975 pop pop % Discard seek and post
4976 /enc encs indx get def % Get the indxth encoding
4977 mirrormap i get 49 eq { % Reverse enc if 1 in this position in mirrormap
4978 /enclen enc length def
4979 /revenc enclen string def
4980 0 1 enclen 1 sub {
4981 /j exch def
4982 /char enc j get def
4983 revenc enclen j sub 1 sub char put
4984 } for
4985 /enc revenc def
4986 } if
4987 sbs i 6 mul 3 add enc putinterval % Put encoded digit into sbs
4988 txt i [barcode i 1 getinterval i 1 sub 9 mul 10 add textxoffset add textyoffset textfont textsize] put
4989 } for
4990
4991 % Return the arguments
4992 <<
4993 /ren /renlinear
4994 /sbs [sbs {48 sub} forall]
4995 /bhs [12{height}repeat]
4996 /bbs [12{0}repeat]
4997 includetext {
4998 /txt txt
4999 } if
5000 /opt options
5001 /guardrightpos 5.0
5002 /guardrightypos textyoffset 4 add
5003 /borderleft 12.0
5004 /borderright 5.0
5005 /bordertop 10.0
5006 >>
5007
5008 dontdraw not //renlinear if
5009
5010 //unloadctx exec
5011
5012 end
5013
5014 }
5015 [/barcode] {null def} forall
5016 bind def
5017 /ean2 dup load /uk.co.terryburton.bwipp defineresource pop
5018 end
5019 /setpacking where {pop setpacking} if
5020 %%EndData
5021 %%EndResource
5022 % --END ENCODER ean2--
5023
5024 % --BEGIN ENCODER ean13--
5025 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear ean5 ean2--
5026 % --DESC: EAN-13
5027 % --EXAM: 9520123456788
5028 % --EXOP: includetext guardwhitespace
5029 % --RNDR: renlinear
5030 %%BeginResource: uk.co.terryburton.bwipp ean13 0.0 2025111800 89019 88564
5031 %%BeginData: 208 ASCII Lines
5032 /setpacking where {pop currentpacking true setpacking} if
5033 10 dict
5034 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
5035 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
5036 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
5037 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
5038 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
5039 dup /ean2 dup /uk.co.terryburton.bwipp findresource put
5040 dup /ean5 dup /uk.co.terryburton.bwipp findresource put
5041 begin
5042 /ean13 {
5043
5044 20 dict begin
5045
5046 /ctx null def
5047 /dontdraw false def
5048 /includetext false def
5049 /textfont /Helvetica def
5050 /textsize 12.0 def
5051 /textxoffset -11.0 def
5052 /textyoffset -4.0 def
5053 /height 1.0 def
5054 /addongap 12.0 def
5055 /addontextfont (unset) def
5056 /addontextsize null def % realtype sentinal
5057 /addontextxoffset null def % realtype sentinal
5058 /addontextyoffset null def % realtype sentinal
5059
5060 //processoptions exec /options exch def
5061 /barcode exch def
5062
5063 /ean13 //loadctx exec
5064
5065 % Split off the addon
5066 barcode ( ) search {
5067 /barcode exch def
5068 pop
5069 /addon exch def
5070 } {
5071 pop
5072 /addon () def
5073 } ifelse
5074
5075 % Validate the input
5076 barcode length 12 ne barcode length 13 ne and {
5077 /bwipp.ean13badLength (EAN-13 must be 12 or 13 digits) //raiseerror exec
5078 } if
5079 barcode {
5080 dup 48 lt exch 57 gt or {
5081 /bwipp.ean13badCharacter (EAN-13 must contain only digits) //raiseerror exec
5082 } if
5083 } forall
5084 addon length 0 ne addon length 2 ne and addon length 5 ne and {
5085 /bwipp.ean13badAddOnLength (Add-on for EAN-13 must be 2 or 5 digits) //raiseerror exec
5086 } if
5087
5088 % Add checksum digit
5089 /pad 13 string def
5090 /checksum 0 def
5091 0 1 11 {
5092 /i exch def
5093 /barchar barcode i get 48 sub def
5094 i 2 mod 0 eq {
5095 /checksum barchar checksum add def
5096 } {
5097 /checksum barchar 3 mul checksum add def
5098 } ifelse
5099 } for
5100 /checksum 10 checksum 10 mod sub 10 mod def
5101 barcode length 13 eq {
5102 barcode 12 get checksum 48 add ne {
5103 /bwipp.ean13badCheckDigit (Incorrect EAN-13 check digit provided) //raiseerror exec
5104 } if
5105 } if
5106 pad 0 barcode putinterval % Add barcode to the start of the pad
5107 pad 12 checksum 48 add put % Put ascii for checksum at end of pad
5108 /barcode pad def
5109
5110 {
5111 % Create an array containing the character mappings
5112 /encs
5113 [ (3211) (2221) (2122) (1411) (1132)
5114 (1231) (1114) (1312) (1213) (3112)
5115 (111) (11111) (111)
5116 ] def
5117
5118 % Create a string of the available characters
5119 /barchars (0123456789) def
5120
5121 % Digits to mirror on left side
5122 /mirrormaps
5123 [ (000000) (001011) (001101) (001110) (010011)
5124 (011001) (011100) (010101) (010110) (011010)
5125 ] def
5126 } ctxdef
5127
5128 /sbs 59 string def
5129 /txt 13 array def
5130
5131 % Put the start character
5132 sbs 0 encs 10 get putinterval
5133
5134 % First digit - determine mirrormap by this and show before guard bars
5135 /mirrormap mirrormaps barcode 0 get 48 sub get def
5136 txt 0 [barcode 0 1 getinterval textxoffset textyoffset textfont textsize] put
5137
5138 % Left side - performs mirroring
5139 1 1 6 {
5140 % Lookup the encoding for the each barcode character
5141 /i exch def
5142 barcode i 1 getinterval barchars exch search
5143 pop % Discard true leaving pre
5144 length /indx exch def % indx is the length of pre
5145 pop pop % Discard seek and post
5146 /enc encs indx get def % Get the indxth encoding
5147 mirrormap i 1 sub get 49 eq { % Reverse enc if 1 in this position in mirrormap
5148 /enclen enc length def
5149 /revenc enclen string def
5150 0 1 enclen 1 sub {
5151 /j exch def
5152 /char enc j get def
5153 revenc enclen j sub 1 sub char put
5154 } for
5155 /enc revenc def
5156 } if
5157 sbs i 1 sub 4 mul 3 add enc putinterval % Put encoded digit into sbs
5158 txt i [barcode i 1 getinterval i 1 sub 7 mul 15 add textxoffset add textyoffset textfont textsize] put
5159 } for
5160
5161 % Put the middle character
5162 sbs 7 1 sub 4 mul 3 add encs 11 get putinterval
5163
5164 % Right side
5165 7 1 12 {
5166 % Lookup the encoding for the each barcode character
5167 /i exch def
5168 barcode i 1 getinterval barchars exch search
5169 pop % Discard true leaving pre
5170 length /indx exch def % indx is the length of pre
5171 pop pop % Discard seek and post
5172 /enc encs indx get def % Get the indxth encoding
5173 sbs i 1 sub 4 mul 8 add enc putinterval % Put encoded digit into sbs
5174 txt i [barcode i 1 getinterval i 1 sub 7 mul 19 add textxoffset add textyoffset textfont textsize] put
5175 } for
5176
5177 % Put the end character
5178 sbs 56 encs 12 get putinterval
5179
5180 /sbs [sbs {48 sub} forall] def
5181 includetext {
5182 /bhs [height height 12{height .075 sub}repeat height height 12{height .075 sub}repeat height height] def
5183 /bbs [0 0 12{.075}repeat 0 0 12{.075}repeat 0 0] def
5184 } {
5185 /bhs [30{height}repeat] def
5186 /bbs [30{0}repeat] def
5187 /txt [] def
5188 } ifelse
5189 /guardrightypos 0.0 def
5190
5191 % Append the addon
5192 addon () ne {
5193 /addopts <<
5194 /dontdraw true
5195 /includetext true
5196 /height height includetext { 0.15 sub } if
5197 /textxoffset addontextxoffset null ne {addontextxoffset} {95 addongap add} ifelse
5198 addontextyoffset null ne {/textyoffset addontextyoffset} if
5199 /textsize addontextsize null ne {addontextsize} {textsize} ifelse
5200 /textfont addontextfont (unset) ne {addontextfont} {textfont} ifelse
5201 >> def
5202 addon length 2 eq {addon addopts //ean2 exec} if
5203 addon length 5 eq {addon addopts //ean5 exec} if
5204 /addcode exch def
5205 /sbs [sbs aload pop addongap addcode (sbs) get aload pop] def
5206 /bhs [bhs aload pop addcode (bhs) get aload pop] def
5207 /bbs [bbs aload pop addcode (bbs) get aload pop] def
5208 /txt [txt aload pop addcode (txt) get aload pop] def
5209 /guardrightypos height 72 mul 6 sub def
5210 } if
5211
5212 % Return the arguments
5213 <<
5214 /ren /renlinear
5215 /sbs sbs
5216 /bhs bhs
5217 /bbs bbs
5218 /txt txt
5219 /opt options
5220 /guardrightpos addon () eq {7.0} {5.0} ifelse
5221 /guardrightypos guardrightypos
5222 /borderleft 11.0
5223 /borderright addon () eq {7.0} {5.0} ifelse
5224 /bordertop 0.0
5225 /borderbottom 5.0
5226 >>
5227
5228 dontdraw not //renlinear if
5229
5230 //unloadctx exec
5231
5232 end
5233
5234 }
5235 [/barcode] {null def} forall
5236 bind def
5237 /ean13 dup load /uk.co.terryburton.bwipp defineresource pop
5238 end
5239 /setpacking where {pop setpacking} if
5240 %%EndData
5241 %%EndResource
5242 % --END ENCODER ean13--
5243
5244 % --BEGIN ENCODER ean8--
5245 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear ean5 ean2--
5246 % --DESC: EAN-8
5247 % --EXAM: 95200002
5248 % --EXOP: includetext guardwhitespace
5249 % --RNDR: renlinear
5250 %%BeginResource: uk.co.terryburton.bwipp ean8 0.0 2025111800 87094 86521
5251 %%BeginData: 193 ASCII Lines
5252 /setpacking where {pop currentpacking true setpacking} if
5253 10 dict
5254 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
5255 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
5256 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
5257 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
5258 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
5259 dup /ean2 dup /uk.co.terryburton.bwipp findresource put
5260 dup /ean5 dup /uk.co.terryburton.bwipp findresource put
5261 begin
5262 /ean8 {
5263
5264 20 dict begin
5265
5266 /ctx null def
5267 /dontdraw false def
5268 /includetext false def % Enable/disable text
5269 /textfont /Helvetica def
5270 /textsize 12.0 def
5271 /textxoffset 4.0 def
5272 /textyoffset -4.0 def
5273 /height 1.0 def
5274 /permitaddon false def
5275 /addongap 12.0 def
5276 /addontextfont (unset) def
5277 /addontextsize null def
5278 /addontextxoffset null def % realtype sentinal
5279 /addontextyoffset null def % realtype sentinal
5280
5281 //processoptions exec /options exch def
5282 /barcode exch def
5283
5284 /ean8 //loadctx exec
5285
5286 % Split off the addon
5287 barcode ( ) search {
5288 /barcode exch def
5289 pop
5290 /addon exch def
5291 } {
5292 pop
5293 /addon () def
5294 } ifelse
5295
5296 % Validate the input
5297 barcode length 7 ne barcode length 8 ne and {
5298 /bwipp.ean8badLength (EAN-8 must be 7 or 8 digits) //raiseerror exec
5299 } if
5300 barcode {
5301 dup 48 lt exch 57 gt or {
5302 /bwipp.ean8badCharacter (EAN-8 must contain only digits) //raiseerror exec
5303 } if
5304 } forall
5305 addon length 0 ne addon length 2 ne and addon length 5 ne and {
5306 /bwipp.ean8badAddOnLength (Add-on for EAN-8 must be 2 or 5 digits) //raiseerror exec
5307 } if
5308 permitaddon not addon length 0 ne and {
5309 /bwipp.ean8badAddOnLength (Non-standard use of add-on for EAN-8 requires "permitaddon" option) //raiseerror exec
5310 } if
5311
5312 % Add checksum digit
5313 /pad 8 string def
5314 /checksum 0 def
5315 0 1 6 {
5316 /i exch def
5317 /barchar barcode i get 48 sub def
5318 i 2 mod 0 ne {
5319 /checksum barchar checksum add def
5320 } {
5321 /checksum barchar 3 mul checksum add def
5322 } ifelse
5323 } for
5324 /checksum 10 checksum 10 mod sub 10 mod def
5325 barcode length 8 eq {
5326 barcode 7 get checksum 48 add ne {
5327 /bwipp.ean8badCheckDigit (Incorrect EAN-8 check digit provided) //raiseerror exec
5328 } if
5329 } if
5330 pad 0 barcode putinterval % Add barcode to the start of the pad
5331 pad 7 checksum 48 add put % Put ascii for checksum at end of pad
5332 /barcode pad def
5333
5334 % Create an array containing the character mappings
5335 {
5336 /encs
5337 [ (3211) (2221) (2122) (1411) (1132)
5338 (1231) (1114) (1312) (1213) (3112)
5339 (111) (11111) (111)
5340 ] def
5341
5342 % Create a string of the available characters
5343 /barchars (0123456789) def
5344 } ctxdef
5345
5346 /sbs 43 string def
5347 /txt 8 array def
5348
5349 % Put the start character
5350 sbs 0 encs 10 get putinterval
5351
5352 % Left side
5353 0 1 3 {
5354 % Lookup the encoding for the each barcode character
5355 /i exch def
5356 barcode i 1 getinterval barchars exch search
5357 pop % Discard true leaving pre
5358 length /indx exch def % indx is the length of pre
5359 pop pop % Discard seek and post
5360 /enc encs indx get def % Get the indxth encoding
5361 sbs i 4 mul 3 add enc putinterval % Put encoded digit into sbs
5362 txt i [barcode i 1 getinterval i 7 mul textxoffset add textyoffset textfont textsize] put
5363 } for
5364
5365 % Put the middle character
5366 sbs 4 4 mul 3 add encs 11 get putinterval
5367
5368 % Right side
5369 4 1 7 {
5370 % Lookup the encoding for the each barcode character
5371 /i exch def
5372 barcode i 1 getinterval barchars exch search
5373 pop % Discard true leaving pre
5374 length /indx exch def % indx is the length of pre
5375 pop pop % Discard seek and post
5376 /enc encs indx get def % Get the indxth encoding
5377 sbs i 4 mul 8 add enc putinterval % Put encoded digit into sbs
5378 txt i [barcode i 1 getinterval i 7 mul textxoffset add 4 add textyoffset textfont textsize] put
5379 } for
5380
5381 % Put the end character
5382 sbs 40 encs 12 get putinterval
5383
5384 /sbs [sbs {48 sub} forall] def
5385 includetext {
5386 /bhs [height height 8{height .075 sub}repeat height height 8{height .075 sub}repeat height height] def
5387 /bbs [0 0 8{.075}repeat 0 0 8{.075}repeat 0 0] def
5388 } {
5389 /bhs [22{height}repeat] def
5390 /bbs [22{0}repeat] def
5391 /txt [] def
5392 } ifelse
5393 /guardrightypos 0.0 def
5394
5395 % Append the addon
5396 addon () ne {
5397 /addopts <<
5398 /dontdraw true
5399 /includetext true
5400 /height height includetext { 0.15 sub } if
5401 /textxoffset addontextxoffset null ne {addontextxoffset} {67 addongap add} ifelse
5402 addontextyoffset null ne {/textyoffset addontextyoffset} if
5403 /textsize addontextsize null ne {addontextsize} {textsize} ifelse
5404 /textfont addontextfont (unset) ne {addontextfont} {textfont} ifelse
5405 >> def
5406 addon length 2 eq {addon addopts //ean2 exec} if
5407 addon length 5 eq {addon addopts //ean5 exec} if
5408 /addcode exch def
5409 /sbs [sbs aload pop addongap addcode (sbs) get aload pop] def
5410 /bhs [bhs aload pop addcode (bhs) get aload pop] def
5411 /bbs [bbs aload pop addcode (bbs) get aload pop] def
5412 /txt [txt aload pop addcode (txt) get aload pop] def
5413 /guardrightypos height 72 mul 6 sub def
5414 } if
5415
5416 % Return the arguments
5417 <<
5418 /ren /renlinear
5419 /sbs sbs
5420 /bhs bhs
5421 /bbs bbs
5422 /txt txt
5423 /opt options
5424 /guardleftpos 7.0
5425 /guardrightpos addon () eq {7.0} {5.0} ifelse
5426 /guardrightypos guardrightypos
5427 /borderleft 7.0
5428 /borderright addon () eq {7.0} {5.0} ifelse
5429 /bordertop 0.0
5430 /borderbottom 5.0
5431 >>
5432
5433 dontdraw not //renlinear if
5434
5435 //unloadctx exec
5436
5437 end
5438
5439 }
5440 [/barcode] {null def} forall
5441 bind def
5442 /ean8 dup load /uk.co.terryburton.bwipp defineresource pop
5443 end
5444 /setpacking where {pop setpacking} if
5445 %%EndData
5446 %%EndResource
5447 % --END ENCODER ean8--
5448
5449 % --BEGIN ENCODER upca--
5450 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear ean5 ean2--
5451 % --DESC: UPC-A
5452 % --EXAM: 012345000058
5453 % --EXOP: includetext
5454 % --RNDR: renlinear
5455 %%BeginResource: uk.co.terryburton.bwipp upca 0.0 2025111800 93908 93371
5456 %%BeginData: 241 ASCII Lines
5457 /setpacking where {pop currentpacking true setpacking} if
5458 10 dict
5459 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
5460 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
5461 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
5462 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
5463 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
5464 dup /ean2 dup /uk.co.terryburton.bwipp findresource put
5465 dup /ean5 dup /uk.co.terryburton.bwipp findresource put
5466 begin
5467 /upca {
5468
5469 20 dict begin
5470
5471 /ctx null def
5472 /dontdraw false def
5473 /includetext false def
5474 /textfont /Helvetica def
5475 /textsize 12.0 def
5476 /textxoffset -9.0 def
5477 /textyoffset -4.0 def
5478 /height 1.0 def
5479 /addongap 12.0 def
5480 /addontextfont (unset) def
5481 /addontextsize null def % sentinal realtype
5482 /addontextxoffset null def % sentinal realtype
5483 /addontextyoffset null def % sentinal realtype
5484
5485 //processoptions exec /options exch def
5486 /barcode exch def
5487
5488 /upca //loadctx exec
5489
5490 % Split off the addon
5491 barcode ( ) search {
5492 /barcode exch def
5493 pop
5494 /addon exch def
5495 } {
5496 pop
5497 /addon () def
5498 } ifelse
5499
5500 % Expand a given UPC-E
5501 barcode length 7 eq barcode length 8 eq or {
5502 % Validate the input
5503 barcode {
5504 dup 48 lt exch 57 gt or {
5505 /bwipp.upcAupcEbadCharacter (UPC-E must contain only digits) //raiseerror exec
5506 } if
5507 } forall
5508 barcode 0 get dup 48 ne exch 49 ne and {
5509 /bwipp.upcAupcEbadNumberSystem (UPC-E must have number system 0 or 1) //raiseerror exec
5510 } if
5511 1 { % Common exit
5512 /upcacode barcode length 8 eq {12} {11} ifelse string def
5513 barcode 6 get 48 sub 2 le {
5514 upcacode 0 barcode 0 3 getinterval putinterval
5515 upcacode 3 barcode 6 1 getinterval putinterval
5516 upcacode 4 (0000) putinterval
5517 upcacode 8 barcode 3 3 getinterval putinterval
5518 exit
5519 } if
5520 barcode 6 get 48 sub 3 eq {
5521 upcacode 0 barcode 0 4 getinterval putinterval
5522 upcacode 4 (00000) putinterval
5523 upcacode 9 barcode 4 2 getinterval putinterval
5524 exit
5525 } if
5526 barcode 6 get 48 sub 4 eq {
5527 upcacode 0 barcode 0 5 getinterval putinterval
5528 upcacode 5 (00000) putinterval
5529 upcacode 10 barcode 5 1 getinterval putinterval
5530 exit
5531 } if
5532 barcode 6 get 48 sub 5 ge {
5533 upcacode 0 barcode 0 6 getinterval putinterval
5534 upcacode 6 (0000) putinterval
5535 upcacode 10 barcode 6 1 getinterval putinterval
5536 exit
5537 } if
5538 } repeat
5539 barcode length 8 eq {
5540 upcacode 11 barcode 7 1 getinterval putinterval
5541 } if
5542 /barcode upcacode def
5543 } if
5544
5545 % Validate the input
5546 barcode length 11 ne barcode length 12 ne and {
5547 /bwipp.upcAbadLength (UPC-A must be 11 or 12 digits) //raiseerror exec
5548 } if
5549 barcode {
5550 dup 48 lt exch 57 gt or {
5551 /bwipp.upcAbadCharacter (UPC-A must contain only digits) //raiseerror exec
5552 } if
5553 } forall
5554 addon length 0 ne addon length 2 ne and addon length 5 ne and {
5555 /bwipp.upcAbadAddOnLength (Add-on for UPC-A must be 2 or 5 digits) //raiseerror exec
5556 } if
5557
5558 % Add checksum digit to barcode
5559 /pad 12 string def % Create pad one bigger than barcode
5560 /checksum 0 def
5561 0 1 10 {
5562 /i exch def
5563 /barchar barcode i get 48 sub def
5564 i 2 mod 0 ne {
5565 /checksum checksum barchar add def
5566 } {
5567 /checksum checksum barchar 3 mul add def
5568 } ifelse
5569 } for
5570 /checksum 10 checksum 10 mod sub 10 mod def
5571 barcode length 12 eq {
5572 barcode 11 get checksum 48 add ne {
5573 /bwipp.upcAbadCheckDigit (Incorrect UPC check digit provided) //raiseerror exec
5574 } if
5575 } if
5576 pad 0 barcode putinterval % Add barcode to the start of the pad
5577 pad 11 checksum 48 add put % Put ascii for checksum at end of pad
5578 /barcode pad def
5579
5580 % Create an array containing the character mappings
5581 {
5582 /encs
5583 [ (3211) (2221) (2122) (1411) (1132)
5584 (1231) (1114) (1312) (1213) (3112)
5585 (111) (11111) (111)
5586 ] def
5587
5588 % Create a string of the available characters
5589 /barchars (0123456789) def
5590 } ctxdef
5591
5592 /sbs 59 string def
5593 /txt 12 array def
5594
5595 % Put the start character
5596 sbs 0 encs 10 get putinterval
5597
5598 % Left side
5599 0 1 5 {
5600 % Lookup the encoding for the each barcode character
5601 /i exch def
5602 barcode i 1 getinterval barchars exch search
5603 pop % Discard true leaving pre
5604 length /indx exch def % indx is the length of pre
5605 pop pop % Discard seek and post
5606 /enc encs indx get def % Get the indxth encoding
5607 sbs i 4 mul 3 add enc putinterval % Put encoded digit into sbs
5608 i 0 eq { % First digit is before the guard bars
5609 txt 0 [barcode 0 1 getinterval textxoffset textyoffset textfont textsize 2 sub] put
5610 } {
5611 txt i [barcode i 1 getinterval i 7 mul 13 add textxoffset add textyoffset textfont textsize] put
5612 } ifelse
5613 } for
5614
5615 % Put the middle character
5616 sbs 6 4 mul 3 add encs 11 get putinterval
5617
5618 % Right side
5619 6 1 11 {
5620 % Lookup the encoding for the each barcode character
5621 /i exch def
5622 barcode i 1 getinterval barchars exch search
5623 pop % Discard true leaving pre
5624 length /indx exch def % indx is the length of pre
5625 pop pop % Discard seek and post
5626 /enc encs indx get def % Get the indxth encoding
5627 sbs i 4 mul 8 add enc putinterval % Put encoded digit into sbs
5628 i 11 eq { % Last digit is after guard bars
5629 txt 11 [barcode 11 1 getinterval textxoffset 107 add textyoffset textfont textsize 2 sub] put
5630 } {
5631 txt i [barcode i 1 getinterval i 7 mul textxoffset add 17 add textyoffset textfont textsize] put
5632 } ifelse
5633 } for
5634
5635 % Put the end character
5636 sbs 56 encs 12 get putinterval
5637
5638 /sbs [sbs {48 sub} forall] def
5639 includetext {
5640 /bhs [4{height}repeat 10{height .075 sub}repeat height height 10{height .075 sub}repeat 4{height}repeat] def
5641 /bbs [0 0 0 0 10{.075}repeat 0 0 10{.075}repeat 0 0 0 0] def
5642 } {
5643 /bhs [30{height}repeat] def
5644 /bbs [30{0}repeat] def
5645 /txt [] def
5646 } ifelse
5647 /guardrightypos 0.0 def
5648
5649 % Append the addon
5650 addon () ne {
5651 /addopts <<
5652 /dontdraw true
5653 /includetext true
5654 /height height includetext { 0.15 sub } if
5655 /textxoffset addontextxoffset null ne {addontextxoffset} {95 addongap add} ifelse
5656 addontextyoffset null ne {/textyoffset addontextyoffset} if
5657 /textsize addontextsize null ne {addontextsize} {textsize} ifelse
5658 /textfont addontextfont (unset) ne {addontextfont} {textfont} ifelse
5659 >> def
5660 addon length 2 eq {addon addopts //ean2 exec} if
5661 addon length 5 eq {addon addopts //ean5 exec} if
5662 /addcode exch def
5663 /sbs [sbs aload pop addongap addcode (sbs) get aload pop] def
5664 /bhs [bhs aload pop addcode (bhs) get aload pop] def
5665 /bbs [bbs aload pop addcode (bbs) get aload pop] def
5666 /txt [txt aload pop addcode (txt) get aload pop] def
5667 /guardrightypos height 72 mul 6 sub def
5668 } if
5669
5670 % Return the arguments
5671 <<
5672 /ren /renlinear
5673 /sbs sbs
5674 /bhs bhs
5675 /bbs bbs
5676 /txt txt
5677 /opt options
5678 /guardrightpos addon () eq {9.0} {5.0} ifelse
5679 /guardrightypos guardrightypos
5680 /borderleft 9.0
5681 /borderright addon () eq {9.0} {5.0} ifelse
5682 /bordertop 0.0
5683 /borderbottom 5.0
5684 >>
5685
5686 dontdraw not //renlinear if
5687
5688 //unloadctx exec
5689
5690 end
5691
5692 }
5693 [/barcode] {null def} forall
5694 bind def
5695 /upca dup load /uk.co.terryburton.bwipp defineresource pop
5696 end
5697 /setpacking where {pop setpacking} if
5698 %%EndData
5699 %%EndResource
5700 % --END ENCODER upca--
5701
5702 % --BEGIN ENCODER upce--
5703 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear ean5 ean2--
5704 % --DESC: UPC-E
5705 % --EXAM: 01234558
5706 % --EXOP: includetext
5707 % --RNDR: renlinear
5708 %%BeginResource: uk.co.terryburton.bwipp upce 0.0 2025111800 98641 97811
5709 %%BeginData: 280 ASCII Lines
5710 /setpacking where {pop currentpacking true setpacking} if
5711 10 dict
5712 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
5713 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
5714 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
5715 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
5716 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
5717 dup /ean2 dup /uk.co.terryburton.bwipp findresource put
5718 dup /ean5 dup /uk.co.terryburton.bwipp findresource put
5719 begin
5720 /upce {
5721
5722 20 dict begin
5723
5724 /ctx null def
5725 /dontdraw false def
5726 /includetext false def % Enable/disable text
5727 /textfont /Helvetica def
5728 /textsize 12.0 def
5729 /textxoffset -9.0 def
5730 /textyoffset -4.0 def
5731 /height 1.0 def
5732 /addongap 12.0 def
5733 /addontextfont (unset) def
5734 /addontextsize null def % sentinal realtype
5735 /addontextxoffset null def % sentinal realtype
5736 /addontextyoffset null def % sentinal realtype
5737
5738 //processoptions exec /options exch def
5739 /barcode exch def
5740
5741 /upce //loadctx exec
5742
5743 % Split off the addon
5744 barcode ( ) search {
5745 /barcode exch def
5746 pop
5747 /addon exch def
5748 } {
5749 pop
5750 /addon () def
5751 } ifelse
5752
5753 % Compress a given UPC-A
5754 barcode length 11 eq barcode length 12 eq or {
5755 % Validate the input
5756 barcode {
5757 dup 48 lt exch 57 gt or {
5758 /bwipp.upcEupcAbadCharacter (UPC-A must contain only digits) //raiseerror exec
5759 } if
5760 } forall
5761 1 { % Common exit
5762 /upcecode barcode length 12 eq {8} {7} ifelse string def
5763 barcode 3 get 48 sub 2 le barcode 4 4 getinterval (0000) eq and {
5764 upcecode 0 barcode 0 3 getinterval putinterval
5765 upcecode 3 barcode 8 3 getinterval putinterval
5766 upcecode 6 barcode 3 1 getinterval putinterval
5767 exit
5768 } if
5769 barcode 4 5 getinterval (00000) eq {
5770 upcecode 0 barcode 0 4 getinterval putinterval
5771 upcecode 4 barcode 9 2 getinterval putinterval
5772 upcecode 6 (3) putinterval
5773 exit
5774 } if
5775 barcode 5 5 getinterval (00000) eq {
5776 upcecode 0 barcode 0 5 getinterval putinterval
5777 upcecode 5 barcode 10 1 getinterval putinterval
5778 upcecode 6 (4) putinterval
5779 exit
5780 } if
5781 barcode 10 get 48 sub 5 ge barcode 6 4 getinterval (0000) eq and {
5782 upcecode 0 barcode 0 6 getinterval putinterval
5783 upcecode 6 barcode 10 1 getinterval putinterval
5784 exit
5785 } if
5786 /bwipp.upcEupcAnotCompressible (UPC-A cannot be converted to a UPC-E) //raiseerror exec
5787 } repeat
5788 barcode length 12 eq {
5789 upcecode 7 barcode 11 1 getinterval putinterval
5790 } if
5791 /barcode upcecode def
5792 } if
5793
5794 % Validate the input
5795 barcode length 7 ne barcode length 8 ne and {
5796 /bwipp.upcEbadLength (UPC-E must be 7 or 8 digits) //raiseerror exec
5797 } if
5798 barcode {
5799 dup 48 lt exch 57 gt or {
5800 /bwipp.upcEbadCharacter (UPC-E must contain only digits) //raiseerror exec
5801 } if
5802 } forall
5803 addon length 0 ne addon length 2 ne and addon length 5 ne and {
5804 /bwipp.upcEbadAddOnLength (Add-on for UPC-E must be 2 or 5 digits) //raiseerror exec
5805 } if
5806
5807 % Ensure 0 or 1 number systems
5808 barcode 0 get dup 48 ne exch 49 ne and {
5809 /bwipp.upcEbadNumberSystem (UPC-E must have number system 0 or 1) //raiseerror exec
5810 } if
5811
5812 {
5813 % Create an array containing the character mappings
5814 /encs
5815 [ (3211) (2221) (2122) (1411) (1132)
5816 (1231) (1114) (1312) (1213) (3112)
5817 (111) (111111)
5818 ] def
5819
5820 % Create a string of the available characters
5821 /barchars (0123456789) def
5822
5823 /mirrormaps
5824 [ (000111) (001011) (001101) (001110) (010011)
5825 (011001) (011100) (010101) (010110) (011010)
5826 ] def
5827 } ctxdef
5828
5829 % Derive the equivalent UPC-A for its checksum
5830 1 { % Common exit
5831 /upcacode 11 string def
5832 barcode 6 get 48 sub 2 le {
5833 upcacode 0 barcode 0 3 getinterval putinterval
5834 upcacode 3 barcode 6 1 getinterval putinterval
5835 upcacode 4 (0000) putinterval
5836 upcacode 8 barcode 3 3 getinterval putinterval
5837 exit
5838 } if
5839 barcode 6 get 48 sub 3 eq {
5840 upcacode 0 barcode 0 4 getinterval putinterval
5841 upcacode 4 (00000) putinterval
5842 upcacode 9 barcode 4 2 getinterval putinterval
5843 exit
5844 } if
5845 barcode 6 get 48 sub 4 eq {
5846 upcacode 0 barcode 0 5 getinterval putinterval
5847 upcacode 5 (00000) putinterval
5848 upcacode 10 barcode 5 1 getinterval putinterval
5849 exit
5850 } if
5851 barcode 6 get 48 sub 5 ge {
5852 upcacode 0 barcode 0 6 getinterval putinterval
5853 upcacode 6 (0000) putinterval
5854 upcacode 10 barcode 6 1 getinterval putinterval
5855 exit
5856 } if
5857 } repeat
5858 /checksum 0 def
5859 0 1 10 {
5860 /i exch def
5861 /barchar upcacode i get 48 sub def
5862 i 2 mod 0 ne {
5863 /checksum checksum barchar add def
5864 } {
5865 /checksum checksum barchar 3 mul add def
5866 } ifelse
5867 } for
5868 /checksum 10 checksum 10 mod sub 10 mod def
5869 barcode length 8 eq {
5870 barcode 7 get checksum 48 add ne {
5871 /bwipp.upcEbadCheckDigit (Incorrect UPC check digit provided) //raiseerror exec
5872 } if
5873 } if
5874 /pad 8 string def
5875 pad 0 barcode putinterval % Add barcode to the start of the pad
5876 pad 7 checksum 48 add put % Put ascii for checksum at end of pad
5877 /barcode pad def
5878 /txt 8 array def
5879 txt 0 [barcode 0 1 getinterval textxoffset textyoffset textfont textsize 2 sub] put
5880
5881 % Determine the mirror map based on checksum
5882 /mirrormap mirrormaps checksum get def
5883
5884 % Invert the mirrormap if we are using a non-zero number system
5885 barcode 0 get 48 eq {
5886 /invt mirrormap length string def
5887 0 1 mirrormap length 1 sub {
5888 /i exch def
5889 mirrormap i get 48 eq {
5890 invt i 49 put
5891 } {
5892 invt i 48 put
5893 } ifelse
5894 } for
5895 /mirrormap invt def
5896 } if
5897
5898 /sbs 33 string def
5899
5900 % Put the start character
5901 sbs 0 encs 10 get putinterval
5902
5903 1 1 6 {
5904 /i exch def
5905 % Lookup the encoding for the each barcode character
5906 barcode i 1 getinterval barchars exch search
5907 pop % Discard true leaving pre
5908 length /indx exch def % indx is the length of pre
5909 pop pop % Discard seek and post
5910 /enc encs indx get def % Get the indxth encoding
5911 mirrormap i 1 sub get 49 eq { % Reverse enc if 1 in this position in mirrormap
5912 /enclen enc length def
5913 /revenc enclen string def
5914 0 1 enclen 1 sub {
5915 /j exch def
5916 /char enc j get def
5917 revenc enclen j sub 1 sub char put
5918 } for
5919 /enc revenc def
5920 } if
5921 sbs i 1 sub 4 mul 3 add enc putinterval % Put encoded digit into sbs
5922 txt i [barcode i 1 getinterval i 1 sub 7 mul 13 add textxoffset add textyoffset textfont textsize] put
5923 } for
5924
5925 txt 7 [barcode 7 1 getinterval 6 7 mul 21 add textxoffset add textyoffset textfont textsize 2 sub] put
5926
5927 % Put the end character
5928 sbs 27 encs 11 get putinterval
5929
5930 /sbs [sbs {48 sub} forall] def
5931 includetext {
5932 /bhs [height height 12{height .075 sub}repeat height height height] def
5933 /bbs [0 0 12{.075}repeat 0 0 0] def
5934 } {
5935 /bhs [17{height}repeat] def
5936 /bbs [17{0}repeat] def
5937 /txt [] def
5938 } ifelse
5939 /guardrightypos 0.0 def
5940
5941 % Append the addon
5942 addon () ne {
5943 /addopts <<
5944 /dontdraw true
5945 /includetext true
5946 /height height includetext { 0.15 sub } if
5947 /textxoffset addontextxoffset null ne {addontextxoffset} {51 addongap add} ifelse
5948 addontextyoffset null ne {/textyoffset addontextyoffset} if
5949 /textsize addontextsize null ne {addontextsize} {textsize} ifelse
5950 /textfont addontextfont (unset) ne {addontextfont} {textfont} ifelse
5951 >> def
5952 addon length 2 eq {addon addopts //ean2 exec} if
5953 addon length 5 eq {addon addopts //ean5 exec} if
5954 /addcode exch def
5955 /sbs [sbs aload pop addongap addcode (sbs) get aload pop] def
5956 /bhs [bhs aload pop addcode (bhs) get aload pop] def
5957 /bbs [bbs aload pop addcode (bbs) get aload pop] def
5958 /txt [txt aload pop addcode (txt) get aload pop] def
5959 /guardrightypos height 72 mul 6 sub def
5960 } if
5961
5962 % Return the arguments
5963 <<
5964 /ren /renlinear
5965 /sbs sbs
5966 /bhs bhs
5967 /bbs bbs
5968 /txt txt
5969 /opt options
5970 /guardrightpos addon () eq {9.0} {5.0} ifelse
5971 /guardrightypos guardrightypos
5972 /borderleft 9.0
5973 /borderright addon () eq {9.0} {5.0} ifelse
5974 /bordertop 0.0
5975 /borderbottom 5.0
5976 >>
5977
5978 dontdraw not //renlinear if
5979
5980 //unloadctx exec
5981
5982 end
5983
5984 }
5985 [/barcode] {null def} forall
5986 bind def
5987 /upce dup load /uk.co.terryburton.bwipp defineresource pop
5988 end
5989 /setpacking where {pop setpacking} if
5990 %%EndData
5991 %%EndResource
5992 % --END ENCODER upce--
5993
5994 % --BEGIN ENCODER isbn--
5995 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear ean5 ean2 ean13--
5996 % --DESC: ISBN
5997 % --EXAM: 978-1-56581-231-4 90000
5998 % --EXOP: includetext guardwhitespace
5999 % --RNDR: renlinear
6000 %%BeginResource: uk.co.terryburton.bwipp isbn 0.0 2025111800 97613 99986
6001 %%BeginData: 238 ASCII Lines
6002 /setpacking where {pop currentpacking true setpacking} if
6003 10 dict
6004 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
6005 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
6006 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
6007 dup /ean13 dup /uk.co.terryburton.bwipp findresource put
6008 begin
6009 /isbn {
6010
6011 20 dict begin
6012
6013 /ctx null def
6014 /dontdraw false def
6015 /includetext false def % Enable/disable ISBN text
6016 /isbntextfont /Courier def
6017 /isbntextsize 9.0 def
6018 /isbntextxoffset null def % sentinal realtype
6019 /isbntextyoffset null def % sentinal realtype
6020 /height 1.0 def
6021 /addongap 12.0 def
6022 /legacy false def
6023
6024 //processoptions exec /options exch def
6025 /barcode exch def
6026
6027 % Split off the addon
6028 barcode ( ) search {
6029 /barcode exch def
6030 pop
6031 /addon exch def
6032 } {
6033 pop
6034 /addon () def
6035 } ifelse
6036
6037 % Validate the input
6038 barcode length 15 ne barcode length 17 ne and
6039 barcode length 11 ne barcode length 13 ne and and {
6040 /bwipp.isbnBadLength (ISBN-13 must be 15 or 17 characters including dashes. ISBN-10 must be 11 or 13 characters including dashes) //raiseerror exec
6041 } if
6042 addon length 0 ne addon length 2 ne and addon length 5 ne and {
6043 /bwipp.isbnBadAddOnLength (Add-on for ISBN must be 2 or 5 digits) //raiseerror exec
6044 } if
6045 barcode length 15 ge { % ISBN-13
6046 barcode 0 4 getinterval dup (978-) ne exch (979-) ne and {
6047 /bwipp.isbn13badPrefix (ISBN-13 prefix must be 978- or 979-) //raiseerror exec
6048 } if
6049 /wasdash false def /numdash 0 def /numdigit 0 def
6050 barcode 5 9 getinterval {
6051 dup
6052 45 eq {
6053 wasdash {
6054 /bwipp.isbn13adjacentDashes (ISBN-13 does not permit adjacent dashes) //raiseerror exec
6055 } if
6056 /wasdash true def
6057 /numdash numdash 1 add def
6058 } if
6059 dup 48 ge exch 57 le and {
6060 /wasdash false def
6061 /numdigit numdigit 1 add def
6062 } if
6063 } forall
6064 numdash 2 ne numdigit 7 ne or {
6065 /bwipp.isbn13numDashesDigits (Incorrect number of dashes and digits for ISBN-13) //raiseerror exec
6066 } if
6067 barcode 14 get dup 48 lt exch 57 gt or {
6068 /bwipp.isbn13character15 (ISBN-13 character 15 must be a digit) //raiseerror exec
6069 } if
6070 barcode length 17 eq {
6071 barcode 15 1 getinterval (-) ne {
6072 /bwipp.isbn13character16 (ISBN-13 penultimate character must be a dash) //raiseerror exec
6073 } if
6074 barcode 16 get dup 48 lt exch 57 gt or {
6075 /bwipp.isbn13character17 (ISBN-13 final character must be a digit) //raiseerror exec
6076 } if
6077 } if
6078 } { % ISBN-10
6079 barcode 0 get dup 48 lt exch 57 gt or {
6080 /bwipp.isbn10FirstDigit (ISBN-10 first character must be a digit) //raiseerror exec
6081 } if
6082 /wasdash false def /numdash 0 def /numdigit 0 def
6083 barcode 1 9 getinterval {
6084 dup
6085 45 eq {
6086 wasdash {
6087 /bwipp.isbn10adjacentDashes (ISBN-10 does not permit adjacent dashes) //raiseerror exec
6088 } if
6089 /wasdash true def
6090 /numdash numdash 1 add def
6091 } if
6092 dup 48 ge exch 57 le and {
6093 /wasdash false def
6094 /numdigit numdigit 1 add def
6095 } if
6096 } forall
6097 numdash 2 ne numdigit 7 ne or {
6098 /bwipp.isbn10numDashesDigits (Incorrect number of dashes and digits for ISBN-10) //raiseerror exec
6099 } if
6100 barcode 10 get dup 48 lt exch 57 gt or {
6101 /bwipp.isbn10character11 (ISBN-10 character 11 must be a digit) //raiseerror exec
6102 } if
6103 barcode length 13 eq {
6104 barcode 11 1 getinterval (-) ne {
6105 /bwipp.isbn10character12 (ISBN-10 penultimate character must be a dash) //raiseerror exec
6106 } if
6107 barcode 12 get dup dup 48 lt exch 57 gt or exch 88 ne and {
6108 /bwipp.isbn10character13 (ISBN-10 final character must be a digit or X) //raiseerror exec
6109 } if
6110 } if
6111 } ifelse
6112
6113 /isbntxt barcode def
6114
6115 % Read the digits from isbntxt and validate checksum for ISBN-10
6116 isbntxt length 13 le {
6117 /isbn 10 string def
6118 /checksum 0 def
6119 /i 0 def /n 0 def
6120 { % loop
6121 /isbnchar isbntxt i get 48 sub def
6122 isbnchar -3 ne { % Ignore dashes
6123 isbn n isbnchar 48 add put
6124 n 9 lt {
6125 /checksum checksum 10 n sub isbnchar mul add def
6126 } if
6127 /n n 1 add def
6128 } if
6129 /i i 1 add def
6130 i isbntxt length eq {exit} if
6131 } loop
6132 /checksum 11 checksum 11 mod sub 11 mod dup 10 eq {pop 40} if 48 add def
6133 /isbn isbn 0 9 getinterval def
6134 isbntxt length 13 eq {
6135 isbntxt 12 get checksum ne {
6136 /bwipp.isbn10badCheckDigit (Incorrect ISBN-10 check digit provided) //raiseerror exec
6137 } if
6138 } if
6139 } if
6140
6141 legacy not isbntxt length 15 ge or {
6142
6143 % Convert ISBN-10 to ISBN-13
6144 isbntxt length 13 le {
6145 /pad 15 string def
6146 pad 0 (978-) putinterval
6147 pad 4 isbntxt 0 11 getinterval putinterval
6148 /isbntxt pad def
6149 } if
6150
6151 % Read the digits from isbntxt and validate checksum for ISBN-13
6152 /isbn 13 string def
6153 /checksum 0 def
6154 /i 0 def /n 0 def
6155 { % loop
6156 /isbnchar isbntxt i get 48 sub def
6157 isbnchar -3 ne { % Ignore dashes
6158 isbn n isbnchar 48 add put
6159 n 12 lt {
6160 /checksum isbnchar n 2 mod 0 ne {3 mul} if checksum add def
6161 } if
6162 /n n 1 add def
6163 } if
6164 /i i 1 add def
6165 i isbntxt length eq {exit} if
6166 } loop
6167 /checksum 10 checksum 10 mod sub 10 mod 48 add def
6168 /isbn isbn 0 12 getinterval def
6169 isbntxt length 17 eq {
6170 isbntxt 16 get checksum ne {
6171 /bwipp.isbn13badCheckDigit (Incorrect ISBN-13 check digit provided) //raiseerror exec
6172 } if
6173 } if
6174
6175 } if
6176
6177 % Add the ISBN header to the isbntxt
6178 /pad isbn length 12 eq {22} {18} ifelse string def
6179 pad 0 (ISBN ) putinterval
6180 pad 5 isbntxt putinterval
6181 pad pad length 2 sub 45 put
6182 pad pad length 1 sub checksum put
6183 /isbntxt pad def
6184
6185 % Convert ISBN digits to EAN-13
6186 /barcode 12 string def
6187 isbn length 9 eq {
6188 barcode 0 (978) putinterval
6189 barcode 3 isbn putinterval
6190 } {
6191 barcode 0 isbn putinterval
6192 } ifelse
6193
6194 % Append the addon
6195 addon () ne {
6196 12 addon length add 1 add string
6197 dup 0 barcode putinterval
6198 dup 12 ( ) putinterval
6199 dup 13 addon putinterval
6200 /barcode exch def
6201 } if
6202
6203 % Get the result of encoding with ean13
6204 options (dontdraw) true put
6205 options (addongap) addongap put
6206 /args barcode options //ean13 exec def
6207
6208 % Add the ISBN text
6209 includetext {
6210 isbntextxoffset null eq {
6211 /isbntextxoffset isbn length 9 eq {-1.0} {-12.0} ifelse def
6212 } if
6213 isbntextyoffset null eq {
6214 /isbntextyoffset height 72 mul 3 add def
6215 } if
6216 args (txt) known {
6217 /txt args (txt) get def
6218 /newtxt txt length 1 add array def
6219 newtxt 0 txt putinterval
6220 newtxt newtxt length 1 sub [isbntxt isbntextxoffset isbntextyoffset isbntextfont isbntextsize] put
6221 args (txt) newtxt put
6222 } {
6223 args (txt) [ [isbntxt isbntextxoffset isbntextyoffset isbntextfont isbntextsize] ] put
6224 } ifelse
6225 } if
6226
6227 args (opt) options put
6228 args
6229
6230 dontdraw not //renlinear if
6231
6232 end
6233
6234 }
6235 [/barcode] {null def} forall
6236 bind def
6237 /isbn dup load /uk.co.terryburton.bwipp defineresource pop
6238 end
6239 /setpacking where {pop setpacking} if
6240 %%EndData
6241 %%EndResource
6242 % --END ENCODER isbn--
6243
6244 % --BEGIN ENCODER ismn--
6245 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear ean5 ean2 ean13--
6246 % --DESC: ISMN
6247 % --EXAM: 979-0-2605-3211-3
6248 % --EXOP: includetext guardwhitespace
6249 % --RNDR: renlinear
6250 %%BeginResource: uk.co.terryburton.bwipp ismn 0.0 2025111800 94081 96339
6251 %%BeginData: 217 ASCII Lines
6252 /setpacking where {pop currentpacking true setpacking} if
6253 10 dict
6254 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
6255 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
6256 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
6257 dup /ean13 dup /uk.co.terryburton.bwipp findresource put
6258 begin
6259 /ismn {
6260
6261 20 dict begin
6262
6263 /ctx null def
6264 /dontdraw false def
6265 /includetext false def
6266 /ismntextfont /Courier def
6267 /ismntextsize 9.0 def
6268 /ismntextxoffset null def % sentinal realtype
6269 /ismntextyoffset null def % sentinal realtype
6270 /height 1.0 def
6271 /addongap 12.0 def
6272 /legacy false def
6273
6274 //processoptions exec /options exch def
6275 /barcode exch def
6276
6277 % Split off the addon
6278 barcode ( ) search {
6279 /barcode exch def
6280 pop
6281 /addon exch def
6282 } {
6283 pop
6284 /addon () def
6285 } ifelse
6286
6287 % Validate the input
6288 barcode length 15 ne barcode length 17 ne and
6289 barcode length 11 ne barcode length 13 ne and and {
6290 /bwipp.ismnBadLength (ISMN-13 must be 15 or 17 characters including dashes. ISMN-10 must be 11 or 13 characters including dashes) //raiseerror exec
6291 } if
6292 addon length 0 ne addon length 2 ne and addon length 5 ne and {
6293 /bwipp.ismnBadAddOnLength (Add-on for ISMN must be 2 or 5 digits) //raiseerror exec
6294 } if
6295 barcode length 15 ge { % ISMN-13
6296 barcode 0 4 getinterval (979-) ne {
6297 /bwipp.ismn13badPrefix (ISMN-13 prefix must be 979-) //raiseerror exec
6298 } if
6299 /wasdash false def /numdash 0 def /numdigit 0 def
6300 barcode 5 9 getinterval {
6301 dup
6302 45 eq {
6303 wasdash {
6304 /bwipp.ismn13adjacentDashes (ISMN-13 does not permit adjacent dashes) //raiseerror exec
6305 } if
6306 /wasdash true def
6307 /numdash numdash 1 add def
6308 } if
6309 dup 48 ge exch 57 le and {
6310 /wasdash false def
6311 /numdigit numdigit 1 add def
6312 } if
6313 } forall
6314 numdash 2 ne numdigit 7 ne or {
6315 /bwipp.ismn13numDashesDigits (Incorrect number of dashes and digits for ISMN-13) //raiseerror exec
6316 } if
6317 barcode 14 get dup 48 lt exch 57 gt or {
6318 /bwipp.ismn13character15 (ISMN-13 character 15 must be a digit) //raiseerror exec
6319 } if
6320 barcode length 17 eq {
6321 barcode 15 1 getinterval (-) ne {
6322 /bwipp.ismn13character16 (ISMN-13 penultimate character must be a dash) //raiseerror exec
6323 } if
6324 barcode 16 get dup 48 lt exch 57 gt or {
6325 /bwipp.ismn13character17 (ISMN-13 final character must be a digit) //raiseerror exec
6326 } if
6327 } if
6328 } { % ISMN-10
6329 barcode 0 2 getinterval (M-) ne {
6330 /bwipp.ismn10badPrefix (ISMN-10 prefix must be M-) //raiseerror exec
6331 } if
6332 barcode 2 get dup 48 lt exch 57 gt or {
6333 /bwipp.ismn10character3 (ISMN-10 character 3 must be a digit) //raiseerror exec
6334 } if
6335 /wasdash false def /numdash 0 def /numdigit 0 def
6336 barcode 3 7 getinterval {
6337 dup
6338 45 eq {
6339 wasdash {
6340 /bwipp.ismn10adjacentDashes (ISMN-10 does not permit adjacent dashes) //raiseerror exec
6341 } if
6342 /wasdash true def
6343 /numdash numdash 1 add def
6344 } if
6345 dup 48 ge exch 57 le and {
6346 /wasdash false def
6347 /numdigit numdigit 1 add def
6348 } if
6349 } forall
6350 numdash 1 ne numdigit 6 ne or {
6351 /bwipp.ismn10numDashesDigits (Incorrect number of dashes and digits for ISMN-10) //raiseerror exec
6352 } if
6353 barcode 10 get dup 48 lt exch 57 gt or {
6354 /bwipp.ismn10character11 (ISMN-10 character 11 must be a digit) //raiseerror exec
6355 } if
6356 barcode length 13 eq {
6357 barcode 11 1 getinterval (-) ne {
6358 /bwipp.ismn10character12 (ISMN-10 penultimate character must be a dash) //raiseerror exec
6359 } if
6360 barcode 12 get dup dup 48 lt exch 57 gt or exch 88 ne and {
6361 /bwipp.ismn10character13 (ISMN-10 final character must be a digit or X) //raiseerror exec
6362 } if
6363 } if
6364 } ifelse
6365
6366 /ismntxt barcode def
6367
6368 % Convert old ISMN to ISMN-13
6369 /legacytxt () def
6370 ismntxt length 13 le {
6371 /legacytxt ismntxt def
6372 /pad ismntxt length 4 add string def
6373 pad 0 (979-0-) putinterval
6374 pad 6 ismntxt 2 ismntxt length 2 sub getinterval putinterval
6375 /ismntxt pad def
6376 } if
6377
6378 % Read the digits from ismntxt and calculate checksums
6379 /ismn 13 string def
6380 /checksum 0 def
6381 /i 0 def /n 0 def
6382 { % loop
6383 /ismnchar ismntxt i get 48 sub def
6384 ismnchar -3 ne { % Ignore dashes
6385 ismn n ismnchar 48 add put
6386 n 12 lt {
6387 n 2 mod 0 eq {
6388 /checksum ismnchar checksum add def
6389 } {
6390 /checksum ismnchar 3 mul checksum add def
6391 } ifelse
6392 } if
6393 /n n 1 add def
6394 } if
6395 /i i 1 add def
6396 i ismntxt length eq {exit} if
6397 } loop
6398 /checksum 10 checksum 10 mod sub 10 mod 48 add def
6399
6400 % Validate the checksum
6401 barcode length 13 eq barcode length 17 eq or {
6402 barcode dup length 1 sub get checksum ne {
6403 /bwipp.ismnBadCheckDigit (Incorrect ISMN check digit provided) //raiseerror exec
6404 } if
6405 } if
6406
6407 % Add the ISMN header and checksum to the ismntxt
6408 legacy legacytxt () ne and {
6409 /ismntxt legacytxt def
6410 /pad 18 string def
6411 } {
6412 /pad 22 string def
6413 } ifelse
6414 pad 0 (ISMN ) putinterval
6415 pad 5 ismntxt putinterval
6416 pad pad length 2 sub 45 put
6417 pad pad length 1 sub checksum put
6418 /ismntxt pad def
6419
6420 % Convert ISMN digits to EAN-13
6421 /barcode ismn 0 12 getinterval def
6422
6423 % Append the addon
6424 addon () ne {
6425 12 addon length add 1 add string
6426 dup 0 barcode putinterval
6427 dup 12 ( ) putinterval
6428 dup 13 addon putinterval
6429 /barcode exch def
6430 } if
6431
6432 % Get the result of encoding with ean13
6433 options (dontdraw) true put
6434 options (addongap) addongap put
6435 /args barcode options //ean13 exec def
6436
6437 % Add the ISMN text
6438 includetext {
6439 ismntextxoffset null eq {
6440 /ismntextxoffset ismntxt length 18 eq {-1.0} {-12.0} ifelse def
6441 } if
6442 ismntextyoffset null eq {
6443 /ismntextyoffset height 72 mul 3 add def
6444 } if
6445 args (txt) known {
6446 /txt args (txt) get def
6447 /newtxt txt length 1 add array def
6448 newtxt 0 txt putinterval
6449 newtxt newtxt length 1 sub [ismntxt ismntextxoffset ismntextyoffset ismntextfont ismntextsize] put
6450 args (txt) newtxt put
6451 } {
6452 args (txt) [ [ismntxt ismntextxoffset ismntextyoffset ismntextfont ismntextsize] ] put
6453 } ifelse
6454 } if
6455
6456 args (opt) options put
6457 args
6458
6459 dontdraw not //renlinear if
6460
6461 end
6462
6463 }
6464 [/barcode] {null def} forall
6465 bind def
6466 /ismn dup load /uk.co.terryburton.bwipp defineresource pop
6467 end
6468 /setpacking where {pop setpacking} if
6469 %%EndData
6470 %%EndResource
6471 % --END ENCODER ismn--
6472
6473 % --BEGIN ENCODER issn--
6474 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear ean2 ean5 ean13--
6475 % --DESC: ISSN
6476 % --EXAM: 0311-175X 00 17
6477 % --EXOP: includetext guardwhitespace
6478 % --RNDR: renlinear
6479 %%BeginResource: uk.co.terryburton.bwipp issn 0.0 2025111800 85321 88015
6480 %%BeginData: 160 ASCII Lines
6481 /setpacking where {pop currentpacking true setpacking} if
6482 10 dict
6483 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
6484 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
6485 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
6486 dup /ean13 dup /uk.co.terryburton.bwipp findresource put
6487 begin
6488 /issn {
6489
6490 20 dict begin
6491
6492 /ctx null def
6493 /dontdraw false def
6494 /includetext false def
6495 /issntextfont /Courier def
6496 /issntextsize 9.0 def
6497 /issntextxoffset null def % sentinal realtype
6498 /issntextyoffset null def % sentinal realtype
6499 /height 1.0 def
6500 /addongap 12.0 def
6501
6502 //processoptions exec /options exch def
6503 /issntxt exch def
6504
6505 % Split off the ISSN
6506 issntxt ( ) search {
6507 /issntxt exch def
6508 pop
6509 /seqvar exch def
6510 } {
6511 pop
6512 /seqvar (00) def
6513 } ifelse
6514
6515 % Split off the sequence variant and addon
6516 seqvar ( ) search {
6517 /seqvar exch def
6518 pop
6519 /addon exch def
6520 } {
6521 pop
6522 /addon () def
6523 } ifelse
6524
6525 % Validate the input
6526 issntxt length 8 ne issntxt length 9 ne and {
6527 /bwipp.issnBadLength (ISSN must be 8 or 9 characters including dash, in the format XXXX-XXXX) //raiseerror exec
6528 } if
6529 issntxt 0 4 getinterval {
6530 dup 48 lt exch 57 gt or {
6531 /bwipp.issnFirstThroughFourthNotNumeric (ISSN first four characters must be numeral characters) //raiseerror exec
6532 } if
6533 } forall
6534 issntxt 4 1 getinterval (-) ne {
6535 /bwipp.issnNeedsDash (ISSN fifth character must be a dash) //raiseerror exec
6536 } if
6537 issntxt 5 3 getinterval {
6538 dup 48 lt exch 57 gt or {
6539 /bwipp.issnSixthThroughEighthNotNumeric (ISSN sixth through eighth characters must be numerals) //raiseerror exec
6540 } if
6541 } forall
6542 issntxt length 9 eq {
6543 issntxt 8 get dup dup 48 lt exch 57 gt or exch 88 ne and { % Digits or X
6544 /bwipp.issnNinthCharacterBadFormat (ISSN ninth character must be a number or the character X) //raiseerror exec
6545 } if
6546 } if
6547 seqvar length 2 ne {
6548 /bwipp.issnBadSequenceVariantLength (Sequence variant for ISSN must be 2 digits) //raiseerror exec
6549 } if
6550 seqvar {
6551 dup 48 lt exch 57 gt or {
6552 /bwipp.issnSequenceVariantBadCharacter (Sequence variant for ISSN must contain only digits) //raiseerror exec
6553 } if
6554 } forall
6555 addon length 0 ne addon length 2 ne and addon length 5 ne and {
6556 /bwipp.issnBadAddOnLength (Add-on for ISSN must be 2 or 5 digits) //raiseerror exec
6557 } if
6558
6559 % Read the digits from issntxt and calculate checksums
6560 /issn 8 string def
6561 /checksum 0 def
6562 /i 0 def /n 0 def
6563 { % loop
6564 /issnchar issntxt i get 48 sub def
6565 issnchar -3 ne { % Ignore dashes
6566 issn n issnchar 48 add put
6567 n 7 lt {
6568 /checksum checksum issnchar 8 n sub mul add def
6569 } if
6570 /n n 1 add def
6571 } if
6572 /i i 1 add def
6573 i issntxt length eq {exit} if
6574 } loop
6575 /checksum 11 checksum 11 mod sub 11 mod def
6576 /checksum checksum 48 add dup 58 eq {pop 88} if def
6577 issntxt length 9 eq {
6578 issntxt 8 get checksum ne {
6579 /bwipp.issnBadCheckDigit (Incorrect ISSN check digit provided) //raiseerror exec
6580 } if
6581 } if
6582
6583 % Add the ISSN header and checksum to the issntxt
6584 /pad 14 string def
6585 pad 0 (ISSN ) putinterval
6586 pad 5 issntxt putinterval % Add issntxt to the pad
6587 pad 13 checksum put
6588 /issntxt pad def
6589
6590 % Convert ISSN digits to EAN-13
6591 /barcode issn 0 7 getinterval def
6592
6593 % Append the sequence variant
6594 /barcode 12 string def
6595 barcode 0 (977) putinterval
6596 barcode 3 issn putinterval
6597 barcode 10 seqvar putinterval
6598
6599 % Append the addon
6600 addon () ne {
6601 12 addon length add 1 add string
6602 dup 0 barcode putinterval
6603 dup 12 ( ) putinterval
6604 dup 13 addon putinterval
6605 /barcode exch def
6606 } if
6607
6608 % Get the result of encoding with ean13
6609 options (dontdraw) true put
6610 options (addongap) addongap put
6611 /args barcode options //ean13 exec def
6612
6613 % Add the ISSN text
6614 includetext {
6615 issntextxoffset null eq {/issntextxoffset 10.0 def} if
6616 issntextyoffset null eq {/issntextyoffset height 72 mul 3 add def} if
6617 args (txt) known {
6618 /txt args (txt) get def
6619 /newtxt txt length 1 add array def
6620 newtxt 0 txt putinterval
6621 newtxt newtxt length 1 sub [issntxt issntextxoffset issntextyoffset issntextfont issntextsize] put
6622 args (txt) newtxt put
6623 } {
6624 args (txt) [ [issntxt issntextxoffset issntextyoffset issntextfont issntextsize] ] put
6625 } ifelse
6626 } if
6627
6628 args (opt) options put
6629 args
6630
6631 dontdraw not //renlinear if
6632
6633 end
6634
6635 }
6636 [/barcode] {null def} forall
6637 bind def
6638 /issn dup load /uk.co.terryburton.bwipp defineresource pop
6639 end
6640 /setpacking where {pop setpacking} if
6641 %%EndData
6642 %%EndResource
6643 % --END ENCODER issn--
6644
6645 % --BEGIN ENCODER mands--
6646 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear ean2 ean5 ean8--
6647 % --DESC: Marks & Spencer
6648 % --EXAM: 0642118
6649 % --EXOP: includetext
6650 % --RNDR: renlinear
6651 %%BeginResource: uk.co.terryburton.bwipp mands 0.0 2025111800 75222 78587
6652 %%BeginData: 73 ASCII Lines
6653 /setpacking where {pop currentpacking true setpacking} if
6654 10 dict
6655 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
6656 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
6657 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
6658 dup /ean8 dup /uk.co.terryburton.bwipp findresource put
6659 begin
6660 /mands {
6661
6662 20 dict begin
6663
6664 /ctx null def
6665 /dontdraw false def
6666 /includetext false def
6667
6668 //processoptions exec /options exch def
6669 /barcode exch def
6670
6671 /barlen barcode length def
6672
6673 % Validate the input
6674 barlen 7 ne barlen 8 ne and {
6675 /bwipp.MandSbadLength (M&S barcode must be 7 or 8 characters) //raiseerror exec
6676 } if
6677
6678 barlen 7 eq {
6679 /barcode (00000000) 8 string copy dup 1 barcode putinterval def
6680 } if
6681
6682 % Get the result of encoding with ean8
6683 options (dontdraw) true put
6684 /args barcode options //ean8 exec def
6685
6686 % Remove the centre guard
6687 args (bbs) get dup
6688 dup 2 get 10 exch put
6689 dup 2 get 11 exch put
6690 args (bhs) get dup
6691 dup 2 get 10 exch put
6692 dup 2 get 11 exch put
6693
6694 % Fix up the text for 7-digit inputs
6695 /txt args (txt) get def
6696 barlen 7 eq {
6697 0 1 6 {
6698 txt exch 2 copy
6699 1 add get 0 get 3 1 roll get
6700 0 get exch 0 exch putinterval
6701 } for
6702 txt 7 get 0 get 0 ( ) putinterval
6703 } if
6704
6705 % Add the M and S guards
6706 10 array dup 0 txt putinterval /txt exch def
6707 txt 0 get dup length array copy txt exch 8 exch put
6708 txt 0 get dup length array copy txt exch 9 exch put
6709 txt 8 get 0 (M) put txt 8 get 1 -12 put
6710 txt 9 get 0 (S) put txt 9 get 1 69 put
6711
6712 args (txt) txt put
6713 args (opt) options put
6714 args
6715
6716 dontdraw not //renlinear if
6717
6718 end
6719
6720 }
6721 [/barcode] {null def} forall
6722 bind def
6723 /mands dup load /uk.co.terryburton.bwipp defineresource pop
6724 end
6725 /setpacking where {pop setpacking} if
6726 %%EndData
6727 %%EndResource
6728 % --END ENCODER mands--
6729
6730 % --BEGIN ENCODER code128--
6731 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renlinear--
6732 % --DESC: Code 128
6733 % --EXAM: Count01234567!
6734 % --EXOP: includetext
6735 % --RNDR: renlinear
6736 %%BeginResource: uk.co.terryburton.bwipp code128 0.0 2025111800 177648 182080
6737 %%BeginData: 590 ASCII Lines
6738 /setpacking where {pop currentpacking true setpacking} if
6739 10 dict
6740 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
6741 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
6742 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
6743 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
6744 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
6745 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
6746 begin
6747 /code128 {
6748
6749 20 dict begin
6750
6751 /ctx null def
6752 /dontdraw false def
6753 /includetext false def
6754 /textfont /Courier def
6755 /textsize 10.0 def
6756 /textxoffset 0.0 def
6757 /textyoffset -7.0 def
6758 /height 1.0 def
6759 /raw false def
6760 /newencoder false def
6761 /parse false def
6762 /parsefnc false def
6763 /suppressc false def % Suppress code set C
6764 /unlatchextbeforec false def % Suppress extended ASCII with code set C
6765
6766 //processoptions exec /options exch def
6767 /barcode exch def
6768
6769 /code128 //loadctx exec
6770
6771 % Special function characters
6772 {
6773 /sta -1 def /stb -2 def /stc -3 def
6774 /swa -4 def /swb -5 def /swc -6 def
6775 /fn1 -7 def /fn2 -8 def /fn3 -9 def
6776 /fn4 -10 def /sft -11 def /stp -12 def
6777 /lka -13 def /lkc -14 def % CC-A/B and CC-C linkage
6778 } ctxdef
6779
6780 % Parse the input
6781 /fncvals <<
6782 /parse parse
6783 /parsefnc parsefnc
6784 (FNC1) fn1
6785 (FNC2) fn2
6786 (FNC3) fn3
6787 % (FNC4) fn4 Not user accessible as encoded automatically
6788 (LNKA) lka
6789 (LNKC) lkc
6790 >> def
6791 /msg barcode fncvals //parseinput exec def
6792 /msglen msg length def
6793
6794 /encoding (legacy) def
6795 newencoder {/encoding (new) def} if
6796 raw {/encoding (raw) def} if
6797
6798 encoding (raw) eq {
6799 /cws barcode length array def
6800 /i 0 def /j 0 def
6801 { % loop
6802 i barcode length eq {exit} if
6803 /cw barcode i 1 add 3 getinterval cvi def
6804 cws j cw put
6805 /i i 4 add def
6806 /j j 1 add def
6807 } loop
6808 /cws cws 0 j getinterval def
6809 /text () def
6810 } {
6811 /text msglen string def
6812 0 1 msglen 1 sub {
6813 /i exch def
6814 text i msg i get dup 0 lt { pop 32 } if put
6815 } for
6816 } ifelse
6817
6818 % Character maps for each state, used by the legacy encoder
6819 {
6820 /charmaps [
6821 % A B C A B C A B C
6822 [ 32 32 (00) ] [ (!) (!) (01) ] [ (") (") (02) ] % 0-2
6823 [ (#) (#) (03) ] [ ($) ($) (04) ] [ (%) (%) (05) ] % 3-5
6824 [ (&) (&) (06) ] [ (') (') (07) ] [ 40 40 (08) ] % 6-8
6825 [ 41 41 (09) ] [ (*) (*) (10) ] [ (+) (+) (11) ] % 9-11
6826 [ (,) (,) (12) ] [ (-) (-) (13) ] [ (.) (.) (14) ] % 12-14
6827 [ (/) (/) (15) ] [ (0) (0) (16) ] [ (1) (1) (17) ] % 15-17
6828 [ (2) (2) (18) ] [ (3) (3) (19) ] [ (4) (4) (20) ] % 18-20
6829 [ (5) (5) (21) ] [ (6) (6) (22) ] [ (7) (7) (23) ] % 21-23
6830 [ (8) (8) (24) ] [ (9) (9) (25) ] [ (:) (:) (26) ] % 24-26
6831 [ (;) (;) (27) ] [ (<) (<) (28) ] [ (=) (=) (29) ] % 27-29
6832 [ (>) (>) (30) ] [ (?) (?) (31) ] [ (@) (@) (32) ] % 30-32
6833 [ (A) (A) (33) ] [ (B) (B) (34) ] [ (C) (C) (35) ] % 33-35
6834 [ (D) (D) (36) ] [ (E) (E) (37) ] [ (F) (F) (38) ] % 36-38
6835 [ (G) (G) (39) ] [ (H) (H) (40) ] [ (I) (I) (41) ] % 39-41
6836 [ (J) (J) (42) ] [ (K) (K) (43) ] [ (L) (L) (44) ] % 42-44
6837 [ (M) (M) (45) ] [ (N) (N) (46) ] [ (O) (O) (47) ] % 45-47
6838 [ (P) (P) (48) ] [ (Q) (Q) (49) ] [ (R) (R) (50) ] % 48-50
6839 [ (S) (S) (51) ] [ (T) (T) (52) ] [ (U) (U) (53) ] % 51-53
6840 [ (V) (V) (54) ] [ (W) (W) (55) ] [ (X) (X) (56) ] % 54-56
6841 [ (Y) (Y) (57) ] [ (Z) (Z) (58) ] [ ([) ([) (59) ] % 57-59
6842 [ 92 92 (60) ] [ (]) (]) (61) ] [ (^) (^) (62) ] % 60-62
6843 [ (_) (_) (63) ] [ 0 (`) (64) ] [ 1 (a) (65) ] % 63-65
6844 [ 2 (b) (66) ] [ 3 (c) (67) ] [ 4 (d) (68) ] % 66-68
6845 [ 5 (e) (69) ] [ 6 (f) (70) ] [ 7 (g) (71) ] % 69-71
6846 [ 8 (h) (72) ] [ 9 (i) (73) ] [ 10 (j) (74) ] % 72-74
6847 [ 11 (k) (75) ] [ 12 (l) (76) ] [ 13 (m) (77) ] % 75-77
6848 [ 14 (n) (78) ] [ 15 (o) (79) ] [ 16 (p) (80) ] % 78-80
6849 [ 17 (q) (81) ] [ 18 (r) (82) ] [ 19 (s) (83) ] % 81-83
6850 [ 20 (t) (84) ] [ 21 (u) (85) ] [ 22 (v) (86) ] % 84-86
6851 [ 23 (w) (87) ] [ 24 (x) (88) ] [ 25 (y) (89) ] % 87-89
6852 [ 26 (z) (90) ] [ 27 ({) (91) ] [ 28 (|) (92) ] % 90-92
6853 [ 29 (}) (93) ] [ 30 (~) (94) ] [ 31 127 (95) ] % 93-95
6854 [ fn3 fn3 (96) ] [ fn2 fn2 (97) ] [ sft sft (98) ] % 96-98
6855 [ swc swc (99) ] [ swb fn4 swb ] [ fn4 swa swa ] % 99-101
6856 [ fn1 fn1 fn1 ] [ sta sta sta ] [ stb stb stb ] % 102-104
6857 [ stc stc stc ] [ stp stp stp ] % 105-106
6858 ] def
6859
6860 % Invert charmaps to give character to value maps for each state
6861 /charvals [ 109 dict 109 dict 109 dict ] def
6862 0 1 charmaps length 1 sub {
6863 /i exch def
6864 /encs charmaps i get def
6865 0 1 2 {
6866 /j exch def
6867 encs j get dup type /stringtype eq {0 get} if % convert string to ASCII if required
6868 charvals j get exch i put
6869 } for
6870 } for
6871 } ctxdef
6872
6873 encoding (legacy) eq {
6874
6875 % Include pseudo characters for GS1-128 Composite linkage identifiers
6876 /seta charvals 0 get def seta lka seta swb get put seta lkc seta swc get put
6877 /setb charvals 1 get def setb lka setb swc get put setb lkc setb swa get put
6878 /setc charvals 2 get def setc lka setc swa get put setc lkc setc swb get put
6879
6880 % Standard and extended ASCII runlength at position
6881 /numSA [ msglen {0} repeat 0 ] def
6882 /numEA [ msglen {0} repeat 0 ] def
6883 msglen 1 sub -1 0 {
6884 /i exch def
6885 msg i get 0 ge {
6886 msg i get 128 ge {
6887 numEA i numEA i 1 add get 1 add put
6888 } {
6889 numSA i numSA i 1 add get 1 add put
6890 } ifelse
6891 } if
6892 } for
6893
6894 % FNC4 codeword insertion for extended ASCII
6895 /ea false def /msgtmp [] def
6896 0 1 msglen 1 sub {
6897 /i exch def
6898 /c msg i get def
6899 ea c 128 lt xor not c 0 ge and { % Other mode required
6900 ea {numSA} {numEA} ifelse i get dup % Runlength of other mode
6901 i add msglen eq {3} {5} ifelse % Does run terminate symbol
6902 lt { % Shift
6903 /msgtmp [ msgtmp aload pop fn4 ] def
6904 } { % Latch
6905 /msgtmp [ msgtmp aload pop fn4 fn4 ] def
6906 /ea ea not def
6907 } ifelse
6908 } if
6909 /msgtmp [ msgtmp aload pop c 0 ge {c 127 and} {c} ifelse ] def
6910 } for
6911 /msg msgtmp def
6912 /msglen msg length def
6913
6914 % Determine digit runlength from given position
6915 /numsscr {
6916 /s 0 def
6917 /p exch def {
6918 p msglen ge {exit} if
6919 msg p get
6920 dup setc exch known not {pop exit} if
6921 dup -1 le {
6922 % FNC1 in odd position of run like two digits
6923 fn1 eq s 2 mod 0 eq and {/s s 1 add def} {exit} ifelse
6924 } {
6925 pop
6926 } ifelse
6927 /s s 1 add def
6928 /p p 1 add def
6929 } loop
6930 s
6931 } def
6932
6933 % Encoding for each alphabet
6934 /enca {
6935 seta exch get cws exch j exch put
6936 /j j 1 add def
6937 } def
6938 /encb {
6939 setb exch get cws exch j exch put
6940 /j j 1 add def
6941 } def
6942 /encc {
6943 dup type /arraytype ne {
6944 setc exch get
6945 } {
6946 aload pop 48 sub exch 48 sub 10 mul add
6947 } ifelse
6948 cws exch j exch put
6949 /j j 1 add def
6950 } def
6951
6952 % Character exclusively in either alphabet A or B
6953 /anotb {dup seta exch known exch setb exch known not and} def
6954 /bnota {dup setb exch known exch seta exch known not and} def
6955
6956 % Pre-compute relative position of next anotb and next bnota characters
6957 /nextanotb [ msg length {0} repeat 9999 ] def
6958 /nextbnota [ msg length {0} repeat 9999 ] def
6959 msg length 1 sub -1 0 {
6960 /i exch def
6961 msg i get anotb {
6962 nextanotb i 0 put
6963 } {
6964 nextanotb i nextanotb i 1 add get 1 add put
6965 } ifelse
6966 msg i get bnota {
6967 nextbnota i 0 put
6968 } {
6969 nextbnota i nextbnota i 1 add get 1 add put
6970 } ifelse
6971 } for
6972
6973 % Does a-only come before b-only after given position and vice versa
6974 /abeforeb {dup nextanotb exch get exch nextbnota exch get lt} def
6975 /bbeforea {dup nextbnota exch get exch nextanotb exch get lt} def
6976
6977 /cws barcode length 2 mul 3 add array def
6978
6979 % Select start character
6980 /j 0 def
6981 msglen 0 gt {0 numsscr} {-1} ifelse /nums exch def
6982 { % common exit
6983 msglen 0 eq {
6984 stb enca
6985 /cset (setb) def
6986 exit
6987 } if
6988 msglen 2 eq nums 2 eq and {
6989 stc enca
6990 /cset (setc) def
6991 exit
6992 } if
6993 nums 4 ge {
6994 stc enca
6995 /cset (setc) def
6996 exit
6997 } if
6998 0 abeforeb {
6999 sta enca
7000 /cset (seta) def
7001 exit
7002 } if
7003 stb enca
7004 /cset (setb) def
7005 exit
7006 } loop
7007
7008 % Main encoding loop
7009 /i 0 def {
7010 i msglen eq {exit} if
7011
7012 i numsscr /nums exch def
7013
7014 % Determine switches and shifts
7015 { % common exit
7016 cset (seta) eq cset (setb) eq or nums 4 ge and
7017 msg i get fn1 ne and {
7018 nums 2 mod 0 eq {
7019 swc cset (seta) eq {enca} {encb} ifelse
7020 /cset (setc) def
7021 exit
7022 } {
7023 msg i get cset (seta) eq {enca} {encb} ifelse
7024 /i i 1 add def
7025 i numsscr 4 ge {
7026 swc cset (seta) eq {enca} {encb} ifelse
7027 /cset (setc) def
7028 exit
7029 } if
7030 } ifelse
7031 } if
7032 cset (setb) eq msg i get anotb and {
7033 i msglen 1 sub lt {
7034 i 1 add bbeforea {
7035 sft encb
7036 msg i get enca
7037 /i i 1 add def
7038 exit
7039 } if
7040 } if
7041 swa encb
7042 /cset (seta) def
7043 exit
7044 } if
7045 cset (seta) eq msg i get bnota and {
7046 i msglen 1 sub lt {
7047 i 1 add abeforeb {
7048 sft enca
7049 msg i get encb
7050 /i i 1 add def
7051 exit
7052 } if
7053 } if
7054 swb enca
7055 /cset (setb) def
7056 exit
7057 } if
7058 cset (setc) eq nums 2 lt and msg i get -1 gt msg i get fn4 eq or and {
7059 i abeforeb {
7060 swa encc
7061 /cset (seta) def
7062 exit
7063 } if
7064 swb encc
7065 /cset (setb) def
7066 exit
7067 } if
7068
7069 % No switches or latches so encode
7070 cset (seta) eq {
7071 msg i get enca
7072 /i i 1 add def
7073 exit
7074 } if
7075 cset (setb) eq {
7076 msg i get encb
7077 /i i 1 add def
7078 exit
7079 } if
7080 cset (setc) eq {
7081 msg i get -1 le {
7082 msg i get encc
7083 /i i 1 add def
7084 } {
7085 msg i 2 getinterval encc
7086 /i i 2 add def
7087 } ifelse
7088 exit
7089 } if
7090
7091 exit
7092 } loop
7093
7094 } loop
7095 /cws cws 0 j getinterval def
7096
7097 } if % legacy encoder
7098
7099 encoding (new) eq {
7100
7101 % Include pseudo characters for GS1-128 Composite linkage identifiers
7102 /seta <<fn3 96 fn2 97 fn1 102 stp 106 lka 100 lkc 99>> def
7103 /setb <<fn3 96 fn2 97 fn1 102 stp 106 lka 99 lkc 101>> def
7104 /setc << fn1 102 stp 106 lka 101 lkc 100>> def
7105
7106 % Encoder states are named A0, B0, C0, A1, B1, and C1.
7107 % A, B, and C are the Code 128 code sets.
7108 % 0 is for ASCII and 1 is for extended ASCII range.
7109 % The encoder relies on this order a lot, but it uses
7110 % the "state_priority" list for prioritizing states.
7111 % Strings are a convenient way of defining latch
7112 % sequences. The strings map to Code 128 instructions.
7113 % The (dddc) sequences are never inserted, but they
7114 % are in the lists to provide the correct length.
7115 % Prior state
7116 % A0 B0 C0 A1 B1 C1
7117 /latch_a0 [() (e) (e) (ee) (eee) (eee) ] def
7118 /latch_b0 [(d) () (d) (ddd) (dd) (ddd) ] def
7119 /latch_c0 [(c) (c) () (eec) (ddc) (dddc)] def
7120 /latch_a1 [(ee) (eee) (eee) () (e) (e) ] def
7121 /latch_b1 [(ddd) (dd) (ddd) (d) () (d) ] def
7122 /latch_c1 [(eec) (ddc) (dddc) (c) (c) () ] def
7123
7124 /latch_length_a0 [latch_a0 {length} forall] def
7125 /latch_length_a1 [latch_a1 {length} forall] def
7126 /latch_length_b0 [latch_b0 {length} forall] def
7127 /latch_length_b1 [latch_b1 {length} forall] def
7128 /latch_length_c0 [latch_c0 {length} forall] def
7129 /latch_length_c1 [latch_c1 {length} forall] def
7130
7131 % Backtracking needs a way of mapping states to sequences
7132 /latch_sequence [latch_a0 latch_b0 latch_c0 latch_a1 latch_b1 latch_c1] def
7133 /encode [{enc_a0} {enc_b0} {enc_c } {enc_a1} {enc_b1} {enc_c }] def
7134 /start_code [103 104 105] def
7135
7136 /state_priority [1 0 2 4 3 5] def % Configure encoder to conform with existing tests
7137 /start_state [0 1 2 0 1 2] def % Encoding starts in ASCII
7138 /start_length [1 1 1 1 1 1] def % Room for start code
7139
7140 % A reverse priority list is handy for preprocessing latch lengths and final state
7141 /reverse_priority [[5 4 3 2 1 0] {state_priority exch get} forall] def
7142
7143 % Preprocessed latch lengths help satisfy the need for speed
7144 /prioritized_latch_length_a0 [reverse_priority {dup dup latch_length_a0 exch get exch} forall] def
7145 /prioritized_latch_length_a1 [reverse_priority {dup dup latch_length_a1 exch get exch} forall] def
7146 /prioritized_latch_length_b0 [reverse_priority {dup dup latch_length_b0 exch get exch} forall] def
7147 /prioritized_latch_length_b1 [reverse_priority {dup dup latch_length_b1 exch get exch} forall] def
7148 /prioritized_latch_length_c0 [reverse_priority {dup dup latch_length_c0 exch get exch} forall] def
7149 /prioritized_latch_length_c1 [reverse_priority {dup dup latch_length_c1 exch get exch} forall] def
7150
7151 /max_int 16#7FFFFFFF def % Make sure state doesn't get picked.
7152
7153 % Predicates for ability to encode
7154 /can_a {c 0 ge {true} {seta c known} ifelse} def
7155 /can_b {c 0 ge {true} {setb c known} ifelse} def
7156 /can_c0 {num_digits 2 ge {true} {setc c known} ifelse} def
7157 /can_c1 {num_digits 2 ge {true} {setc c known} ifelse} def
7158
7159 % Predicates overruled by options
7160 suppressc {/can_c0 {false} def} if
7161 suppressc unlatchextbeforec or {/can_c1 {false} def} if
7162
7163 % Output length
7164 /out_a0 {1 c 0 ge {c 128 ge {1 add} if c 127 and 96 ge {1 add} if} if} def
7165 /out_a1 {1 c 0 ge {c 128 lt {1 add} if c 127 and 96 ge {1 add} if} if} def
7166 /out_b0 {1 c 0 ge {c 128 ge {1 add} if c 127 and 32 lt {1 add} if} if} def
7167 /out_b1 {1 c 0 ge {c 128 lt {1 add} if c 127 and 32 lt {1 add} if} if} def
7168
7169 % Encode
7170 /map_ab {dup 32 lt {64 add} {32 sub} ifelse} def
7171 /enc_a0 {[c 0 lt {seta c get} {c 128 ge {101} if c 127 and dup 96 ge {98 exch} if map_ab} ifelse]} def
7172 /enc_a1 {[c 0 lt {seta c get} {c 128 lt {101} if c 127 and dup 96 ge {98 exch} if map_ab} ifelse]} def
7173 /enc_b0 {[c 0 lt {setb c get} {c 128 ge {100} if c 127 and dup 32 lt {98 exch} if map_ab} ifelse]} def
7174 /enc_b1 {[c 0 lt {setb c get} {c 128 lt {100} if c 127 and dup 32 lt {98 exch} if map_ab} ifelse]} def
7175 /enc_c {[c 0 lt {setc c get} {msg n get 48 sub 10 mul msg n 1 add get 48 sub add } ifelse]} def
7176
7177 % Get best prior state based on a prior row of lengths and a row of latch
7178 % lengths (unrolled and with preprocessed latch lengths on the stack)
7179 /get_best_prior_state {
7180 bln_0 exch get add /len exch def /o exch def
7181 bln_0 exch get add dup len lt {/len exch def /o exch def} {pop pop} ifelse
7182 bln_0 exch get add dup len lt {/len exch def /o exch def} {pop pop} ifelse
7183 bln_0 exch get add dup len lt {/len exch def /o exch def} {pop pop} ifelse
7184 bln_0 exch get add dup len lt {/len exch def /o exch def} {pop pop} ifelse
7185 bln_0 exch get add len lt { /o exch def} { pop} ifelse
7186 o
7187 } def
7188
7189 % The encoder considers the current row and two rows back.
7190 % The circular history buffer size is 4 for convenience.
7191 % The names are short to keep the lines below reasonable
7192 /bln_0 start_length def /bln_1 start_length def /bln [4 {[0 0 0 0 0 0]} repeat] def % Best Length
7193 /bps_0 start_state def /bps_1 start_state def /bps [4 {[0 0 0 0 0 0]} repeat] def % Best Prior State
7194
7195 % Path for backtracking
7196 /path [msg length {[0 0 0 0 0 0]} repeat] def
7197
7198 /make_tables {
7199 /num_digits 0 def
7200 0 1 msg length 1 sub {
7201 /n exch def
7202 /c msg n get def
7203
7204 % Keep a tab on digits
7205 /num_digits c 48 ge c 58 lt and {num_digits 1 add} {0} ifelse def
7206
7207 % Circular history buffer machinery
7208 /bln_2 bln_1 def /bln_1 bln_0 def /bln_0 bln n 3 and get def
7209 /bps_2 bps_1 def /bps_1 bps_0 def /bps_0 bps n 3 and get def
7210
7211 % Pick history rows for code set c depending on digits
7212 /bps_c num_digits 2 ge {bps_2} {bps_1} ifelse def
7213 /bln_c num_digits 2 ge {bln_2} {bln_1} ifelse def
7214
7215 % Use the best prior states and the prior best lengths to determine new best lengths and plot the path
7216 bln_0 0 can_a {/p bps_1 0 get def path n get 0 p put bln_1 p get latch_length_a0 p get add out_a0 add} {max_int} ifelse put
7217 bln_0 3 can_a {/p bps_1 3 get def path n get 3 p put bln_1 p get latch_length_a1 p get add out_a1 add} {max_int} ifelse put
7218 bln_0 1 can_b {/p bps_1 1 get def path n get 1 p put bln_1 p get latch_length_b0 p get add out_b0 add} {max_int} ifelse put
7219 bln_0 4 can_b {/p bps_1 4 get def path n get 4 p put bln_1 p get latch_length_b1 p get add out_b1 add} {max_int} ifelse put
7220 bln_0 2 can_c0 {/p bps_c 2 get def path n get 2 p put bln_c p get latch_length_c0 p get add 1 add} {max_int} ifelse put
7221 bln_0 5 can_c1 {/p bps_c 5 get def path n get 5 p put bln_c p get latch_length_c1 p get add 1 add} {max_int} ifelse put
7222
7223 % Use the new best lengths to determine new best prior states
7224 bps_0 0 prioritized_latch_length_a0 aload pop get_best_prior_state put
7225 bps_0 3 prioritized_latch_length_a1 aload pop get_best_prior_state put
7226 bps_0 1 prioritized_latch_length_b0 aload pop get_best_prior_state put
7227 bps_0 4 prioritized_latch_length_b1 aload pop get_best_prior_state put
7228 bps_0 2 prioritized_latch_length_c0 aload pop get_best_prior_state put
7229 bps_0 5 prioritized_latch_length_c1 aload pop get_best_prior_state put
7230 } for
7231 } def
7232
7233 /backtrack {
7234 /n msg length def
7235
7236 % Get best final state and final length
7237 reverse_priority {dup bln_0 exch get dup} forall
7238 pop /len exch def /state exch def
7239 5 {len lt {/len exch def /state exch def} {pop pop} ifelse} repeat
7240
7241 len array % Put output array on the stack
7242 {
7243 n 0 le {exit} if
7244 /prior_state path n 1 sub get state get def % Get prior state (following path)
7245 /latch [latch_sequence state get prior_state get {} forall] def % Get latch sequence and convert from string to array
7246 /n n state 2 eq state 5 eq or msg n 1 sub get 48 ge and {2} {1} ifelse sub def % Get intake and subtract it from the input index
7247 /c msg n get def % Get current character (the encoding below needs it)
7248 /enc encode state get exec def % Encode state
7249 /len len latch length sub enc length sub def % Subtract latch length and output length from output index
7250 dup len latch 3 copy putinterval length add enc putinterval % Copy latch and encoded entry to output
7251 /state prior_state def % Prepare for next iteration
7252 } loop
7253 dup 0 start_code state get put % Add start code
7254 } def
7255
7256 make_tables backtrack
7257
7258 /cws exch def
7259
7260 } if % auto encoding
7261
7262 % Derive checksum and place stop character
7263 /j cws length def
7264 /cws j 2 add array dup 0 cws putinterval def
7265 /csum cws 0 get def
7266 1 1 j 1 sub {
7267 /i exch def
7268 /csum csum cws i get i mul add def
7269 } for
7270 /csum csum 103 mod def
7271 cws j csum put
7272 cws j 1 add 106 put % stp
7273
7274 options /debugcws known { /bwipp.debugcws cws //raiseerror exec } if
7275
7276 % Create an array containing the character mappings
7277 {
7278 /encs
7279 [ (212222) (222122) (222221) (121223) (121322) (131222) (122213)
7280 (122312) (132212) (221213) (221312) (231212) (112232) (122132)
7281 (122231) (113222) (123122) (123221) (223211) (221132) (221231)
7282 (213212) (223112) (312131) (311222) (321122) (321221) (312212)
7283 (322112) (322211) (212123) (212321) (232121) (111323) (131123)
7284 (131321) (112313) (132113) (132311) (211313) (231113) (231311)
7285 (112133) (112331) (132131) (113123) (113321) (133121) (313121)
7286 (211331) (231131) (213113) (213311) (213131) (311123) (311321)
7287 (331121) (312113) (312311) (332111) (314111) (221411) (431111)
7288 (111224) (111422) (121124) (121421) (141122) (141221) (112214)
7289 (112412) (122114) (122411) (142112) (142211) (241211) (221114)
7290 (413111) (241112) (134111) (111242) (121142) (121241) (114212)
7291 (124112) (124211) (411212) (421112) (421211) (212141) (214121)
7292 (412121) (111143) (111341) (131141) (114113) (114311) (411113)
7293 (411311) (113141) (114131) (311141) (411131) (211412) (211214)
7294 (211232) (2331112)
7295 ] def
7296 } ctxdef
7297
7298 % Derive space bar succession
7299 /sbs cws length 6 mul 1 add string def
7300 0 1 cws length 1 sub {
7301 /i exch def
7302 sbs i 6 mul encs cws i get get putinterval
7303 } for
7304
7305 % Return the arguments
7306 <<
7307 /ren /renlinear
7308 /sbs [sbs {48 sub} forall]
7309 /bhs [sbs length 1 add 2 idiv {height} repeat]
7310 /bbs [sbs length 1 add 2 idiv {0} repeat]
7311 /txt [ [text textxoffset textyoffset textfont textsize] ]
7312 /textxalign (center)
7313 /opt options
7314 >>
7315
7316 dontdraw not //renlinear if
7317
7318 //unloadctx exec
7319
7320 end
7321
7322 }
7323 [/barcode] {null def} forall
7324 bind def
7325 /code128 dup load /uk.co.terryburton.bwipp defineresource pop
7326 end
7327 /setpacking where {pop setpacking} if
7328 %%EndData
7329 %%EndResource
7330 % --END ENCODER code128--
7331
7332 % --BEGIN ENCODER gs1-128--
7333 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process rendertext renlinear code128--
7334 % --DESC: GS1-128
7335 % --EXAM: (01)09521234543213(3103)000123
7336 % --EXOP: includetext
7337 % --RNDR: renlinear
7338 %%BeginResource: uk.co.terryburton.bwipp gs1-128 0.0 2025111800 83236 86555
7339 %%BeginData: 102 ASCII Lines
7340 /setpacking where {pop currentpacking true setpacking} if
7341 10 dict
7342 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
7343 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
7344 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
7345 dup /gs1process dup /uk.co.terryburton.bwipp findresource put
7346 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
7347 dup /code128 dup /uk.co.terryburton.bwipp findresource put
7348 begin
7349 /gs1-128 {
7350
7351 20 dict begin % Confine variables to local scope
7352
7353 /ctx null def
7354 /dontdraw false def
7355 /includetext false def % Enable/disable text
7356 /textfont /Courier def
7357 /textsize 10.0 def
7358 /textxoffset 0.0 def
7359 /textyoffset -7.0 def
7360 /height 0.5 def
7361 /linkagea false def
7362 /linkagec false def
7363 /parse false def
7364 /dontlint false def
7365 /lintreqs false def
7366
7367 //processoptions exec /options exch def
7368 /barcode exch def
7369
7370 linkagea linkagec and {
7371 /bwipp.gs1128badLinkage (linkagea and linkagec cannot be used together) //raiseerror exec
7372 } if
7373
7374 /text barcode def
7375
7376 barcode /ai //gs1process exec
7377 /fncs exch def
7378 /vals exch def
7379 /ais exch def
7380
7381 % Create the code128 data
7382 /fnc1 -1 def
7383 /c128 [ fnc1 ] def
7384 0 1 ais length 1 sub {
7385 /i exch def
7386 /ai ais i get def
7387 /val vals i get def
7388 c128 length ai length add val length add array
7389 dup 0 c128 putinterval
7390 dup c128 length ai [ exch {} forall ] putinterval
7391 dup c128 length ai length add val [ exch {} forall ] putinterval
7392 /c128 exch def
7393 i ais length 1 sub ne fncs i get and { % Append FNC1
7394 c128 length 1 add array
7395 dup 0 c128 putinterval
7396 dup c128 length fnc1 put
7397 /c128 exch def
7398 } if
7399 } for
7400
7401 % Compose input to code128
7402 /barcode c128 length 1 add 5 mul string def
7403 /i 0 def /j 0 def {
7404 i c128 length eq {exit} if
7405 c128 i get dup fnc1 eq {
7406 pop barcode j (^FNC1) putinterval
7407 /j j 4 add def
7408 } {
7409 barcode exch j exch put
7410 } ifelse
7411 /i i 1 add def
7412 /j j 1 add def
7413 } loop
7414 linkagea linkagec or {
7415 barcode j linkagea {(^LNKA)} {(^LNKC)} ifelse putinterval
7416 /j j 5 add def
7417 } if
7418 /barcode barcode 0 j getinterval def
7419
7420 % Get the result of encoding with code128
7421 options (parse) undef
7422 options (height) height put
7423 options (dontdraw) true put
7424 options (parsefnc) true put
7425 /args barcode options //code128 exec def
7426
7427 args (txt) [ [text textxoffset textyoffset textfont textsize] ] put
7428 args (textxalign) (center) put
7429 args (opt) options put
7430 args
7431
7432 dontdraw not //renlinear if
7433
7434 end
7435
7436 }
7437 [/barcode] {null def} forall
7438 bind def
7439 /gs1-128 dup load /uk.co.terryburton.bwipp defineresource pop
7440 end
7441 /setpacking where {pop setpacking} if
7442 %%EndData
7443 %%EndResource
7444 % --END ENCODER gs1-128--
7445
7446 % --BEGIN ENCODER ean14--
7447 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renlinear code128--
7448 % --DESC: EAN-14
7449 % --EXAM: (01) 0 952 8765 43210 8
7450 % --EXOP: includetext
7451 % --RNDR: renlinear
7452 %%BeginResource: uk.co.terryburton.bwipp ean14 0.0 2025111800 75529 75291
7453 %%BeginData: 92 ASCII Lines
7454 /setpacking where {pop currentpacking true setpacking} if
7455 10 dict
7456 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
7457 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
7458 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
7459 dup /code128 dup /uk.co.terryburton.bwipp findresource put
7460 begin
7461 /ean14 {
7462
7463 20 dict begin % Confine variables to local scope
7464
7465 /ctx null def
7466 /dontdraw false def
7467 /includetext false def % Enable/disable text
7468 /textfont /Courier def
7469 /textsize 10.0 def
7470 /textxoffset 0.0 def
7471 /textyoffset -7.0 def
7472 /height 1.0 def
7473
7474 //processoptions exec /options exch def
7475 /barcode exch def
7476
7477 % Strip spaces from the given data
7478 /text barcode def
7479 barcode dup length string exch 0 exch
7480 {dup 32 ne {3 copy put pop 1 add} {pop} ifelse} forall
7481 0 exch getinterval /barcode exch def
7482 /hasspace text length barcode length ne def
7483
7484 % Validate the input
7485 barcode length 17 ne barcode length 18 ne and {
7486 /bwipp.ean14badLength (EAN-14 must be 13 or 14 digits) //raiseerror exec
7487 } if
7488 barcode 0 4 getinterval (\(01\)) ne {
7489 /bwipp.ean14badAI (EAN-14 must begin with (01) application identifier) //raiseerror exec
7490 } if
7491 barcode 4 barcode length 4 sub getinterval {
7492 dup 48 lt exch 57 gt or {
7493 /bwipp.ean14badCharacter (EAN-14 must contain only digits) //raiseerror exec
7494 } if
7495 } forall
7496
7497 % Calculate checksum and add to end of barcode
7498 /checksum 0 def
7499 0 1 12 {
7500 /i exch def
7501 /checksum checksum barcode i 4 add get 48 sub i 2 mod 0 eq {3 mul} if add def
7502 } for
7503 /checksum 10 checksum 10 mod sub 10 mod def
7504 barcode length 18 eq {
7505 barcode 17 get checksum 48 add ne {
7506 /bwipp.ean14badCheckDigit (Incorrect EAN-14 check digit provided) //raiseerror exec
7507 } if
7508 } {
7509 18 string
7510 dup 0 barcode putinterval
7511 dup 17 checksum 48 add put
7512 /barcode exch def
7513 text length hasspace {2} {1} ifelse add string
7514 dup dup length 2 sub ( ) putinterval
7515 dup dup length 1 sub checksum 48 add put
7516 dup 0 text putinterval
7517 /text exch def
7518 } ifelse
7519 /gtin barcode 4 14 getinterval def
7520
7521 % Compose input to code128
7522 /barcode 21 string def
7523 barcode 0 (^FNC101) putinterval
7524 barcode 7 gtin putinterval
7525
7526 % Get the result of encoding with code128
7527 options (dontdraw) true put
7528 options (parsefnc) true put
7529 /args barcode options //code128 exec def
7530
7531 args (txt) [ [text textxoffset textyoffset textfont textsize] ] put
7532 args (textxalign) (center) put
7533 args (opt) options put
7534 args
7535
7536 dontdraw not //renlinear if
7537
7538 end
7539
7540 }
7541 [/barcode] {null def} forall
7542 bind def
7543 /ean14 dup load /uk.co.terryburton.bwipp defineresource pop
7544 end
7545 /setpacking where {pop setpacking} if
7546 %%EndData
7547 %%EndResource
7548 % --END ENCODER ean14--
7549
7550 % --BEGIN ENCODER sscc18--
7551 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renlinear code128--
7552 % --DESC: SSCC-18
7553 % --EXAM: (00) 0 9528765 432101234 6
7554 % --EXOP: includetext
7555 % --RNDR: renlinear
7556 %%BeginResource: uk.co.terryburton.bwipp sscc18 0.0 2025111800 75541 75298
7557 %%BeginData: 92 ASCII Lines
7558 /setpacking where {pop currentpacking true setpacking} if
7559 10 dict
7560 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
7561 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
7562 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
7563 dup /code128 dup /uk.co.terryburton.bwipp findresource put
7564 begin
7565 /sscc18 {
7566
7567 20 dict begin % Confine variables to local scope
7568
7569 /ctx null def
7570 /dontdraw false def
7571 /includetext false def % Enable/disable text
7572 /textfont /Courier def
7573 /textsize 10.0 def
7574 /textxoffset 0.0 def
7575 /textyoffset -7.0 def
7576 /height 1.0 def
7577
7578 //processoptions exec /options exch def
7579 /barcode exch def
7580
7581 % Strip spaces from the given data
7582 /text barcode def
7583 barcode dup length string exch 0 exch
7584 {dup 32 ne {3 copy put pop 1 add} {pop} ifelse} forall
7585 0 exch getinterval /barcode exch def
7586 /hasspace text length barcode length ne def
7587
7588 % Validate the input
7589 barcode length 21 ne barcode length 22 ne and {
7590 /bwipp.sscc18badLength (SSCC-18 must be 17 or 18 digits) //raiseerror exec
7591 } if
7592 barcode 0 4 getinterval (\(00\)) ne {
7593 /bwipp.sscc18badAI (SSCC-18 must begin with (00) application identifier) //raiseerror exec
7594 } if
7595 barcode 4 barcode length 4 sub getinterval {
7596 dup 48 lt exch 57 gt or {
7597 /bwipp.sscc18badCharacter (SSCC-18 must contain only digits) //raiseerror exec
7598 } if
7599 } forall
7600
7601 % Calculate checksum and add to end of barcode
7602 /checksum 0 def
7603 0 1 16 {
7604 /i exch def
7605 /checksum checksum barcode i 4 add get 48 sub i 2 mod 0 eq {3 mul} if add def
7606 } for
7607 /checksum 10 checksum 10 mod sub 10 mod def
7608 barcode length 22 eq {
7609 barcode 21 get checksum 48 add ne {
7610 /bwipp.sscc18badCheckDigit (Incorrect SSCC-18 check digit provided) //raiseerror exec
7611 } if
7612 } {
7613 22 string
7614 dup 0 barcode putinterval
7615 dup 21 checksum 48 add put
7616 /barcode exch def
7617 text length hasspace {2} {1} ifelse add string
7618 dup dup length 2 sub ( ) putinterval
7619 dup dup length 1 sub checksum 48 add put
7620 dup 0 text putinterval
7621 /text exch def
7622 } ifelse
7623 /sscc barcode 4 18 getinterval def
7624
7625 % Compose input to code128
7626 /barcode 25 string def
7627 barcode 0 (^FNC100) putinterval
7628 barcode 7 sscc putinterval
7629
7630 % Get the result of encoding with code128
7631 options (dontdraw) true put
7632 options (parsefnc) true put
7633 /args barcode options //code128 exec def
7634
7635 args (txt) [ [text textxoffset textyoffset textfont textsize] ] put
7636 args (textxalign) (center) put
7637 args (opt) options put
7638 args
7639
7640 dontdraw not //renlinear if
7641
7642 end
7643
7644 }
7645 [/barcode] {null def} forall
7646 bind def
7647 /sscc18 dup load /uk.co.terryburton.bwipp defineresource pop
7648 end
7649 /setpacking where {pop setpacking} if
7650 %%EndData
7651 %%EndResource
7652 % --END ENCODER sscc18--
7653
7654 % --BEGIN ENCODER code39--
7655 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear--
7656 % --DESC: Code 39
7657 % --EXAM: THIS IS CODE 39
7658 % --EXOP: includetext includecheck includecheckintext
7659 % --RNDR: renlinear
7660 %%BeginResource: uk.co.terryburton.bwipp code39 0.0 2025111800 75808 75682
7661 %%BeginData: 141 ASCII Lines
7662 /setpacking where {pop currentpacking true setpacking} if
7663 10 dict
7664 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
7665 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
7666 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
7667 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
7668 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
7669 begin
7670 /code39 {
7671
7672 20 dict begin % Confine variables to local scope
7673
7674 /ctx null def
7675 /dontdraw false def
7676 /includecheck false def
7677 /validatecheck false def
7678 /includetext false def
7679 /includecheckintext false def
7680 /hidestars false def
7681 /textfont /Courier def
7682 /textsize 10.0 def
7683 /textyoffset -7.0 def
7684 /height 1.0 def
7685
7686 //processoptions exec /options exch def
7687 /barcode exch def
7688
7689 barcode () eq {
7690 /bwipp.code39emptyData (The data must not be empty) //raiseerror exec
7691 } if
7692
7693 /code39 //loadctx exec
7694
7695 {
7696 % Create an array containing the character mappings
7697 /encs
7698 [ (1113313111) (3113111131) (1133111131) (3133111111) (1113311131)
7699 (3113311111) (1133311111) (1113113131) (3113113111) (1133113111)
7700 (3111131131) (1131131131) (3131131111) (1111331131) (3111331111)
7701 (1131331111) (1111133131) (3111133111) (1131133111) (1111333111)
7702 (3111111331) (1131111331) (3131111311) (1111311331) (3111311311)
7703 (1131311311) (1111113331) (3111113311) (1131113311) (1111313311)
7704 (3311111131) (1331111131) (3331111111) (1311311131) (3311311111)
7705 (1331311111) (1311113131) (3311113111) (1331113111) (1313131111)
7706 (1313111311) (1311131311) (1113131311) (1311313111)
7707 ] def
7708
7709 % Create a string of the available characters
7710 /barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def
7711 /charvals 43 dict def
7712 0 1 42 {charvals exch dup barchars exch 1 getinterval exch put} for
7713 } ctxdef
7714
7715 % Validate the input
7716 0 1 barcode length 1 sub {
7717 barcode exch 1 getinterval charvals exch known not {
7718 /bwipp.code39badCharacter (Code 39 must contain only digits, capital letters, spaces and the symbols -.$/+%) //raiseerror exec
7719 } if
7720 } for
7721
7722 /barlen barcode length validatecheck {1 sub} if def
7723
7724 /checksum 0 def
7725 0 1 barlen 1 sub {
7726 barcode exch 1 getinterval charvals exch get
7727 checksum add /checksum exch def
7728 } for
7729 /checksum checksum 43 mod def
7730 validatecheck {
7731 barcode barlen get barchars checksum get ne {
7732 /bwipp.code39badCheckDigit (Incorrect Code 39 check digit provided) //raiseerror exec
7733 } if
7734 /barcode barcode 0 barlen getinterval def
7735 /includecheck true def
7736 } if
7737
7738 /sbs barlen includecheck {3} {2} ifelse add 10 mul string def
7739 /txt barlen includecheck {3} {2} ifelse add array def
7740
7741 % Put the start character
7742 sbs 0 encs 43 get putinterval
7743 hidestars not {
7744 txt 0 [(*) 0 textyoffset textfont textsize] put
7745 } {
7746 txt 0 [() 0 textyoffset textfont textsize] put
7747 } ifelse
7748
7749 0 1 barlen 1 sub {
7750 /i exch def
7751 /indx charvals barcode i 1 getinterval get def
7752 sbs i 10 mul 10 add encs indx get putinterval
7753 txt i 1 add [barcode i 1 getinterval i 1 add 16 mul textyoffset textfont textsize] put
7754 } for
7755
7756 % Put the checksum and end characters
7757 includecheck {
7758 sbs barlen 10 mul 10 add encs checksum get putinterval
7759 includecheckintext {
7760 txt barlen 1 add [barchars checksum 1 getinterval barlen 1 add 16 mul textyoffset textfont textsize] put
7761 } {
7762 txt barlen 1 add [() barlen 1 add 16 mul textyoffset textfont textsize] put
7763 } ifelse
7764 sbs barlen 10 mul 20 add encs 43 get putinterval
7765 hidestars not {
7766 txt barlen 2 add [(*) barlen 2 add 16 mul textyoffset textfont textsize] put
7767 } {
7768 txt barlen 2 add [() barlen 2 add 16 mul textyoffset textfont textsize] put
7769 } ifelse
7770 } {
7771 sbs barlen 10 mul 10 add encs 43 get putinterval
7772 hidestars not {
7773 txt barlen 1 add [(*) barlen 1 add 16 mul textyoffset textfont textsize] put
7774 } {
7775 txt barlen 1 add [() barlen 1 add 16 mul textyoffset textfont textsize] put
7776 } ifelse
7777 } ifelse
7778
7779 % Return the arguments
7780 <<
7781 /ren /renlinear
7782 /sbs [sbs {48 sub} forall]
7783 /bhs [sbs length 1 add 2 idiv {height} repeat]
7784 /bbs [sbs length 1 add 2 idiv {0} repeat]
7785 includetext {
7786 /txt txt
7787 } if
7788 /opt options
7789 >>
7790
7791 dontdraw not //renlinear if
7792
7793 //unloadctx exec
7794
7795 end
7796
7797 }
7798 [/barcode] {null def} forall
7799 bind def
7800 /code39 dup load /uk.co.terryburton.bwipp defineresource pop
7801 end
7802 /setpacking where {pop setpacking} if
7803 %%EndData
7804 %%EndResource
7805 % --END ENCODER code39--
7806
7807 % --BEGIN ENCODER code39ext--
7808 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renlinear code39--
7809 % --DESC: Code 39 Extended
7810 % --EXAM: Code39 Ext!
7811 % --EXOP: includetext includecheck includecheckintext
7812 % --RNDR: renlinear
7813 %%BeginResource: uk.co.terryburton.bwipp code39ext 0.0 2025111800 78787 74849
7814 %%BeginData: 99 ASCII Lines
7815 /setpacking where {pop currentpacking true setpacking} if
7816 10 dict
7817 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
7818 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
7819 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
7820 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
7821 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
7822 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
7823 dup /code39 dup /uk.co.terryburton.bwipp findresource put
7824 begin
7825 /code39ext {
7826
7827 20 dict begin
7828
7829 /ctx null def
7830 /dontdraw false def
7831 /includetext false def
7832 /parse false def
7833
7834 //processoptions exec /options exch def
7835 /barcode exch def
7836
7837 /code39ext //loadctx exec
7838
7839 % Parse ordinals of the form ^NNN to ASCII
7840 /fncvals <<
7841 /parse parse
7842 /parseonly true
7843 /parsefnc false
7844 >> def
7845 /barcode barcode fncvals //parseinput exec def
7846 /barlen barcode length def
7847 options (parse) undef
7848
7849 % Validate the input
7850 barcode {
7851 128 ge {
7852 /bwipp.code39extBadCharacter (Code 39 Extended must contain only ASCII characters) //raiseerror exec
7853 } if
7854 } forall
7855
7856 % Extended alphabet to non-extended alphabet
7857 {
7858 /extencs
7859 [ (%U) ($A) ($B) ($C) ($D) ($E) ($F) ($G) ($H) ($I) ($J) ($K) ($L) ($M) ($N) ($O)
7860 ($P) ($Q) ($R) ($S) ($T) ($U) ($V) ($W) ($X) ($Y) ($Z) (%A) (%B) (%C) (%D) (%E)
7861 ( ) (/A) (/B) (/C) (/D) (/E) (/F) (/G) (/H) (/I) (/J) (/K) (/L) (-) (.) (/O)
7862 (0) (1) (2) (3) (4) (5) (6) (7) (8) (9) (/Z) (%F) (%G) (%H) (%I) (%J)
7863 (%V) (A) (B) (C) (D) (E) (F) (G) (H) (I) (J) (K) (L) (M) (N) (O)
7864 (P) (Q) (R) (S) (T) (U) (V) (W) (X) (Y) (Z) (%K) (%L) (%M) (%N) (%O)
7865 (%W) (+A) (+B) (+C) (+D) (+E) (+F) (+G) (+H) (+I) (+J) (+K) (+L) (+M) (+N) (+O)
7866 (+P) (+Q) (+R) (+S) (+T) (+U) (+V) (+W) (+X) (+Y) (+Z) (%P) (%Q) (%R) (%S) (%T)
7867 ] def
7868 } ctxdef
7869
7870 /newcode barlen 2 mul string def
7871 /newtext barlen 2 mul string def
7872 /j 0 def
7873 0 1 barlen 1 sub {
7874 /i exch def
7875 /extchar extencs barcode i get get def
7876 newcode j extchar putinterval
7877 newtext j barcode i get dup dup 32 lt exch 127 eq or { pop 32 } if put
7878 extchar length 1 ne { newtext j 1 add 32 put } if
7879 /j j extchar length add def
7880 } for
7881 /newcode newcode 0 j getinterval def
7882 /newtext newtext 0 j getinterval def
7883
7884 % Get the result of encoding with code39
7885 options (dontdraw) true put
7886 /args newcode options //code39 exec def
7887
7888 % Replace chars in /txt with chars in newtext
7889 includetext {
7890 /txt args (txt) get def
7891 0 1 newtext length 1 sub {
7892 /i exch def
7893 /txtentry txt i 1 add get def
7894 txtentry 0 newtext i 1 getinterval put
7895 txt i 1 add txtentry put
7896 } for
7897 args (txt) txt put
7898 } if
7899 args (opt) options put
7900 args
7901
7902 dontdraw not //renlinear if
7903
7904 //unloadctx exec
7905
7906 end
7907
7908 }
7909 [/barcode] {null def} forall
7910 bind def
7911 /code39ext dup load /uk.co.terryburton.bwipp defineresource pop
7912 end
7913 /setpacking where {pop setpacking} if
7914 %%EndData
7915 %%EndResource
7916 % --END ENCODER code39ext--
7917
7918 % --BEGIN ENCODER code32--
7919 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear code39--
7920 % --DESC: Italian Pharmacode
7921 % --EXAM: 01234567
7922 % --EXOP: includetext
7923 % --RNDR: renlinear
7924 %%BeginResource: uk.co.terryburton.bwipp code32 0.0 2025111800 70518 70351
7925 %%BeginData: 87 ASCII Lines
7926 /setpacking where {pop currentpacking true setpacking} if
7927 10 dict
7928 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
7929 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
7930 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
7931 dup /code39 dup /uk.co.terryburton.bwipp findresource put
7932 begin
7933 /code32 {
7934
7935 20 dict begin
7936
7937 /ctx null def
7938 /dontdraw false def
7939 /includetext false def % Enable/disable code32 text
7940 /textfont /Courier def
7941 /textsize 10.0 def
7942 /textyoffset -7.0 def
7943 /textxoffset 0.0 def
7944 /height 1.0 def
7945
7946 //processoptions exec /options exch def
7947 /barcode exch def
7948
7949 % Validate the input
7950 barcode length 8 ne barcode length 9 ne and {
7951 /bwipp.code32badLength (Italian Pharmacode must be 8 or 9 digits) //raiseerror exec
7952 } if
7953 barcode {
7954 dup 48 lt exch 57 gt or {
7955 /bwipp.code32badCharacter (Italian Pharmacode must contain only digits) //raiseerror exec
7956 } if
7957 } forall
7958
7959 % Calculate check digit
7960 /checksum 0 def
7961 0 1 7 {
7962 /i exch def
7963 barcode i get 48 sub i 2 mod 0 ne {2 mul} if dup 9 gt {9 sub} if
7964 checksum add /checksum exch def
7965 } for
7966 /checksum checksum 10 mod def
7967 barcode length 9 eq {
7968 barcode 8 get checksum 48 add ne {
7969 /bwipp.code32badCheckDigit (Incorrect Italian Pharmacode check digit provided) //raiseerror exec
7970 } if
7971 } if
7972 10 string
7973 dup 0 barcode putinterval
7974 dup 8 checksum 48 add put
7975 /text exch def
7976
7977 % convert number from base10 to base32
7978 /val text cvi 32 6 string cvrs def
7979 /barcode 6 string def
7980 0 1 5 {barcode exch 48 put} for
7981 barcode 6 val length sub val putinterval
7982
7983 % convert base32 number to specified character set
7984 0 1 5 {
7985 dup barcode exch get
7986 dup (AEIO) {ge {1 add} if dup} forall pop
7987 barcode 3 1 roll put
7988 } for
7989
7990 % format HRI
7991 text 1 text 0 9 getinterval putinterval
7992 text 0 65 put
7993
7994 % Get the result of encoding with code39
7995 options (dontdraw) true put
7996 /args barcode options //code39 exec def
7997
7998 args (txt) [ [text textxoffset textyoffset textfont textsize] ] put
7999 args (textxalign) (center) put
8000 args (opt) options put
8001 args
8002
8003 dontdraw not //renlinear if
8004
8005 end
8006
8007 }
8008 [/barcode] {null def} forall
8009 bind def
8010 /code32 dup load /uk.co.terryburton.bwipp defineresource pop
8011 end
8012 /setpacking where {pop setpacking} if
8013 %%EndData
8014 %%EndResource
8015 % --END ENCODER code32--
8016
8017 % --BEGIN ENCODER pzn--
8018 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear code39--
8019 % --DESC: Pharmazentralnummer (PZN)
8020 % --EXAM: 123456
8021 % --EXOP: includetext
8022 % --RNDR: renlinear
8023 %%BeginResource: uk.co.terryburton.bwipp pzn 0.0 2025111800 70365 70123
8024 %%BeginData: 87 ASCII Lines
8025 /setpacking where {pop currentpacking true setpacking} if
8026 10 dict
8027 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
8028 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
8029 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
8030 dup /code39 dup /uk.co.terryburton.bwipp findresource put
8031 begin
8032 /pzn {
8033
8034 20 dict begin
8035
8036 /ctx null def
8037 /dontdraw false def
8038 /includetext false def % Enable/disable code32 text
8039 /textfont /Courier def
8040 /textsize 10.0 def
8041 /textyoffset -7.0 def
8042 /textxoffset 0.0 def
8043 /height 1.0 def
8044 /pzn8 false def
8045
8046 //processoptions exec /options exch def
8047 /barcode exch def
8048
8049 % Validate the input
8050 pzn8 {
8051 barcode length 7 ne barcode length 8 ne and {
8052 /bwipp.pzn8badLength (PZN8 must be 7 or 8 digits) //raiseerror exec
8053 } if
8054 } {
8055 barcode length 6 ne barcode length 7 ne and {
8056 /bwipp.pzn7badLength (PZN7 must be 6 or 7 digits) //raiseerror exec
8057 } if
8058 } ifelse
8059 barcode {
8060 dup 48 lt exch 57 gt or {
8061 /bwipp.pznBadCharacter (PZN must contain only digits) //raiseerror exec
8062 } if
8063 } forall
8064
8065 % Calculate check digit
8066 /msglen pzn8 {9} {8} ifelse def
8067 /checksum 0 def
8068 0 1 msglen 3 sub {
8069 /i exch def
8070 barcode i get 48 sub i pzn8 {1} {2} ifelse add mul
8071 checksum add /checksum exch def
8072 } for
8073 /checksum checksum 11 mod def
8074 checksum 10 eq {
8075 /bwipp.pznBadInputSequence (Incorrect PZN input sequence provided) //raiseerror exec
8076 } if
8077 barcode length msglen 1 sub eq {
8078 barcode msglen 2 sub get checksum 48 add ne {
8079 /bwipp.pznBadCheckDigit (Incorrect PZN check digit provided) //raiseerror exec
8080 } if
8081 } if
8082 msglen string
8083 dup 0 45 put
8084 dup 1 barcode putinterval
8085 dup msglen 1 sub checksum 48 add put
8086 /msg exch def
8087
8088 % Get the result of encoding with code39
8089 options (dontdraw) true put
8090 /args msg options //code39 exec def
8091
8092 % format HRI
8093 /text msglen 5 add string def
8094 text 0 (PZN - ) putinterval
8095 text 6 msg 1 msglen 1 sub getinterval putinterval
8096
8097 args (txt) [ [text textxoffset textyoffset textfont textsize] ] put
8098 args (textxalign) (center) put
8099 args (opt) options put
8100 args
8101
8102 dontdraw not //renlinear if
8103
8104 end
8105
8106 }
8107 [/barcode] {null def} forall
8108 bind def
8109 /pzn dup load /uk.co.terryburton.bwipp defineresource pop
8110 end
8111 /setpacking where {pop setpacking} if
8112 %%EndData
8113 %%EndResource
8114 % --END ENCODER pzn--
8115
8116 % --BEGIN ENCODER code93--
8117 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renlinear--
8118 % --DESC: Code 93
8119 % --EXAM: THIS IS CODE 93
8120 % --EXOP: includetext includecheck
8121 % --RNDR: renlinear
8122 %%BeginResource: uk.co.terryburton.bwipp code93 0.0 2025111800 75828 75286
8123 %%BeginData: 134 ASCII Lines
8124 /setpacking where {pop currentpacking true setpacking} if
8125 10 dict
8126 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
8127 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
8128 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
8129 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
8130 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
8131 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
8132 begin
8133 /code93 {
8134
8135 20 dict begin % Confine variables to local scope
8136
8137 /ctx null def
8138 /dontdraw false def
8139 /includecheck false def % Enable/disable checkdigit
8140 /includetext false def % Enable/disable text
8141 /textfont /Courier def
8142 /textsize 10.0 def
8143 /textyoffset -7.0 def
8144 /height 1.0 def
8145 /parse false def
8146 /parsefnc false def
8147
8148 //processoptions exec /options exch def
8149 /barcode exch def
8150
8151 /code93 //loadctx exec
8152
8153 {
8154 /encs
8155 [ (131112) (111213) (111312) (111411) (121113) % 0-4
8156 (121212) (121311) (111114) (131211) (141111) % 5-9
8157 (211113) (211212) (211311) (221112) (221211) % A-E
8158 (231111) (112113) (112212) (112311) (122112) % F-J
8159 (132111) (111123) (111222) (111321) (121122) % K-O
8160 (131121) (212112) (212211) (211122) (211221) % P-T
8161 (221121) (222111) (112122) (112221) (122121) % U-Y
8162 (123111) (121131) (311112) (311211) (321111) % "Z" "-" "." " " "$"
8163 (112131) (113121) (211131) (121221) (312111) % "/" "+" "%" ($) (%)
8164 (311121) (122211) (111141) (1111411) % (/) (+) STA END
8165 ] def
8166
8167 % Create a string of the available characters
8168 /barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def
8169 /charvals 47 dict def
8170 0 1 42 {charvals exch dup barchars exch get exch put} for
8171
8172 /sft1 -1 def /sft2 -2 def /sft3 -3 def /sft4 -4 def
8173
8174 charvals sft1 43 put
8175 charvals sft2 44 put
8176 charvals sft3 45 put
8177 charvals sft4 46 put
8178
8179 } ctxdef
8180
8181 % Special function characters
8182 /fncvals <<
8183 /parse parse
8184 /parsefnc parsefnc
8185 (SFT$) sft1
8186 (SFT%) sft2
8187 (SFT/) sft3
8188 (SFT+) sft4
8189 >> def
8190 /msg barcode fncvals //parseinput exec def
8191 /msglen msg length def
8192
8193 % Validate the input
8194 msg {
8195 charvals exch known not {
8196 /bwipp.code93BadCharacter (Code 93 must only contain digits, capital letters, spaces, the symbols -.$/+ and shift non-data characters) //raiseerror exec
8197 } if
8198 } forall
8199
8200 includecheck {
8201 /sbs msglen 6 mul 25 add string def
8202 } {
8203 /sbs msglen 6 mul 13 add string def
8204 } ifelse
8205 /txt msglen array def
8206
8207 % Put the start character
8208 sbs 0 encs 47 get putinterval
8209
8210 /checksum1 0 def /checksum2 0 def
8211 0 1 msglen 1 sub {
8212 /i exch def
8213 /indx charvals msg i get get def
8214 sbs i 6 mul 6 add encs indx get putinterval
8215 /char msg i get dup 0 lt { pop ( ) } { 1 string dup 0 4 -1 roll put } ifelse def
8216 txt i [char i 9 mul 9 add textyoffset textfont textsize] put
8217 /checksum1 checksum1 msglen i sub 1 sub 20 mod 1 add indx mul add def
8218 /checksum2 checksum2 msglen i sub 15 mod 1 add indx mul add def
8219 } for
8220
8221 includecheck {
8222 % Put the first checksum character
8223 /checksum1 checksum1 47 mod def
8224 /checksum2 checksum2 checksum1 add 47 mod def
8225 sbs msglen 6 mul 6 add encs checksum1 get putinterval
8226 sbs msglen 6 mul 12 add encs checksum2 get putinterval
8227 % Put the end character
8228 sbs msglen 6 mul 18 add encs 48 get putinterval
8229 } {
8230 % Put the end character
8231 sbs msglen 6 mul 6 add encs 48 get putinterval
8232 } ifelse
8233
8234 % Return the arguments
8235 <<
8236 /ren /renlinear
8237 /sbs [sbs {48 sub} forall]
8238 /bhs [sbs length 1 add 2 idiv {height} repeat]
8239 /bbs [sbs length 1 add 2 idiv {0} repeat]
8240 includetext {
8241 /txt txt
8242 } if
8243 /opt options
8244 >>
8245
8246 dontdraw not //renlinear if
8247
8248 //unloadctx exec
8249
8250 end
8251
8252 }
8253 [/barcode] {null def} forall
8254 bind def
8255 /code93 dup load /uk.co.terryburton.bwipp defineresource pop
8256 end
8257 /setpacking where {pop setpacking} if
8258 %%EndData
8259 %%EndResource
8260 % --END ENCODER code93--
8261
8262 % --BEGIN ENCODER code93ext--
8263 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renlinear code93--
8264 % --DESC: Code 93 Extended
8265 % --EXAM: Code93 Ext!
8266 % --EXOP: includetext includecheck
8267 % --RNDR: renlinear
8268 %%BeginResource: uk.co.terryburton.bwipp code93ext 0.0 2025111800 76543 75777
8269 %%BeginData: 107 ASCII Lines
8270 /setpacking where {pop currentpacking true setpacking} if
8271 10 dict
8272 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
8273 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
8274 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
8275 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
8276 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
8277 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
8278 dup /code93 dup /uk.co.terryburton.bwipp findresource put
8279 begin
8280 /code93ext {
8281
8282 20 dict begin
8283
8284 /ctx null def
8285 /dontdraw false def
8286 /includetext false def
8287 /parse false def
8288
8289 //processoptions exec /options exch def
8290 /barcode exch def
8291
8292 /code93ext //loadctx exec
8293
8294 % Parse ordinals of the form ^NNN to ASCII
8295 /fncvals <<
8296 /parse parse
8297 /parseonly true
8298 /parsefnc false
8299 >> def
8300 /barcode barcode fncvals //parseinput exec def
8301 /barlen barcode length def
8302 options (parse) undef
8303
8304 % Extended alphabet to non-extended alphabet
8305 {
8306 /extencs
8307 [ (^SFT%U) (^SFT$A) (^SFT$B) (^SFT$C) (^SFT$D) (^SFT$E) (^SFT$F) (^SFT$G)
8308 (^SFT$H) (^SFT$I) (^SFT$J) (^SFT$K) (^SFT$L) (^SFT$M) (^SFT$N) (^SFT$O)
8309 (^SFT$P) (^SFT$Q) (^SFT$R) (^SFT$S) (^SFT$T) (^SFT$U) (^SFT$V) (^SFT$W)
8310 (^SFT$X) (^SFT$Y) (^SFT$Z) (^SFT%A) (^SFT%B) (^SFT%C) (^SFT%D) (^SFT%E)
8311 ( ) (^SFT/A) (^SFT/B) (^SFT/C) ($) (%) (^SFT/F) (^SFT/G)
8312 (^SFT/H) (^SFT/I) (^SFT/J) (+) (^SFT/L) (-) (.) (/)
8313 (0) (1) (2) (3) (4) (5) (6) (7)
8314 (8) (9) (^SFT/Z) (^SFT%F) (^SFT%G) (^SFT%H) (^SFT%I) (^SFT%J)
8315 (^SFT%V) (A) (B) (C) (D) (E) (F) (G)
8316 (H) (I) (J) (K) (L) (M) (N) (O)
8317 (P) (Q) (R) (S) (T) (U) (V) (W)
8318 (X) (Y) (Z) (^SFT%K) (^SFT%L) (^SFT%M) (^SFT%N) (^SFT%O)
8319 (^SFT%W) (^SFT+A) (^SFT+B) (^SFT+C) (^SFT+D) (^SFT+E) (^SFT+F) (^SFT+G)
8320 (^SFT+H) (^SFT+I) (^SFT+J) (^SFT+K) (^SFT+L) (^SFT+M) (^SFT+N) (^SFT+O)
8321 (^SFT+P) (^SFT+Q) (^SFT+R) (^SFT+S) (^SFT+T) (^SFT+U) (^SFT+V) (^SFT+W)
8322 (^SFT+X) (^SFT+Y) (^SFT+Z) (^SFT%P) (^SFT%Q) (^SFT%R) (^SFT%S) (^SFT%T)
8323 ] def
8324 } ctxdef
8325
8326 /newcode barlen 6 mul string def
8327 /newtext barlen 6 mul string def
8328 /j 0 def /k 0 def
8329 0 1 barlen 1 sub {
8330 /i exch def
8331 barcode i get
8332 dup 127 gt {
8333 pop /bwipp.code93extbadCharacter (Code 93 Extended only support ASCII characters with values 0 to 127) //raiseerror exec
8334 } if
8335 extencs exch get /extchar exch def
8336 /extlen extchar length def
8337 newcode j extchar putinterval
8338 newtext k barcode i get dup dup 32 lt exch 127 eq or { pop 32 } if put
8339 extlen 1 ne { newtext k 1 add 32 put } if
8340 /j j extlen add def
8341 /k k extlen 1 eq {1} {2} ifelse add def
8342 } for
8343 /newcode newcode 0 j getinterval def
8344 /newtext newtext 0 k getinterval def
8345
8346 % Get the result of encoding with code93
8347 options (dontdraw) true put
8348 options (parsefnc) true put
8349 /args newcode options //code93 exec def
8350
8351 % Replace chars in /txt with chars in newtext
8352 includetext {
8353 /txt args (txt) get def
8354 0 1 newtext length 1 sub {
8355 /i exch def
8356 /txtentry txt i get def
8357 txtentry 0 newtext i 1 getinterval put
8358 txt i txtentry put
8359 } for
8360 args (txt) txt put
8361 } if
8362 args (opt) options put
8363 args
8364
8365 dontdraw not //renlinear if
8366
8367 //unloadctx exec
8368
8369 end
8370
8371 }
8372 [/barcode] {null def} forall
8373 bind def
8374 /code93ext dup load /uk.co.terryburton.bwipp defineresource pop
8375 end
8376 /setpacking where {pop setpacking} if
8377 %%EndData
8378 %%EndResource
8379 % --END ENCODER code93ext--
8380
8381 % --BEGIN ENCODER interleaved2of5--
8382 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear--
8383 % --DESC: Interleaved 2 of 5 (ITF)
8384 % --EXAM: 2401234567
8385 % --EXOP: height=0.5 includecheck includetext includecheckintext
8386 % --RNDR: renlinear
8387 %%BeginResource: uk.co.terryburton.bwipp interleaved2of5 0.0 2025111800 73860 73551
8388 %%BeginData: 147 ASCII Lines
8389 /setpacking where {pop currentpacking true setpacking} if
8390 10 dict
8391 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
8392 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
8393 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
8394 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
8395 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
8396 begin
8397 /interleaved2of5 {
8398
8399 20 dict begin % Confine variables to local scope
8400
8401 /ctx null def
8402 /dontdraw false def
8403 /includecheck false def % Enable/disable checkdigit
8404 /includetext false def % Enable/disable text
8405 /includecheckintext false def
8406 /textfont /Courier def
8407 /textsize 10.0 def
8408 /textyoffset -7.0 def
8409 /height 1.0 def
8410
8411 //processoptions exec /options exch def
8412 /barcode exch def
8413
8414 /interleaved2of5 //loadctx exec
8415
8416 % Validate the input
8417 barcode {
8418 dup 48 lt exch 57 gt or {
8419 /bwipp.interleaved2of5badCharacter (Interleaved 2 of 5 must contain only digits) //raiseerror exec
8420 } if
8421 } forall
8422
8423 /barlen barcode length def % Length of the code
8424
8425 % Prefix 0 to barcode if length is even and including checkdigit
8426 % or length is odd and not including checkdigit
8427 barlen 2 mod 0 eq includecheck and % even & includecheck
8428 barlen 2 mod 0 ne includecheck not and or { % odd & !includecheck
8429 /pad barlen 1 add string def % Create pad one bigger than barcode
8430 pad 0 48 put % Put ascii 0 at start of pad
8431 pad 1 barcode putinterval % Add barcode to the end of pad
8432 /barcode pad def % barcode=pad
8433 /barlen barlen 1 add def % barlen++
8434 } if
8435
8436 % Add checksum to end of barcode
8437 includecheck {
8438 /checksum 0 def
8439 0 1 barlen 1 sub {
8440 /i exch def
8441 i 2 mod 0 eq {
8442 /checksum checksum barcode i get 48 sub 3 mul add def
8443 } {
8444 /checksum checksum barcode i get 48 sub add def
8445 } ifelse
8446 } for
8447 /checksum 10 checksum 10 mod sub 10 mod def
8448 /pad barlen 1 add string def % Create pad one bigger than barcode
8449 pad 0 barcode putinterval % Add barcode to the start of pad
8450 pad barlen checksum 48 add put % Add checksum to end of pad
8451 /barcode pad def % barcode=pad
8452 /barlen barlen 1 add def % barlen++
8453 } if
8454
8455 % Create an array containing the character mappings
8456 {
8457 /encs
8458 [ (11221) (21112) (12112) (22111) (11212)
8459 (21211) (12211) (11122) (21121) (12121)
8460 (1111) (2111)
8461 ] def
8462
8463 % Create a string of the available characters
8464 /barchars (0123456789) def
8465 } ctxdef
8466
8467 /sbs barlen 5 mul 8 add string def
8468 /txt barlen array def
8469
8470 % Put the start character
8471 sbs 0 encs 10 get putinterval
8472
8473 0 2 barlen 1 sub {
8474 /i exch def
8475 % Lookup the encodings for two consecutive barcode characters
8476 barcode i 1 getinterval barchars exch search
8477 pop % Discard true leaving pre
8478 length /indx exch def % indx is the length of pre
8479 pop pop % Discard seek and post
8480 /enca encs indx get def % Get the indxth encoding
8481
8482 barcode i 1 add 1 getinterval barchars exch search
8483 pop % Discard true leaving pre
8484 length /indx exch def % indx is the length of pre
8485 pop pop % Discard seek and post
8486 /encb encs indx get def % Get the indxth encoding
8487
8488 % Interleave the two character encodings
8489 /intl enca length 2 mul string def
8490 0 1 enca length 1 sub {
8491 /j exch def
8492 /achar enca j get def
8493 /bchar encb j get def
8494 intl j 2 mul achar put
8495 intl j 2 mul 1 add bchar put
8496 } for
8497
8498 sbs i 5 mul 4 add intl putinterval % Put encoded digit into sbs
8499 txt i [barcode i 1 getinterval i 9 mul 4 add textyoffset textfont textsize] put
8500 includecheck includecheckintext not and barlen 2 sub i eq and {
8501 txt i 1 add [( ) i 1 add 9 mul 4 add textyoffset textfont textsize] put
8502 } {
8503 txt i 1 add [barcode i 1 add 1 getinterval i 1 add 9 mul 4 add textyoffset textfont textsize] put
8504 } ifelse
8505 } for
8506
8507 % Put the end character
8508 sbs barlen 5 mul 4 add encs 11 get putinterval
8509
8510 % Return the arguments
8511 <<
8512 /ren /renlinear
8513 /sbs [sbs {48 sub} forall]
8514 /bhs [sbs length 1 add 2 idiv {height} repeat]
8515 /bbs [sbs length 1 add 2 idiv {0} repeat]
8516 includetext {
8517 /txt txt
8518 } if
8519 /barratio 2.0
8520 /spaceratio 2.0
8521 /opt options
8522 >>
8523
8524 dontdraw not //renlinear if
8525
8526 //unloadctx exec
8527
8528 end
8529
8530 }
8531 [/barcode] {null def} forall
8532 bind def
8533 /interleaved2of5 dup load /uk.co.terryburton.bwipp defineresource pop
8534 end
8535 /setpacking where {pop setpacking} if
8536 %%EndData
8537 %%EndResource
8538 % --END ENCODER interleaved2of5--
8539
8540 % --BEGIN ENCODER itf14--
8541 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear interleaved2of5--
8542 % --DESC: ITF-14
8543 % --EXAM: 0 952 1234 54321 3
8544 % --EXOP: includetext
8545 % --RNDR: renlinear
8546 %%BeginResource: uk.co.terryburton.bwipp itf14 0.0 2025111800 73073 72905
8547 %%BeginData: 97 ASCII Lines
8548 /setpacking where {pop currentpacking true setpacking} if
8549 10 dict
8550 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
8551 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
8552 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
8553 dup /interleaved2of5 dup /uk.co.terryburton.bwipp findresource put
8554 begin
8555 /itf14 {
8556
8557 20 dict begin % Confine variables to local scope
8558
8559 /ctx null def
8560 /dontdraw false def
8561 /includetext false def
8562 /includecheckintext true def
8563 /textfont /Courier def
8564 /textsize 10.0 def
8565 /textxoffset 0.0 def
8566 /textyoffset -3.5 def
8567 /height 0.5 def
8568 /showborder true def
8569 /borderwidth 4.0 def
8570 /borderleft 10.0 def
8571 /borderright 10.0 def
8572 /bordertop -0.2 def % Ensure border/bearer touches bars with default inkspread
8573 /borderbottom -0.2 def
8574
8575 //processoptions exec /options exch def
8576 /barcode exch def
8577
8578 % Strip spaces from the given data
8579 /text barcode def
8580 barcode dup length string exch 0 exch
8581 {dup 32 ne {3 copy put pop 1 add} {pop} ifelse} forall
8582 0 exch getinterval /barcode exch def
8583 /hasspace text length barcode length ne def
8584
8585 % Validate the input
8586 barcode length 13 ne barcode length 14 ne and {
8587 /bwipp.itf14badLength (ITF-14 must be 13 or 14 digits) //raiseerror exec
8588 } if
8589 barcode {
8590 dup 48 lt exch 57 gt or {
8591 /bwipp.itf14badCharacter (ITF-14 must contain only digits) //raiseerror exec
8592 } if
8593 } forall
8594
8595 % Calculate ITF checksum and add to end of barcode
8596 /checksum 0 def
8597 0 1 12 {
8598 /i exch def
8599 /checksum checksum barcode i get 48 sub i 2 mod 0 eq {3 mul} if add def
8600 } for
8601 /checksum 10 checksum 10 mod sub 10 mod def
8602 barcode length 14 eq {
8603 barcode 13 get checksum 48 add ne {
8604 /bwipp.itf14badCheckDigit (Incorrect ITF-14 check digit provided) //raiseerror exec
8605 } if
8606 } {
8607 14 string
8608 dup 0 barcode putinterval
8609 dup 13 checksum 48 add put
8610 /barcode exch def
8611 text length hasspace {2} {1} ifelse add string
8612 dup dup length 2 sub ( ) putinterval
8613 dup dup length 1 sub checksum 48 add put
8614 dup 0 text putinterval
8615 /text exch def
8616 } ifelse
8617
8618 % Get the result of encoding with interleaved2of5
8619 options (dontdraw) true put
8620 options (showborder) showborder put
8621 options (borderwidth) borderwidth put
8622 options (borderleft) borderleft put
8623 options (borderright) borderright put
8624 options (bordertop) bordertop put
8625 options (borderbottom) borderbottom put
8626 options (height) height put
8627 options (textyoffset) textyoffset put
8628 /args barcode options //interleaved2of5 exec def
8629
8630 args (txt) [ [text textxoffset textyoffset textfont textsize] ] put
8631 args (textxalign) (center) put
8632 args (opt) options put
8633 args
8634
8635 dontdraw not //renlinear if
8636
8637 end
8638
8639 }
8640 [/barcode] {null def} forall
8641 bind def
8642 /itf14 dup load /uk.co.terryburton.bwipp defineresource pop
8643 end
8644 /setpacking where {pop setpacking} if
8645 %%EndData
8646 %%EndResource
8647 % --END ENCODER itf14--
8648
8649 % --BEGIN ENCODER identcode--
8650 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear interleaved2of5--
8651 % --DESC: Deutsche Post Identcode
8652 % --EXAM: 563102430313
8653 % --EXOP: includetext
8654 % --RNDR: renlinear
8655 %%BeginResource: uk.co.terryburton.bwipp identcode 0.0 2025111800 69387 69371
8656 %%BeginData: 78 ASCII Lines
8657 /setpacking where {pop currentpacking true setpacking} if
8658 10 dict
8659 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
8660 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
8661 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
8662 dup /interleaved2of5 dup /uk.co.terryburton.bwipp findresource put
8663 begin
8664 /identcode {
8665
8666 20 dict begin % Confine variables to local scope
8667
8668 /ctx null def
8669 /dontdraw false def
8670 /includetext false def % Enable/disable text
8671 /textfont /Courier def
8672 /textsize 10.0 def
8673 /textxoffset 0.0 def
8674 /textyoffset -7.0 def
8675 /height 1.0 def
8676
8677 //processoptions exec /options exch def
8678 /barcode exch def
8679
8680 % Validate the input
8681 barcode length 11 ne barcode length 12 ne and {
8682 /bwipp.identcodeBadLength (Deutsche Post Identcode must be 11 or 12 digits) //raiseerror exec
8683 } if
8684 barcode {
8685 dup 48 lt exch 57 gt or {
8686 /bwipp.identcodeBadCharacter (Deutsche Post Identcode must contain only digits) //raiseerror exec
8687 } if
8688 } forall
8689
8690 % Calculate checksum and add to end of barcode
8691 /checksum 0 def
8692 0 1 10 {
8693 /i exch def
8694 /checksum checksum barcode i get 48 sub i 2 mod 0 eq {4 mul} {9 mul} ifelse add def
8695 } for
8696 /checksum 10 checksum 10 mod sub 10 mod def
8697 barcode length 12 eq {
8698 barcode 11 get checksum 48 add ne {
8699 /bwipp.identcodeBadCheckDigit (Incorrect Deutsche Post Identcode check digit provided) //raiseerror exec
8700 } if
8701 } if
8702 12 string
8703 dup 0 barcode putinterval
8704 dup 11 checksum 48 add put
8705 /barcode exch def
8706
8707 % Compose the human readable text
8708 /text ( . . ) 16 string copy def
8709 text 0 barcode 0 2 getinterval putinterval
8710 text 3 barcode 2 3 getinterval putinterval
8711 text 7 barcode 5 3 getinterval putinterval
8712 text 11 barcode 8 3 getinterval putinterval
8713 text 15 barcode 11 1 getinterval putinterval
8714
8715 % Get the result of encoding with interleaved2of5
8716 options (dontdraw) true put
8717 options (includecheck) false put
8718 /args barcode options //interleaved2of5 exec def
8719
8720 args (txt) [ [text textxoffset textyoffset textfont textsize] ] put
8721 args (textxalign) (center) put
8722 args (opt) options put
8723 args
8724
8725 dontdraw not //renlinear if
8726
8727 end
8728
8729 }
8730 [/barcode] {null def} forall
8731 bind def
8732 /identcode dup load /uk.co.terryburton.bwipp defineresource pop
8733 end
8734 /setpacking where {pop setpacking} if
8735 %%EndData
8736 %%EndResource
8737 % --END ENCODER identcode--
8738
8739 % --BEGIN ENCODER leitcode--
8740 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear interleaved2of5--
8741 % --DESC: Deutsche Post Leitcode
8742 % --EXAM: 21348075016401
8743 % --EXOP: includetext
8744 % --RNDR: renlinear
8745 %%BeginResource: uk.co.terryburton.bwipp leitcode 0.0 2025111800 69379 69367
8746 %%BeginData: 78 ASCII Lines
8747 /setpacking where {pop currentpacking true setpacking} if
8748 10 dict
8749 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
8750 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
8751 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
8752 dup /interleaved2of5 dup /uk.co.terryburton.bwipp findresource put
8753 begin
8754 /leitcode {
8755
8756 20 dict begin % Confine variables to local scope
8757
8758 /ctx null def
8759 /dontdraw false def
8760 /includetext false def % Enable/disable text
8761 /textfont /Courier def
8762 /textsize 10.0 def
8763 /textxoffset 0.0 def
8764 /textyoffset -7.0 def
8765 /height 1.0 def
8766
8767 //processoptions exec /options exch def
8768 /barcode exch def
8769
8770 % Validate the input
8771 barcode length 13 ne barcode length 14 ne and {
8772 /bwipp.leitcodeBadLength (Deutsche Post Leitcode must be 13 or 14 digits) //raiseerror exec
8773 } if
8774 barcode {
8775 dup 48 lt exch 57 gt or {
8776 /bwipp.leitcodeBadCharacter (Deutsche Post Leitcode must contain only digits) //raiseerror exec
8777 } if
8778 } forall
8779
8780 % Calculate checksum and add to end of barcode
8781 /checksum 0 def
8782 0 1 12 {
8783 /i exch def
8784 /checksum checksum barcode i get 48 sub i 2 mod 0 eq {4 mul} {9 mul} ifelse add def
8785 } for
8786 /checksum 10 checksum 10 mod sub 10 mod def
8787 barcode length 14 eq {
8788 barcode 13 get checksum 48 add ne {
8789 /bwipp.leitcodeBadCheckDigit (Incorrect Deutsche Post Leitcode check digit provided) //raiseerror exec
8790 } if
8791 } if
8792 14 string
8793 dup 0 barcode putinterval
8794 dup 13 checksum 48 add put
8795 /barcode exch def
8796
8797 % Compose the human readable text
8798 /text ( . . . ) 18 string copy def
8799 text 0 barcode 0 5 getinterval putinterval
8800 text 6 barcode 5 3 getinterval putinterval
8801 text 10 barcode 8 3 getinterval putinterval
8802 text 14 barcode 11 2 getinterval putinterval
8803 text 17 barcode 13 1 getinterval putinterval
8804
8805 % Get the result of encoding with interleaved2of5
8806 options (dontdraw) true put
8807 options (includecheck) false put
8808 /args barcode options //interleaved2of5 exec def
8809
8810 args (txt) [ [text textxoffset textyoffset textfont textsize] ] put
8811 args (textxalign) (center) put
8812 args (opt) options put
8813 args
8814
8815 dontdraw not //renlinear if
8816
8817 end
8818
8819 }
8820 [/barcode] {null def} forall
8821 bind def
8822 /leitcode dup load /uk.co.terryburton.bwipp defineresource pop
8823 end
8824 /setpacking where {pop setpacking} if
8825 %%EndData
8826 %%EndResource
8827 % --END ENCODER leitcode--
8828
8829 % --BEGIN ENCODER databaromni--
8830 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear renmatrix--
8831 % --DESC: GS1 DataBar Omnidirectional
8832 % --EXAM: (01)09521234543213
8833 % --EXOP:
8834 % --RNDR: renlinear renmatrix
8835 %%BeginResource: uk.co.terryburton.bwipp databaromni 0.0 2025111800 120633 119100
8836 %%BeginData: 455 ASCII Lines
8837 /setpacking where {pop currentpacking true setpacking} if
8838 20 dict
8839 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
8840 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
8841 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
8842 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
8843 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
8844 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
8845 begin
8846 /databaromni {
8847
8848 20 dict begin
8849
8850 /ctx null def
8851 /dontdraw false def
8852 /height 33.0 72 div def
8853 /linkage false def
8854 /format (omni) def
8855 /barxmult 33 def
8856
8857 //processoptions exec /options exch def
8858 /barcode exch def
8859
8860 barcode length 17 ne barcode length 18 ne and {
8861 /bwipp.databaromniBadLength (GS1 DataBar Omnidirectional must be 13 or 14 digits) //raiseerror exec
8862 } if
8863 barcode 0 4 getinterval (\(01\)) ne {
8864 /bwipp.databaromniBadAI (GS1 DataBar Omnidirectional must begin with (01) application identifier) //raiseerror exec
8865 } if
8866 barcode 4 barcode length 4 sub getinterval {
8867 dup 48 lt exch 57 gt or {
8868 /bwipp.databaromniBadCharacter (GS1 DataBar Omnidirectional must contain only digits) //raiseerror exec
8869 } if
8870 } forall
8871
8872 barxmult 33 lt {
8873 /bwipp.databarStackedOmniBarXmult (GS1 DataBar Stacked Omnidirectional must have a barxmult of at least 33) //raiseerror exec
8874 } if
8875
8876 format (omni) ne format (stacked) ne and format (stackedomni) ne and format (truncated) ne and {
8877 /bwipp.databaromniBadFormat (Valid formats are omni, stacked, stackedomni and truncated) //raiseerror exec
8878 } if
8879
8880 format (truncated) eq {/height 13.0 72 div def} if
8881
8882 /databaromni //loadctx exec
8883
8884 % Calculate checksum and add to end of barcode
8885 /checksum 0 def
8886 0 1 12 {
8887 /i exch def
8888 /checksum checksum barcode i 4 add get 48 sub i 2 mod 0 eq {3 mul} if add def
8889 } for
8890 /checksum 10 checksum 10 mod sub 10 mod def
8891 barcode length 18 eq {
8892 barcode 17 get checksum 48 add ne {
8893 /bwipp.databaromniBadCheckDigit (Incorrect GS1 DataBar Omnidirectional check digit provided) //raiseerror exec
8894 } if
8895 } if
8896 18 string
8897 dup 0 barcode putinterval
8898 dup 17 checksum 48 add put
8899 /barcode exch def
8900
8901 % Create the human readable text
8902 /txt barcode length array def
8903 0 1 barcode length 1 sub {
8904 /i exch def
8905 txt i [barcode i 1 getinterval 0 0 () 0] put
8906 } for
8907
8908 /ncr { % n r
8909 2 copy sub 2 copy lt {exch} if % n r maxd mind
8910 1 1 5 3 roll % mind j=1 v=1 n maxd
8911 1 add -1 exch { % mind j v n -1 maxd+1
8912 mul % mind j v*i
8913 1 index 3 index le {
8914 1 index idiv exch 1 add exch
8915 } if
8916 } for
8917 { % mind j v
8918 1 index 3 index gt {exit} if
8919 1 index idiv exch 1 add exch
8920 } loop
8921 exch pop exch pop
8922 } def
8923
8924 /getRSSwidths {
8925 /oe exch def
8926 /el exch def
8927 /mw exch def
8928 /nm exch def
8929 /val exch def
8930 /out el array def
8931 /mask 0 def
8932 0 1 el 2 sub {
8933 /bar exch def
8934 /ew 1 def
8935 /mask mask 1 bar bitshift or def {
8936 /sval nm ew sub 1 sub el bar sub 2 sub ncr def
8937 oe mask 0 eq and nm ew sub el 2 mul sub bar 2 mul add -2 ge and {
8938 /sval sval nm ew sub el sub bar add el bar sub 2 sub ncr sub def
8939 } if
8940 el bar sub 2 gt {
8941 /lval 0 def
8942 nm ew sub el sub bar add 2 add -1 mw 1 add {
8943 nm exch sub ew sub 1 sub el bar sub 3 sub ncr
8944 /lval exch lval add def
8945 } for
8946 /sval sval lval el bar sub 1 sub mul sub def
8947 } {
8948 nm ew sub mw gt {/sval sval 1 sub def} if
8949 } ifelse
8950 /val val sval sub def
8951 val 0 lt {exit} if
8952 /ew ew 1 add def
8953 /mask mask 1 bar bitshift not and def
8954 } loop
8955 /val val sval add def
8956 /nm nm ew sub def
8957 out bar ew put
8958 } for
8959 out el 1 sub nm put
8960 out
8961 } def
8962
8963 /binval [
8964 linkage {1} {0} ifelse
8965 barcode 4 13 getinterval {48 sub} forall
8966 ] def
8967
8968 0 1 12 {
8969 /i exch def
8970 binval i 1 add 2 copy get binval i get 4537077 mod 10 mul add put
8971 binval i binval i get 4537077 idiv put
8972 } for
8973 /right binval 13 get 4537077 mod def
8974 binval 13 2 copy get 4537077 idiv put
8975
8976 /left 0 def
8977 /i true def
8978 0 1 13 {
8979 /j exch def
8980 binval j get
8981 dup 0 eq i and {
8982 pop
8983 } {
8984 /i false def
8985 /left left 3 -1 roll 10 13 j sub exp cvi mul add def
8986 } ifelse
8987 } for
8988
8989 /d1 left 1597 idiv def
8990 /d2 left 1597 mod def
8991 /d3 right 1597 idiv def
8992 /d4 right 1597 mod def
8993
8994 {
8995 /tab164 [
8996 160 0 12 4 8 1 161 1
8997 960 161 10 6 6 3 80 10
8998 2014 961 8 8 4 5 31 34
8999 2714 2015 6 10 3 6 10 70
9000 2840 2715 4 12 1 8 1 126
9001 ] def
9002
9003 /tab154 [
9004 335 0 5 10 2 7 4 84
9005 1035 336 7 8 4 5 20 35
9006 1515 1036 9 6 6 3 48 10
9007 1596 1516 11 4 8 1 81 1
9008 ] def
9009 } ctxdef
9010
9011 /i 0 def {
9012 d1 tab164 i get le {
9013 tab164 i 1 add 7 getinterval aload pop
9014 /d1te exch def /d1to exch def
9015 /d1mwe exch def /d1mwo exch def
9016 /d1ele exch def /d1elo exch def
9017 /d1gs exch def
9018 exit
9019 } if
9020 /i i 8 add def
9021 } loop
9022
9023 /i 0 def {
9024 d2 tab154 i get le {
9025 tab154 i 1 add 7 getinterval aload pop
9026 /d2te exch def /d2to exch def
9027 /d2mwe exch def /d2mwo exch def
9028 /d2ele exch def /d2elo exch def
9029 /d2gs exch def
9030 exit
9031 } if
9032 /i i 8 add def
9033 } loop
9034
9035 /i 0 def {
9036 d3 tab164 i get le {
9037 tab164 i 1 add 7 getinterval aload pop
9038 /d3te exch def /d3to exch def
9039 /d3mwe exch def /d3mwo exch def
9040 /d3ele exch def /d3elo exch def
9041 /d3gs exch def
9042 exit
9043 } if
9044 /i i 8 add def
9045 } loop
9046
9047 /i 0 def {
9048 d4 tab154 i get le {
9049 tab154 i 1 add 7 getinterval aload pop
9050 /d4te exch def /d4to exch def
9051 /d4mwe exch def /d4mwo exch def
9052 /d4ele exch def /d4elo exch def
9053 /d4gs exch def
9054 exit
9055 } if
9056 /i i 8 add def
9057 } loop
9058
9059 /d1wo d1 d1gs sub d1te idiv d1elo d1mwo 4 false getRSSwidths def
9060 /d1we d1 d1gs sub d1te mod d1ele d1mwe 4 true getRSSwidths def
9061 /d2wo d2 d2gs sub d2to mod d2elo d2mwo 4 true getRSSwidths def
9062 /d2we d2 d2gs sub d2to idiv d2ele d2mwe 4 false getRSSwidths def
9063 /d3wo d3 d3gs sub d3te idiv d3elo d3mwo 4 false getRSSwidths def
9064 /d3we d3 d3gs sub d3te mod d3ele d3mwe 4 true getRSSwidths def
9065 /d4wo d4 d4gs sub d4to mod d4elo d4mwo 4 true getRSSwidths def
9066 /d4we d4 d4gs sub d4to idiv d4ele d4mwe 4 false getRSSwidths def
9067
9068 /d1w 8 array def
9069 0 1 3 {
9070 /i exch def
9071 d1w i 2 mul d1wo i get put
9072 d1w i 2 mul 1 add d1we i get put
9073 } for
9074
9075 /d2w 8 array def
9076 0 1 3 {
9077 /i exch def
9078 d2w 7 i 2 mul sub d2wo i get put
9079 d2w 6 i 2 mul sub d2we i get put
9080 } for
9081
9082 /d3w 8 array def
9083 0 1 3 {
9084 /i exch def
9085 d3w 7 i 2 mul sub d3wo i get put
9086 d3w 6 i 2 mul sub d3we i get put
9087 } for
9088
9089 /d4w 8 array def
9090 0 1 3 {
9091 /i exch def
9092 d4w i 2 mul d4wo i get put
9093 d4w i 2 mul 1 add d4we i get put
9094 } for
9095
9096 /widths [
9097 d1w aload pop
9098 d2w aload pop
9099 d3w aload pop
9100 d4w aload pop
9101 ] def
9102
9103 {
9104 /checkweights [
9105 1 3 9 27 2 6 18 54
9106 58 72 24 8 29 36 12 4
9107 74 51 17 32 37 65 48 16
9108 64 34 23 69 49 68 46 59
9109 ] def
9110
9111 /checkwidths [
9112 3 8 2 1 1 3 5 5 1 1 3 3 7 1 1
9113 3 1 9 1 1 2 7 4 1 1 2 5 6 1 1
9114 2 3 8 1 1 1 5 7 1 1 1 3 9 1 1
9115 ] def
9116 } ctxdef
9117
9118 /checksum 0 def
9119 0 1 31 {
9120 /i exch def
9121 /checksum checksum widths i get checkweights i get mul add def
9122 } for
9123 /checksum checksum 79 mod def
9124 checksum 8 ge {/checksum checksum 1 add def} if
9125 checksum 72 ge {/checksum checksum 1 add def} if
9126 /checklt checkwidths checksum 9 idiv 5 mul 5 getinterval def
9127 /checkrtrev checkwidths checksum 9 mod 5 mul 5 getinterval def
9128 /checkrt 5 array def
9129 0 1 4 {
9130 /i exch def
9131 checkrt i checkrtrev 4 i sub get put
9132 } for
9133
9134 % Stacked format
9135 format (omni) eq format (truncated) eq or { % linear
9136
9137 /sbs [
9138 1
9139 d1w aload pop
9140 checklt aload pop
9141 d2w aload pop
9142 d4w aload pop
9143 checkrt aload pop
9144 d3w aload pop
9145 1 1
9146 ] def
9147
9148 <<
9149 /ren /renlinear
9150 /sbs sbs
9151 /bhs [sbs length 1 add 2 idiv {height} repeat]
9152 /bbs [sbs length 1 add 2 idiv {0} repeat]
9153 /txt txt
9154 /textxalign (center)
9155 /borderleft 0.0
9156 /borderright 0.0
9157 /opt options
9158 >>
9159
9160 dontdraw not //renlinear if
9161
9162 } { % 2D - stacked or stackedomni
9163
9164 /top [
9165 1 1
9166 d1w aload pop
9167 checklt aload pop
9168 d2w aload pop
9169 1 1 0
9170 ] def
9171 /bot [
9172 1 1
9173 d4w aload pop
9174 checkrt aload pop
9175 d3w aload pop
9176 1 1 0
9177 ] def
9178 0 2 24 {
9179 /i exch def
9180 top i get {0} repeat
9181 top i 1 add get {1} repeat
9182 } for
9183 50 array astore /top exch def
9184 0 2 24 {
9185 /i exch def
9186 bot i get {1} repeat
9187 bot i 1 add get {0} repeat
9188 } for
9189 50 array astore /bot exch def
9190
9191 % Stacked
9192 format (stacked) eq {
9193 /sep 50 array def
9194 sep 0 0 put
9195 1 1 49 {
9196 /i exch def
9197 top i get bot i get eq {
9198 sep i 1 top i get sub put
9199 } {
9200 sep i 1 sep i 1 sub get sub put
9201 } ifelse
9202 } for
9203 sep 0 [ 0 0 0 0 ] putinterval
9204 sep 46 [ 0 0 0 0 ] putinterval
9205 /pixs [
9206 5 {top aload pop} repeat
9207 sep aload pop
9208 7 {bot aload pop} repeat
9209 ] def
9210 /pixy pixs length 50 idiv def
9211 } if
9212
9213 % Stacked omnidirectional
9214 format (stackedomni) eq {
9215 /sep1 [ top {1 exch sub} forall ] def
9216 sep1 0 [ 0 0 0 0 ] putinterval
9217 sep1 46 [ 0 0 0 0 ] putinterval
9218 18 1 30 {
9219 /i exch def
9220 top i get 0 eq {
9221 top i 1 sub get 1 eq {
9222 1
9223 } {
9224 sep1 i 1 sub get 0 eq {1} {0} ifelse
9225 } ifelse
9226 } {
9227 0
9228 } ifelse
9229 sep1 exch i exch put
9230 } for
9231 /sep2 [ 0 0 0 0 21 { 0 1 } repeat 0 0 0 0 ] def
9232 /sep3 [ bot {1 exch sub} forall ] def
9233 sep3 0 [ 0 0 0 0 ] putinterval
9234 sep3 46 [ 0 0 0 0 ] putinterval
9235 19 1 31 {
9236 /i exch def
9237 bot i get 0 eq {
9238 bot i 1 sub get 1 eq {
9239 1
9240 } {
9241 sep3 i 1 sub get 0 eq {1} {0} ifelse
9242 } ifelse
9243 } {
9244 0
9245 } ifelse
9246 sep3 exch i exch put
9247 } for
9248 /f3 [1 1 1 1 1 1 1 1 1 0 1 1 1] def
9249 true 0 1 12 {dup bot exch 19 add get exch f3 exch get eq and} for {
9250 % Right shifted module for value 3 finder
9251 sep3 19 [ 0 0 0 0 0 0 0 0 0 0 1 0 0 ] putinterval
9252 } if
9253 /pixs [
9254 barxmult {top aload pop} repeat
9255 sep1 aload pop
9256 sep2 aload pop
9257 sep3 aload pop
9258 barxmult {bot aload pop} repeat
9259 ] def
9260 /pixy pixs length 50 idiv def
9261 } if
9262
9263 % Return the arguments
9264 <<
9265 /ren /renmatrix
9266 /pixs pixs
9267 /pixx 50
9268 /pixy pixy
9269 /height pixy 72 div
9270 /width 50 72 div
9271 /borderleft 0.0
9272 /borderright 0.0
9273 /bordertop 0.0
9274 /borderbottom 0.0
9275 /opt options
9276 >>
9277
9278 dontdraw not //renmatrix if
9279
9280 } ifelse
9281
9282 //unloadctx exec
9283
9284 end
9285
9286 }
9287 [/barcode] {null def} forall
9288 bind def
9289 /databaromni dup load /uk.co.terryburton.bwipp defineresource pop
9290 end
9291 /setpacking where {pop setpacking} if
9292 %%EndData
9293 %%EndResource
9294 % --END ENCODER databaromni--
9295
9296 % --BEGIN ENCODER databarstacked--
9297 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear renmatrix databaromni--
9298 % --DESC: GS1 DataBar Stacked
9299 % --EXAM: (01)09521234543213
9300 % --EXOP:
9301 % --RNDR: renmatrix
9302 %%BeginResource: uk.co.terryburton.bwipp databarstacked 0.0 2025111800 70849 70506
9303 %%BeginData: 66 ASCII Lines
9304 /setpacking where {pop currentpacking true setpacking} if
9305 10 dict
9306 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
9307 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
9308 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
9309 dup /databaromni dup /uk.co.terryburton.bwipp findresource put
9310 begin
9311 /databarstacked {
9312
9313 20 dict begin % Confine variables to local scope
9314
9315 /ctx null def
9316 /dontdraw false def
9317
9318 //processoptions exec /options exch def
9319 /barcode exch def
9320
9321 % Validate the input
9322 barcode length 17 ne barcode length 18 ne and {
9323 /bwipp.databarstackedBadLength (GS1 DataBar Stacked must be 13 or 14 digits) //raiseerror exec
9324 } if
9325 barcode 0 4 getinterval (\(01\)) ne {
9326 /bwipp.databarstackedBadAI (GS1 DataBar Stacked must begin with (01) application identifier) //raiseerror exec
9327 } if
9328 barcode 4 barcode length 4 sub getinterval {
9329 dup 48 lt exch 57 gt or {
9330 /bwipp.databarstackedBadCharacter (GS1 DataBar Stacked must contain only digits) //raiseerror exec
9331 } if
9332 } forall
9333
9334 % Calculate checksum and add to end of barcode
9335 /checksum 0 def
9336 0 1 12 {
9337 /i exch def
9338 /checksum checksum barcode i 4 add get 48 sub i 2 mod 0 eq {3 mul} if add def
9339 } for
9340 /checksum 10 checksum 10 mod sub 10 mod def
9341 barcode length 18 eq {
9342 barcode 17 get checksum 48 add ne {
9343 /bwipp.databarstackedBadCheckDigit (Incorrect GS1 DataBar Stacked check digit provided) //raiseerror exec
9344 } if
9345 } if
9346 18 string
9347 dup 0 barcode putinterval
9348 dup 17 checksum 48 add put
9349 /barcode exch def
9350
9351 % Get the result of encoding with databaromni with format=stacked
9352 options (dontdraw) true put
9353 options (format) (stacked) put
9354
9355 /args barcode options //databaromni exec def
9356
9357 args (opt) options put
9358 args
9359
9360 dontdraw not //renmatrix if
9361
9362 end
9363
9364 }
9365 [/barcode] {null def} forall
9366 bind def
9367 /databarstacked dup load /uk.co.terryburton.bwipp defineresource pop
9368 end
9369 /setpacking where {pop setpacking} if
9370 %%EndData
9371 %%EndResource
9372 % --END ENCODER databarstacked--
9373
9374 % --BEGIN ENCODER databarstackedomni--
9375 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear renmatrix databaromni--
9376 % --DESC: GS1 DataBar Stacked Omnidirectional
9377 % --EXAM: (01)24012345678905
9378 % --EXOP:
9379 % --RNDR: renmatrix
9380 %%BeginResource: uk.co.terryburton.bwipp databarstackedomni 0.0 2025111800 70997 70634
9381 %%BeginData: 66 ASCII Lines
9382 /setpacking where {pop currentpacking true setpacking} if
9383 10 dict
9384 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
9385 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
9386 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
9387 dup /databaromni dup /uk.co.terryburton.bwipp findresource put
9388 begin
9389 /databarstackedomni {
9390
9391 20 dict begin % Confine variables to local scope
9392
9393 /ctx null def
9394 /dontdraw false def
9395
9396 //processoptions exec /options exch def
9397 /barcode exch def
9398
9399 % Validate the input
9400 barcode 0 4 getinterval (\(01\)) ne {
9401 /bwipp.databarstackedomniBadAI (GS1 DataBar Stacked Omnidirectional must begin with (01) application identifier) //raiseerror exec
9402 } if
9403 barcode length 17 ne barcode length 18 ne and {
9404 /bwipp.databarstackedomniBadLength (GS1 DataBar Stacked Omnidirectional must be 13 or 14 digits) //raiseerror exec
9405 } if
9406 barcode 4 barcode length 4 sub getinterval {
9407 dup 48 lt exch 57 gt or {
9408 /bwipp.databarstackedomniBadCharacter (GS1 DataBar Stacked Omnidirectional must contain only digits) //raiseerror exec
9409 } if
9410 } forall
9411
9412 % Calculate checksum and add to end of barcode
9413 /checksum 0 def
9414 0 1 12 {
9415 /i exch def
9416 /checksum checksum barcode i 4 add get 48 sub i 2 mod 0 eq {3 mul} if add def
9417 } for
9418 /checksum 10 checksum 10 mod sub 10 mod def
9419 barcode length 18 eq {
9420 barcode 17 get checksum 48 add ne {
9421 /bwipp.databarstackedomniBadCheckDigit (Incorrect GS1 DataBar Stacked Omnidirectional check digit provided) //raiseerror exec
9422 } if
9423 } if
9424 18 string
9425 dup 0 barcode putinterval
9426 dup 17 checksum 48 add put
9427 /barcode exch def
9428
9429 % Get the result of encoding with databaromni with format=stackedomni
9430 options (dontdraw) true put
9431 options (format) (stackedomni) put
9432
9433 /args barcode options //databaromni exec def
9434
9435 args (opt) options put
9436 args
9437
9438 dontdraw not //renmatrix if
9439
9440 end
9441
9442 }
9443 [/barcode] {null def} forall
9444 bind def
9445 /databarstackedomni dup load /uk.co.terryburton.bwipp defineresource pop
9446 end
9447 /setpacking where {pop setpacking} if
9448 %%EndData
9449 %%EndResource
9450 % --END ENCODER databarstackedomni--
9451
9452 % --BEGIN ENCODER databartruncated--
9453 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear renmatrix databaromni--
9454 % --DESC: GS1 DataBar Truncated
9455 % --EXAM: (01)09521234543213
9456 % --EXOP:
9457 % --RNDR: renlinear renmatrix
9458 %%BeginResource: uk.co.terryburton.bwipp databartruncated 0.0 2025111800 70875 70522
9459 %%BeginData: 66 ASCII Lines
9460 /setpacking where {pop currentpacking true setpacking} if
9461 10 dict
9462 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
9463 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
9464 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
9465 dup /databaromni dup /uk.co.terryburton.bwipp findresource put
9466 begin
9467 /databartruncated {
9468
9469 20 dict begin % Confine variables to local scope
9470
9471 /ctx null def
9472 /dontdraw false def
9473
9474 //processoptions exec /options exch def
9475 /barcode exch def
9476
9477 % Validate the input
9478 barcode length 17 ne barcode length 18 ne and {
9479 /bwipp.databartruncatedBadLength (GS1 DataBar Truncated must be 13 or 14 digits) //raiseerror exec
9480 } if
9481 barcode 0 4 getinterval (\(01\)) ne {
9482 /bwipp.databartruncatedBadAI (GS1 DataBar Truncated must begin with (01) application identifier) //raiseerror exec
9483 } if
9484 barcode 4 barcode length 4 sub getinterval {
9485 dup 48 lt exch 57 gt or {
9486 /bwipp.databartruncatedBadCharacter (GS1 DataBar Truncated must contain only digits) //raiseerror exec
9487 } if
9488 } forall
9489
9490 % Calculate checksum and add to end of barcode
9491 /checksum 0 def
9492 0 1 12 {
9493 /i exch def
9494 /checksum checksum barcode i 4 add get 48 sub i 2 mod 0 eq {3 mul} if add def
9495 } for
9496 /checksum 10 checksum 10 mod sub 10 mod def
9497 barcode length 18 eq {
9498 barcode 17 get checksum 48 add ne {
9499 /bwipp.databartruncatedBadCheckDigit (Incorrect GS1 DataBar Truncated check digit provided) //raiseerror exec
9500 } if
9501 } if
9502 18 string
9503 dup 0 barcode putinterval
9504 dup 17 checksum 48 add put
9505 /barcode exch def
9506
9507 % Get the result of encoding with databaromni with format=truncated
9508 options (dontdraw) true put
9509 options (format) (truncated) put
9510
9511 /args barcode options //databaromni exec def
9512
9513 args (opt) options put
9514 args
9515
9516 dontdraw not //renlinear if
9517
9518 end
9519
9520 }
9521 [/barcode] {null def} forall
9522 bind def
9523 /databartruncated dup load /uk.co.terryburton.bwipp defineresource pop
9524 end
9525 /setpacking where {pop setpacking} if
9526 %%EndData
9527 %%EndResource
9528 % --END ENCODER databartruncated--
9529
9530 % --BEGIN ENCODER databarlimited--
9531 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear--
9532 % --DESC: GS1 DataBar Limited
9533 % --EXAM: (01)09521234543213
9534 % --EXOP:
9535 % --RNDR: renlinear
9536 %%BeginResource: uk.co.terryburton.bwipp databarlimited 0.0 2025111800 94503 93792
9537 %%BeginData: 285 ASCII Lines
9538 /setpacking where {pop currentpacking true setpacking} if
9539 20 dict
9540 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
9541 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
9542 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
9543 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
9544 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
9545 begin
9546 /databarlimited {
9547
9548 20 dict begin % Confine variables to local scope
9549
9550 /ctx null def
9551 /dontdraw false def
9552 /height 10.0 72 div def
9553 /linkage false def
9554
9555 //processoptions exec /options exch def
9556 /barcode exch def
9557
9558 /databarlimited //loadctx exec
9559
9560 % Validate the input
9561 barcode length 17 ne barcode length 18 ne and {
9562 /bwipp.databarlimitedBadLength (GS1 DataBar Limited must be 13 or 14 digits) //raiseerror exec
9563 } if
9564 barcode 0 4 getinterval (\(01\)) ne {
9565 /bwipp.databarlimitedBadAI (GS1 DataBar Limited must begin with (01) application identifier) //raiseerror exec
9566 } if
9567 barcode 4 get dup 48 lt exch 49 gt or {
9568 /bwipp.databarlimitedBadStartDigit (GS1 DataBar Limited must begin with 0 or 1) //raiseerror exec
9569 } if
9570 barcode 5 barcode length 5 sub getinterval {
9571 dup 48 lt exch 57 gt or {
9572 /bwipp.databarlimitedBadCharacter (GS1 DataBar Limited must contain only digits) //raiseerror exec
9573 } if
9574 } forall
9575
9576 % Calculate checksum and add to end of barcode
9577 /checksum 0 def
9578 0 1 12 {
9579 /i exch def
9580 /checksum checksum barcode i 4 add get 48 sub i 2 mod 0 eq {3 mul} if add def
9581 } for
9582 /checksum 10 checksum 10 mod sub 10 mod def
9583 barcode length 18 eq {
9584 barcode 17 get checksum 48 add ne {
9585 /bwipp.databarlimitedBadCheckDigit (Incorrect GS1 DataBar Limited check digit provided) //raiseerror exec
9586 } if
9587 } if
9588 18 string
9589 dup 0 barcode putinterval
9590 dup 17 checksum 48 add put
9591 /barcode exch def
9592
9593 % Strip the AI and optional check digit
9594 {
9595 /linkval [ 2 0 1 5 1 3 3 5 3 1 0 9 6 ] def
9596 } ctxdef
9597 /binval [
9598 barcode 4 13 getinterval {48 sub} forall
9599 ] def
9600 linkage {
9601 0 1 binval length 1 sub {
9602 /i exch def
9603 binval i binval i get linkval i get add put
9604 } for
9605 } if
9606
9607 % Create the human readable text
9608 /txt barcode length array def
9609 0 1 barcode length 1 sub {
9610 /i exch def
9611 txt i [barcode i 1 getinterval 0 0 () 0] put
9612 } for
9613
9614 /ncr { % n r
9615 2 copy sub 2 copy lt {exch} if % n r maxd mind
9616 1 1 5 3 roll % mind j=1 v=1 n maxd
9617 1 add -1 exch { % mind j v n -1 maxd+1
9618 mul % mind j v*i
9619 1 index 3 index le {
9620 1 index idiv exch 1 add exch
9621 } if
9622 } for
9623 { % mind j v
9624 1 index 3 index gt {exit} if
9625 1 index idiv exch 1 add exch
9626 } loop
9627 exch pop exch pop
9628 } def
9629
9630 /getRSSwidths {
9631 /oe exch def
9632 /el exch def
9633 /mw exch def
9634 /nm exch def
9635 /val exch def
9636 /out el array def
9637 /mask 0 def
9638 0 1 el 2 sub {
9639 /bar exch def
9640 /ew 1 def
9641 /mask mask 1 bar bitshift or def {
9642 /sval nm ew sub 1 sub el bar sub 2 sub ncr def
9643 oe mask 0 eq and nm ew sub el 2 mul sub bar 2 mul add -2 ge and {
9644 /sval sval nm ew sub el sub bar add el bar sub 2 sub ncr sub def
9645 } if
9646 el bar sub 2 gt {
9647 /lval 0 def
9648 nm ew sub el sub bar add 2 add -1 mw 1 add {
9649 nm exch sub ew sub 1 sub el bar sub 3 sub ncr
9650 /lval exch lval add def
9651 } for
9652 /sval sval lval el bar sub 1 sub mul sub def
9653 } {
9654 nm ew sub mw gt {/sval sval 1 sub def} if
9655 } ifelse
9656 /val val sval sub def
9657 val 0 lt {exit} if
9658 /ew ew 1 add def
9659 /mask mask 1 bar bitshift not and def
9660 } loop
9661 /val val sval add def
9662 /nm nm ew sub def
9663 out bar ew put
9664 } for
9665 out el 1 sub nm put
9666 out
9667 } def
9668
9669 0 1 11 {
9670 /i exch def
9671 binval i 1 add 2 copy get binval i get 2013571 mod 10 mul add put
9672 binval i binval i get 2013571 idiv put
9673 } for
9674 /d2 binval 12 get 2013571 mod def
9675 binval 12 2 copy get 2013571 idiv put
9676
9677 /d1 0 def
9678 /i true def
9679 0 1 12 {
9680 /j exch def
9681 binval j get
9682 dup 0 eq i and {
9683 pop
9684 } {
9685 /i false def
9686 /d1 d1 3 -1 roll 10 12 j sub exp cvi mul add def
9687 } ifelse
9688 } for
9689
9690 {
9691 /tab267 [
9692 183063 0 17 9 6 3 6538 28
9693 820063 183064 13 13 5 4 875 728
9694 1000775 820064 9 17 3 6 28 6454
9695 1491020 1000776 15 11 5 4 2415 203
9696 1979844 1491021 11 15 4 5 203 2408
9697 1996938 1979845 19 7 8 1 17094 1
9698 2013570 1996939 7 19 1 8 1 16632
9699 ] def
9700 } ctxdef
9701
9702 /i 0 def {
9703 d1 tab267 i get le {
9704 tab267 i 1 add 7 getinterval aload pop
9705 /d1te exch def /d1to exch def
9706 /d1mwe exch def /d1mwo exch def
9707 /d1ele exch def /d1elo exch def
9708 /d1gs exch def
9709 exit
9710 } if
9711 /i i 8 add def
9712 } loop
9713
9714 /i 0 def {
9715 d2 tab267 i get le {
9716 tab267 i 1 add 7 getinterval aload pop
9717 /d2te exch def /d2to exch def
9718 /d2mwe exch def /d2mwo exch def
9719 /d2ele exch def /d2elo exch def
9720 /d2gs exch def
9721 exit
9722 } if
9723 /i i 8 add def
9724 } loop
9725
9726 /d1wo d1 d1gs sub d1te idiv d1elo d1mwo 7 false getRSSwidths def
9727 /d1we d1 d1gs sub d1te mod d1ele d1mwe 7 true getRSSwidths def
9728 /d2wo d2 d2gs sub d2te idiv d2elo d2mwo 7 false getRSSwidths def
9729 /d2we d2 d2gs sub d2te mod d2ele d2mwe 7 true getRSSwidths def
9730
9731 /d1w 14 array def
9732 0 1 6 {
9733 /i exch def
9734 d1w i 2 mul d1wo i get put
9735 d1w i 2 mul 1 add d1we i get put
9736 } for
9737
9738 /d2w 14 array def
9739 0 1 6 {
9740 /i exch def
9741 d2w i 2 mul d2wo i get put
9742 d2w i 2 mul 1 add d2we i get put
9743 } for
9744
9745 /widths [
9746 d1w aload pop
9747 d2w aload pop
9748 ] def
9749
9750 {
9751 /checkweights [
9752 1 3 9 27 81 65 17 51 64 14 42 37 22 66
9753 20 60 2 6 18 54 73 41 34 13 39 28 84 74
9754 ] def
9755
9756 /checkseq [
9757 0 1 43 {} for
9758 45 52 57
9759 63 1 66 {} for
9760 73 1 79 {} for
9761 82
9762 126 1 130 {} for
9763 132
9764 141 1 146 {} for
9765 210 1 217 {} for
9766 220
9767 316 1 320 {} for
9768 322 323
9769 326 337
9770 ] def
9771 } ctxdef
9772
9773 /checksum 0 def
9774 0 1 27 {
9775 /i exch def
9776 /checksum checksum widths i get checkweights i get mul add def
9777 } for
9778 /checksum checksum 89 mod def
9779 /seq checkseq checksum get def
9780 /swidths seq 21 idiv 8 3 6 false getRSSwidths def
9781 /bwidths seq 21 mod 8 3 6 false getRSSwidths def
9782
9783 /checkwidths [0 0 0 0 0 0 0 0 0 0 0 0 1 1] def
9784 0 1 5 {
9785 /i exch def
9786 checkwidths i 2 mul swidths i get put
9787 checkwidths i 2 mul 1 add bwidths i get put
9788 } for
9789
9790 /sbs [
9791 1
9792 d1w aload pop
9793 checkwidths aload pop
9794 d2w aload pop
9795 1 1 5
9796 ] def
9797
9798 % Return the arguments
9799 <<
9800 /ren /renlinear
9801 /sbs sbs
9802 /bhs [sbs length 1 add 2 idiv {height} repeat]
9803 /bbs [sbs length 1 add 2 idiv {0} repeat]
9804 /txt txt
9805 /textxalign (center)
9806 /borderleft 0.0
9807 /borderright 0.0
9808 /opt options
9809 >>
9810
9811 dontdraw not //renlinear if
9812
9813 //unloadctx exec
9814
9815 end
9816
9817 }
9818 [/barcode] {null def} forall
9819 bind def
9820 /databarlimited dup load /uk.co.terryburton.bwipp defineresource pop
9821 end
9822 /setpacking where {pop setpacking} if
9823 %%EndData
9824 %%EndResource
9825 % --END ENCODER databarlimited--
9826
9827 % --BEGIN ENCODER databarexpanded--
9828 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process rendertext renlinear renmatrix--
9829 % --DESC: GS1 DataBar Expanded
9830 % --EXAM: (01)09521234543213(3103)000123
9831 % --EXOP:
9832 % --RNDR: renlinear renmatrix
9833 %%BeginResource: uk.co.terryburton.bwipp databarexpanded 0.0 2025111800 254888 250034
9834 %%BeginData: 864 ASCII Lines
9835 /setpacking where {pop currentpacking true setpacking} if
9836 10 dict
9837 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
9838 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
9839 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
9840 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
9841 dup /gs1process dup /uk.co.terryburton.bwipp findresource put
9842 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
9843 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
9844 begin
9845 /databarexpanded {
9846
9847 20 dict begin % Confine variables to local scope
9848
9849 /ctx null def
9850 /parse false def
9851 /dontlint false def
9852 /lintreqs true def
9853 /dontdraw false def
9854 /height 34.0 72 div def
9855 /format (expanded) def
9856 /segments -1 def
9857 /linkage false def
9858 /barxmult 34 def
9859
9860 //processoptions exec /options exch def
9861 /barcode exch def
9862
9863 /databarexpanded //loadctx exec
9864
9865 barxmult 34 lt {
9866 /bwipp.databarStackedOmniBarXmult (GS1 DataBar Expanded Stacked must have a barxmult of at least 34) //raiseerror exec
9867 } if
9868
9869 format (expanded) ne format (expandedstacked) ne and {
9870 /bwipp.databarexpandedBadFormat (Valid formats are expanded and expandedstacked) //raiseerror exec
9871 } if
9872
9873 segments -1 eq {
9874 /segments format (expandedstacked) eq {4} {22} ifelse def
9875 } {
9876 segments 2 lt segments 22 gt or segments 2 mod 0 ne or {
9877 /bwipp.gs1databarexpandedBadSegments (The number of segments must be even from 2 to 22) //raiseerror exec
9878 } if
9879 } ifelse
9880
9881 barcode /ai //gs1process exec
9882 /fncs exch def
9883 /vals exch def
9884 /ais exch def
9885
9886 % Method selection
9887 { % common exit
9888
9889 % (01)9...(3103)...
9890 ais length 2 eq {
9891 ais 0 get (01) eq ais 1 get (3103) eq and {
9892 vals 0 get 0 1 getinterval (9) eq vals 1 get cvi 32767 le and {
9893 (0100) false exit
9894 } if
9895 } if
9896 } if
9897
9898 % (01)9...(3202)...
9899 ais length 2 eq {
9900 ais 0 get (01) eq ais 1 get (3202) eq and {
9901 vals 0 get 0 1 getinterval (9) eq vals 1 get cvi 9999 le and {
9902 (0101) false exit
9903 } if
9904 } if
9905 } if
9906
9907 % (01)9...(3203)...
9908 ais length 2 eq {
9909 ais 0 get (01) eq ais 1 get (3203) eq and {
9910 vals 0 get 0 1 getinterval (9) eq vals 1 get cvi 22767 le and {
9911 (0101) false exit
9912 } if
9913 } if
9914 } if
9915
9916 % (01)9...(310x/320x)...[(11/13/15/17)...]
9917 ais length dup 2 eq exch 3 eq or {
9918 /ai310x false 3100 1 3109 {10 4 string cvrs ais 1 get eq or} for def
9919 /ai320x false 3200 1 3209 {10 4 string cvrs ais 1 get eq or} for def
9920 ais length 3 eq {
9921 /aibad true [ (11) (13) (15) (17) ] {ais 2 get ne and} forall def
9922 } {
9923 /aibad false def
9924 } ifelse
9925 ais 0 get (01) eq ai310x ai320x or and aibad not and {
9926 ais length 3 eq {
9927 vals 0 get 0 1 getinterval (9) eq
9928 vals 1 get cvi 99999 le and
9929 vals 2 get 2 2 getinterval cvi dup 1 ge exch 12 le and and % Month 1-12
9930 vals 2 get 4 2 getinterval cvi dup 0 ge exch 31 le and and { % Day 0-31
9931 ai310x ais 2 get (11) eq and { (0111000) false exit } if
9932 ai320x ais 2 get (11) eq and { (0111001) false exit } if
9933 ai310x ais 2 get (13) eq and { (0111010) false exit } if
9934 ai320x ais 2 get (13) eq and { (0111011) false exit } if
9935 ai310x ais 2 get (15) eq and { (0111100) false exit } if
9936 ai320x ais 2 get (15) eq and { (0111101) false exit } if
9937 ai310x ais 2 get (17) eq and { (0111110) false exit } if
9938 ai320x ais 2 get (17) eq and { (0111111) false exit } if
9939 } if
9940 } {
9941 vals 0 get 0 1 getinterval (9) eq
9942 vals 1 get cvi 99999 le and {
9943 ai310x { (0111000) false exit } if
9944 ai320x { (0111001) false exit } if
9945 } if
9946 } ifelse
9947 } if
9948 } if
9949
9950 % (01)9...(392x)...
9951 ais length 2 ge {
9952 /ai392x false 3920 1 3923 {10 4 string cvrs ais 1 get eq or} for def
9953 ais 0 get (01) eq ai392x and {
9954 vals 0 get 0 1 getinterval (9) eq { (01100) true exit } if
9955 } if
9956 } if
9957
9958 % (01)9...(393x)...
9959 ais length 2 ge {
9960 /ai393x false 3930 1 3933 {10 4 string cvrs ais 1 get eq or} for def
9961 ais 0 get (01) eq ai393x and {
9962 vals 0 get 0 1 getinterval (9) eq { (01101) true exit } if
9963 } if
9964 } if
9965
9966 % (01)...
9967 ais 0 get (01) eq { (1) true exit } if
9968
9969 % Freeform
9970 (00) true exit
9971
9972 } loop
9973 /gpfallow exch def
9974 /method exch def
9975
9976 /conv12to40 {
9977 (0000000000000000000000000000000000000000) 40 string copy
9978 2 copy 0 10 getinterval exch 0 3 getinterval cvi 2 10 string cvrs dup length 10 exch sub exch putinterval
9979 2 copy 10 10 getinterval exch 3 3 getinterval cvi 2 10 string cvrs dup length 10 exch sub exch putinterval
9980 2 copy 20 10 getinterval exch 6 3 getinterval cvi 2 10 string cvrs dup length 10 exch sub exch putinterval
9981 2 copy 30 10 getinterval exch 9 3 getinterval cvi 2 10 string cvrs dup length 10 exch sub exch putinterval
9982 exch pop
9983 } def
9984
9985 /conv13to44 {
9986 (00000000000000000000000000000000000000000000) 44 string copy
9987 2 copy 0 4 getinterval exch 0 1 getinterval cvi 2 4 string cvrs dup length 4 exch sub exch putinterval
9988 dup 3 -1 roll 1 12 getinterval conv12to40 4 exch putinterval
9989 } def
9990
9991 /tobin {
9992 string dup length 1 sub 0 exch 1 exch {1 index exch 48 put} for
9993 dup 3 -1 roll 2 2 index length string cvrs dup length 2 index length exch sub exch putinterval
9994 } def
9995
9996 /fnc1 -1 def /lnumeric -2 def /lalphanumeric -3 def /liso646 -4 def
9997
9998 method (00) eq {
9999 /cdf [] def
10000 /gpf [] def
10001 } if
10002
10003 method (1) eq {
10004 /cdf vals 0 get 0 13 getinterval conv13to44 def
10005 /cdf [ cdf {48 sub} forall ] def
10006 /gpf [] def
10007 /ais ais 1 ais length 1 sub getinterval def
10008 /vals vals 1 vals length 1 sub getinterval def
10009 /fncs fncs 1 fncs length 1 sub getinterval def
10010 } if
10011
10012 method (0100) eq {
10013 /cdf 55 string def
10014 cdf 0 vals 0 get 1 12 getinterval conv12to40 putinterval
10015 cdf 40 vals 1 get cvi 15 tobin putinterval
10016 /cdf [ cdf {48 sub} forall ] def
10017 /gpf [] def
10018 /ais [] def
10019 /vals [] def
10020 /fncs [] def
10021 } if
10022
10023 method (0101) eq {
10024 /cdf 55 string def
10025 cdf 0 vals 0 get 1 12 getinterval conv12to40 putinterval
10026 ais 1 get (3202) eq {
10027 vals 1 get cvi 15 tobin
10028 } {
10029 vals 1 get cvi 10000 add 15 tobin
10030 } ifelse
10031 cdf exch 40 exch putinterval
10032 /cdf [ cdf {48 sub} forall ] def
10033 /gpf [] def
10034 /ais [] def
10035 /vals [] def
10036 /fncs [] def
10037 } if
10038
10039 method length 7 eq {
10040 /cdf 76 string def
10041 cdf 0 vals 0 get 1 12 getinterval conv12to40 putinterval
10042 6 string dup 0 ais 1 get 3 1 getinterval putinterval
10043 dup vals 1 get 1 5 getinterval 1 exch putinterval cvi 20 tobin
10044 cdf exch 40 exch putinterval
10045 ais length 3 eq {
10046 vals 2 get
10047 dup 0 2 getinterval cvi 384 mul exch
10048 dup 2 2 getinterval cvi 1 sub 32 mul exch
10049 4 2 getinterval cvi add add
10050 } {
10051 38400
10052 } ifelse
10053 16 tobin cdf exch 60 exch putinterval
10054 /cdf [ cdf {48 sub} forall ] def
10055 /gpf [] def
10056 /ais [] def
10057 /vals [] def
10058 /fncs [] def
10059 } if
10060
10061 method (01100) eq {
10062 /cdf 42 string def
10063 cdf 0 vals 0 get 1 12 getinterval conv12to40 putinterval
10064 cdf 40 ais 1 get 3 1 getinterval cvi 2 tobin putinterval
10065 /cdf [ cdf {48 sub} forall ] def
10066 /gpf [ vals 1 get {} forall ais length 2 gt { fnc1 } if ] def
10067 /ais ais 2 ais length 2 sub getinterval def
10068 /vals vals 2 vals length 2 sub getinterval def
10069 /fncs fncs 2 fncs length 2 sub getinterval def
10070 } if
10071
10072 method (01101) eq {
10073 /cdf 52 string def
10074 cdf 0 vals 0 get 1 12 getinterval conv12to40 putinterval
10075 cdf 40 ais 1 get 3 1 getinterval cvi 2 tobin putinterval
10076 cdf 42 vals 1 get 0 3 getinterval cvi 10 tobin putinterval
10077 /cdf [ cdf {48 sub} forall ] def
10078 /gpf [ vals 1 get dup length 3 sub 3 exch getinterval {} forall ais length 2 gt { fnc1 } if ] def
10079 /ais ais 2 ais length 2 sub getinterval def
10080 /vals vals 2 vals length 2 sub getinterval def
10081 /fncs fncs 2 fncs length 2 sub getinterval def
10082 } if
10083
10084 % Variable length symbol field
10085 gpfallow {
10086 /vlf 2 array def
10087 } {
10088 /vlf [] def
10089 } ifelse
10090
10091 {
10092 /numeric <<
10093 0 1 119 {
10094 dup (00) 2 string copy dup 3 -1 roll 11 2 string cvrs
10095 dup length 2 exch sub exch putinterval
10096 dup 0 get 65 eq {dup 0 94 put} if
10097 dup 1 get 65 eq {dup 1 94 put} if
10098 exch 8 add
10099 (0000000) 7 string copy dup 3 -1 roll 2 7 string cvrs
10100 dup length 7 exch sub exch putinterval
10101 } for
10102 lalphanumeric (0000)
10103 >> def
10104
10105 /alphanumeric <<
10106 48 1 57 {dup 43 sub 5 tobin} for
10107 fnc1 (01111)
10108 65 1 90 {dup 33 sub 6 tobin} for
10109 42 (111010)
10110 44 1 47 {dup 15 add 6 tobin} for
10111 lnumeric (000)
10112 liso646 (00100)
10113 >> def
10114
10115 /iso646 <<
10116 48 1 57 {dup 43 sub 5 tobin} for
10117 fnc1 (01111)
10118 65 1 90 {dup 1 sub 7 tobin} for
10119 97 1 122 {dup 7 sub 7 tobin} for
10120 33 (11101000)
10121 34 (11101001)
10122 37 1 47 {dup 197 add 8 tobin} for
10123 58 1 63 {dup 187 add 8 tobin} for
10124 95 (11111011)
10125 32 (11111100)
10126 lnumeric (000)
10127 lalphanumeric (00100)
10128 >> def
10129 } ctxdef
10130
10131 % Append the remaining AI data
10132 0 1 ais length 1 sub {
10133 /i exch def
10134 /ai ais i get def
10135 /val vals i get def
10136 gpf length ai length add val length add array
10137 dup 0 gpf putinterval
10138 dup gpf length ai [ exch {} forall ] putinterval
10139 dup gpf length ai length add val [ exch {} forall ] putinterval
10140 /gpf exch def
10141 i ais length 1 sub ne fncs i get and { % Append FNC1
10142 gpf length 1 add array
10143 dup 0 gpf putinterval
10144 dup gpf length fnc1 put
10145 /gpf exch def
10146 } if
10147 } for
10148
10149 % Calculate the number of bits remaining to the next valid symbol size
10150 /rembits {
10151 dup
10152 12 div ceiling cvi 12 mul % Round up to multiple of 12
10153 48 2 copy lt {exch} if pop % At least 4 symbols
10154 dup 12 idiv dup segments mod 1 eq { % At least 2 symbols on last row of stacked symbol
10155 1 add 12 mul exch pop
10156 } {
10157 pop
10158 } ifelse
10159 exch sub
10160 } def
10161
10162 /encode {
10163 dup /raw ne {exch get} {pop} ifelse
10164 dup length j add 252 ge {
10165 pop /bwipp.gs1databarexpandedTooLong (Maximum length exceeded) //raiseerror exec
10166 } if
10167 [ exch {48 sub} forall ]
10168 dup length exch
10169 gpfenc exch j exch putinterval
10170 /j exch j add def
10171 } def
10172
10173 % Pre-compute alphanumeric and numeric runlengths and position of next ISO646-only characters
10174 /numericruns [ gpf length {0} repeat 0 -1 ] def
10175 /alphanumericruns [ gpf length {0} repeat 0 ] def
10176 /nextiso646only [ gpf length {0} repeat 9999 ] def
10177 gpf length 1 sub -1 0 {
10178 /i exch def
10179 gpf i get
10180 (00) 2 string copy
10181 dup 0 gpf i get dup fnc1 eq {pop 94} if put
10182 i gpf length 1 sub lt {dup 1 gpf i 1 add get dup fnc1 eq {pop 94} if put} if
10183 numeric exch known {
10184 numericruns i numericruns i 2 add get 2 add put
10185 } {
10186 numericruns i 0 put
10187 } ifelse
10188 dup alphanumeric exch known {
10189 alphanumericruns i alphanumericruns i 1 add get 1 add put
10190 } {
10191 alphanumericruns i 0 put
10192 } ifelse
10193 dup iso646 exch known exch alphanumeric exch known not and {
10194 nextiso646only i 0 put
10195 } {
10196 nextiso646only i nextiso646only i 1 add get 1 add put
10197 } ifelse
10198 } for
10199
10200 % Encode the general purpose field
10201 /gpfenc 252 array def
10202 /i 0 def /j 0 def /mode (numeric) def
10203 { % loop
10204 i gpf length eq {exit} if
10205 { % not a loop but common exit point
10206
10207 mode (numeric) eq {
10208 i gpf length 2 sub le {
10209 2 string
10210 dup 0 gpf i get dup fnc1 eq {pop 94} if put
10211 dup 1 gpf i 1 add get dup fnc1 eq {pop 94} if put
10212 dup numeric exch known {
10213 numeric encode
10214 /i i 2 add def
10215 exit
10216 } if
10217 pop
10218 lalphanumeric numeric encode
10219 /mode (alphanumeric) def
10220 exit
10221 } {
10222 gpf i get dup 48 lt exch 57 gt or {
10223 lalphanumeric numeric encode
10224 /mode (alphanumeric) def
10225 exit
10226 } if
10227 /rem 12 1 add method length add vlf length add cdf length add j add rembits def
10228 rem 4 ge rem 6 le and { % C1 + 1 into 4 to 6 bits
10229 (000000) 6 string copy 0 rem getinterval
10230 dup gpf i get 47 sub 2 4 string cvrs
10231 dup length 4 exch sub exch putinterval /raw encode
10232 /i i 1 add def
10233 exit
10234 } { % C1.FNC1
10235 2 string dup 0 gpf i get put dup 1 94 put numeric encode
10236 /i i 1 add def
10237 exit
10238 } ifelse
10239 } ifelse
10240 } if
10241
10242 mode (alphanumeric) eq {
10243 gpf i get fnc1 eq {
10244 fnc1 alphanumeric encode
10245 /mode (numeric) def
10246 /i i 1 add def
10247 exit
10248 } if
10249 gpf i get dup iso646 exch known exch alphanumeric exch known not and {
10250 liso646 alphanumeric encode
10251 /mode (iso646) def
10252 exit
10253 } if
10254 numericruns i get 6 ge {
10255 lnumeric alphanumeric encode
10256 /mode (numeric) def
10257 exit
10258 } if
10259 numericruns i get dup 4 ge exch i add gpf length eq and {
10260 lnumeric alphanumeric encode
10261 /mode (numeric) def
10262 exit
10263 } if
10264 gpf i get alphanumeric encode
10265 /i i 1 add def
10266 exit
10267 } if
10268
10269 mode (iso646) eq {
10270 gpf i get fnc1 eq {
10271 fnc1 iso646 encode
10272 /mode (numeric) def
10273 /i i 1 add def
10274 exit
10275 } if
10276 numericruns i get 4 ge nextiso646only i get 10 ge and {
10277 lnumeric iso646 encode
10278 /mode (numeric) def
10279 exit
10280 } if
10281 alphanumericruns i get 5 ge nextiso646only i get 10 ge and {
10282 lalphanumeric iso646 encode
10283 /mode (alphanumeric) def
10284 exit
10285 } if
10286 gpf i get iso646 encode
10287 /i i 1 add def
10288 exit
10289 } if
10290
10291 } loop
10292 } loop
10293 /gpf gpfenc 0 j getinterval def
10294
10295 % Complete the variable length field and create pad
10296 1 12 add method length add vlf length add cdf length add gpf length add
10297 dup rembits dup array /pad exch def
10298 vlf length 0 ne {
10299 add 12 idiv
10300 dup 2 mod vlf exch 0 exch put
10301 14 le {0} {1} ifelse vlf exch 1 exch put
10302 } {
10303 pop pop
10304 } ifelse
10305 pad length 0 gt {
10306 0 5 pad length 1 sub { % Fill with 00100
10307 /i exch def
10308 pad i [ 0 0 1 0 0 ] 0 pad length i sub 5 2 copy gt {exch} if pop getinterval putinterval
10309 } for
10310 mode (numeric) eq { % Prefix shift from numeric to ASCII
10311 /pad [ 0 0 0 0 pad aload pop ] 0 pad length getinterval def
10312 } if
10313 } if
10314
10315 % Concatenate fields
10316 /binval [
10317 linkage {1} {0} ifelse
10318 method {48 sub} forall
10319 vlf aload pop
10320 cdf aload pop
10321 gpf aload pop
10322 pad aload pop
10323 ] def
10324 /datalen binval length 12 idiv def
10325
10326 /ncr { % n r
10327 2 copy sub 2 copy lt {exch} if % n r maxd mind
10328 1 1 5 3 roll % mind j=1 v=1 n maxd
10329 1 add -1 exch { % mind j v n -1 maxd+1
10330 mul % mind j v*i
10331 1 index 3 index le {
10332 1 index idiv exch 1 add exch
10333 } if
10334 } for
10335 { % mind j v
10336 1 index 3 index gt {exit} if
10337 1 index idiv exch 1 add exch
10338 } loop
10339 exch pop exch pop
10340 } def
10341
10342 /getRSSwidths {
10343 /oe exch def
10344 /el exch def
10345 /mw exch def
10346 /nm exch def
10347 /val exch def
10348 /out el array def
10349 /mask 0 def
10350 0 1 el 2 sub {
10351 /bar exch def
10352 /ew 1 def
10353 /mask mask 1 bar bitshift or def {
10354 /sval nm ew sub 1 sub el bar sub 2 sub ncr def
10355 oe mask 0 eq and nm ew sub el 2 mul sub bar 2 mul add -2 ge and {
10356 /sval sval nm ew sub el sub bar add el bar sub 2 sub ncr sub def
10357 } if
10358 el bar sub 2 gt {
10359 /lval 0 def
10360 nm ew sub el sub bar add 2 add -1 mw 1 add {
10361 nm exch sub ew sub 1 sub el bar sub 3 sub ncr
10362 /lval exch lval add def
10363 } for
10364 /sval sval lval el bar sub 1 sub mul sub def
10365 } {
10366 nm ew sub mw gt {/sval sval 1 sub def} if
10367 } ifelse
10368 /val val sval sub def
10369 val 0 lt {exit} if
10370 /ew ew 1 add def
10371 /mask mask 1 bar bitshift not and def
10372 } loop
10373 /val val sval add def
10374 /nm nm ew sub def
10375 out bar ew put
10376 } for
10377 out el 1 sub nm put
10378 out
10379 } def
10380
10381 {
10382 /tab174 [
10383 347 0 12 5 7 2 87 4
10384 1387 348 10 7 5 4 52 20
10385 2947 1388 8 9 4 5 30 52
10386 3987 2948 6 11 3 6 10 104
10387 4191 3988 4 13 1 8 1 204
10388 ] def
10389 } ctxdef
10390
10391 /dxw datalen array def
10392
10393 0 1 datalen 1 sub {
10394
10395 /x exch def
10396
10397 /d binval x 12 mul 12 getinterval def
10398 /d 0 0 1 11 {/j exch def 2 11 j sub exp cvi d j get mul add} for def
10399
10400 /j 0 def {
10401 d tab174 j get le {
10402 tab174 j 1 add 7 getinterval aload pop
10403 /dte exch def /dto exch def
10404 /dmwe exch def /dmwo exch def
10405 /dele exch def /delo exch def
10406 /dgs exch def
10407 exit
10408 } if
10409 /j j 8 add def
10410 } loop
10411
10412 /dwo d dgs sub dte idiv delo dmwo 4 true getRSSwidths def
10413 /dwe d dgs sub dte mod dele dmwe 4 false getRSSwidths def
10414
10415 /dw 8 array def
10416 x 2 mod 0 eq {
10417 0 1 3 {
10418 /j exch def
10419 dw 7 j 2 mul sub dwo j get put
10420 dw 6 j 2 mul sub dwe j get put
10421 } for
10422 } {
10423 0 1 3 {
10424 /j exch def
10425 dw j 2 mul dwo j get put
10426 dw j 2 mul 1 add dwe j get put
10427 } for
10428 } ifelse
10429
10430 dxw x dw put
10431
10432 } for
10433
10434 {
10435 /finderwidths [
10436 1 8 4 1 1 1 1 4 8 1
10437 3 6 4 1 1 1 1 4 6 3
10438 3 4 6 1 1 1 1 6 4 3
10439 3 2 8 1 1 1 1 8 2 3
10440 2 6 5 1 1 1 1 5 6 2
10441 2 2 9 1 1 1 1 9 2 2
10442 ] def
10443
10444 /finderseq [
10445 [0 1]
10446 [0 3 2]
10447 [0 5 2 7]
10448 [0 9 2 7 4]
10449 [0 9 2 7 6 11]
10450 [0 9 2 7 8 11 10]
10451 [0 1 2 3 4 5 6 7]
10452 [0 1 2 3 4 5 6 9 8]
10453 [0 1 2 3 4 5 6 9 10 11]
10454 [0 1 2 3 4 7 6 9 8 11 10]
10455 ] def
10456 } ctxdef
10457
10458 /seq finderseq datalen 2 sub 2 idiv get def
10459 /fxw seq length array def
10460 0 1 seq length 1 sub {
10461 /x exch def
10462 fxw x finderwidths seq x get 5 mul 5 getinterval put
10463 } for
10464
10465 {
10466 /checkweights [
10467 -1 -1 -1 -1 -1 -1 -1 -1 % A1L
10468 77 96 32 81 27 9 3 1 % A1R
10469 20 60 180 118 143 7 21 63 % A2L
10470 205 209 140 117 39 13 145 189 % A2R
10471 193 157 49 147 19 57 171 91 % B1L
10472 132 44 85 169 197 136 186 62 % B1R
10473 185 133 188 142 4 12 36 108 % B2L
10474 50 87 29 80 97 173 128 113 % B2R
10475 150 28 84 41 123 158 52 156 % C1L
10476 166 196 206 139 187 203 138 46 % C1R
10477 76 17 51 153 37 111 122 155 % C2L
10478 146 119 110 107 106 176 129 43 % C2R
10479 16 48 144 10 30 90 59 177 % D1L
10480 164 125 112 178 200 137 116 109 % D1R
10481 70 210 208 202 184 130 179 115 % D2L
10482 190 204 68 93 31 151 191 134 % D2R
10483 148 22 66 198 172 94 71 2 % E1L
10484 40 154 192 64 162 54 18 6 % E1R
10485 120 149 25 75 14 42 126 167 % E2L
10486 175 199 207 69 23 78 26 79 % E2R
10487 103 98 83 38 114 131 182 124 % F1L
10488 159 53 88 170 127 183 61 161 % F1R
10489 55 165 73 8 24 72 5 15 % F2L
10490 89 100 174 58 160 194 135 45 % F2R
10491 ] def
10492 } ctxdef
10493
10494 /checkweightseq [
10495 seq {16 mul checkweights exch 16 getinterval aload pop} forall
10496 ] dup length 8 sub 8 exch getinterval def
10497
10498 /widths [
10499 dxw {aload pop} forall
10500 ] def
10501
10502 /checksum 0 def
10503 0 1 widths length 1 sub {
10504 /i exch def
10505 /checksum checksum widths i get checkweightseq i get mul add def
10506 } for
10507 /checksum checksum 211 mod datalen 3 sub 211 mul add def
10508
10509 /i 0 def {
10510 checksum tab174 i get le {
10511 tab174 i 1 add 7 getinterval aload pop
10512 /cte exch def /cto exch def
10513 /cmwe exch def /cmwo exch def
10514 /cele exch def /celo exch def
10515 /cgs exch def
10516 exit
10517 } if
10518 /i i 8 add def
10519 } loop
10520
10521 /cwo checksum cgs sub cte idiv celo cmwo 4 true getRSSwidths def
10522 /cwe checksum cgs sub cte mod cele cmwe 4 false getRSSwidths def
10523
10524 /cw 8 array def
10525 0 1 3 {
10526 /i exch def
10527 cw i 2 mul cwo i get put
10528 cw i 2 mul 1 add cwe i get put
10529 } for
10530
10531 22 array dup dup
10532 0 cw put 1 dxw putinterval 0 datalen 1 add getinterval
10533 /dxw exch def
10534 /datalen dxw length def
10535
10536 % Encode row runlengths
10537 /rows datalen segments div ceiling cvi array def
10538 /numrows rows length def
10539 0 1 numrows 1 sub {
10540 /r exch def
10541 mark
10542 segments 4 mod 0 ne r 2 mod 1 eq and {0} if
10543 1 1
10544 0 1 segments 1 sub {
10545 /pos exch r segments mul add def
10546 pos datalen lt {
10547 dxw pos get aload pop
10548 pos 2 mod 0 eq {fxw pos 2 idiv get aload pop} if
10549 } if
10550 } for
10551 1 1
10552 counttomark array astore rows exch r exch put pop
10553 } for
10554
10555 format (expandedstacked) ne { % Linear
10556
10557 % Remove leading space
10558 /sbs rows 0 get dup length 1 sub 1 exch getinterval def
10559
10560 /sbs [
10561 1
10562 0 1 datalen 1 sub {
10563 /i exch def
10564 dxw i get aload pop
10565 i 2 mod 0 eq {fxw i 2 idiv get aload pop} if
10566 } for
10567 1 1
10568 ] def
10569
10570 <<
10571 /ren /renlinear
10572 /sbs sbs
10573 /bhs [sbs length 1 add 2 idiv {height} repeat]
10574 /bbs [sbs length 1 add 2 idiv {0} repeat]
10575 /borderleft 0.0
10576 /borderright 0.0
10577 /bordertop 0.0
10578 /borderbottom 0.0
10579 /opt options
10580 >>
10581
10582 dontdraw not //renlinear if
10583
10584 } { % expandedstacked
10585
10586 /seps numrows array def
10587 0 1 numrows 1 sub {
10588
10589 /r exch def
10590 /row rows r get def
10591
10592 % Sample runlengths into bitmap
10593 mark
10594 0 2 row length 1 sub {
10595 /i exch def
10596 row i get {0} repeat
10597 i row length 1 sub lt {row i 1 add get {1} repeat} if
10598 } for
10599 counttomark array astore /row exch def pop
10600
10601 % Derive the separator pattern
10602 /sep [ row {1 exch sub} forall ] def
10603 /finderpos [ % Finder pattern module positions
10604 19 98 row length 13 sub {} for
10605 68 98 row length 13 sub {} for
10606 ] def
10607 finderpos {
10608 dup 14 add 1 exch {
10609 /i exch def
10610 row i get 0 eq {
10611 row i 1 sub get 1 eq {
10612 1
10613 } {
10614 sep i 1 sub get 0 eq {1} {0} ifelse
10615 } ifelse
10616 } {
10617 0
10618 } ifelse
10619 sep exch i exch put
10620 } for
10621 } forall
10622 sep 0 [ 0 0 0 0 ] putinterval
10623 sep row length 4 sub [ 0 0 0 0 ] putinterval
10624
10625 % For even segment-pair symbols reverse alternate rows
10626 segments 4 mod 0 eq r 2 mod 1 eq and {
10627 rows r get length rows 0 get length ne % Except partial width last row
10628 finderpos length 2 mod 1 eq and { % with odd finders
10629 /row [ 0 row aload pop ] def
10630 /sep [ 0 sep aload pop ] def
10631 } {
10632 row length 1 sub -1 0 {row exch get} for
10633 row astore pop
10634 sep length 1 sub -1 0 {sep exch get} for
10635 sep astore pop
10636 } ifelse
10637 } if
10638
10639 rows r row put
10640 seps r sep put
10641
10642 } for
10643
10644 % Extend last row and separator to fill width of symbol
10645 /pixx rows 0 get length def
10646 [ pixx {0} repeat ] dup 0 rows numrows 1 sub get putinterval
10647 rows exch numrows 1 sub exch put
10648 [ pixx {0} repeat ] dup 0 seps numrows 1 sub get putinterval
10649 seps exch numrows 1 sub exch put
10650
10651 % Middle separator pattern
10652 /sep [ pixx 2 idiv 1 add { 0 1 } repeat ] 0 pixx getinterval def
10653 sep 0 [0 0 0 0] putinterval
10654 sep pixx 4 sub [0 0 0 0] putinterval
10655
10656 % Compose the symbol
10657 /pixs [
10658 0 1 numrows 1 sub {
10659 /r exch def
10660 r 0 ne {
10661 seps r get aload pop
10662 } if
10663 barxmult {rows r get aload pop} repeat
10664 r numrows 1 sub ne {
10665 seps r get aload pop
10666 sep aload pop
10667 } if
10668 } for
10669 ] def
10670
10671 <<
10672 /ren /renmatrix
10673 /pixs pixs
10674 /pixx pixx
10675 /pixy pixs length pixx idiv
10676 /height pixs length pixx idiv 72 div
10677 /width pixx 72 div
10678 /borderleft 0.0
10679 /borderright 0.0
10680 /bordertop 0.0
10681 /borderbottom 0.0
10682 /opt options
10683 >>
10684
10685 dontdraw not //renmatrix if
10686
10687 } ifelse
10688
10689 //unloadctx exec
10690
10691 end
10692
10693 }
10694 [/barcode] {null def} forall
10695 bind def
10696 /databarexpanded dup load /uk.co.terryburton.bwipp defineresource pop
10697 end
10698 /setpacking where {pop setpacking} if
10699 %%EndData
10700 %%EndResource
10701 % --END ENCODER databarexpanded--
10702
10703 % --BEGIN ENCODER databarexpandedstacked--
10704 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process rendertext renlinear renmatrix databarexpanded--
10705 % --DESC: GS1 DataBar Expanded Stacked
10706 % --EXAM: (01)09521234543213(3103)000123
10707 % --EXOP: segments=4
10708 % --RNDR: renlinear renmatrix
10709 %%BeginResource: uk.co.terryburton.bwipp databarexpandedstacked 0.0 2025111800 72272 79094
10710 %%BeginData: 36 ASCII Lines
10711 /setpacking where {pop currentpacking true setpacking} if
10712 10 dict
10713 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
10714 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
10715 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
10716 dup /databarexpanded dup /uk.co.terryburton.bwipp findresource put
10717 begin
10718 /databarexpandedstacked {
10719
10720 20 dict begin % Confine variables to local scope
10721
10722 /ctx null def
10723 /dontdraw false def
10724
10725 //processoptions exec /options exch def
10726 /barcode exch def
10727
10728 % Get the result of encoding with databarexpanded with format=expandedstacked
10729 options (dontdraw) true put
10730 options (format) (expandedstacked) put
10731
10732 /args barcode options //databarexpanded exec def
10733
10734 args (opt) options put
10735 args
10736
10737 dontdraw not //renmatrix if
10738
10739 end
10740
10741 }
10742 [/barcode] {null def} forall
10743 bind def
10744 /databarexpandedstacked dup load /uk.co.terryburton.bwipp defineresource pop
10745 end
10746 /setpacking where {pop setpacking} if
10747 %%EndData
10748 %%EndResource
10749 % --END ENCODER databarexpandedstacked--
10750
10751 % --BEGIN ENCODER gs1northamericancoupon--
10752 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process rendertext renlinear renmatrix databarexpanded databarexpandedstacked--
10753 % --DESC: GS1 North American Coupon
10754 % --EXAM: (8110)106141416543213500110000310123196000
10755 % --EXOP: includetext segments=8
10756 % --RNDR: renlinear renmatrix
10757 %%BeginResource: uk.co.terryburton.bwipp gs1northamericancoupon 0.0 2025111800 89936 86223
10758 %%BeginData: 89 ASCII Lines
10759 /setpacking where {pop currentpacking true setpacking} if
10760 10 dict
10761 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
10762 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
10763 dup /gs1process dup /uk.co.terryburton.bwipp findresource put
10764 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
10765 dup /databarexpandedstacked dup /uk.co.terryburton.bwipp findresource put
10766 begin
10767 /gs1northamericancoupon {
10768
10769 20 dict begin % Confine variables to local scope
10770
10771 /ctx null def
10772 /dontdraw false def
10773 /includetext false def % Enable/disable coupon text
10774 /coupontextfont /Helvetica def
10775 /coupontextsize 9.0 def
10776 /coupontextxoffset null def
10777 /coupontextyoffset null def
10778 /parse false def
10779 /dontlint false def
10780 /lintreqs true def
10781
10782 //processoptions exec /options exch def
10783 /barcode exch def
10784
10785 barcode /ai //gs1process exec
10786 pop
10787 /vals exch def
10788 /ais exch def
10789
10790 % Validate the AI structure
10791 ais length 1 ne {
10792 /bwipp.gs1northamericancouponBadAIStructure (A GS1 North American Coupon should consist of a single AI (8110)) //raiseerror exec
10793 } if
10794 ais 0 get (8110) ne {
10795 /bwipp.gs1northamericancouponBadAIStructure (A GS1 North American Coupon should consist of a single AI (8110)) //raiseerror exec
10796 } if
10797
10798 % Parse out the Company Prefix and Offer Code
10799 /val vals 0 get def
10800 /vli val 0 get 48 sub def
10801 vli 0 lt vli 6 gt or {
10802 /bwipp.gs1northamericancouponBadVLI (The AI (8110) data should start with a Company Prefix length indicator in the range 0 to 6) //raiseerror exec
10803 } if
10804 /gcp val 1 vli 6 add getinterval def
10805 /cod val vli 7 add 6 getinterval def
10806 /coupontext gcp length 7 add string def
10807 coupontext 0 gcp putinterval
10808 coupontext gcp length (-) putinterval
10809 coupontext gcp length 1 add cod putinterval
10810
10811 % Get the result of encoding with databarexpandedstacked
10812 options (dontdraw) true put
10813
10814 /args barcode options //databarexpandedstacked exec def
10815
10816 % Add the coupon text
10817 includetext {
10818 coupontextxoffset null eq {
10819 /coupontextxoffset 0.0 def
10820 } if
10821 coupontextyoffset null eq {
10822 /coupontextyoffset args (height) get 72 mul 3 add def
10823 } if
10824 args (txt) known {
10825 /txt args (txt) get def
10826 /newtxt txt length 1 add array def
10827 newtxt 0 txt putinterval
10828 newtxt newtxt length 1 sub [coupontext coupontextxoffset coupontextyoffset coupontextfont coupontextsize] put
10829 args (txt) newtxt put
10830 } {
10831 args (txt) [ [coupontext coupontextxoffset coupontextyoffset coupontextfont coupontextsize] ] put
10832 } ifelse
10833 } if
10834
10835 args (opt) options put
10836 args
10837
10838 dontdraw not //renmatrix if
10839
10840 end
10841
10842 }
10843 [/barcode] {null def} forall
10844 bind def
10845 /gs1northamericancoupon dup load /uk.co.terryburton.bwipp defineresource pop
10846 end
10847 /setpacking where {pop setpacking} if
10848 %%EndData
10849 %%EndResource
10850 % --END ENCODER gs1northamericancoupon--
10851
10852 % --BEGIN ENCODER pharmacode--
10853 % --REQUIRES preamble raiseerror processoptions rendertext renlinear--
10854 % --DESC: Pharmaceutical Binary Code
10855 % --EXAM: 117480
10856 % --EXOP: showborder
10857 % --RNDR: renlinear
10858 %%BeginResource: uk.co.terryburton.bwipp pharmacode 0.0 2025111800 57951 61141
10859 %%BeginData: 79 ASCII Lines
10860 /setpacking where {pop currentpacking true setpacking} if
10861 10 dict
10862 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
10863 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
10864 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
10865 begin
10866 /pharmacode {
10867
10868 20 dict begin % Confine variables to local scope
10869
10870 /ctx null def
10871 /dontdraw false def
10872 /height 8.0 2.835 mul 72 div def
10873 /nwidth 0.5 2.835 mul def
10874 /wwidth 1.5 2.835 mul def
10875 /swidth 1.0 2.835 mul def
10876
10877 //processoptions exec /options exch def
10878 /barcode exch def
10879
10880 % Validate the input
10881 barcode length 1 lt barcode length 6 gt or {
10882 /bwipp.pharmacodeBadLength (Pharmacode must be 1 to 6 digits) //raiseerror exec
10883 } if
10884 barcode {
10885 dup 48 lt exch 57 gt or {
10886 /bwipp.pharmacodeBadCharacter (Pharmacode must contain only digits) //raiseerror exec
10887 } if
10888 } forall
10889 barcode cvi dup 3 lt exch 131070 gt or {
10890 /bwipp.pharmacodeBadValue (Pharmacode value must be between 3 and 131070) //raiseerror exec
10891 } if
10892
10893 % Create the human readable text
10894 /txt barcode length array def
10895 0 1 barcode length 1 sub {
10896 /i exch def
10897 txt i [barcode i 1 getinterval 0 0 () 0] put
10898 } for
10899
10900 % Convert the integer into the paramacode string
10901 /barcode barcode cvi 1 add 2 17 string cvrs def
10902 /barcode barcode 1 barcode length 1 sub getinterval def
10903
10904 /barlen barcode length def % Length of the code
10905 /sbs barlen 2 mul array def
10906
10907 0 1 barlen 1 sub {
10908 /i exch def
10909 /enc barcode i 1 getinterval def
10910 enc (0) eq {
10911 sbs i 2 mul nwidth put
10912 } {
10913 sbs i 2 mul wwidth put
10914 } ifelse
10915 sbs i 2 mul 1 add swidth put
10916 } for
10917
10918 % Return the arguments
10919 <<
10920 /ren /renlinear
10921 /sbs sbs
10922 /bhs [sbs length 1 add 2 idiv {height} repeat]
10923 /bbs [sbs length 1 add 2 idiv {0} repeat]
10924 /txt txt
10925 /textxalign (center)
10926 /opt options
10927 >>
10928
10929 dontdraw not //renlinear if
10930
10931 end
10932
10933 }
10934 [/barcode] {null def} forall
10935 bind def
10936 /pharmacode dup load /uk.co.terryburton.bwipp defineresource pop
10937 end
10938 /setpacking where {pop setpacking} if
10939 %%EndData
10940 %%EndResource
10941 % --END ENCODER pharmacode--
10942
10943 % --BEGIN ENCODER pharmacode2--
10944 % --REQUIRES preamble raiseerror processoptions rendertext renlinear--
10945 % --DESC: Two-track Pharmacode
10946 % --EXAM: 117480
10947 % --EXOP: includetext showborder
10948 % --RNDR: renlinear
10949 %%BeginResource: uk.co.terryburton.bwipp pharmacode2 0.0 2025111800 59318 62431
10950 %%BeginData: 87 ASCII Lines
10951 /setpacking where {pop currentpacking true setpacking} if
10952 10 dict
10953 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
10954 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
10955 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
10956 begin
10957 /pharmacode2 {
10958
10959 20 dict begin
10960
10961 /ctx null def
10962 /dontdraw false def
10963 /includetext false def % Enable/disable text
10964 /height 4.0 def % Height of short bars in millimetres
10965
10966 //processoptions exec /options exch def
10967 /barcode exch def
10968
10969 % Validate the input
10970 barcode length 1 lt barcode length 8 gt or {
10971 /bwipp.pharmacode2BadLength (Two-track Pharmacode must be 1 to 6 digits) //raiseerror exec
10972 } if
10973 barcode {
10974 dup 48 lt exch 57 gt or {
10975 /bwipp.pharmacode2badCharacter (Two-track Pharmacode must contain only digits) //raiseerror exec
10976 } if
10977 } forall
10978 barcode cvi dup 4 lt exch 64570080 gt or {
10979 /bwipp.pharmacode2badValue (Two-track Pharmacode value must be between 4 and 64570080) //raiseerror exec
10980 } if
10981
10982 % Create the human readable text
10983 /txt barcode length array def
10984 0 1 barcode length 1 sub {
10985 /i exch def
10986 txt i [barcode i 1 getinterval 0 0 () 0] put
10987 } for
10988
10989 /encstr 16 string def
10990 /sbs 32 array def
10991 /bar 1 25.4 div height mul def % bar height (mm)
10992 /spc 1 25.4 div 72 mul def % bar width & spacing (1mm)
10993
10994 % Convert number into a base3 representation
10995 /i 15 def
10996 /val barcode cvi def
10997 { % loop
10998 val 0 eq {exit} if
10999 val 3 mod dup
11000 [3 1 2] exch get val exch sub 3 idiv /val exch def
11001 encstr i [2 0 1] 4 -1 roll get put
11002 /i i 1 sub def
11003 } loop
11004 /encstr encstr i 1 add 15 i sub getinterval def
11005
11006 % Generate the bar pattern
11007 /bhs encstr length array def
11008 /bbs encstr length array def
11009 0 1 encstr length 1 sub {
11010 /i exch def
11011 encstr i get dup
11012 bhs i bar [1 1 2] 5 -1 roll get mul put
11013 bbs i [0 bar 0] 4 -1 roll get put
11014 } for
11015
11016 % Return the arguments
11017 <<
11018 /ren /renlinear
11019 /bhs bhs
11020 /bbs bbs
11021 /sbs [encstr length 2 mul {spc} repeat]
11022 /txt txt
11023 /textxalign (center)
11024 /textyoffset 4.0
11025 /opt options
11026 >>
11027
11028 dontdraw not //renlinear if
11029
11030 end
11031
11032 }
11033 [/barcode] {null def} forall
11034 bind def
11035 /pharmacode2 dup load /uk.co.terryburton.bwipp defineresource pop
11036 end
11037 /setpacking where {pop setpacking} if
11038 %%EndData
11039 %%EndResource
11040 % --END ENCODER pharmacode2--
11041
11042 % --BEGIN ENCODER code2of5--
11043 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear--
11044 % --DESC: Code 25
11045 % --EXAM: 01234567
11046 % --EXOP: includetext includecheck includecheckintext
11047 % --RNDR: renlinear
11048 %%BeginResource: uk.co.terryburton.bwipp code2of5 0.0 2025111800 76309 75842
11049 %%BeginData: 154 ASCII Lines
11050 /setpacking where {pop currentpacking true setpacking} if
11051 10 dict
11052 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
11053 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
11054 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
11055 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
11056 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
11057 begin
11058 /code2of5 {
11059
11060 20 dict begin % Confine variable to local scope
11061
11062 /ctx null def
11063 /dontdraw false def
11064 /includecheck false def
11065 /validatecheck false def
11066 /includetext false def % Enable/disable text
11067 /includecheckintext false def
11068 /textfont /Courier def
11069 /textsize 10.0 def
11070 /textyoffset -7.0 def
11071 /height 1.0 def
11072 /version (industrial) def
11073
11074 //processoptions exec /options exch def
11075 /barcode exch def
11076
11077 barcode () eq {
11078 /bwipp.code2of5emptyData (The data must not be empty) //raiseerror exec
11079 } if
11080
11081 /code2of5 //loadctx exec
11082
11083 % Validate input
11084 barcode {
11085 dup 48 lt exch 57 gt or {
11086 /bwipp.code2of5badCharacter (Code 25 must contain only digits) //raiseerror exec
11087 } if
11088 } forall
11089
11090 /barlen barcode length validatecheck {1 sub} if def
11091
11092 /checksum 0 def
11093 0 1 barlen 1 sub {
11094 /i exch def
11095 /checksum checksum barcode i get 48 sub barlen i sub 2 mod 0 ne {3 mul} if add def
11096 } for
11097 /checksum 10 checksum 10 mod sub 10 mod def
11098 validatecheck {
11099 barcode barlen get checksum 48 add ne {
11100 /bwipp.code2of5badCheckDigit (Incorrect Code 25 check digit provided) //raiseerror exec
11101 } if
11102 /barcode barcode 0 barlen getinterval def
11103 /includecheck true def
11104 } if
11105
11106 % Create an array containing the character mappings
11107 {
11108 /versions <<
11109 /industrial
11110 [ (1111313111) (3111111131) (1131111131) (3131111111)
11111 (1111311131) (3111311111) (1131311111) (1111113131)
11112 (3111113111) (1131113111) (313111) (31113)
11113 ]
11114 /iata
11115 [ (1111313111) (3111111131) (1131111131) (3131111111)
11116 (1111311131) (3111311111) (1131311111) (1111113131)
11117 (3111113111) (1131113111) (1111) (311)
11118 ]
11119 /matrix
11120 [ (113311) (311131) (131131) (331111) (113131) (313111)
11121 (133111) (111331) (311311) (131311) (311111) (31111)
11122 ]
11123 /coop
11124 [ (331111) (111331) (113131) (113311) (131131) (131311)
11125 (133111) (311131) (311311) (313111) (3131) (133)
11126 ]
11127 /datalogic
11128 [ (113311) (311131) (131131) (331111) (113131) (313111)
11129 (133111) (111331) (311311) (131311) (1111) (311)
11130 ]
11131 >> def
11132 } ctxdef
11133
11134 versions version known not {
11135 /bwipp.code2of5badVersion (Unrecognised Code 25 version) //raiseerror exec
11136 } if
11137 /encs versions version get def
11138
11139 /cs encs 0 get length def
11140 /cw 0 encs 0 get {48 sub add} forall def
11141 /ss encs 10 get length def
11142 /sw 0 encs 10 get {48 sub add} forall def
11143 /es encs 11 get length def
11144
11145 % Create a string of the available characters
11146 {
11147 /barchars (0123456789) def
11148 } ctxdef
11149
11150 /sbs barlen includecheck {1 add} if cs mul ss add es add string def
11151 /txt barlen includecheck {1 add} if array def
11152
11153 % Put the start character
11154 sbs 0 encs 10 get putinterval
11155 0 1 barlen 1 sub {
11156 /i exch def
11157 % Lookup the encoding for the each barcode character
11158 barcode i 1 getinterval barchars exch search
11159 pop % Discard true leaving pre
11160 length /indx exch def % indx is the length of pre
11161 pop pop % Discard seek and post
11162 /enc encs indx get def % Get the indxth encoding
11163 sbs i cs mul ss add enc putinterval % Put encoded digit into sbs
11164 txt i [barcode i 1 getinterval i cw mul sw add textyoffset textfont textsize] put
11165 } for
11166
11167 % Put the checksum and end characters
11168 includecheck {
11169 sbs barlen cs mul ss add encs checksum get putinterval
11170 sbs barlen cs mul cs add ss add encs 11 get putinterval
11171 includecheckintext {
11172 txt barlen [barchars checksum 1 getinterval barlen cw mul sw add textyoffset textfont textsize] put
11173 } {
11174 txt barlen [( ) barlen cw mul sw add textyoffset textfont textsize] put
11175 } ifelse
11176 } {
11177 sbs barlen cs mul ss add encs 11 get putinterval
11178 } ifelse
11179
11180 % Return the arguments
11181 <<
11182 /ren /renlinear
11183 /sbs [sbs {48 sub} forall]
11184 /bhs [sbs length 1 add 2 idiv {height} repeat]
11185 /bbs [sbs length 1 add 2 idiv {0} repeat]
11186 includetext {
11187 /txt txt
11188 } if
11189 /opt options
11190 >>
11191
11192 dontdraw not //renlinear if
11193
11194 //unloadctx exec
11195
11196 end
11197
11198 }
11199 [/barcode] {null def} forall
11200 bind def
11201 /code2of5 dup load /uk.co.terryburton.bwipp defineresource pop
11202 end
11203 /setpacking where {pop setpacking} if
11204 %%EndData
11205 %%EndResource
11206 % --END ENCODER code2of5--
11207
11208 % --BEGIN ENCODER industrial2of5--
11209 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear code2of5--
11210 % --DESC: Industrial 2 of 5
11211 % --EXAM: 01234567
11212 % --EXOP: includetext includecheck includecheckintext
11213 % --RNDR: renlinear
11214 %%BeginResource: uk.co.terryburton.bwipp industrial2of5 0.0 2025111800 63115 63209
11215 %%BeginData: 36 ASCII Lines
11216 /setpacking where {pop currentpacking true setpacking} if
11217 10 dict
11218 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
11219 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
11220 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
11221 dup /code2of5 dup /uk.co.terryburton.bwipp findresource put
11222 begin
11223 /industrial2of5 {
11224
11225 20 dict begin % Confine variables to local scope
11226
11227 /ctx null def
11228 /dontdraw false def
11229
11230 //processoptions exec /options exch def
11231 /barcode exch def
11232
11233 % Get the result of encoding with code2of5 with version=industrial
11234 options (dontdraw) true put
11235 options (version) (industrial) put
11236
11237 /args barcode options //code2of5 exec def
11238
11239 args (opt) options put
11240 args
11241
11242 dontdraw not //renlinear if
11243
11244 end
11245
11246 }
11247 [/barcode] {null def} forall
11248 bind def
11249 /industrial2of5 dup load /uk.co.terryburton.bwipp defineresource pop
11250 end
11251 /setpacking where {pop setpacking} if
11252 %%EndData
11253 %%EndResource
11254 % --END ENCODER industrial2of5--
11255
11256 % --BEGIN ENCODER iata2of5--
11257 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear code2of5--
11258 % --DESC: IATA 2 of 5
11259 % --EXAM: 01234567
11260 % --EXOP: includetext includecheck includecheckintext
11261 % --RNDR: renlinear
11262 %%BeginResource: uk.co.terryburton.bwipp iata2of5 0.0 2025111800 63085 63185
11263 %%BeginData: 36 ASCII Lines
11264 /setpacking where {pop currentpacking true setpacking} if
11265 10 dict
11266 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
11267 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
11268 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
11269 dup /code2of5 dup /uk.co.terryburton.bwipp findresource put
11270 begin
11271 /iata2of5 {
11272
11273 20 dict begin % Confine variables to local scope
11274
11275 /ctx null def
11276 /dontdraw false def
11277
11278 //processoptions exec /options exch def
11279 /barcode exch def
11280
11281 % Get the result of encoding with code2of5 with version=iata
11282 options (dontdraw) true put
11283 options (version) (iata) put
11284
11285 /args barcode options //code2of5 exec def
11286
11287 args (opt) options put
11288 args
11289
11290 dontdraw not //renlinear if
11291
11292 end
11293
11294 }
11295 [/barcode] {null def} forall
11296 bind def
11297 /iata2of5 dup load /uk.co.terryburton.bwipp defineresource pop
11298 end
11299 /setpacking where {pop setpacking} if
11300 %%EndData
11301 %%EndResource
11302 % --END ENCODER iata2of5--
11303
11304 % --BEGIN ENCODER matrix2of5--
11305 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear code2of5--
11306 % --DESC: Matrix 2 of 5
11307 % --EXAM: 01234567
11308 % --EXOP: includetext includecheck includecheckintext
11309 % --RNDR: renlinear
11310 %%BeginResource: uk.co.terryburton.bwipp matrix2of5 0.0 2025111800 63095 63193
11311 %%BeginData: 36 ASCII Lines
11312 /setpacking where {pop currentpacking true setpacking} if
11313 10 dict
11314 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
11315 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
11316 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
11317 dup /code2of5 dup /uk.co.terryburton.bwipp findresource put
11318 begin
11319 /matrix2of5 {
11320
11321 20 dict begin % Confine variables to local scope
11322
11323 /ctx null def
11324 /dontdraw false def
11325
11326 //processoptions exec /options exch def
11327 /barcode exch def
11328
11329 % Get the result of encoding with code2of5 with version=matrix
11330 options (dontdraw) true put
11331 options (version) (matrix) put
11332
11333 /args barcode options //code2of5 exec def
11334
11335 args (opt) options put
11336 args
11337
11338 dontdraw not //renlinear if
11339
11340 end
11341
11342 }
11343 [/barcode] {null def} forall
11344 bind def
11345 /matrix2of5 dup load /uk.co.terryburton.bwipp defineresource pop
11346 end
11347 /setpacking where {pop setpacking} if
11348 %%EndData
11349 %%EndResource
11350 % --END ENCODER matrix2of5--
11351
11352 % --BEGIN ENCODER coop2of5--
11353 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear code2of5--
11354 % --DESC: COOP 2 of 5
11355 % --EXAM: 01234567
11356 % --EXOP: includetext includecheck includecheckintext
11357 % --RNDR: renlinear
11358 %%BeginResource: uk.co.terryburton.bwipp coop2of5 0.0 2025111800 63085 63185
11359 %%BeginData: 36 ASCII Lines
11360 /setpacking where {pop currentpacking true setpacking} if
11361 10 dict
11362 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
11363 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
11364 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
11365 dup /code2of5 dup /uk.co.terryburton.bwipp findresource put
11366 begin
11367 /coop2of5 {
11368
11369 20 dict begin % Confine variables to local scope
11370
11371 /ctx null def
11372 /dontdraw false def
11373
11374 //processoptions exec /options exch def
11375 /barcode exch def
11376
11377 % Get the result of encoding with code2of5 with version=coop
11378 options (dontdraw) true put
11379 options (version) (coop) put
11380
11381 /args barcode options //code2of5 exec def
11382
11383 args (opt) options put
11384 args
11385
11386 dontdraw not //renlinear if
11387
11388 end
11389
11390 }
11391 [/barcode] {null def} forall
11392 bind def
11393 /coop2of5 dup load /uk.co.terryburton.bwipp defineresource pop
11394 end
11395 /setpacking where {pop setpacking} if
11396 %%EndData
11397 %%EndResource
11398 % --END ENCODER coop2of5--
11399
11400 % --BEGIN ENCODER datalogic2of5--
11401 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear code2of5--
11402 % --DESC: Datalogic 2 of 5
11403 % --EXAM: 01234567
11404 % --EXOP: includetext includecheck includecheckintext
11405 % --RNDR: renlinear
11406 %%BeginResource: uk.co.terryburton.bwipp datalogic2of5 0.0 2025111800 63110 63205
11407 %%BeginData: 36 ASCII Lines
11408 /setpacking where {pop currentpacking true setpacking} if
11409 10 dict
11410 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
11411 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
11412 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
11413 dup /code2of5 dup /uk.co.terryburton.bwipp findresource put
11414 begin
11415 /datalogic2of5 {
11416
11417 20 dict begin % Confine variables to local scope
11418
11419 /ctx null def
11420 /dontdraw false def
11421
11422 //processoptions exec /options exch def
11423 /barcode exch def
11424
11425 % Get the result of encoding with code2of5 with version=datalogic
11426 options (dontdraw) true put
11427 options (version) (datalogic) put
11428
11429 /args barcode options //code2of5 exec def
11430
11431 args (opt) options put
11432 args
11433
11434 dontdraw not //renlinear if
11435
11436 end
11437
11438 }
11439 [/barcode] {null def} forall
11440 bind def
11441 /datalogic2of5 dup load /uk.co.terryburton.bwipp defineresource pop
11442 end
11443 /setpacking where {pop setpacking} if
11444 %%EndData
11445 %%EndResource
11446 % --END ENCODER datalogic2of5--
11447
11448 % --BEGIN ENCODER code11--
11449 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear--
11450 % --DESC: Code 11
11451 % --EXAM: 0123456789
11452 % --EXOP: includetext includecheck includecheckintext
11453 % --RNDR: renlinear
11454 %%BeginResource: uk.co.terryburton.bwipp code11 0.0 2025111800 77721 77411
11455 %%BeginData: 158 ASCII Lines
11456 /setpacking where {pop currentpacking true setpacking} if
11457 10 dict
11458 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
11459 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
11460 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
11461 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
11462 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
11463 begin
11464 /code11 {
11465
11466 20 dict begin % Confine variables to local scope
11467
11468 /ctx null def
11469 /dontdraw false def
11470 /includecheck false def
11471 /validatecheck false def
11472 /includetext false def
11473 /includecheckintext false def
11474 /textfont /Courier def
11475 /textsize 10.0 def
11476 /textyoffset -7.0 def
11477 /height 1.0 def
11478
11479 //processoptions exec /options exch def
11480 /barcode exch def
11481
11482 barcode () eq {
11483 /bwipp.code11emptyData (The data must not be empty) //raiseerror exec
11484 } if
11485
11486 /code11 //loadctx exec
11487
11488 % Create an array containing the character mappings
11489 {
11490 /encs
11491 [ (111131) (311131) (131131) (331111) (113131)
11492 (313111) (133111) (111331) (311311) (311111)
11493 (113111) (113311)
11494 ] def
11495
11496 % Create a string of the available characters
11497 /barchars (0123456789-) def
11498 /charvals 11 dict def
11499 0 1 10 {charvals exch dup barchars exch 1 getinterval exch put} for
11500 } ctxdef
11501
11502 % Validate the input
11503 0 1 barcode length 1 sub {
11504 barcode exch 1 getinterval charvals exch known not {
11505 /bwipp.code11badCharacter (Code 11 must contain only digits and dashes) //raiseerror exec
11506 } if
11507 } for
11508
11509 /barlen barcode length def
11510 validatecheck {
11511 barlen 11 eq {
11512 /bwipp.code11badLength (Code 11 cannot be 11 characters using check digits) //raiseerror exec
11513 } if
11514 /barlen barlen barlen 10 le {1} {2} ifelse sub def
11515 } if
11516
11517 /numchecks includecheck validatecheck or {barlen 10 ge {2} {1} ifelse} {0} ifelse def
11518 /checksum1 0 def /checksum2 0 def
11519 0 1 barlen 1 sub {
11520 /i exch def
11521 /indx charvals barcode i 1 getinterval get def
11522 /checksum1 checksum1 barlen i sub 1 sub 10 mod 1 add indx mul add def
11523 /checksum2 checksum2 barlen i sub 9 mod 1 add indx mul add def
11524 } for
11525 /checksum1 checksum1 11 mod def
11526 /checksum2 checksum2 checksum1 add 11 mod def
11527 validatecheck {
11528 numchecks 1 eq {
11529 barcode barlen get barchars checksum1 get ne {
11530 /bwipp.code11badCheckDigit (Incorrect Code 11 check digit provided) //raiseerror exec
11531 } if
11532 } {
11533 barcode barlen get barchars checksum1 get ne
11534 barcode barlen 1 add get barchars checksum2 get ne or {
11535 /bwipp.code11badCheckDigits (Incorrect Code 11 check digits provided) //raiseerror exec
11536 } if
11537 } ifelse
11538 /barcode barcode 0 barlen getinterval def
11539 /includecheck true def
11540 } if
11541
11542 /sbs barlen numchecks add 6 mul 12 add string def
11543 /txt barlen numchecks add array def
11544
11545 % Put the start character
11546 sbs 0 encs 11 get putinterval
11547
11548 /xpos 8 def
11549 0 1 barlen 1 sub {
11550 /i exch def
11551 /indx charvals barcode i 1 getinterval get def
11552 /enc encs indx get def
11553 sbs i 6 mul 6 add enc putinterval
11554 txt i [barcode i 1 getinterval xpos textyoffset textfont textsize] put
11555 0 1 5 { % xpos+=width of the character
11556 /xpos exch enc exch get 48 sub xpos add def
11557 } for
11558 } for
11559
11560 % Put the checksum and end characters
11561 includecheck {
11562 barlen 10 ge {
11563 sbs barlen 6 mul 6 add encs checksum1 get putinterval
11564 sbs barlen 6 mul 12 add encs checksum2 get putinterval
11565 includecheckintext {
11566 txt barlen [barchars checksum1 1 getinterval xpos textyoffset textfont textsize] put
11567 /enc encs checksum1 get def
11568 0 1 5 { % xpos+=width of the character
11569 /xpos exch enc exch get 48 sub xpos add def
11570 } for
11571 txt barlen 1 add [barchars checksum2 1 getinterval xpos textyoffset textfont textsize] put
11572 } {
11573 txt barlen [() xpos textyoffset textfont textsize] put
11574 txt barlen 1 add [() xpos textyoffset textfont textsize] put
11575 } ifelse
11576 sbs barlen 6 mul 18 add encs 11 get putinterval
11577 } {
11578 sbs barlen 6 mul 6 add encs checksum1 get putinterval
11579 includecheckintext {
11580 txt barlen [barchars checksum1 1 getinterval xpos textyoffset textfont textsize] put
11581 } {
11582 txt barlen [() xpos textyoffset textfont textsize] put
11583 } ifelse
11584 sbs barlen 6 mul 12 add encs 11 get putinterval
11585 } ifelse
11586 } {
11587 sbs barlen 6 mul 6 add encs 11 get putinterval
11588 } ifelse
11589
11590 % Return the arguments
11591 <<
11592 /ren /renlinear
11593 /sbs [sbs {48 sub} forall]
11594 /bhs [sbs length 1 add 2 idiv {height} repeat]
11595 /bbs [sbs length 1 add 2 idiv {0} repeat]
11596 includetext {
11597 /txt txt
11598 } if
11599 /opt options
11600 >>
11601
11602 dontdraw not //renlinear if
11603
11604 //unloadctx exec
11605
11606 end
11607
11608 }
11609 [/barcode] {null def} forall
11610 bind def
11611 /code11 dup load /uk.co.terryburton.bwipp defineresource pop
11612 end
11613 /setpacking where {pop setpacking} if
11614 %%EndData
11615 %%EndResource
11616 % --END ENCODER code11--
11617
11618 % --BEGIN ENCODER bc412--
11619 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear--
11620 % --DESC: BC412
11621 % --EXAM: BC412SEMI
11622 % --EXOP: semi includetext includecheckintext
11623 % --RNDR: renlinear
11624 %%BeginResource: uk.co.terryburton.bwipp bc412 0.0 2025111800 78780 78496
11625 %%BeginData: 192 ASCII Lines
11626 /setpacking where {pop currentpacking true setpacking} if
11627 10 dict
11628 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
11629 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
11630 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
11631 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
11632 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
11633 begin
11634 /bc412 {
11635
11636 20 dict begin % Confine variables to local scope
11637
11638 /ctx null def
11639 /dontdraw false def
11640 /includecheck false def
11641 /validatecheck false def
11642 /includetext false def
11643 /includecheckintext false def
11644 /includestartstop false def
11645 /semi false def
11646 /textfont /Courier def
11647 /textsize 10.0 def
11648 /textyoffset -7.0 def
11649 /height 1.0 def
11650
11651 //processoptions exec /options exch def
11652 /barcode exch def
11653
11654 barcode () eq {
11655 /bwipp.bc412emptyData (The data must not be empty) //raiseerror exec
11656 } if
11657
11658 semi {
11659 % Implies includecheck and includecheckintext also
11660 /includestartstop true def
11661 } if
11662
11663 /bc412 //loadctx exec
11664
11665 % Create a string of the available characters
11666 {
11667 /barchars (0R9GLVHA8EZ4NTS1J2Q6C7DYKBUIX3FWP5M) def
11668 /charvals 35 dict def
11669 0 1 34 {charvals exch dup barchars exch 1 getinterval exch put} for
11670 } ctxdef
11671
11672 % Validate the input
11673 0 1 barcode length 1 sub {
11674 barcode exch 1 getinterval charvals exch known not {
11675 /bwipp.bc412badCharacter (BC412 must contain only digits and capital letters except O) //raiseerror exec
11676 } if
11677 } for
11678
11679 semi {
11680 % Validate length
11681 validatecheck {
11682 barcode length 8 lt barcode length 19 gt or {
11683 /bwipp.bc412semivalidateBadLength (BC412 semi with check digit must be 8 to 19 characters long) //raiseerror exec
11684 } if
11685 } {
11686 barcode length 7 lt barcode length 18 gt or {
11687 /bwipp.bc412semiBadLength (BC412 semi must be 7 to 18 characters long) //raiseerror exec
11688 } if
11689 } ifelse
11690
11691 /barlen barcode length def
11692 validatecheck not { % Place dummy (0) in checksum position (1-based 2nd)
11693 /barlen barlen 1 add def
11694 /sbarcode barlen string def
11695 sbarcode 0 barcode 0 get put
11696 sbarcode 1 48 put % (0)
11697 sbarcode 2 barcode 1 barlen 2 sub getinterval putinterval
11698 /barcode sbarcode def
11699 } if
11700 /sumodd 0 def /sumeven 0 def
11701 0 1 barlen 1 sub {
11702 /i exch def
11703 barcode i 1 getinterval charvals exch get
11704 i 2 mod 0 eq { % 1-based odd
11705 sumodd add /sumodd exch def
11706 } {
11707 sumeven add /sumeven exch def
11708 } ifelse
11709 } for
11710 /checksum sumodd 35 mod sumeven 35 mod 2 mul add 35 mod def % F = Mod35( Mod35( Fodd ) + 2 * Mod35( Feven ) )
11711 validatecheck {
11712 checksum 0 ne {
11713 /bwipp.bc412semiBadCheckDigit (Incorrect BC412 semi check digit provided) //raiseerror exec
11714 } if
11715 } {
11716 /checksum checksum 17 mul 35 mod def % CD = Mod35( 17 * F )
11717 barcode 1 barchars checksum get put
11718 } ifelse
11719 } {
11720 /barlen barcode length validatecheck {1 sub} if def
11721
11722 /checksum 0 def
11723 0 1 barlen 1 sub {
11724 barcode exch 1 getinterval charvals exch get
11725 checksum add /checksum exch def
11726 } for
11727 /checksum checksum 35 mod def
11728 validatecheck {
11729 barcode barlen get barchars checksum get ne {
11730 /bwipp.bc412badCheckDigit (Incorrect BC412 check digit provided) //raiseerror exec
11731 } if
11732 /barcode barcode 0 barlen getinterval def
11733 /includecheck true def
11734 } if
11735 } ifelse
11736
11737 % Create an array containing the character mappings
11738 {
11739 /encs
11740 [ (11111115) (13111212) (11131113) (12111213) (12121311) % 0R9GL
11741 (13131111) (12111312) (11131212) (11121411) (11151111) % VHA8E
11742 (15111111) (11111511) (12131211) (13121112) (13111311) % Z4NTS
11743 (11111214) (12121113) (11111313) (13111113) (11121213) % 1J2Q6
11744 (11141112) (11121312) (11141211) (14121111) (12121212) % C7DYK
11745 (11131311) (13121211) (12111411) (14111211) (11111412) % BUIX3
11746 (12111114) (14111112) (12141111) (11121114) (12131112) % FWP5M
11747 (12) (111) % Start Stop
11748 ] def
11749 } ctxdef
11750
11751 /sbs barlen 1 add 8 mul 5 add string def
11752 includecheck {
11753 /txt barlen 1 add array def
11754 } {
11755 /txt barlen array def
11756 } ifelse
11757
11758 % Put the start character
11759 includestartstop {
11760 sbs 0 encs 35 get putinterval
11761 /pos 2 def
11762 /txtpos 3.0 def
11763 } {
11764 /pos 0 def
11765 /txtpos 0.0 def
11766 } ifelse
11767
11768 0 1 barlen 1 sub {
11769 /i exch def
11770 /indx charvals barcode i 1 getinterval get def
11771 sbs pos encs indx get putinterval
11772 txt i [barcode i 1 getinterval i 12 mul txtpos add textyoffset textfont textsize] put
11773 /pos pos 8 add def
11774 } for
11775
11776 % Put the checksum
11777 includecheck {
11778 sbs pos encs checksum get putinterval
11779 includecheckintext {
11780 txt barlen [barchars checksum 1 getinterval barlen 12 mul txtpos add textyoffset textfont textsize] put
11781 } {
11782 txt barlen [() barlen 12 mul txtpos add textyoffset textfont textsize] put
11783 } ifelse
11784 /pos pos 8 add def
11785 } if
11786
11787 % Put the stop character
11788 includestartstop {
11789 sbs pos encs 36 get putinterval
11790 /pos pos 3 add def
11791 } if
11792
11793 % Return the arguments
11794 /sbs sbs 0 pos getinterval def
11795 <<
11796 /ren /renlinear
11797 /sbs [sbs {48 sub} forall]
11798 /bhs [sbs length 1 add 2 idiv {height} repeat]
11799 /bbs [sbs length 1 add 2 idiv {0} repeat]
11800 includetext {
11801 /txt txt
11802 } if
11803 /opt options
11804 >>
11805
11806 dontdraw not //renlinear if
11807
11808 //unloadctx exec
11809
11810 end
11811
11812 }
11813 [/barcode] {null def} forall
11814 bind def
11815 /bc412 dup load /uk.co.terryburton.bwipp defineresource pop
11816 end
11817 /setpacking where {pop setpacking} if
11818 %%EndData
11819 %%EndResource
11820 % --END ENCODER bc412--
11821
11822 % --BEGIN ENCODER rationalizedCodabar--
11823 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear--
11824 % --DESC: Codabar
11825 % --EXAM: A0123456789B
11826 % --EXOP: includetext includecheck includecheckintext
11827 % --RNDR: renlinear
11828 %%BeginResource: uk.co.terryburton.bwipp rationalizedCodabar 0.0 2025111800 78894 78550
11829 %%BeginData: 156 ASCII Lines
11830 /setpacking where {pop currentpacking true setpacking} if
11831 10 dict
11832 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
11833 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
11834 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
11835 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
11836 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
11837 begin
11838 /rationalizedCodabar {
11839
11840 20 dict begin % Confine variables to local scope
11841
11842 /ctx null def
11843 /dontdraw false def
11844 /altstartstop false def
11845 /includecheck false def % Enable/disable checkdigit
11846 /validatecheck false def
11847 /includetext false def % Enable/disable text
11848 /includecheckintext false def
11849 /textfont /Courier def
11850 /textsize 10.0 def
11851 /textyoffset -7.0 def
11852 /height 1.0 def
11853
11854 //processoptions exec /options exch def
11855 /barcode exch def
11856
11857 barcode length 2 lt barcode length 3 lt validatecheck and or {
11858 /bwipp.rationalizedCodabarBadLength (Codabar must be at least 2 characters in length excluding any check digit) //raiseerror exec
11859 } if
11860
11861 /rationalizedCodabar //loadctx exec
11862
11863 {
11864 % Create an array containing the character mappings
11865 /encs
11866 [ (11111331) (11113311) (11131131) (33111111) (11311311)
11867 (31111311) (13111131) (13113111) (13311111) (31131111)
11868 (11133111) (11331111) (31113131) (31311131) (31313111)
11869 (11313131) (11331311) (13131131) (11131331) (11133311)
11870 ] def
11871
11872 % Create a string of the available characters
11873 /barcharsnormal (0123456789-$:/.+ABCD) def
11874 /barcharsalt (0123456789-$:/.+TN*E) def
11875 } ctxdef
11876
11877 /barchars altstartstop {barcharsalt} {barcharsnormal} ifelse def
11878
11879 /charvals 20 dict def
11880 0 1 19 {charvals exch dup barchars exch 1 getinterval exch put} for
11881 /bodyvals 16 dict def
11882 0 1 15 {bodyvals exch dup barchars exch 1 getinterval exch put} for
11883 /ssvals 4 dict def
11884 16 1 19 {ssvals exch dup barchars exch 1 getinterval exch put} for
11885
11886 % Validate the input
11887 barcode 0 1 getinterval ssvals exch known not
11888 barcode barcode length 1 sub 1 getinterval ssvals exch known not or {
11889 altstartstop {
11890 /bwipp.rationalizedCodabarBadAltStartStop (Codabar start and stop characters must be one of E N T or *) //raiseerror exec
11891 } {
11892 /bwipp.rationalizedCodabarBadStartStop (Codabar start and stop characters must be one of A B C or D) //raiseerror exec
11893 } ifelse
11894 } if
11895 1 1 barcode length 2 sub {
11896 barcode exch 1 getinterval bodyvals exch known not {
11897 /bwipp.rationalizedCodabarBadCharacter (Codabar body must contain only digits and symbols - $ : / . +) //raiseerror exec
11898 } if
11899 } for
11900
11901 /barlen barcode length validatecheck {1 sub} if def
11902
11903 /checksum 0 def
11904 0 1 barlen 2 sub {
11905 barcode exch 1 getinterval charvals exch get
11906 checksum add /checksum exch def
11907 } for
11908 barcode barcode length 1 sub 1 getinterval charvals exch get
11909 checksum add /checksum exch def
11910 /checksum 16 checksum 16 mod sub 16 mod def
11911 validatecheck {
11912 barcode barlen 1 sub get barchars checksum get ne {
11913 /bwipp.rationalizedCodabarBadCheckDigit (Incorrect Codabar check digit provided) //raiseerror exec
11914 } if
11915 barlen string
11916 dup 0 barcode 0 barlen 1 sub getinterval putinterval
11917 dup barlen 1 sub barcode barlen 1 getinterval putinterval
11918 /barcode exch def
11919 /includecheck true def
11920 } if
11921
11922 /sbs barlen includecheck {1 add} if 8 mul string def
11923 /txt barlen includecheck {1 add} if array def
11924
11925 /xpos 0 def
11926 0 1 barlen 2 sub {
11927 /i exch def
11928 /indx charvals barcode i 1 getinterval get def
11929 /enc encs indx get def
11930 sbs i 8 mul enc putinterval % Put encoded digit into sbs
11931 txt i [barcode i 1 getinterval xpos textyoffset textfont textsize] put
11932 0 1 7 { % xpos+=width of the character
11933 /xpos exch enc exch get 48 sub xpos add def
11934 } for
11935 } for
11936
11937 % Put the checksum character and stop character
11938 includecheck {
11939 % Put the checksum character
11940 sbs barlen 8 mul 8 sub encs checksum get putinterval
11941 includecheckintext {
11942 txt barlen 1 sub [barchars checksum 1 getinterval xpos textyoffset textfont textsize] put
11943 } {
11944 txt barlen 1 sub [( ) xpos textyoffset textfont textsize] put
11945 } ifelse
11946 0 1 7 { % xpos+=width of the character
11947 /xpos exch encs checksum get exch get 48 sub xpos add def
11948 } for
11949 % Put the end character
11950 /indx charvals barcode barlen 1 sub 1 getinterval get def
11951 /enc encs indx get def % Get the indxth encoding
11952 sbs barlen 8 mul enc putinterval % Put encoded digit into sbs
11953 txt barlen [barcode barlen 1 sub 1 getinterval xpos textyoffset textfont textsize] put
11954 } {
11955 % Put the end character
11956 /indx charvals barcode barlen 1 sub 1 getinterval get def
11957 /enc encs indx get def % Get the indxth encoding
11958 sbs barlen 8 mul 8 sub enc putinterval % Put encoded digit into sbs
11959 txt barlen 1 sub [barcode barlen 1 sub 1 getinterval xpos textyoffset textfont textsize] put
11960 } ifelse
11961
11962 % Return the arguments
11963 <<
11964 /ren /renlinear
11965 /sbs [sbs {48 sub} forall]
11966 /bhs [sbs length 1 add 2 idiv {height} repeat]
11967 /bbs [sbs length 1 add 2 idiv {0} repeat]
11968 includetext {
11969 /txt txt
11970 } if
11971 /opt options
11972 >>
11973
11974 dontdraw not //renlinear if
11975
11976 //unloadctx exec
11977
11978 end
11979
11980 }
11981 [/barcode] {null def} forall
11982 bind def
11983 /rationalizedCodabar dup load /uk.co.terryburton.bwipp defineresource pop
11984 end
11985 /setpacking where {pop setpacking} if
11986 %%EndData
11987 %%EndResource
11988 % --END ENCODER rationalizedCodabar--
11989
11990 % --BEGIN ENCODER onecode--
11991 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear--
11992 % --DESC: USPS Intelligent Mail
11993 % --EXAM: 0123456709498765432101234567891
11994 % --EXOP: barcolor=FF0000
11995 % --RNDR: renlinear
11996 %%BeginResource: uk.co.terryburton.bwipp onecode 0.0 2025111800 113001 113030
11997 %%BeginData: 347 ASCII Lines
11998 /setpacking where {pop currentpacking true setpacking} if
11999 10 dict
12000 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
12001 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
12002 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
12003 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
12004 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
12005 begin
12006 /onecode {
12007
12008 20 dict begin
12009
12010 /ctx null def
12011 /dontdraw false def
12012 /height 0.15 def
12013
12014 //processoptions exec /options exch def
12015 /barcode exch def
12016
12017 /onecode //loadctx exec
12018
12019 /barlen barcode length def
12020
12021 barcode {
12022 dup 48 lt exch 57 gt or {
12023 /bwipp.onecodeBadCharacter (The data must contain only digits) //raiseerror exec
12024 } if
12025 } forall
12026
12027 barlen 20 ne barlen 25 ne and barlen 29 ne and barlen 31 ne and {
12028 /bwipp.onecodeInvalidLength (The data must be 20, 25, 29 or 31 digits) //raiseerror exec
12029 } if
12030
12031 % Create the human readable text
12032 /txtdict <<
12033 2 dup
12034 5 dup
12035 barcode 5 1 getinterval (9) eq {14} {11} ifelse dup
12036 20 dup
12037 25 dup
12038 29 dup
12039 >> def
12040 /txt barlen 6 add array def
12041 /spacecnt 0 def
12042 0 1 barlen 1 sub {
12043 /i exch def
12044 txtdict i known {
12045 txt i spacecnt add [( ) 0 0 () 0] put
12046 /spacecnt spacecnt 1 add def
12047 } if
12048 txt i spacecnt add [barcode i 1 getinterval 0 0 () 0] put
12049 } for
12050 /txt txt 0 barcode length spacecnt add getinterval def
12051
12052 /normalize {
12053 /base exch def
12054 /num exch def
12055 num length 1 sub -1 1 {
12056 /i exch def
12057 num i 1 sub 2 copy get num i get base idiv add put
12058 num i num i get base mod put
12059 } for
12060 { %loop - extend input as necessary
12061 num 0 get base lt {exit} if
12062 /num [ 0 num aload pop ] def
12063 num 0 num 0 get num 1 get base idiv add put
12064 num 1 num 1 get base mod put
12065 } loop
12066 % Trim leading zeros
12067 /num [/i true def num {dup 0 eq i and {pop} {/i false def} ifelse} forall] def
12068 num length 0 eq {/num [0] def} if
12069 num
12070 } def
12071
12072 /bigadd {
12073 2 copy length exch length
12074 2 copy sub abs /offset exch def
12075 lt {exch} if
12076 /a exch def /b exch def
12077 0 1 b length 1 sub {
12078 dup a exch offset add 2 copy get b 5 -1 roll get add put
12079 } for
12080 a
12081 } def
12082
12083 % Conversion of data fields into binary data
12084 {
12085 /startvals <<
12086 20 [0]
12087 25 [1]
12088 29 [1 0 0 0 0 1]
12089 31 [1 0 0 0 1 0 0 0 0 1]
12090 >> def
12091 } ctxdef
12092
12093 /binval startvals barlen get [barcode 20 barlen 20 sub getinterval {48 sub} forall] bigadd def
12094 /binval [binval aload pop barcode 0 get 48 sub] def
12095 /binval [binval {5 mul} forall] [barcode 1 get 48 sub] bigadd 10 normalize def
12096 /binval [binval aload pop barcode 2 18 getinterval {48 sub} forall] def
12097
12098 % Conversion of binary data into byte array
12099 /bytes 13 array def
12100 /bintmp binval dup length array copy def
12101 12 -1 0 {
12102 /i exch def
12103 0 1 bintmp length 2 sub {
12104 /j exch def
12105 bintmp j 1 add 2 copy get bintmp j get 256 mod 10 mul add put
12106 bintmp j bintmp j get 256 idiv put
12107 } for
12108 bytes i bintmp bintmp length 1 sub get 256 mod put
12109 bintmp bintmp length 1 sub 2 copy get 256 idiv put
12110 } for
12111
12112 % Generation of 11-bit CRC on byte array
12113 /fcs 2047 def
12114 /dat bytes 0 get 5 bitshift def
12115 6 {
12116 fcs dat xor 1024 and 0 ne {
12117 /fcs fcs 1 bitshift 3893 xor def
12118 } {
12119 /fcs fcs 1 bitshift def
12120 } ifelse
12121 /fcs fcs 2047 and def
12122 /dat dat 1 bitshift def
12123 } repeat
12124 1 1 12 {
12125 bytes exch get 3 bitshift /dat exch def
12126 8 {
12127 fcs dat xor 1024 and 0 ne {
12128 /fcs fcs 1 bitshift 3893 xor def
12129 } {
12130 /fcs fcs 1 bitshift def
12131 } ifelse
12132 /fcs fcs 2047 and def
12133 /dat dat 1 bitshift def
12134 } repeat
12135 } for
12136
12137 % Conversion from binary data to codewords
12138 /codewords 10 array def
12139 9 -1 0 {
12140 /i exch def
12141 /b i 9 eq { 636 } { 1365 } ifelse def
12142 0 1 binval length 2 sub {
12143 /j exch def
12144 binval j 1 add 2 copy get binval j get b mod 10 mul add put
12145 binval j binval j get b idiv put
12146 } for
12147 codewords i binval binval length 1 sub get b mod put
12148 binval binval length 1 sub 2 copy get b idiv put
12149 } for
12150
12151 % Inserting additional information into codewords
12152 codewords 9 codewords 9 get 2 mul put
12153 fcs 1024 and 0 ne {
12154 codewords 0 codewords 0 get 659 add put
12155 } if
12156
12157 % Conversion from codewords to characters
12158 {
12159 /tab513 [
12160 31 7936 47 7808 55 7552 59 7040 61 6016 62 3968 79 7744 87
12161 7488 91 6976 93 5952 94 3904 103 7360 107 6848 109 5824 110 3776
12162 115 6592 117 5568 118 3520 121 5056 122 3008 124 1984 143 7712 151
12163 7456 155 6944 157 5920 158 3872 167 7328 171 6816 173 5792 174 3744
12164 179 6560 181 5536 182 3488 185 5024 186 2976 188 1952 199 7264 203
12165 6752 205 5728 206 3680 211 6496 213 5472 214 3424 217 4960 218 2912
12166 220 1888 227 6368 229 5344 230 3296 233 4832 234 2784 236 1760 241
12167 4576 242 2528 244 1504 248 992 271 7696 279 7440 283 6928 285 5904
12168 286 3856 295 7312 299 6800 301 5776 302 3728 307 6544 309 5520 310
12169 3472 313 5008 314 2960 316 1936 327 7248 331 6736 333 5712 334 3664
12170 339 6480 341 5456 342 3408 345 4944 346 2896 348 1872 355 6352 357
12171 5328 358 3280 361 4816 362 2768 364 1744 369 4560 370 2512 372 1488
12172 376 976 391 7216 395 6704 397 5680 398 3632 403 6448 405 5424 406
12173 3376 409 4912 410 2864 412 1840 419 6320 421 5296 422 3248 425 4784
12174 426 2736 428 1712 433 4528 434 2480 436 1456 440 944 451 6256 453
12175 5232 454 3184 457 4720 458 2672 460 1648 465 4464 466 2416 468 1392
12176 472 880 481 4336 482 2288 484 1264 488 752 527 7688 535 7432 539
12177 6920 541 5896 542 3848 551 7304 555 6792 557 5768 558 3720 563 6536
12178 565 5512 566 3464 569 5000 570 2952 572 1928 583 7240 587 6728 589
12179 5704 590 3656 595 6472 597 5448 598 3400 601 4936 602 2888 604 1864
12180 611 6344 613 5320 614 3272 617 4808 618 2760 620 1736 625 4552 626
12181 2504 628 1480 632 968 647 7208 651 6696 653 5672 654 3624 659 6440
12182 661 5416 662 3368 665 4904 666 2856 668 1832 675 6312 677 5288 678
12183 3240 681 4776 682 2728 684 1704 689 4520 690 2472 692 1448 696 936
12184 707 6248 709 5224 710 3176 713 4712 714 2664 716 1640 721 4456 722
12185 2408 724 1384 728 872 737 4328 738 2280 740 1256 775 7192 779 6680
12186 781 5656 782 3608 787 6424 789 5400 790 3352 793 4888 794 2840 796
12187 1816 803 6296 805 5272 806 3224 809 4760 810 2712 812 1688 817 4504
12188 818 2456 820 1432 824 920 835 6232 837 5208 838 3160 841 4696 842
12189 2648 844 1624 849 4440 850 2392 852 1368 865 4312 866 2264 868 1240
12190 899 6200 901 5176 902 3128 905 4664 906 2616 908 1592 913 4408 914
12191 2360 916 1336 929 4280 930 2232 932 1208 961 4216 962 2168 964 1144
12192 1039 7684 1047 7428 1051 6916 1053 5892 1054 3844 1063 7300 1067 6788 1069
12193 5764 1070 3716 1075 6532 1077 5508 1078 3460 1081 4996 1082 2948 1084 1924
12194 1095 7236 1099 6724 1101 5700 1102 3652 1107 6468 1109 5444 1110 3396 1113
12195 4932 1114 2884 1116 1860 1123 6340 1125 5316 1126 3268 1129 4804 1130 2756
12196 1132 1732 1137 4548 1138 2500 1140 1476 1159 7204 1163 6692 1165 5668 1166
12197 3620 1171 6436 1173 5412 1174 3364 1177 4900 1178 2852 1180 1828 1187 6308
12198 1189 5284 1190 3236 1193 4772 1194 2724 1196 1700 1201 4516 1202 2468 1204
12199 1444 1219 6244 1221 5220 1222 3172 1225 4708 1226 2660 1228 1636 1233 4452
12200 1234 2404 1236 1380 1249 4324 1250 2276 1287 7188 1291 6676 1293 5652 1294
12201 3604 1299 6420 1301 5396 1302 3348 1305 4884 1306 2836 1308 1812 1315 6292
12202 1317 5268 1318 3220 1321 4756 1322 2708 1324 1684 1329 4500 1330 2452 1332
12203 1428 1347 6228 1349 5204 1350 3156 1353 4692 1354 2644 1356 1620 1361 4436
12204 1362 2388 1377 4308 1378 2260 1411 6196 1413 5172 1414 3124 1417 4660 1418
12205 2612 1420 1588 1425 4404 1426 2356 1441 4276 1442 2228 1473 4212 1474 2164
12206 1543 7180 1547 6668 1549 5644 1550 3596 1555 6412 1557 5388 1558 3340 1561
12207 4876 1562 2828 1564 1804 1571 6284 1573 5260 1574 3212 1577 4748 1578 2700
12208 1580 1676 1585 4492 1586 2444 1603 6220 1605 5196 1606 3148 1609 4684 1610
12209 2636 1617 4428 1618 2380 1633 4300 1634 2252 1667 6188 1669 5164 1670 3116
12210 1673 4652 1674 2604 1681 4396 1682 2348 1697 4268 1698 2220 1729 4204 1730
12211 2156 1795 6172 1797 5148 1798 3100 1801 4636 1802 2588 1809 4380 1810 2332
12212 1825 4252 1826 2204 1857 4188 1858 2140 1921 4156 1922 2108 2063 7682 2071
12213 7426 2075 6914 2077 5890 2078 3842 2087 7298 2091 6786 2093 5762 2094 3714
12214 2099 6530 2101 5506 2102 3458 2105 4994 2106 2946 2119 7234 2123 6722 2125
12215 5698 2126 3650 2131 6466 2133 5442 2134 3394 2137 4930 2138 2882 2147 6338
12216 2149 5314 2150 3266 2153 4802 2154 2754 2161 4546 2162 2498 2183 7202 2187
12217 6690 2189 5666 2190 3618 2195 6434 2197 5410 2198 3362 2201 4898 2202 2850
12218 2211 6306 2213 5282 2214 3234 2217 4770 2218 2722 2225 4514 2226 2466 2243
12219 6242 2245 5218 2246 3170 2249 4706 2250 2658 2257 4450 2258 2402 2273 4322
12220 2311 7186 2315 6674 2317 5650 2318 3602 2323 6418 2325 5394 2326 3346 2329
12221 4882 2330 2834 2339 6290 2341 5266 2342 3218 2345 4754 2346 2706 2353 4498
12222 2354 2450 2371 6226 2373 5202 2374 3154 2377 4690 2378 2642 2385 4434 2401
12223 4306 2435 6194 2437 5170 2438 3122 2441 4658 2442 2610 2449 4402 2465 4274
12224 2497 4210 2567 7178 2571 6666 2573 5642 2574 3594 2579 6410 2581 5386 2582
12225 3338 2585 4874 2586 2826 2595 6282 2597 5258 2598 3210 2601 4746 2602 2698
12226 2609 4490 2627 6218 2629 5194 2630 3146 2633 4682 2641 4426 2657 4298 2691
12227 6186 2693 5162 2694 3114 2697 4650 2705 4394 2721 4266 2753 4202 2819 6170
12228 2821 5146 2822 3098 2825 4634 2833 4378 2849 4250 2881 4186 2945 4154 3079
12229 7174 3083 6662 3085 5638 3086 3590 3091 6406 3093 5382 3094 3334 3097 4870
12230 3107 6278 3109 5254 3110 3206 3113 4742 3121 4486 3139 6214 3141 5190 3145
12231 4678 3153 4422 3169 4294 3203 6182 3205 5158 3209 4646 3217 4390 3233 4262
12232 3265 4198 3331 6166 3333 5142 3337 4630 3345 4374 3361 4246 3393 4182 3457
12233 4150 3587 6158 3589 5134 3593 4622 3601 4366 3617 4238 3649 4174 3713 4142
12234 3841 4126 4111 7681 4119 7425 4123 6913 4125 5889 4135 7297 4139 6785 4141
12235 5761 4147 6529 4149 5505 4153 4993 4167 7233 4171 6721 4173 5697 4179 6465
12236 4181 5441 4185 4929 4195 6337 4197 5313 4201 4801 4209 4545 4231 7201 4235
12237 6689 4237 5665 4243 6433 4245 5409 4249 4897 4259 6305 4261 5281 4265 4769
12238 4273 4513 4291 6241 4293 5217 4297 4705 4305 4449 4359 7185 4363 6673 4365
12239 5649 4371 6417 4373 5393 4377 4881 4387 6289 4389 5265 4393 4753 4401 4497
12240 4419 6225 4421 5201 4425 4689 4483 6193 4485 5169 4489 4657 4615 7177 4619
12241 6665 4621 5641 4627 6409 4629 5385 4633 4873 4643 6281 4645 5257 4649 4745
12242 4675 6217 4677 5193 4739 6185 4741 5161 4867 6169 4869 5145 5127 7173 5131
12243 6661 5133 5637 5139 6405 5141 5381 5155 6277 5157 5253 5187 6213 5251 6181
12244 5379 6165 5635 6157 6151 7171 6155 6659 6163 6403 6179 6275 6211 5189 4681
12245 4433 4321 3142 2634 2386 2274 1612 1364 1252 856 744 496
12246 ] def
12247
12248 /tab213 [
12249 3 6144 5 5120 6 3072 9 4608 10 2560 12 1536 17 4352 18
12250 2304 20 1280 24 768 33 4224 34 2176 36 1152 40 640 48 384
12251 65 4160 66 2112 68 1088 72 576 80 320 96 192 129 4128 130
12252 2080 132 1056 136 544 144 288 257 4112 258 2064 260 1040 264 528
12253 513 4104 514 2056 516 1032 1025 4100 1026 2052 2049 4098 4097 2050 1028
12254 520 272 160
12255 ] def
12256 } ctxdef
12257
12258 /chars 10 array def
12259 0 1 9 {
12260 /i exch def
12261 codewords i get dup 1286 le {
12262 tab513 exch get
12263 } {
12264 tab213 exch 1287 sub get
12265 } ifelse
12266 chars i 3 -1 roll put
12267 } for
12268
12269 9 -1 0 {
12270 /i exch def
12271 2 i exp cvi fcs and 0 ne {
12272 chars i chars i get 8191 xor put
12273 } if
12274 } for
12275
12276 % Conversion from characters to the OneCode encoding
12277 {
12278 /barmap [
12279 7 2 4 3 1 10 0 0 9 12 2 8 5 5 6 11 8 9 3 1
12280 0 1 5 12 2 5 1 8 4 4 9 11 6 3 8 10 3 9 7 6
12281 5 11 1 4 8 5 2 12 9 10 0 2 7 1 6 7 3 6 4 9
12282 0 3 8 6 6 4 2 7 1 1 9 9 7 10 5 2 4 0 3 8
12283 6 2 0 4 8 11 1 0 9 8 3 12 2 6 7 7 5 1 4 10
12284 1 12 6 9 7 3 8 0 5 8 9 7 4 6 2 10 3 4 0 5
12285 8 4 5 7 7 11 1 9 6 0 9 6 0 6 4 8 2 1 3 2
12286 5 9 8 12 4 11 6 1 9 5 7 4 3 3 1 2 0 7 2 0
12287 1 3 4 1 6 10 3 5 8 7 9 4 2 11 5 6 0 8 7 12
12288 4 2 8 1 5 10 3 0 9 3 0 9 6 5 2 4 7 8 1 7
12289 5 0 4 5 2 3 0 10 6 12 9 2 3 11 1 6 8 8 7 9
12290 5 4 0 11 1 5 2 2 9 1 4 12 8 3 6 6 7 0 3 7
12291 4 7 7 5 0 12 1 11 2 9 9 0 6 8 5 3 3 10 8 2
12292 ] def
12293 } ctxdef
12294
12295 /bbs 65 array def
12296 /bhs 65 array def
12297 0 1 64 {
12298 /i exch def
12299 /dec chars barmap i 4 mul get get 2 barmap i 4 mul 1 add get exp cvi and 0 ne def
12300 /asc chars barmap i 4 mul 2 add get get 2 barmap i 4 mul 3 add get exp cvi and 0 ne def
12301 dec not asc not and {
12302 bbs i 3 height mul 8 div put
12303 bhs i 2 height mul 8 div put
12304 } if
12305 dec not asc and {
12306 bbs i 3 height mul 8 div put
12307 bhs i 5 height mul 8 div put
12308 } if
12309 dec asc not and {
12310 bbs i 0 height mul 8 div put
12311 bhs i 5 height mul 8 div put
12312 } if
12313 dec asc and {
12314 bbs i 0 height mul 8 div put
12315 bhs i 8 height mul 8 div put
12316 } if
12317 } for
12318
12319 % Return the arguments
12320 <<
12321 /ren /renlinear
12322 /bbs bbs
12323 /bhs bhs
12324 /sbs [bhs length 1 sub {1.44 1.872} repeat 1.44]
12325 /txt txt
12326 /textxalign (left)
12327 /textfont /Helvetica
12328 /textyoffset 1.0
12329 /textxoffset -0.3
12330 /opt options
12331 >>
12332
12333 dontdraw not //renlinear if
12334
12335 //unloadctx exec
12336
12337 end
12338
12339 }
12340 [/barcode] {null def} forall
12341 bind def
12342 /onecode dup load /uk.co.terryburton.bwipp defineresource pop
12343 end
12344 /setpacking where {pop setpacking} if
12345 %%EndData
12346 %%EndResource
12347 % --END ENCODER onecode--
12348
12349 % --BEGIN ENCODER postnet--
12350 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear--
12351 % --DESC: USPS POSTNET
12352 % --EXAM: 01234
12353 % --EXOP: includetext includecheckintext
12354 % --RNDR: renlinear
12355 %%BeginResource: uk.co.terryburton.bwipp postnet 0.0 2025111800 73629 73330
12356 %%BeginData: 136 ASCII Lines
12357 /setpacking where {pop currentpacking true setpacking} if
12358 10 dict
12359 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
12360 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
12361 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
12362 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
12363 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
12364 begin
12365 /postnet {
12366
12367 20 dict begin
12368
12369 /ctx null def
12370 /dontdraw false def
12371 /includetext false def % Enable/disable text
12372 /validatecheck false def
12373 /includecheckintext false def
12374 /textfont /Courier def
12375 /textsize 10.0 def
12376 /textyoffset -7.0 def
12377 /height 0.125 def
12378
12379 //processoptions exec /options exch def
12380 /barcode exch def
12381
12382 /postnet //loadctx exec
12383
12384 /barlen barcode length validatecheck {1 sub} if def
12385
12386 % Validate the input
12387 barlen 5 ne barlen 9 ne and barlen 11 ne and {
12388 /bwipp.postnetBadLength (USPS POSTNET must be 5, 9 or 11 digits excluding check digit) //raiseerror exec
12389 } if
12390 barcode {
12391 dup 48 lt exch 57 gt or {
12392 /bwipp.postnetBadCharacter (USPS POSTNET must contain only digits) //raiseerror exec
12393 } if
12394 } forall
12395
12396 {
12397 % Create a string of the available characters
12398 /barchars (0123456789) def
12399
12400 % Create an array containing the character mappings
12401 /encs
12402 [ (55222) (22255) (22525) (22552) (25225)
12403 (25252) (25522) (52225) (52252) (52522)
12404 (5) (5)
12405 ] def
12406 } ctxdef
12407
12408 /checksum 0 def
12409 0 1 barlen 1 sub {
12410 /i exch def
12411 /checksum checksum barcode i get 48 sub add def
12412 } for
12413 /checksum 10 checksum 10 mod sub 10 mod def
12414 validatecheck {
12415 barcode barlen get barchars checksum get ne {
12416 /bwipp.postnetBadCheckDigit (Incorrect USPS POSTNET check digit provided) //raiseerror exec
12417 } if
12418 /barcode barcode 0 barlen getinterval def
12419 } if
12420
12421 /bhs barlen 5 mul 7 add array def
12422 /txt barlen 1 add array def
12423
12424 % Put start character
12425 /enc encs 10 get def
12426 /heights enc length array def
12427 0 1 enc length 1 sub {
12428 /j exch def
12429 heights j enc j 1 getinterval cvi height mul 5 div put
12430 } for
12431 bhs 0 heights putinterval % Put encoded digit into sbs
12432
12433 0 1 barlen 1 sub {
12434 /i exch def
12435 /enc encs barcode i get 48 sub get def
12436 /heights enc length array def
12437 0 1 enc length 1 sub {
12438 /j exch def
12439 heights j enc j 1 getinterval cvi height mul 5 div put
12440 } for
12441 bhs i 5 mul 1 add heights putinterval % Put encoded digit into sbs
12442 txt i [barcode i 1 getinterval i 5 mul 1 add 3.312 mul textyoffset textfont textsize] put
12443 } for
12444
12445 % Put the checksum character
12446 /enc encs checksum get def
12447 /heights enc length array def
12448 0 1 enc length 1 sub {
12449 /j exch def
12450 heights j enc j 1 getinterval cvi height mul 5 div put
12451 } for
12452 bhs barlen 5 mul 1 add heights putinterval
12453
12454 includecheckintext {
12455 txt barlen [barchars checksum 1 getinterval barlen 5 mul 1 add 3.312 mul textyoffset textfont textsize] put
12456 } {
12457 txt barlen [( ) barlen 5 mul 1 add 72 mul 25 div textyoffset textfont textsize] put
12458 } ifelse
12459
12460 % Put end character
12461 /enc encs 11 get def
12462 /heights enc length array def
12463 0 1 enc length 1 sub {
12464 /j exch def
12465 heights j enc j 1 getinterval cvi height mul 5 div put
12466 } for
12467 bhs barlen 5 mul 6 add heights putinterval
12468
12469 % Return the arguments
12470 <<
12471 /ren /renlinear
12472 /bhs bhs
12473 /bbs [bhs length {0} repeat]
12474 /sbs [bhs length 1 sub {1.44 1.872} repeat 1.44]
12475 includetext {
12476 /txt txt
12477 } if
12478 /opt options
12479 >>
12480
12481 dontdraw not //renlinear if
12482
12483 //unloadctx exec
12484
12485 end
12486
12487 }
12488 [/barcode] {null def} forall
12489 bind def
12490 /postnet dup load /uk.co.terryburton.bwipp defineresource pop
12491 end
12492 /setpacking where {pop setpacking} if
12493 %%EndData
12494 %%EndResource
12495 % --END ENCODER postnet--
12496
12497 % --BEGIN ENCODER planet--
12498 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear--
12499 % --DESC: USPS PLANET
12500 % --EXAM: 01234567890
12501 % --EXOP: includetext includecheckintext
12502 % --RNDR: renlinear
12503 %%BeginResource: uk.co.terryburton.bwipp planet 0.0 2025111800 73473 73178
12504 %%BeginData: 137 ASCII Lines
12505 /setpacking where {pop currentpacking true setpacking} if
12506 10 dict
12507 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
12508 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
12509 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
12510 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
12511 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
12512 begin
12513 /planet {
12514
12515 20 dict begin
12516
12517 /ctx null def
12518 /dontdraw false def
12519 /includetext false def % Enable/disable text
12520 /validatecheck false def
12521 /includecheckintext false def
12522 /textfont /Courier def
12523 /textsize 10.0 def
12524 /textyoffset -7.0 def
12525 /height 0.125 def
12526
12527 //processoptions exec /options exch def
12528 /barcode exch def
12529
12530 /planet //loadctx exec
12531
12532 /barlen barcode length validatecheck {1 sub} if def
12533
12534 % Validate the input
12535 barlen 11 ne barlen 13 ne and {
12536 /bwipp.planetBadLength (USPS PLANET must be 11 or 13 digits excluding check digit) //raiseerror exec
12537 } if
12538 barcode {
12539 dup 48 lt exch 57 gt or {
12540 /bwipp.planetBadCharacter (USPS PLANET must contain only digits) //raiseerror exec
12541 } if
12542 } forall
12543
12544 {
12545 % Create a string of the available characters
12546 /barchars (0123456789) def
12547
12548 % Create an array containing the character mappings
12549 /encs
12550 [ (22555) (55522) (55252) (55225) (52552)
12551 (52525) (52255) (25552) (25525) (25255)
12552 (5) (5)
12553 ] def
12554 } ctxdef
12555
12556 % Calculate the checksum
12557 /checksum 0 def
12558 0 1 barlen 1 sub {
12559 /i exch def
12560 /checksum checksum barcode i get 48 sub add def
12561 } for
12562 /checksum 10 checksum 10 mod sub 10 mod def
12563 validatecheck {
12564 barcode barlen get barchars checksum get ne {
12565 /bwipp.planetBadCheckDigit (Incorrect USPS PLANET check digit provided) //raiseerror exec
12566 } if
12567 /barcode barcode 0 barlen getinterval def
12568 } if
12569
12570 /bhs barlen 5 mul 7 add array def
12571 /txt barlen 1 add array def
12572
12573 % Put start character
12574 /enc encs 10 get def
12575 /heights enc length array def
12576 0 1 enc length 1 sub {
12577 /j exch def
12578 heights j enc j 1 getinterval cvi height mul 5 div put
12579 } for
12580 bhs 0 heights putinterval % Put encoded digit into sbs
12581
12582 0 1 barlen 1 sub {
12583 /i exch def
12584 /enc encs barcode i get 48 sub get def
12585 /heights enc length array def
12586 0 1 enc length 1 sub {
12587 /j exch def
12588 heights j enc j 1 getinterval cvi height mul 5 div put
12589 } for
12590 bhs i 5 mul 1 add heights putinterval % Put encoded digit into sbs
12591 txt i [barcode i 1 getinterval i 5 mul 1 add 3.312 mul textyoffset textfont textsize] put
12592 } for
12593
12594 % Put the checksum character
12595 /enc encs checksum get def
12596 /heights enc length array def
12597 0 1 enc length 1 sub {
12598 /j exch def
12599 heights j enc j 1 getinterval cvi height mul 5 div put
12600 } for
12601 bhs barlen 5 mul 1 add heights putinterval
12602
12603 includecheckintext {
12604 txt barlen [barchars checksum 1 getinterval barlen 5 mul 1 add 3.312 mul textyoffset textfont textsize] put
12605 } {
12606 txt barlen [( ) barlen 5 mul 1 add 72 mul 25 div textyoffset textfont textsize] put
12607 } ifelse
12608
12609 % Put end character
12610 /enc encs 11 get def
12611 /heights enc length array def
12612 0 1 enc length 1 sub {
12613 /j exch def
12614 heights j enc j 1 getinterval cvi height mul 5 div put
12615 } for
12616 bhs barlen 5 mul 6 add heights putinterval
12617
12618 % Return the arguments
12619 <<
12620 /ren /renlinear
12621 /bhs bhs
12622 /bbs [bhs length {0} repeat]
12623 /sbs [bhs length 1 sub {1.44 1.872} repeat 1.44]
12624 includetext {
12625 /txt txt
12626 } if
12627 /opt options
12628 >>
12629
12630 dontdraw not //renlinear if
12631
12632 //unloadctx exec
12633
12634 end
12635
12636 }
12637 [/barcode] {null def} forall
12638 bind def
12639 /planet dup load /uk.co.terryburton.bwipp defineresource pop
12640 end
12641 /setpacking where {pop setpacking} if
12642 %%EndData
12643 %%EndResource
12644 % --END ENCODER planet--
12645
12646 % --BEGIN ENCODER royalmail--
12647 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear--
12648 % --DESC: Royal Mail 4 State Customer Code
12649 % --EXAM: LE28HS9Z
12650 % --EXOP: includetext barcolor=FF0000
12651 % --RNDR: renlinear
12652 %%BeginResource: uk.co.terryburton.bwipp royalmail 0.0 2025111800 74838 74362
12653 %%BeginData: 145 ASCII Lines
12654 /setpacking where {pop currentpacking true setpacking} if
12655 10 dict
12656 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
12657 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
12658 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
12659 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
12660 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
12661 begin
12662 /royalmail {
12663
12664 20 dict begin
12665
12666 /ctx null def
12667 /dontdraw false def
12668 /includetext false def % Enable/disable text
12669 /validatecheck false def
12670 /includecheckintext false def
12671 /textfont /Courier def
12672 /textsize 10.0 def
12673 /textyoffset -7.0 def
12674 /height 0.175 def
12675
12676 //processoptions exec /options exch def
12677 /barcode exch def
12678
12679 barcode () eq {
12680 /bwipp.royalmailEmptyData (The data must not be empty) //raiseerror exec
12681 } if
12682
12683 /royalmail //loadctx exec
12684
12685 {
12686 % Create a string of the available characters
12687 /barchars (ZUVWXY501234B6789AHCDEFGNIJKLMTOPQRS) def
12688 /charvals 36 dict def
12689 0 1 35 {charvals exch dup barchars exch 1 getinterval exch put} for
12690
12691 % Create an array containing the character mappings
12692 /encs
12693 [ (3300) (2211) (2301) (2310) (3201) (3210)
12694 (1122) (0033) (0123) (0132) (1023) (1032)
12695 (1302) (0213) (0303) (0312) (1203) (1212)
12696 (1320) (0231) (0321) (0330) (1221) (1230)
12697 (3102) (2013) (2103) (2112) (3003) (3012)
12698 (3120) (2031) (2121) (2130) (3021) (3030)
12699 (2) (3)
12700 ] def
12701 } ctxdef
12702
12703 % Validate the input
12704 0 1 barcode length 1 sub {
12705 barcode exch 1 getinterval charvals exch known not {
12706 /bwipp.royalmailBadCharacter (RM4SCC must contain only capital letters and digits) //raiseerror exec
12707 } if
12708 } for
12709
12710 /barlen barcode length validatecheck {1 sub} if def
12711
12712 /checksumrow 0 def
12713 /checksumcol 0 def
12714 0 1 barlen 1 sub {
12715 /i exch def
12716 /indx charvals barcode i 1 getinterval get def
12717 /checksumrow checksumrow indx 6 idiv add def
12718 /checksumcol checksumcol indx 6 mod add def
12719 } for
12720 /checksum checksumrow 6 mod 6 mul checksumcol 6 mod add def
12721 validatecheck {
12722 barcode barlen get barchars checksum get ne {
12723 /bwipp.royalmailBadCheckDigit (Incorrect RM4SCC check digit provided) //raiseerror exec
12724 } if
12725 /barcode barcode 0 barlen getinterval def
12726 } if
12727
12728 /encstr barlen 4 mul 6 add string def
12729 /txt barlen 1 add array def
12730
12731 % Put start character
12732 encstr 0 encs 36 get putinterval
12733
12734 0 1 barlen 1 sub {
12735 /i exch def
12736 /indx charvals barcode i 1 getinterval get def
12737 encstr i 4 mul 1 add encs indx get putinterval
12738 txt i [barcode i 1 getinterval i 4 mul 1 add 3.312 mul textyoffset textfont textsize] put
12739 } for
12740
12741 % Put the checksum character
12742 encstr barlen 4 mul 1 add encs checksum get putinterval
12743 includecheckintext {
12744 txt barlen [barchars checksum 1 getinterval barlen 4 mul 1 add 3.312 mul textyoffset textfont textsize] put
12745 } {
12746 txt barlen [( ) barlen 4 mul 1 add 3.312 mul textyoffset textfont textsize] put
12747 } ifelse
12748
12749 % Put end character
12750 encstr barlen 4 mul 5 add encs 37 get putinterval
12751
12752 /bbs encstr length array def
12753 /bhs encstr length array def
12754 0 1 encstr length 1 sub {
12755 /i exch def
12756 /enc encstr i 1 getinterval def
12757 enc (0) eq {
12758 bbs i 3 height mul 8 div put
12759 bhs i 2 height mul 8 div put
12760 } if
12761 enc (1) eq {
12762 bbs i 0 height mul 8 div put
12763 bhs i 5 height mul 8 div put
12764 } if
12765 enc (2) eq {
12766 bbs i 3 height mul 8 div put
12767 bhs i 5 height mul 8 div put
12768 } if
12769 enc (3) eq {
12770 bbs i 0 height mul 8 div put
12771 bhs i 8 height mul 8 div put
12772 } if
12773 } for
12774
12775 % Return the arguments
12776 <<
12777 /ren /renlinear
12778 /bbs bbs
12779 /bhs bhs
12780 /sbs [bhs length 1 sub {1.44 1.872} repeat 1.44]
12781 includetext {
12782 /txt txt
12783 } if
12784 /opt options
12785 >>
12786
12787 dontdraw not //renlinear if
12788
12789 //unloadctx exec
12790
12791 end
12792
12793 }
12794 [/barcode] {null def} forall
12795 bind def
12796 /royalmail dup load /uk.co.terryburton.bwipp defineresource pop
12797 end
12798 /setpacking where {pop setpacking} if
12799 %%EndData
12800 %%EndResource
12801 % --END ENCODER royalmail--
12802
12803 % --BEGIN ENCODER auspost--
12804 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear--
12805 % --DESC: AusPost 4 State Customer Code
12806 % --EXAM: 5956439111ABA 9
12807 % --EXOP: includetext custinfoenc=character
12808 % --RNDR: renlinear
12809 %%BeginResource: uk.co.terryburton.bwipp auspost 0.0 2025111800 90175 89738
12810 %%BeginData: 235 ASCII Lines
12811 /setpacking where {pop currentpacking true setpacking} if
12812 10 dict
12813 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
12814 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
12815 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
12816 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
12817 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
12818 begin
12819 /auspost {
12820
12821 20 dict begin
12822
12823 /ctx null def
12824 /dontdraw false def
12825 /includetext false def % Enable/disable text
12826 /textfont /Courier def
12827 /textsize 10.0 def
12828 /textyoffset -7.0 def
12829 /height 0.175 def
12830 /custinfoenc (character) def
12831
12832 //processoptions exec /options exch def
12833 /barcode exch def
12834
12835 custinfoenc (character) ne custinfoenc (numeric) ne and {
12836 /bwipp.auspostBadCustinfoEncoding (Customer information encoding must be either character or numeric) //raiseerror exec
12837 } if
12838
12839 /auspost //loadctx exec
12840
12841 % Create an array containing the character mappings
12842 {
12843 /encs
12844 [ (000) (001) (002) (010) (011) (012) (020) (021)
12845 (022) (100) (101) (102) (110) (111) (112) (120)
12846 (121) (122) (200) (201) (202) (210) (211) (212)
12847 (220) (221) (222) (300) (301) (302) (310) (311)
12848 (312) (320) (321) (322) (023) (030) (031) (032)
12849 (033) (103) (113) (123) (130) (131) (132) (133)
12850 (203) (213) (223) (230) (231) (232) (233) (303)
12851 (313) (323) (330) (331) (332) (333) (003) (013)
12852 (00) (01) (02) (10) (11) (12) (20) (21) (22) (30)
12853 (13) (3)
12854 ] def
12855
12856 % Create a string of the available characters
12857 /barchars (ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz #) def
12858
12859 % FCC lengths
12860 /fcclen << (11) 37 (45) 37 (59) 52 (62) 67 >> def
12861
12862 } ctxdef
12863
12864 /barlen barcode length def
12865 barlen 10 lt {
12866 /bwipp.auspostTooShort (The data length must be at least 10) //raiseerror exec
12867 } if
12868
12869 /txt barlen 2 sub array def
12870
12871 fcclen barlen 2 ge { barcode 0 2 getinterval } { () } ifelse
12872 2 copy known not {
12873 pop pop /bwipp.auspostBadFCC (Must begin with an FCC, either 11, 45, 59 or 62) //raiseerror exec
12874 } if
12875 get /encstr exch string def
12876
12877 % Validate that the message has a complete, numeric DPID
12878 true
12879 1 {
12880 barlen 10 lt { pop false exit } if
12881 barcode 2 8 getinterval { dup 48 lt exch 57 gt or { pop false exit } if } forall
12882 } repeat
12883 not {
12884 /bwipp.auspostIncompleteDPID (The DPID must be 8 digits) //raiseerror exec
12885 } if
12886
12887 % Validate that the message will fit
12888 barlen 10 sub custinfoenc (numeric) eq {2} {3} ifelse mul
12889 encstr length 22 sub 14 sub gt {
12890 /bwipp.auspostTooLong (The message is too long) //raiseerror exec
12891 } if
12892
12893 % Put start character
12894 encstr 0 encs 74 get putinterval
12895
12896 % Encode the FCC
12897 0 1 1 {
12898 /i exch def
12899 encs barcode i 1 getinterval cvi 64 add get
12900 encstr i 2 mul 2 add 3 2 roll putinterval
12901 } for
12902
12903 % Encode the DPID
12904 2 1 9 {
12905 /i exch def
12906 encs barcode i 1 getinterval cvi 64 add get
12907 encstr i 2 mul 2 add 3 2 roll putinterval
12908 txt i 2 sub [barcode i 1 getinterval i 2 sub 2 mul 6 add 3.312 mul textyoffset textfont textsize] put
12909 } for
12910
12911 % Encode the customer information
12912 custinfoenc (numeric) eq {
12913 0 1 barlen 11 sub {
12914 /i exch def
12915 encs barcode i 10 add get
12916 dup dup 48 lt exch 57 gt or {
12917 /bwipp.auspostInvalidCustinfoDigit (The customer information data contains a non-digit character) //raiseerror exec
12918 } if
12919 48 sub 64 add get
12920 encstr i 2 mul 22 add 3 2 roll putinterval
12921 txt i 8 add [barcode i 10 add 1 getinterval i 2 mul 22 add 3.312 mul textyoffset textfont textsize] put
12922 } for
12923 /ciflen barlen 10 sub 2 mul def
12924 } {
12925 0 1 barlen 11 sub {
12926 /i exch def
12927 barcode i 10 add 1 getinterval barchars exch search
12928 not {
12929 pop /bwipp.auspostInvalidCustinfoCharacter (The customer information contains an invalid character) //raiseerror exec
12930 } if
12931 length /indx exch def
12932 pop pop
12933 /enc encs indx get def
12934 encstr i 3 mul 22 add enc putinterval
12935 txt i 8 add [barcode i 10 add 1 getinterval i 3 mul 22 add 3.312 mul textyoffset textfont textsize] put
12936 } for
12937 /ciflen barlen 10 sub 3 mul def
12938 } ifelse
12939
12940 % Add any filler characters
12941 22 ciflen add 1 encstr length 14 sub {
12942 encstr exch encs 75 get putinterval
12943 } for
12944
12945 % Create the 64x64 Reed-Solomon table
12946 {
12947 /rstable 64 64 mul array def
12948 rstable 0 [ 64 {0} repeat ] putinterval
12949 rstable 64 [ 0 1 63 {} for ] putinterval
12950 /prev 1 def
12951 64 {
12952 /next prev 1 bitshift def
12953 next 64 and 0 ne {
12954 /next next 67 xor def
12955 } if
12956 0 1 63 {
12957 /j exch def
12958 /nextcell {rstable 64 next mul j add} def
12959 nextcell rstable 64 prev mul j add get 1 bitshift put
12960 nextcell get 64 and 0 ne {
12961 nextcell nextcell get 67 xor put
12962 } if
12963 } for
12964 /prev next def
12965 } repeat
12966 } ctxdef
12967
12968 % Calculate the Reed-Solomon codes for triples
12969 /rscodes encstr length 16 sub 3 idiv 4 add array def
12970 rscodes 0 [ 4 {0} repeat ] putinterval
12971 2 3 encstr length 16 sub {
12972 /i exch def
12973 rscodes rscodes length i 2 sub 3 idiv sub 1 sub
12974 encstr i 1 getinterval cvi 16 mul
12975 encstr i 1 add 1 getinterval cvi 4 mul add
12976 encstr i 2 add 1 getinterval cvi add
12977 put
12978 } for
12979 rscodes length 5 sub -1 0 {
12980 /i exch def
12981 0 1 4 {
12982 /j exch def
12983 rscodes i j add rscodes i j add get
12984 rstable 64 [48 17 29 30 1] j get mul rscodes i 4 add get add get
12985 xor put
12986 } for
12987 } for
12988 /checkcode (000000000000) 12 string copy def
12989 0 1 3 {
12990 /i exch def
12991 /enc rscodes 3 i sub get 4 3 string cvrs def
12992 checkcode i 3 mul 3 enc length sub add enc putinterval
12993 } for
12994
12995 % Put checkcode and end characters
12996 encstr encstr length 14 sub checkcode putinterval
12997 encstr encstr length 2 sub encs 74 get putinterval
12998
12999 /bbs encstr length array def
13000 /bhs encstr length array def
13001 0 1 encstr length 1 sub {
13002 /i exch def
13003 /enc encstr i 1 getinterval def
13004 enc (0) eq {
13005 bbs i 0 height mul 8 div put
13006 bhs i 8 height mul 8 div put
13007 } if
13008 enc (1) eq {
13009 bbs i 3 height mul 8 div put
13010 bhs i 5 height mul 8 div put
13011 } if
13012 enc (2) eq {
13013 bbs i 0 height mul 8 div put
13014 bhs i 5 height mul 8 div put
13015 } if
13016 enc (3) eq {
13017 bbs i 3 height mul 8 div put
13018 bhs i 2 height mul 8 div put
13019 } if
13020 } for
13021
13022 % Return the arguments
13023 <<
13024 /ren /renlinear
13025 /bbs bbs
13026 /bhs bhs
13027 /sbs [bhs length 1 sub {1.44 1.872} repeat 1.44]
13028 includetext {
13029 /txt txt
13030 } if
13031 /opt options
13032 >>
13033
13034 dontdraw not //renlinear if
13035
13036 //unloadctx exec
13037
13038 end
13039
13040 }
13041 [/barcode] {null def} forall
13042 bind def
13043 /auspost dup load /uk.co.terryburton.bwipp defineresource pop
13044 end
13045 /setpacking where {pop setpacking} if
13046 %%EndData
13047 %%EndResource
13048 % --END ENCODER auspost--
13049
13050 % --BEGIN ENCODER kix--
13051 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear--
13052 % --DESC: Royal Dutch TPG Post KIX
13053 % --EXAM: 1231FZ13XHS
13054 % --EXOP: includetext
13055 % --RNDR: renlinear
13056 %%BeginResource: uk.co.terryburton.bwipp kix 0.0 2025111800 69974 69757
13057 %%BeginData: 111 ASCII Lines
13058 /setpacking where {pop currentpacking true setpacking} if
13059 10 dict
13060 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
13061 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
13062 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
13063 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
13064 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
13065 begin
13066 /kix {
13067
13068 20 dict begin
13069
13070 /ctx null def
13071 /dontdraw false def
13072 /includetext false def % Enable/disable text
13073 /textfont /Courier def
13074 /textsize 10.0 def
13075 /textyoffset -7.0 def
13076 /height 0.175 def
13077
13078 //processoptions exec /options exch def
13079 /barcode exch def
13080
13081 barcode () eq {
13082 /bwipp.kixEmptyData (The data must not be empty) //raiseerror exec
13083 } if
13084
13085 /kix //loadctx exec
13086
13087 {
13088 % Create an array containing the character mappings
13089 /encs
13090 [ (0033) (0123) (0132) (1023) (1032) (1122)
13091 (0213) (0303) (0312) (1203) (1212) (1302)
13092 (0231) (0321) (0330) (1221) (1230) (1320)
13093 (2013) (2103) (2112) (3003) (3012) (3102)
13094 (2031) (2121) (2130) (3021) (3030) (3120)
13095 (2211) (2301) (2310) (3201) (3210) (3300)
13096 ] def
13097
13098 % Create a string of the available characters
13099 /barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ) def
13100 /charvals 36 dict def
13101 0 1 35 {charvals exch dup barchars exch 1 getinterval exch put} for
13102 } ctxdef
13103
13104 % Validate the input
13105 0 1 barcode length 1 sub {
13106 barcode exch 1 getinterval charvals exch known not {
13107 /bwipp.kixBadCharacter (KIX must contain only capital letters and digits) //raiseerror exec
13108 } if
13109 } for
13110
13111 /barlen barcode length def
13112 /encstr barlen 4 mul string def
13113 /txt barlen array def
13114
13115 0 1 barlen 1 sub {
13116 /i exch def
13117 /indx charvals barcode i 1 getinterval get def
13118 encstr i 4 mul encs indx get putinterval
13119 txt i [barcode i 1 getinterval i 4 mul 3.312 mul textyoffset textfont textsize] put
13120 } for
13121
13122 /bbs encstr length array def
13123 /bhs encstr length array def
13124 0 1 encstr length 1 sub {
13125 /i exch def
13126 /enc encstr i 1 getinterval def
13127 enc (0) eq {
13128 bbs i 3 height mul 8 div put
13129 bhs i 2 height mul 8 div put
13130 } if
13131 enc (1) eq {
13132 bbs i 0 height mul 8 div put
13133 bhs i 5 height mul 8 div put
13134 } if
13135 enc (2) eq {
13136 bbs i 3 height mul 8 div put
13137 bhs i 5 height mul 8 div put
13138 } if
13139 enc (3) eq {
13140 bbs i 0 height mul 8 div put
13141 bhs i 8 height mul 8 div put
13142 } if
13143 } for
13144
13145 % Return the arguments
13146 <<
13147 /ren /renlinear
13148 /bbs bbs
13149 /bhs bhs
13150 /sbs [bhs length 1 sub {1.44 1.872} repeat 1.44]
13151 includetext {
13152 /txt txt
13153 } if
13154 /opt options
13155 >>
13156
13157 dontdraw not //renlinear if
13158
13159 //unloadctx exec
13160
13161 end
13162
13163 }
13164 [/barcode] {null def} forall
13165 bind def
13166 /kix dup load /uk.co.terryburton.bwipp defineresource pop
13167 end
13168 /setpacking where {pop setpacking} if
13169 %%EndData
13170 %%EndResource
13171 % --END ENCODER kix--
13172
13173 % --BEGIN ENCODER japanpost--
13174 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear--
13175 % --DESC: Japan Post 4 State Customer Code
13176 % --EXAM: 6540123789-A-K-Z
13177 % --EXOP: includetext includecheckintext
13178 % --RNDR: renlinear
13179 %%BeginResource: uk.co.terryburton.bwipp japanpost 0.0 2025111800 77125 76659
13180 %%BeginData: 176 ASCII Lines
13181 /setpacking where {pop currentpacking true setpacking} if
13182 10 dict
13183 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
13184 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
13185 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
13186 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
13187 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
13188 begin
13189 /japanpost {
13190
13191 20 dict begin
13192
13193 /ctx null def
13194 /dontdraw false def
13195 /includetext false def % Enable/disable text
13196 /includecheckintext false def
13197 /textfont /Courier def
13198 /textsize 10.0 def
13199 /textyoffset -7.0 def
13200 /height 0.175 def
13201
13202 //processoptions exec /options exch def
13203 /barcode exch def
13204
13205 barcode () eq {
13206 /bwipp.japanpostEmptyData (The data must not be empty) //raiseerror exec
13207 } if
13208
13209 /japanpost //loadctx exec
13210
13211 % Validate the input
13212 barcode {
13213 dup dup 48 ge exch 57 le and exch % 0-9
13214 dup dup 65 ge exch 90 le and exch % A-Z
13215 45 eq or or not { % "-"
13216 /bwipp.japanpostBadCharacter (Japan Post must contain only digits, capital letters and the dash symbol) //raiseerror exec
13217 } if
13218 } forall
13219
13220 {
13221 % Create an array containing the character mappings
13222 /encs
13223 [ (300) (330) (312) (132) (321) (303) (123) (231) (213) (033) (030) % 0-9 and "-"
13224 (120) (102) (210) (012) (201) (021) (003) (333) % C1-C8
13225 (31) (13) % ST EN
13226 ] def
13227
13228 % Create a string of the available characters
13229 /barchars (0123456789-ABCDEFGHIJKLMNOPQRSTUVWXYZ) def
13230 } ctxdef
13231
13232 /barlen barcode length def
13233
13234 /encstr 20 1 add 3 mul 4 add string def
13235 /digits 20 array def
13236 /txt barlen 1 add array def
13237
13238 % Put start character
13239 encstr 0 encs 19 get putinterval
13240
13241 /checksum 0 def
13242 /j 0 def /i 0 def
13243 true
13244 0 1 barlen 1 sub {
13245 /i exch def
13246 barcode i 1 getinterval barchars exch search
13247 pop % Discard true leaving pre
13248 length /indx exch def % indx is the length of pre
13249 pop pop % Discard match and post
13250 indx 11 ge indx 37 lt and { % Insert escape
13251 j 18 gt {pop false exit} if % Should fit in 20 chars
13252 % 11-20: C1 (11)
13253 % 21-30: C2 (12)
13254 % 31-36: C3 (13)
13255 /digit indx 1 sub 10 idiv 10 add def
13256 encstr j 3 mul 2 add encs digit get putinterval
13257 /checksum checksum digit add def
13258 digits j digit put
13259 /j j 1 add def
13260 } if
13261 j 19 gt {pop false exit} if % Should fit in 20 chars
13262 /digit 0 def
13263 indx 37 eq {
13264 /digit 14 def % space (C14)
13265 } if
13266 indx 11 ge indx 37 lt and {
13267 /digit indx 1 sub 10 mod def
13268 } if
13269 indx 11 lt {
13270 /digit indx def
13271 } if
13272 encstr j 3 mul 2 add encs digit get putinterval % space
13273 /checksum checksum digit add def
13274 digits j digit put
13275 txt i [barcode i 1 getinterval j 3 mul 2 add 3.312 mul textyoffset textfont textsize] put
13276 /j j 1 add def
13277 } for
13278
13279 not {
13280 /bwipp.japanpostTooLong (The input is too long) //raiseerror exec
13281 } if
13282
13283 % Fill spaces (c14) at right end
13284 j 1 20 1 sub {
13285 /k exch def
13286 encstr k 3 mul 2 add encs 14 get putinterval
13287 /checksum checksum 14 add def
13288 digits k 14 put
13289 } for
13290
13291 % Put the checksum character
13292 /checksum checksum 19 mod 19 exch sub def
13293 encstr 2 20 3 mul add encs checksum get putinterval
13294
13295 % Put end character
13296 encstr 2 21 3 mul add encs 20 get putinterval
13297 /checkdigit ( ) def
13298 includecheckintext {
13299 /checkdigit barchars checksum 1 getinterval def
13300 } if
13301 txt i 1 add [ checkdigit 20 3 mul 2 add 3.312 mul textyoffset textfont textsize] put
13302
13303 % Put end character
13304 encstr 20 1 add 3 mul 2 add encs 20 get putinterval
13305
13306 /bbs 21 3 mul 4 add array def
13307 /bhs bbs length array def
13308 0 1 bbs length 1 sub {
13309 /i exch def
13310 /enc encstr i 1 getinterval def
13311 /bunit 0 def
13312 /hunit 0 def
13313 enc (0) eq {
13314 /bunit 3 def
13315 /hunit 2 def
13316 } if
13317 enc (1) eq {
13318 /bunit 0 def
13319 /hunit 5 def
13320 } if
13321 enc (2) eq {
13322 /bunit 3 def
13323 /hunit 5 def
13324 } if
13325 enc (3) eq {
13326 /bunit 0 def
13327 /hunit 8 def
13328 } if
13329 bbs i bunit height mul 8 div put
13330 bhs i hunit height mul 8 div put
13331 } for
13332
13333 % Return the arguments
13334 <<
13335 /ren /renlinear
13336 /bbs bbs
13337 /bhs bhs
13338 /sbs [bhs length 1 sub {1.44 1.872} repeat 1.44]
13339 includetext {
13340 /txt txt
13341 } if
13342 /opt options
13343 >>
13344
13345 dontdraw not //renlinear if
13346
13347 //unloadctx exec
13348
13349 end
13350
13351 }
13352 [/barcode] {null def} forall
13353 bind def
13354 /japanpost dup load /uk.co.terryburton.bwipp defineresource pop
13355 end
13356 /setpacking where {pop setpacking} if
13357 %%EndData
13358 %%EndResource
13359 % --END ENCODER japanpost--
13360
13361 % --BEGIN ENCODER msi--
13362 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear--
13363 % --DESC: MSI Modified Plessey
13364 % --EXAM: 0123456789
13365 % --EXOP: includetext includecheck includecheckintext
13366 % --RNDR: renlinear
13367 %%BeginResource: uk.co.terryburton.bwipp msi 0.0 2025111800 82790 82449
13368 %%BeginData: 168 ASCII Lines
13369 /setpacking where {pop currentpacking true setpacking} if
13370 10 dict
13371 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
13372 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
13373 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
13374 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
13375 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
13376 begin
13377 /msi {
13378
13379 20 dict begin % Confine variables to local scope
13380
13381 /ctx null def
13382 /dontdraw false def
13383 /includecheck false def % Enable/disable checkdigit
13384 /includetext false def % Enable/disable text
13385 /includecheckintext false def
13386 /checktype (unset) def
13387 /badmod11 false def
13388 /textfont /Courier def
13389 /textsize 10.0 def
13390 /textyoffset -7.0 def
13391 /height 1.0 def
13392
13393 //processoptions exec /options exch def
13394 /barcode exch def
13395
13396 checktype (unset) ne includecheck not and {
13397 /bwipp.msiCheckTypeWithoutCheck (checktype requires includecheck) //raiseerror exec
13398 } if
13399
13400 badmod11 checktype (mod11) ne checktype (ncrmod11) ne and checktype (mod1110) ne and checktype (ncrmod1110) ne and and {
13401 /bwipp.msiBadMod11Mismatch (badmod11 requires checktype with mod11) //raiseerror exec
13402 } if
13403
13404 checktype (unset) eq { /checktype (mod10) def } if
13405
13406 /msi //loadctx exec
13407
13408 % Validate the input
13409 barcode {
13410 dup 48 lt exch 57 gt or {
13411 /bwipp.msiBadCharacter (MSI must contain only digits) //raiseerror exec
13412 } if
13413 } forall
13414
13415 {
13416 % Create an array containing the character mappings
13417 /encs
13418 [ (12121212) (12121221) (12122112) (12122121) (12211212)
13419 (12211221) (12212112) (12212121) (21121212) (21121221)
13420 (21) (121)
13421 ] def
13422
13423 % Create a string of the available characters
13424 /barchars (0123456789) def
13425 } ctxdef
13426
13427 /barlen barcode length def % Length of the code
13428 /txtlen barlen def
13429
13430 /mod10 {
13431 /code exch def
13432 0 0 code {48 sub exch 10 mul add exch} forall pop 2 mul
13433 0 {1 index 10 mod add exch 10 idiv dup 0 eq {pop exit} if exch} loop
13434 0 0 code {48 sub add exch} forall exch pop add
13435 10 mod 10 exch sub 10 mod
13436 code length 1 add string dup 0 code putinterval dup code length 4 -1 roll 48 add put
13437 } def
13438
13439 /mod11 {
13440 /code exch def
13441 code length 1 sub code {48 sub exch dup 1 sub exch 6 mod 2 add exch} forall pop
13442 0 code length {3 1 roll mul add} repeat
13443 11 mod 11 exch sub 11 mod
13444 dup 10 eq {
13445 badmod11 {
13446 pop code length 2 add string dup 0 code putinterval dup code length (10) putinterval
13447 } {
13448 pop /bwipp.msiBadMod11NotSpecified (mod11 check digit is 10 but badmod11 not specified) //raiseerror exec
13449 } ifelse
13450 } {
13451 code length 1 add string dup 0 code putinterval dup code length 4 -1 roll 48 add put
13452 } ifelse
13453 } def
13454
13455 /ncrmod11 {
13456 /code exch def
13457 code length 1 sub code {48 sub exch dup 1 sub exch 8 mod 2 add exch} forall pop
13458 0 code length {3 1 roll mul add} repeat
13459 11 mod 11 exch sub 11 mod
13460 dup 10 eq {
13461 badmod11 {
13462 pop code length 2 add string dup 0 code putinterval dup code length (10) putinterval
13463 } {
13464 pop /bwipp.msiBadMod11NotSpecified (mod11 check digit is 10 but badmod11 not specified) //raiseerror exec
13465 } ifelse
13466 } {
13467 code length 1 add string dup 0 code putinterval dup code length 4 -1 roll 48 add put
13468 } ifelse
13469 } def
13470
13471 {
13472 /checkfunc <<
13473 /mod10 { mod10 }
13474 /mod1010 { mod10 mod10 }
13475 /mod11 { mod11 }
13476 /ncrmod11 { ncrmod11 }
13477 /mod1110 { mod11 mod10 }
13478 /ncrmod1110 { ncrmod11 mod10 }
13479 >> def
13480 } ctxdef
13481
13482 % Calculate checksum
13483 includecheck {
13484 checkfunc checktype 2 copy known not {
13485 pop pop /bwipp.msiBadCharacter (MSI checktype must be mod10, mod1010, mod11, ncrmod11, mod1110 or ncrmod1110) //raiseerror exec
13486 } if
13487 get barcode exch exec /barcode exch def
13488 /barlen barcode length def
13489 includecheckintext {/txtlen barlen def} if
13490 } if
13491
13492 /sbs barlen 8 mul 5 add string def
13493 /txt barlen array def
13494
13495 % Put start character
13496 sbs 0 encs 10 get putinterval
13497
13498 0 1 barlen 1 sub {
13499 /i exch def
13500 % Lookup the encoding for the each barcode character
13501 barcode i 1 getinterval barchars exch search
13502 pop % Discard true leaving pre
13503 length /indx exch def % indx is the length of pre
13504 pop pop % Discard seek and post
13505 /enc encs indx get def % Get the indxth encoding
13506 sbs i 8 mul 2 add enc putinterval % Put encoded digit into sbs
13507 txt i [barcode i 1 getinterval i 12 mul 3 add textyoffset textfont textsize] put
13508 } for
13509
13510 % Put the end character
13511 sbs barlen 8 mul 2 add encs 11 get putinterval
13512
13513 % Return the arguments
13514 <<
13515 /ren /renlinear
13516 /sbs [sbs {48 sub} forall]
13517 /bhs [sbs length 1 add 2 idiv {height} repeat]
13518 /bbs [sbs length 1 add 2 idiv {0} repeat]
13519 includetext {
13520 /txt txt 0 txtlen getinterval
13521 } if
13522 /opt options
13523 >>
13524
13525 dontdraw not //renlinear if
13526
13527 //unloadctx exec
13528
13529 end
13530
13531 }
13532 [/barcode] {null def} forall
13533 bind def
13534 /msi dup load /uk.co.terryburton.bwipp defineresource pop
13535 end
13536 /setpacking where {pop setpacking} if
13537 %%EndData
13538 %%EndResource
13539 % --END ENCODER msi--
13540
13541 % --BEGIN ENCODER plessey--
13542 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear--
13543 % --DESC: Plessey UK
13544 % --EXAM: 01234ABCD
13545 % --EXOP: includetext includecheckintext
13546 % --RNDR: renlinear
13547 %%BeginResource: uk.co.terryburton.bwipp plessey 0.0 2025111800 76462 76070
13548 %%BeginData: 146 ASCII Lines
13549 /setpacking where {pop currentpacking true setpacking} if
13550 10 dict
13551 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
13552 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
13553 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
13554 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
13555 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
13556 begin
13557 /plessey {
13558
13559 20 dict begin % Confine variables to local scope
13560
13561 /ctx null def
13562 /dontdraw false def
13563 /includetext false def % Enable/disable text
13564 /validatecheck false def
13565 /includecheckintext false def
13566 /unidirectional false def
13567 /textfont /Courier def
13568 /textsize 10.0 def
13569 /textyoffset -7.0 def
13570 /height 1.0 def
13571
13572 //processoptions exec /options exch def
13573 /barcode exch def
13574
13575 barcode () eq {
13576 /bwipp.plesseyEmptyData (The data must not be empty) //raiseerror exec
13577 } if
13578
13579 /plessey //loadctx exec
13580
13581 % Create a string of the available characters
13582 {
13583 /barchars (0123456789ABCDEF) def
13584 /charvals 16 dict def
13585 0 1 15 {charvals exch dup barchars exch 1 getinterval exch put} for
13586
13587 % Create an array containing the character mappings
13588 /encs
13589 [ (14141414) (32141414) (14321414) (32321414)
13590 (14143214) (32143214) (14323214) (32323214)
13591 (14141432) (32141432) (14321432) (32321432)
13592 (14143232) (32143232) (14323232) (32323232)
13593 (32321432) (541412323) (323)
13594 ] def
13595 } ctxdef
13596
13597 % Validate the input
13598 0 1 barcode length 1 sub {
13599 barcode exch 1 getinterval charvals exch known not {
13600 /bwipp.plesseyBadCharacter (Plessey must contain only digits and letters A B C D E F) //raiseerror exec
13601 } if
13602 } for
13603
13604 /barlen barcode length validatecheck {2 sub} if def
13605
13606 % Calculate the checksums
13607 /checkbits barlen 4 mul 8 add array def
13608 checkbits barlen 4 mul [ 0 0 0 0 0 0 0 0 ] putinterval
13609 0 1 barlen 1 sub {
13610 /i exch def
13611 /indx charvals barcode i 1 getinterval get def
13612 checkbits i 4 mul [
13613 indx 1 and
13614 indx -1 bitshift 1 and
13615 indx -2 bitshift 1 and
13616 indx -3 bitshift
13617 ] putinterval
13618 } for
13619 /checksalt [ 1 1 1 1 0 1 0 0 1 ] def
13620 0 1 barlen 4 mul 1 sub {
13621 /i exch def
13622 checkbits i get 1 eq {
13623 0 1 8 {
13624 /j exch def
13625 checkbits i j add checkbits i j add get checksalt j get xor put
13626 } for
13627 } if
13628 } for
13629 /checkval 0 def
13630 0 1 7 {
13631 /i exch def
13632 /checkval checkval 2 i exp cvi checkbits barlen 4 mul i add get mul add def
13633 } for
13634 /checksum1 checkval 15 and def
13635 /checksum2 checkval -4 bitshift def
13636 validatecheck {
13637 barcode barlen get barchars checksum1 get ne
13638 barcode barlen 1 add get barchars checksum2 get ne or {
13639 /bwipp.plesseyBadCheckDigits (Incorrect Plessey check digits provided) //raiseerror exec
13640 } if
13641 /barcode barcode 0 barlen getinterval def
13642 } if
13643
13644 /sbs barlen 8 mul unidirectional {27} {33} ifelse add string def
13645 /txt barlen 2 add array def
13646
13647 % Put start character
13648 sbs 0 encs 16 get putinterval
13649
13650 0 1 barlen 1 sub {
13651 /i exch def
13652 /indx charvals barcode i 1 getinterval get def
13653 sbs i 8 mul 8 add encs indx get putinterval
13654 txt i [barcode i 1 getinterval i 20 mul 20 add textyoffset textfont textsize] put
13655 } for
13656
13657 % Put the checksum characters
13658 sbs barlen 8 mul 8 add encs checksum1 get putinterval
13659 sbs barlen 8 mul 16 add encs checksum2 get putinterval
13660 includecheckintext {
13661 txt barlen [barchars checksum1 1 getinterval barlen 20 mul 20 add textyoffset textfont textsize] put
13662 txt barlen 1 add [barchars checksum2 1 getinterval barlen 1 add 20 mul 20 add textyoffset textfont textsize] put
13663 } {
13664 txt barlen [( ) barlen 20 mul 20 add textyoffset textfont textsize] put
13665 txt barlen 1 add [( ) barlen 1 add 20 mul 20 add textyoffset textfont textsize] put
13666 } ifelse
13667
13668 % Put end character
13669 sbs barlen 8 mul 24 add encs unidirectional {18} {17} ifelse get putinterval
13670
13671 % Return the arguments
13672 <<
13673 /ren /renlinear
13674 /sbs [sbs {48 sub} forall]
13675 /bhs [sbs length 1 add 2 idiv {height} repeat]
13676 /bbs [sbs length 1 add 2 idiv {0} repeat]
13677 includetext {
13678 /txt txt
13679 } if
13680 /opt options
13681 >>
13682
13683 dontdraw not //renlinear if
13684
13685 //unloadctx exec
13686
13687 end
13688
13689 }
13690 [/barcode] {null def} forall
13691 bind def
13692 /plessey dup load /uk.co.terryburton.bwipp defineresource pop
13693 end
13694 /setpacking where {pop setpacking} if
13695 %%EndData
13696 %%EndResource
13697 % --END ENCODER plessey--
13698
13699 % --BEGIN ENCODER telepen--
13700 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renlinear--
13701 % --DESC: Telepen
13702 % --EXAM: ABCDEF
13703 % --EXOP: includetext
13704 % --RNDR: renlinear
13705 %%BeginResource: uk.co.terryburton.bwipp telepen 0.0 2025111800 81000 80612
13706 %%BeginData: 173 ASCII Lines
13707 /setpacking where {pop currentpacking true setpacking} if
13708 10 dict
13709 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
13710 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
13711 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
13712 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
13713 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
13714 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
13715 begin
13716 /telepen {
13717
13718 20 dict begin % Confine variables to local scope
13719
13720 /ctx null def
13721 /numeric false def
13722 /dontdraw false def
13723 /includetext false def % Enable/disable text
13724 /textfont /Courier def
13725 /textsize 10.0 def
13726 /textyoffset -7.0 def
13727 /height 1.0 def
13728 /parse false def
13729
13730 //processoptions exec /options exch def
13731 /barcode exch def
13732
13733 /telepen //loadctx exec
13734
13735 % Parse ordinals of the form ^NNN to ASCII
13736 /fncvals <<
13737 /parse parse
13738 /parseonly true
13739 /parsefnc false
13740 >> def
13741 /barcode barcode fncvals //parseinput exec def
13742 /barlen barcode length def
13743 options (parse) undef
13744
13745 numeric barlen 2 mod 0 ne and {
13746 /bwipp.telepenNumericOddLength (Telepen Numeric must have an even length) //raiseerror exec
13747 } if
13748
13749 % Create an array containing the character mappings
13750 {
13751 /encs
13752 [ (31313131) (1131313111) (33313111) (1111313131)
13753 (3111313111) (11333131) (13133131) (111111313111)
13754 (31333111) (1131113131) (33113131) (1111333111)
13755 (3111113131) (1113133111) (1311133111) (111111113131)
13756 (3131113111) (11313331) (333331) (111131113111)
13757 (31113331) (1133113111) (1313113111) (1111113331)
13758 (31131331) (113111113111) (3311113111) (1111131331)
13759 (311111113111) (1113111331) (1311111331) (11111111113111)
13760 (31313311) (1131311131) (33311131) (1111313311)
13761 (3111311131) (11333311) (13133311) (111111311131)
13762 (31331131) (1131113311) (33113311) (1111331131)
13763 (3111113311) (1113131131) (1311131131) (111111113311)
13764 (3131111131) (1131131311) (33131311) (111131111131)
13765 (3111131311) (1133111131) (1313111131) (111111131311)
13766 (3113111311) (113111111131) (3311111131) (111113111311)
13767 (311111111131) (111311111311) (131111111311) (11111111111131)
13768 (3131311111) (11313133) (333133) (111131311111)
13769 (31113133) (1133311111) (1313311111) (1111113133)
13770 (313333) (113111311111) (3311311111) (11113333)
13771 (311111311111) (11131333) (13111333) (11111111311111)
13772 (31311133) (1131331111) (33331111) (1111311133)
13773 (3111331111) (11331133) (13131133) (111111331111)
13774 (3113131111) (1131111133) (33111133) (111113131111)
13775 (3111111133) (111311131111) (131111131111) (111111111133)
13776 (31311313) (113131111111) (3331111111) (1111311313)
13777 (311131111111) (11331313) (13131313) (11111131111111)
13778 (3133111111) (1131111313) (33111313) (111133111111)
13779 (3111111313) (111313111111) (131113111111) (111111111313)
13780 (313111111111) (1131131113) (33131113) (11113111111111)
13781 (3111131113) (113311111111) (131311111111) (111111131113)
13782 (3113111113) (11311111111111) (331111111111) (111113111113)
13783 (31111111111111) (111311111113) (131111111113) (1111111111111111)
13784 ] def
13785 } ctxdef
13786
13787 /sbs barlen 16 mul 48 add string def
13788 /txt barlen array def
13789
13790 % Put the start character ASCII 95
13791 /enc encs 95 get def
13792 sbs 0 enc putinterval
13793 /l enc length def
13794
13795 /checksum 0 def
13796 /i 0 def /j 0 def
13797 { % loop
13798 i barlen eq {exit} if
13799 numeric {
13800 barcode i get 16 gt { % 00-99 or 0X-9X
13801 /np barcode i 2 getinterval def
13802 np 0 get dup 48 lt exch 57 gt or
13803 np 1 get dup 48 lt 1 index 57 gt or exch 88 eq not and
13804 or {
13805 -1
13806 } {
13807 np 0 get 48 sub
13808 np 1 get 48 sub dup 40 ne { exch 10 mul add 10 add } { pop } ifelse
13809 17 add
13810 } ifelse
13811 dup -1 eq {
13812 /bwipp.telepenInvalidNumericCharacter (Telepen Numeric may contain only digits, or X in even positions) //raiseerror exec
13813 } if
13814 /indx exch def
13815 txt j [np j 16 mul 16 add textyoffset textfont textsize] put
13816 /i i 2 add def
13817 } { % Ordinal values 0-16
13818 /indx barcode i get def
13819 txt j [( ) j 16 mul 16 add textyoffset textfont textsize] put
13820 /i i 1 add def
13821 } ifelse
13822 } { % ASCII mode
13823 /indx barcode i get def
13824 indx 127 gt {
13825 /bwipp.telepenInvalidAlphaCharacter (Telepen Alpha characters must have ordinal values 0 to 127) //raiseerror exec
13826 } if
13827 indx 32 ge indx 126 le and {
13828 txt j [barcode i 1 getinterval j 16 mul 16 add textyoffset textfont textsize] put
13829 } {
13830 txt j [( ) j 16 mul 16 add textyoffset textfont textsize] put
13831 } ifelse
13832 /i i 1 add def
13833 } ifelse
13834 /checksum checksum indx add def
13835 /enc encs indx get def
13836 sbs l enc putinterval % Put encoded digit into sbs
13837 /l l enc length add def
13838 /j j 1 add def
13839 } loop
13840
13841 % Put the checksum character
13842 /checksum 127 checksum 127 mod sub 127 mod def
13843 /enc encs checksum get def
13844 sbs l enc putinterval
13845 /l l enc length add def
13846
13847 % Put the end character ASCII 122
13848 /enc encs 122 get def
13849 sbs l enc putinterval
13850 /l l enc length add def
13851
13852 % Shrink sbs and txt to fit exactly
13853 /sbs sbs 0 l getinterval def
13854 /txt txt 0 j getinterval def
13855
13856 % Return the arguments
13857 <<
13858 /ren /renlinear
13859 /sbs [sbs {48 sub} forall]
13860 /bhs [sbs length 1 add 2 idiv {height} repeat]
13861 /bbs [sbs length 1 add 2 idiv {0} repeat]
13862 includetext {
13863 /txt txt
13864 } if
13865 /opt options
13866 >>
13867
13868 dontdraw not //renlinear if
13869
13870 //unloadctx exec
13871
13872 end
13873
13874 }
13875 [/barcode] {null def} forall
13876 bind def
13877 /telepen dup load /uk.co.terryburton.bwipp defineresource pop
13878 end
13879 /setpacking where {pop setpacking} if
13880 %%EndData
13881 %%EndResource
13882 % --END ENCODER telepen--
13883
13884 % --BEGIN ENCODER telepennumeric--
13885 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renlinear telepen--
13886 % --DESC: Telepen Numeric
13887 % --EXAM: 01234567
13888 % --EXOP: includetext
13889 % --RNDR: renlinear
13890 %%BeginResource: uk.co.terryburton.bwipp telepennumeric 0.0 2025111800 66442 66018
13891 %%BeginData: 36 ASCII Lines
13892 /setpacking where {pop currentpacking true setpacking} if
13893 10 dict
13894 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
13895 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
13896 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
13897 dup /telepen dup /uk.co.terryburton.bwipp findresource put
13898 begin
13899 /telepennumeric {
13900
13901 20 dict begin % Confine variables to local scope
13902
13903 /ctx null def
13904 /dontdraw false def
13905
13906 //processoptions exec /options exch def
13907 /barcode exch def
13908
13909 % Get the result of encoding with telepen with numeric=true
13910 options (dontdraw) true put
13911 options (numeric) true put
13912
13913 /args barcode options //telepen exec def
13914
13915 args (opt) options put
13916 args
13917
13918 dontdraw not //renlinear if
13919
13920 end
13921
13922 }
13923 [/barcode] {null def} forall
13924 bind def
13925 /telepennumeric dup load /uk.co.terryburton.bwipp defineresource pop
13926 end
13927 /setpacking where {pop setpacking} if
13928 %%EndData
13929 %%EndResource
13930 % --END ENCODER telepennumeric--
13931
13932 % --BEGIN ENCODER posicode--
13933 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renlinear--
13934 % --DESC: PosiCode
13935 % --EXAM: ABC123
13936 % --EXOP: version=b inkspread=-0.5 parsefnc includetext
13937 % --RNDR: renlinear
13938 %%BeginResource: uk.co.terryburton.bwipp posicode 0.0 2025111800 122588 121499
13939 %%BeginData: 395 ASCII Lines
13940 /setpacking where {pop currentpacking true setpacking} if
13941 10 dict
13942 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
13943 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
13944 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
13945 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
13946 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
13947 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
13948 begin
13949 /posicode {
13950
13951 20 dict begin % Confine variables to local scope
13952
13953 /ctx null def
13954 /dontdraw false def
13955 /includetext false def % Enable/disable text
13956 /textfont /Courier def
13957 /textsize 10.0 def
13958 /textxoffset 0.0 def
13959 /textyoffset -7.0 def
13960 /height 1.0 def
13961 /encoding (auto) def
13962 /version (a) def
13963 /checkoffset 0 def
13964 /raw false def
13965 /parse false def
13966 /parsefnc false def
13967
13968 //processoptions exec /options exch def
13969 /barcode exch def
13970
13971 /posicode //loadctx exec
13972
13973 {
13974 % Special function characters
13975 /la0 -1 def /la1 -2 def /la2 -3 def
13976 /sf0 -4 def /sf1 -5 def /sf2 -6 def
13977 /fn1 -7 def /fn2 -8 def /fn3 -9 def /fn4 -10 def
13978
13979 % Character maps for each state
13980 /charmapsnormal [
13981 % 0 1 2 0 1 2 0 1 2
13982 [ (0) (^) (') ] [ (1) (;) 27 ] [ (2) (<) 28 ] % 0-2
13983 [ (3) (=) 29 ] [ (4) (>) 30 ] [ (5) (?) 31 ] % 3-5
13984 [ (6) (@) (!) ] [ (7) ([) (") ] [ (8) 92 (#) ] % 6-8
13985 [ (9) (]) (&) ] [ (A) (a) 1 ] [ (B) (b) 2 ] % 9-11
13986 [ (C) (c) 3 ] [ (D) (d) 4 ] [ (E) (e) 5 ] % 12-14
13987 [ (F) (f) 6 ] [ (G) (g) 7 ] [ (H) (h) 8 ] % 15-17
13988 [ (I) (i) 9 ] [ (J) (j) 10 ] [ (K) (k) 11 ] % 18-20
13989 [ (L) (l) 12 ] [ (M) (m) 13 ] [ (N) (n) 14 ] % 21-23
13990 [ (O) (o) 15 ] [ (P) (p) 16 ] [ (Q) (q) 17 ] % 24-26
13991 [ (R) (r) 18 ] [ (S) (s) 19 ] [ (T) (t) 20 ] % 27-29
13992 [ (U) (u) 21 ] [ (V) (v) 22 ] [ (W) (w) 23 ] % 30-32
13993 [ (X) (x) 24 ] [ (Y) (y) 25 ] [ (Z) (z) 26 ] % 33-35
13994 [ (-) (_) 40 ] [ (.) (`) 41 ] [ ( ) 127 0 ] % 36-38
13995 [ ($) ({) (*) ] [ (/) (|) (,) ] [ (+) (}) (:) ] % 39-41
13996 [ (%) (~) fn1 ] [ la1 la0 fn2 ] [ sf1 sf0 fn3 ] % 42-44
13997 [ sf2 sf2 fn4 ] % 45
13998 ] def
13999 /chapmapslimited [
14000 [ (0) -98 -98 ] [ (1) -98 -98 ] [ (2) -98 -98 ] % 0-2
14001 [ (3) -98 -98 ] [ (4) -98 -98 ] [ (5) -98 -98 ] % 3-5
14002 [ (6) -98 -98 ] [ (7) -98 -98 ] [ (8) -98 -98 ] % 6-8
14003 [ (9) -98 -98 ] [ (A) -98 -98 ] [ (B) -98 -98 ] % 9-11
14004 [ (C) -98 -98 ] [ (D) -98 -98 ] [ (E) -98 -98 ] % 12-14
14005 [ (F) -98 -98 ] [ (G) -98 -98 ] [ (H) -98 -98 ] % 15-17
14006 [ (I) -98 -98 ] [ (J) -98 -98 ] [ (K) -98 -98 ] % 18-20
14007 [ (L) -98 -98 ] [ (M) -98 -98 ] [ (N) -98 -98 ] % 21-23
14008 [ (O) -98 -98 ] [ (P) -98 -98 ] [ (Q) -98 -98 ] % 24-26
14009 [ (R) -98 -98 ] [ (S) -98 -98 ] [ (T) -98 -98 ] % 27-29
14010 [ (U) -98 -98 ] [ (V) -98 -98 ] [ (W) -98 -98 ] % 30-32
14011 [ (X) -98 -98 ] [ (Y) -98 -98 ] [ (Z) -98 -98 ] % 33-35
14012 [ (-) -98 -98 ] [ (.) -98 -98 ] % 36-37
14013 ] def
14014 } ctxdef
14015
14016 version (a) ne version (b) ne and version (limiteda) ne and version (limitedb) ne and {
14017 /bwipp.posicodeInvalidVersion (The version must be either a, b, limiteda or limitedb) //raiseerror exec
14018 } if
14019
14020 /charmaps version (a) eq version (b) eq or {charmapsnormal} {chapmapslimited} ifelse def
14021
14022 % Invert charmaps to give character to value maps for each state
14023 /charvals [
14024 charmaps length dict charmaps length dict charmaps length dict
14025 ] def
14026 0 1 charmaps length 1 sub {
14027 /i exch def
14028 /encs charmaps i get def
14029 0 1 2 {
14030 /j exch def
14031 encs j get dup type /stringtype eq {0 get} if % convert string to ASCII if required
14032 charvals j get exch i put
14033 } for
14034 } for
14035 /set0 charvals 0 get def
14036 /set1 charvals 1 get def
14037 /set2 charvals 2 get def
14038
14039 % Validate the input if limited
14040 version (limiteda) eq version (limitedb) eq or {
14041 0 1 barcode length 1 sub {
14042 barcode exch 1 getinterval 0 get set0 exch known not {
14043 /bwipp.posicodeBadCharacter (Posicode limited must contain only digits, capital letters, and the symbols - and .) //raiseerror exec
14044 } if
14045 } for
14046 } if
14047
14048 raw {/encoding (raw) def} if
14049
14050 encoding (raw) eq {
14051 /cws barcode length array def
14052 /i 0 def /j 0 def
14053 { % loop
14054 i barcode length eq {exit} if
14055 /cw barcode i 1 add 3 getinterval cvi def
14056 cws j cw put
14057 /i i 4 add def
14058 /j j 1 add def
14059 } loop
14060 /cws cws 0 j getinterval def
14061 /text () def
14062 } if
14063
14064 encoding (auto) eq {
14065
14066 % Parse the input
14067 /fncvals <<
14068 /parse parse
14069 /parsefnc parsefnc
14070 (FNC1) fn1
14071 (FNC2) fn2
14072 (FNC3) fn3
14073 % (FNC4) fn4 Not user accessible as encoded automatically
14074 >> def
14075 /msg barcode fncvals //parseinput exec def
14076 /msglen msg length def
14077
14078 /text msglen string def
14079 0 1 msglen 1 sub {
14080 /i exch def
14081 text i msg i get dup 0 lt { pop 32 } if put
14082 } for
14083
14084 % Standard and extended ASCII runlength at position
14085 /numSA [ msglen {0} repeat 0 ] def
14086 /numEA [ msglen {0} repeat 0 ] def
14087 msglen 1 sub -1 0 {
14088 /i exch def
14089 msg i get 0 ge {
14090 msg i get 128 ge {
14091 numEA i numEA i 1 add get 1 add put
14092 } {
14093 numSA i numSA i 1 add get 1 add put
14094 } ifelse
14095 } if
14096 } for
14097
14098 % FNC4 codeword insertion for extended ASCII
14099 /ea false def /msgtmp [] def
14100 0 1 msglen 1 sub {
14101 /i exch def
14102 /c msg i get def
14103 ea c 128 lt xor not c 0 ge and { % Other mode required
14104 ea {numSA} {numEA} ifelse i get dup % Runlength of other mode
14105 i add msglen eq {3} {5} ifelse % Does run terminate symbol
14106 lt { % Shift
14107 /msgtmp [ msgtmp aload pop fn4 ] def
14108 } { % Latch
14109 /msgtmp [ msgtmp aload pop fn4 fn4 ] def
14110 /ea ea not def
14111 } ifelse
14112 } if
14113 /msgtmp [ msgtmp aload pop c 0 ge {c 127 and} {c} ifelse ] def
14114 } for
14115 /msg msgtmp def
14116 /msglen msg length def
14117
14118 % Convert the input message to codewords
14119 /enc {
14120 exch get cws exch j exch put
14121 /j j 1 add def
14122 } def
14123
14124 /cws msglen 2 mul array def
14125 /i 0 def /j 0 def /cset (set0) def
14126 {
14127 i msglen eq {exit} if
14128
14129 { % common exit
14130
14131 % Read next two characters
14132 /char1 msg i get def
14133 /char2 i 1 add msglen lt {msg i 1 add get} {-99} ifelse def
14134
14135 % If current mode is sufficient then directly encode
14136 cset load char1 known {
14137 char1 cset load enc
14138 /i i 1 add def
14139 exit
14140 } if
14141
14142 % If char1 is in set2 then shift encode
14143 set2 char1 known {
14144 sf2 cset load enc
14145 char1 set2 enc
14146 /i i 1 add def
14147 exit
14148 } if
14149
14150 % If char2 is also not in this set then latch else shift encode
14151 cset load char2 known not {
14152 cset (set0) eq {
14153 la1 cset load enc
14154 /cset (set1) def
14155 } {
14156 la0 cset load enc
14157 /cset (set0) def
14158 } ifelse
14159 exit
14160 } {
14161 cset (set0) eq {
14162 sf1 cset load enc
14163 char1 set1 enc
14164 } {
14165 sf0 cset load enc
14166 char1 set0 enc
14167 } ifelse
14168 /i i 1 add def
14169 exit
14170 } ifelse
14171
14172 exit
14173 } loop
14174
14175 } loop
14176 /cws cws 0 j getinterval def
14177 } if % auto encoding
14178
14179 % Create an array containing the character mappings
14180 {
14181 /encmaps << % ";"=11, "<"=12
14182 /a
14183 [ (141112) (131212) (121312) (111412) (131113)
14184 (121213) (111313) (121114) (111214) (111115)
14185 (181111) (171211) (161311) (151411) (141511)
14186 (131611) (121711) (111811) (171112) (161212)
14187 (151312) (141412) (131512) (121612) (111712)
14188 (161113) (151213) (141313) (131413) (121513)
14189 (111613) (151114) (141214) (131314) (121414)
14190 (111514) (141115) (131215) (121315) (111415)
14191 (131116) (121216) (111316) (121117) (111217)
14192 (111118) (1<111112) (111111111;1)
14193 ]
14194 /b
14195 [ (151213) (141313) (131413) (121513) (141214)
14196 (131314) (121414) (131215) (121315) (121216)
14197 (191212) (181312) (171412) (161512) (151612)
14198 (141712) (131812) (121912) (181213) (171313)
14199 (161413) (151513) (141613) (131713) (121813)
14200 (171214) (161314) (151414) (141514) (131614)
14201 (121714) (161215) (151315) (141415) (131515)
14202 (121615) (151216) (141316) (131416) (121516)
14203 (141217) (131317) (121417) (131218) (121318)
14204 (121219) (1<121312) (121212121<1)
14205 ]
14206 /limiteda
14207 [ (111411) (111312) (111213) (111114) (121311)
14208 (121212) (121113) (141111) (131211) (131112)
14209 (171111) (161211) (151311) (141411) (131511)
14210 (121611) (111711) (161112) (151212) (141312)
14211 (131412) (121512) (111612) (151113) (141213)
14212 (131313) (121413) (111513) (141114) (131214)
14213 (121314) (111414) (131115) (121215) (111315)
14214 (121116) (111216) (111117) (151111) (1)
14215 ]
14216 /limitedb
14217 [ (121512) (121413) (121314) (121215) (131412)
14218 (131313) (131214) (151212) (141312) (141213)
14219 (181212) (171312) (161412) (151512) (141612)
14220 (131712) (121812) (171213) (161313) (151413)
14221 (141513) (131613) (121713) (161214) (151314)
14222 (141414) (131514) (121614) (151215) (141315)
14223 (131415) (121515) (141216) (131316) (121416)
14224 (131217) (121317) (121218) (141212) (1)
14225 ]
14226 >> def
14227 } ctxdef
14228 encmaps version get /encs exch def
14229
14230 {
14231 /c2w [
14232 [ 495 330 210 126 70 35 15 5 ]
14233 [ 165 120 84 56 35 20 10 4 ]
14234 [ 45 36 28 21 15 10 6 3 ]
14235 [ 9 8 7 6 5 4 3 2 ]
14236 [ 1 1 1 1 1 1 1 1 ]
14237 ] def
14238 } ctxdef
14239 /v 0 def
14240 cws {
14241 /cw exch def
14242 6 {
14243 cw v xor 1 and 0 ne {
14244 /v v 7682 xor def
14245 } if
14246 /v v -1 bitshift def
14247 /cw cw -1 bitshift def
14248 } repeat
14249 } forall
14250 /v v checkoffset add def
14251
14252 version (limiteda) eq version (limitedb) eq or {
14253 /v v 1023 and def
14254 v 824 gt v 853 lt and {
14255 /v v 292 add def
14256 } if
14257 } {
14258 /v v 1023 and 45 add def
14259 } ifelse
14260
14261 /d [ 2 2 2 2 2 2 ] def
14262 /r 0 def /c 0 def /w 0 def /sum 0 def
14263 {
14264 sum v eq {exit} if
14265 /t sum c2w r get c get add def
14266 t v eq {
14267 /w w 1 add def
14268 d r w 2 add put
14269 /sum t def
14270 } if
14271 t v gt {
14272 d r w 2 add put
14273 /r r 1 add def
14274 /w 0 def
14275 } if
14276 t v lt {
14277 /c c 1 add def
14278 /w w 1 add def
14279 /sum t def
14280 } if
14281 } loop
14282 20 0 1 4 {d exch get sub} for
14283 d exch 5 exch put
14284 version (b) eq version (limitedb) eq or {
14285 /d [ d {1 add} forall ] def
14286 } if
14287 /cbs (111111111111) 12 string copy def
14288 5 -1 0 {
14289 /i exch def
14290 cbs 5 i sub 2 mul 1 add d i get 47 add put
14291 } for
14292
14293 % Concatenate the space bar successions
14294 /sbs cws length 6 mul 31 add string def
14295 encs encs length 2 sub get dup
14296 sbs exch 0 exch putinterval
14297 length /j exch def
14298 0 1 cws length 1 sub {
14299 /i exch def
14300 sbs j encs cws i get get putinterval
14301 /j j 6 add def
14302 } for
14303 sbs j cbs putinterval
14304 /j j 12 add def
14305 encs encs length 1 sub get dup
14306 sbs exch j exch putinterval
14307 length j add /j exch def
14308 /sbs sbs 0 j getinterval def
14309
14310 % Return the arguments
14311 <<
14312 /ren /renlinear
14313 /sbs [sbs {48 sub} forall]
14314 /bhs [sbs length 1 add 2 idiv {height} repeat]
14315 /bbs [sbs length 1 add 2 idiv {0} repeat]
14316 /txt [ [text textxoffset textyoffset textfont textsize] ]
14317 /textxalign (center)
14318 /borderleft << /a 0.0 /b 0.0 /limiteda 12.0 /limitedb 13.0 >> version get
14319 /borderright << /a 0.0 /b 0.0 /limiteda 12.0 /limitedb 13.0 >> version get
14320 /opt options
14321 >>
14322
14323 dontdraw not //renlinear if
14324
14325 //unloadctx exec
14326
14327 end
14328
14329 }
14330 [/barcode] {null def} forall
14331 bind def
14332 /posicode dup load /uk.co.terryburton.bwipp defineresource pop
14333 end
14334 /setpacking where {pop setpacking} if
14335 %%EndData
14336 %%EndResource
14337 % --END ENCODER posicode--
14338
14339 % --BEGIN ENCODER codablockf--
14340 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix--
14341 % --DESC: Codablock F
14342 % --EXAM: CODABLOCK F 34567890123456789010040digit
14343 % --EXOP: columns=8
14344 % --RNDR: renmatrix
14345 %%BeginResource: uk.co.terryburton.bwipp codablockf 0.0 2025111800 147463 145711
14346 %%BeginData: 538 ASCII Lines
14347 /setpacking where {pop currentpacking true setpacking} if
14348 10 dict
14349 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
14350 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
14351 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
14352 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
14353 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
14354 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
14355 begin
14356 /codablockf {
14357
14358 20 dict begin
14359
14360 /ctx null def
14361 /dontdraw false def
14362 /rows -1 def
14363 /columns 8 def
14364 /rowheight 10 def
14365 /sepheight 1 def
14366 /parse false def
14367 /parsefnc false def
14368
14369 //processoptions exec /options exch def
14370 /barcode exch def
14371
14372 columns 4 lt columns 62 gt or {
14373 /bwipp.codablockfBadColumns (Codablock F must have 4 to 62 columns) //raiseerror exec
14374 } if
14375
14376 rows -1 ne rows 2 lt rows 44 gt or and {
14377 /bwipp.codablockfBadRows (Codablock F must have 2 to 44 rows) //raiseerror exec
14378 } if
14379
14380 rowheight 8 lt {
14381 /bwipp.codablockfBadRowHeight (Codablock F must have rowheight of at least 8) //raiseerror exec
14382 } if
14383
14384 sepheight 1 lt {
14385 /bwipp.codablockfBadSepHeight (Codablock F must have sepheight of at least 1) //raiseerror exec
14386 } if
14387
14388 /codablockf //loadctx exec
14389
14390 /c columns 4 ge columns 62 le and {columns} {8} ifelse def
14391 /rows rows 2 ge rows 44 le and {rows} {-1} ifelse def
14392
14393 % Convert input into bytes accounting for FNC characters
14394 /swa -1 def /swb -2 def /swc -3 def /sft -4 def
14395 /fn1 -5 def /fn2 -6 def /fn3 -7 def /fn4 -8 def
14396 /sta -9 def /stp -10 def
14397
14398 % Parse the input
14399 /fncvals <<
14400 /parse parse
14401 /parsefnc parsefnc
14402 (FNC1) fn1
14403 % (FNC2) fn2 Not permitted for Codablock F
14404 (FNC3) fn3
14405 % (FNC4) fn4 Not user accessible as encoded automatically
14406 >> def
14407 /msg barcode fncvals //parseinput exec def
14408 /msglen msg length def
14409
14410 % FNC4 codeword insertion for extended ASCII
14411 /msgtmp [] def
14412 msg {
14413 /char exch def
14414 /msgtmp [ msgtmp aload pop char 128 lt {char} {fn4 char 127 and} ifelse ] def
14415 } forall
14416 /kmsg msg def % Keep for k1/k2 check characters calculation
14417 /msg msgtmp def
14418 /msglen msg length def
14419
14420 % Character maps for each state
14421 {
14422 /charmaps [
14423 % A B C A B C A B C
14424 [ 32 32 (00) ] [ (!) (!) (01) ] [ (") (") (02) ] % 0-2
14425 [ (#) (#) (03) ] [ ($) ($) (04) ] [ (%) (%) (05) ] % 3-5
14426 [ (&) (&) (06) ] [ (') (') (07) ] [ 40 40 (08) ] % 6-8
14427 [ 41 41 (09) ] [ (*) (*) (10) ] [ (+) (+) (11) ] % 9-11
14428 [ (,) (,) (12) ] [ (-) (-) (13) ] [ (.) (.) (14) ] % 12-14
14429 [ (/) (/) (15) ] [ (0) (0) (16) ] [ (1) (1) (17) ] % 15-17
14430 [ (2) (2) (18) ] [ (3) (3) (19) ] [ (4) (4) (20) ] % 18-20
14431 [ (5) (5) (21) ] [ (6) (6) (22) ] [ (7) (7) (23) ] % 21-23
14432 [ (8) (8) (24) ] [ (9) (9) (25) ] [ (:) (:) (26) ] % 24-26
14433 [ (;) (;) (27) ] [ (<) (<) (28) ] [ (=) (=) (29) ] % 27-29
14434 [ (>) (>) (30) ] [ (?) (?) (31) ] [ (@) (@) (32) ] % 30-32
14435 [ (A) (A) (33) ] [ (B) (B) (34) ] [ (C) (C) (35) ] % 33-35
14436 [ (D) (D) (36) ] [ (E) (E) (37) ] [ (F) (F) (38) ] % 36-38
14437 [ (G) (G) (39) ] [ (H) (H) (40) ] [ (I) (I) (41) ] % 39-41
14438 [ (J) (J) (42) ] [ (K) (K) (43) ] [ (L) (L) (44) ] % 42-44
14439 [ (M) (M) (45) ] [ (N) (N) (46) ] [ (O) (O) (47) ] % 45-47
14440 [ (P) (P) (48) ] [ (Q) (Q) (49) ] [ (R) (R) (50) ] % 48-50
14441 [ (S) (S) (51) ] [ (T) (T) (52) ] [ (U) (U) (53) ] % 51-53
14442 [ (V) (V) (54) ] [ (W) (W) (55) ] [ (X) (X) (56) ] % 54-56
14443 [ (Y) (Y) (57) ] [ (Z) (Z) (58) ] [ ([) ([) (59) ] % 57-59
14444 [ 92 92 (60) ] [ (]) (]) (61) ] [ (^) (^) (62) ] % 60-62
14445 [ (_) (_) (63) ] [ 0 (`) (64) ] [ 1 (a) (65) ] % 63-65
14446 [ 2 (b) (66) ] [ 3 (c) (67) ] [ 4 (d) (68) ] % 66-68
14447 [ 5 (e) (69) ] [ 6 (f) (70) ] [ 7 (g) (71) ] % 69-71
14448 [ 8 (h) (72) ] [ 9 (i) (73) ] [ 10 (j) (74) ] % 72-74
14449 [ 11 (k) (75) ] [ 12 (l) (76) ] [ 13 (m) (77) ] % 75-77
14450 [ 14 (n) (78) ] [ 15 (o) (79) ] [ 16 (p) (80) ] % 78-80
14451 [ 17 (q) (81) ] [ 18 (r) (82) ] [ 19 (s) (83) ] % 81-83
14452 [ 20 (t) (84) ] [ 21 (u) (85) ] [ 22 (v) (86) ] % 84-86
14453 [ 23 (w) (87) ] [ 24 (x) (88) ] [ 25 (y) (89) ] % 87-89
14454 [ 26 (z) (90) ] [ 27 ({) (91) ] [ 28 (|) (92) ] % 90-92
14455 [ 29 (}) (93) ] [ 30 (~) (94) ] [ 31 127 (95) ] % 93-95
14456 [ fn3 fn3 (96) ] [ fn2 fn2 (97) ] [ sft sft (98) ] % 96-98
14457 [ swc swc (99) ] [ swb fn4 swb ] [ fn4 swa swa ] % 99-101
14458 [ fn1 fn1 fn1 ] [ sta sta sta ] [ stp stp stp ] % 102-104
14459 ] def
14460
14461 % Invert charmaps to give character to value maps for each state
14462 /charvals [ 105 dict 105 dict 105 dict ] def
14463 0 1 charmaps length 1 sub {
14464 /i exch def
14465 /encs charmaps i get def
14466 0 1 2 {
14467 /j exch def
14468 encs j get dup type /stringtype eq {0 get} if % convert string to ASCII if required
14469 charvals j get exch i put
14470 } for
14471 } for
14472 /seta charvals 0 get def
14473 /setb charvals 1 get def
14474 /setc charvals 2 get def
14475 } ctxdef
14476
14477 % Determine digit runlength and characters from given position
14478 /numsscr {
14479 /n 0 def /s 0 def
14480 /p exch def {
14481 p msglen ge {exit} if
14482 p 0 ne { % Check not 2nd byte of FNC4
14483 msg p 1 sub get fn4 eq {exit} if
14484 } if
14485 msg p get
14486 dup setc exch known not {pop exit} if
14487 fn1 eq {
14488 % FNC1 in odd position of run like two digits
14489 s 2 mod 0 eq {/s s 1 add def} {exit} ifelse
14490 } if
14491 /n n 1 add def
14492 /s s 1 add def
14493 /p p 1 add def
14494 } loop
14495 n s
14496 } def
14497
14498 % Encoding for each alphabet
14499 /enca {
14500 seta exch get cws exch j exch put
14501 /j j 1 add def
14502 } def
14503 /encb {
14504 setb exch get cws exch j exch put
14505 /j j 1 add def
14506 } def
14507 /encc {
14508 dup type /arraytype ne {
14509 setc exch get
14510 } {
14511 aload pop 48 sub exch 48 sub 10 mul add
14512 } ifelse
14513 cws exch j exch put
14514 /j j 1 add def
14515 } def
14516
14517 % Character exclusively in either alphabet A or B
14518 /anotb {dup seta exch known exch setb exch known not and} def
14519 /bnota {dup setb exch known exch seta exch known not and} def
14520
14521 % Pre-compute relative position of next anotb and next bnota characters
14522 /nextanotb [ msg length {0} repeat 9999 ] def
14523 /nextbnota [ msg length {0} repeat 9999 ] def
14524 msg length 1 sub -1 0 {
14525 /i exch def
14526 msg i get anotb {
14527 nextanotb i 0 put
14528 } {
14529 nextanotb i nextanotb i 1 add get 1 add put
14530 } ifelse
14531 msg i get bnota {
14532 nextbnota i 0 put
14533 } {
14534 nextbnota i nextbnota i 1 add get 1 add put
14535 } ifelse
14536 } for
14537
14538 % Does a-only come before b-only after given position and vice versa
14539 /abeforeb {dup nextanotb exch get exch nextbnota exch get lt} def
14540 /bbeforea {dup nextbnota exch get exch nextanotb exch get lt} def
14541
14542 % Add padding to row
14543 /padrow {
14544 {
14545 { % common exit
14546 cset (seta) eq {swc enca /cset (setc) def exit} if
14547 cset (setb) eq {swc encb /cset (setc) def exit} if
14548 cset (setc) eq {swb encc /cset (setb) def exit} if
14549 } loop
14550 } repeat
14551 } def
14552
14553 % Encode a if fits in row, allowing for fn4 + possible shift, assuming rem ge 1
14554 /encafitsrow {
14555 rem 2 le msg i get fn4 eq and {
14556 % If have 2 left and don't need to shift
14557 rem 2 eq msg i 1 add get 95 le and dup { % Return false if not
14558 fn4 enca
14559 msg i 1 add get enca
14560 /i i 2 add def
14561 } if
14562 } {
14563 msg i get enca
14564 /i i 1 add def
14565 true
14566 } ifelse
14567 } def
14568
14569 % Encode b if fits in row, allowing for fn4 + possible shift, assuming rem ge 1
14570 /encbfitsrow {
14571 rem 2 le msg i get fn4 eq and {
14572 % If have 2 left and don't need to shift
14573 rem 2 eq msg i 1 add get 32 ge and dup { % Return false if not
14574 fn4 encb
14575 msg i 1 add get encb
14576 /i i 2 add def
14577 } if
14578 } {
14579 msg i get encb
14580 /i i 1 add def
14581 true
14582 } ifelse
14583 } def
14584
14585 % Convert message to codewords
14586 /cws c 5 add 44 mul array def
14587
14588 /i 0 def /j 0 def /r 1 def
14589 /lastrow false def {
14590
14591 lastrow {exit} if
14592
14593 r 44 gt {
14594 /bwipp.codablockfTooBig (Maximum length exceeded) //raiseerror exec
14595 } if
14596
14597 % Add start character and code subset selector
14598 sta enca
14599 i msglen lt {i numsscr} {-1 -1} ifelse /nums exch def /nchars exch def
14600 { % common exit
14601 msglen 0 eq {
14602 swb enca
14603 /cset (setb) def
14604 exit
14605 } if
14606 nums 2 ge {
14607 swc enca
14608 /cset (setc) def
14609 exit
14610 } if
14611 i abeforeb {
14612 sft enca
14613 /cset (seta) def
14614 exit
14615 } if
14616 swb enca
14617 /cset (setb) def
14618 exit
14619 } loop
14620 /j j 1 add def % Skip row indicator position
14621
14622 % Main encoding loop
14623 /endofrow false def {
14624 /rem c 3 add j c 5 add mod sub def % Codewords to end of row
14625
14626 i msglen eq endofrow or {exit} if
14627
14628 i numsscr /nums exch def /nchars exch def
14629 /remnums nums rem 2 mul gt {rem 2 mul} {nums} ifelse def
14630
14631 % Determine switches and shifts
14632 { % common exit
14633 cset (seta) eq cset (setb) eq or remnums 4 ge and
14634 msg i get fn1 ne and {
14635 remnums 2 mod 0 eq
14636 rem 3 ge and {
14637 swc cset (seta) eq {enca} {encb} ifelse
14638 /cset (setc) def
14639 2 {
14640 msg i get fn1 eq {
14641 fn1 encc
14642 /i i 1 add def
14643 } {
14644 msg i 2 getinterval encc
14645 /i i 2 add def
14646 } ifelse
14647 } repeat
14648 exit
14649 } if
14650 remnums 2 mod 0 ne
14651 rem 4 ge and {
14652 msg i get cset (seta) eq {enca} {encb} ifelse
14653 /i i 1 add def
14654 swc cset (seta) eq {enca} {encb} ifelse
14655 /cset (setc) def
14656 2 {
14657 msg i get fn1 eq {
14658 fn1 encc
14659 /i i 1 add def
14660 } {
14661 msg i 2 getinterval encc
14662 /i i 2 add def
14663 } ifelse
14664 } repeat
14665 exit
14666 } if
14667 } if
14668 cset (setb) eq msg i get anotb and
14669 rem 2 ge and {
14670 i msglen 1 sub lt {
14671 i 1 add bbeforea {
14672 sft encb
14673 msg i get enca
14674 /i i 1 add def
14675 exit
14676 } if
14677 } if
14678 swa encb
14679 /cset (seta) def
14680 msg i get enca
14681 /i i 1 add def
14682 exit
14683 } if
14684 cset (seta) eq msg i get bnota and
14685 rem 2 ge and {
14686 i msglen 1 sub lt {
14687 i 1 add abeforeb {
14688 sft enca
14689 msg i get encb
14690 /i i 1 add def
14691 exit
14692 } if
14693 } if
14694 swb enca
14695 /cset (setb) def
14696 msg i get encb
14697 /i i 1 add def
14698 exit
14699 } if
14700 cset (setc) eq remnums 2 lt and
14701 rem 2 ge and {
14702 /rem rem 1 sub def
14703 i abeforeb {
14704 swa encc
14705 /cset (seta) def
14706 encafitsrow { exit } if
14707 } {
14708 swb encc
14709 /cset (setb) def
14710 encbfitsrow { exit } if
14711 } ifelse
14712 } if
14713
14714 % No switches or latches so try to encode
14715 cset (seta) eq seta msg i get known and
14716 rem 1 ge and {
14717 encafitsrow { exit } if
14718 } if
14719 cset (setb) eq setb msg i get known and
14720 rem 1 ge and {
14721 encbfitsrow { exit } if
14722 } if
14723 cset (setc) eq remnums 2 ge and
14724 rem 1 ge and {
14725 msg i get fn1 eq {
14726 fn1 encc
14727 /i i 1 add def
14728 } {
14729 msg i 2 getinterval encc
14730 /i i 2 add def
14731 } ifelse
14732 exit
14733 } if
14734
14735 % Encoding does not fit in the row
14736 /endofrow true def
14737 exit
14738
14739 } loop % common exit
14740
14741 } loop
14742
14743 % Determine whether this is the final row
14744 r rows ge rows -1 eq or r 1 gt and i msglen eq and rem 2 ge and {
14745 rem 2 sub padrow
14746 /j j 3 add def % Skip symbol and row checksum character positions
14747 stp enca
14748 /lastrow true def
14749 } {
14750 rem padrow
14751 /j j 1 add def % Skip row checksum character positions
14752 stp enca
14753 /r r 1 add def
14754 } ifelse
14755
14756 } loop
14757 /cws cws 0 j getinterval def
14758
14759 % Maps for row indicators and symbol checksums
14760 {
14761 /abmap [
14762 64 1 95 {} for
14763 0 1 15 {} for
14764 26 1 63 {} for
14765 ] def
14766 /cmap [ 0 1 85 {} for ] def
14767 } ctxdef
14768
14769 % Add symbol check characters to last row
14770 /chkmsg kmsg length array def % Using kmsg (pre-fn4 insertion)
14771 /j 0 def
14772 0 1 kmsg length 1 sub {
14773 /i exch def
14774 /char kmsg i get def
14775 char 0 ge {chkmsg j char put /j j 1 add def} if
14776 char fn1 eq i 0 ne and {chkmsg j 29 put /j j 1 add def} if
14777 } for
14778 /t1 0 def /t2 0 def /k1 0 def /k2 0 def
14779 0 1 j 1 sub {
14780 /i exch def
14781 /t1 chkmsg i get i mul 86 mod def
14782 /t2 t1 chkmsg i get add 86 mod def
14783 /k1 k1 t2 add 86 mod def
14784 /k2 k2 t1 add 86 mod def
14785 } for
14786 cws cws length 4 sub cset (setc) ne {abmap} {cmap} ifelse k1 get put
14787 cws cws length 3 sub cset (setc) ne {abmap} {cmap} ifelse k2 get put
14788
14789 % Populate row indicators
14790 cws 2 2 copy 1 sub get 99 ne {abmap} {cmap} ifelse r 2 sub get put
14791 1 1 r 1 sub {
14792 /i exch def
14793 cws i c 5 add mul 2 add 2 copy 1 sub get 99 ne {abmap} {cmap} ifelse i 42 add get put
14794 } for
14795
14796 % Calculate row check characters
14797 0 1 r 1 sub {
14798 cws exch c 5 add mul c 4 add getinterval /rcws exch def
14799 /csum rcws 0 get def
14800 1 1 rcws length 2 sub {
14801 /i exch def
14802 /csum csum rcws i get i mul add def
14803 } for
14804 rcws rcws length 1 sub csum 103 mod put
14805 } for
14806
14807 options /debugcws known { /bwipp.debugcws cws //raiseerror exec } if
14808
14809 % Create an array containing the character mappings
14810 {
14811 /encs
14812 [ (212222) (222122) (222221) (121223) (121322) (131222) (122213)
14813 (122312) (132212) (221213) (221312) (231212) (112232) (122132)
14814 (122231) (113222) (123122) (123221) (223211) (221132) (221231)
14815 (213212) (223112) (312131) (311222) (321122) (321221) (312212)
14816 (322112) (322211) (212123) (212321) (232121) (111323) (131123)
14817 (131321) (112313) (132113) (132311) (211313) (231113) (231311)
14818 (112133) (112331) (132131) (113123) (113321) (133121) (313121)
14819 (211331) (231131) (213113) (213311) (213131) (311123) (311321)
14820 (331121) (312113) (312311) (332111) (314111) (221411) (431111)
14821 (111224) (111422) (121124) (121421) (141122) (141221) (112214)
14822 (112412) (122114) (122411) (142112) (142211) (241211) (221114)
14823 (413111) (241112) (134111) (111242) (121142) (121241) (114212)
14824 (124112) (124211) (411212) (421112) (421211) (212141) (214121)
14825 (412121) (111143) (111341) (131141) (114113) (114311) (411113)
14826 (411311) (113141) (114131) (311141) (411131) (211412) (2331112)
14827 ] def
14828 } ctxdef
14829
14830 % Derive the bits for each row
14831 /rowbits r array def
14832 0 1 r 1 sub {
14833 /i exch def
14834 /sbs [
14835 cws i c 5 add mul c 5 add getinterval {
14836 encs exch get {48 sub} forall
14837 } forall
14838 ] def
14839 mark
14840 0 sbs {1 index 1 eq {{0}} {{1}} ifelse repeat} forall
14841 counttomark 1 sub array astore exch pop exch pop
14842 rowbits i 3 -1 roll put
14843 } for
14844
14845 % Populate the bitmap
14846 /symwid c 11 mul 57 add def
14847 /pixs [
14848 symwid sepheight mul {1} repeat
14849 0 1 r 2 sub {
14850 /i exch def
14851 rowheight {rowbits i get aload pop} repeat
14852 sepheight {
14853 1 1 0 1 0 0 0 0 1 0 0
14854 symwid 24 sub {1} repeat
14855 1 1 0 0 0 1 1 1 0 1 0 1 1
14856 } repeat
14857 } for
14858 rowheight {rowbits r 1 sub get aload pop} repeat
14859 symwid sepheight mul {1} repeat
14860 ] def
14861
14862 % Return the arguments
14863 <<
14864 /ren /renmatrix
14865 /pixs pixs
14866 /pixx symwid
14867 /pixy pixs length symwid idiv
14868 /height pixs length symwid idiv 72 div
14869 /width symwid 72 div
14870 /opt options
14871 >>
14872
14873 dontdraw not //renmatrix if
14874
14875 //unloadctx exec
14876
14877 end
14878
14879 }
14880 [/barcode] {null def} forall
14881 bind def
14882 /codablockf dup load /uk.co.terryburton.bwipp defineresource pop
14883 end
14884 /setpacking where {pop setpacking} if
14885 %%EndData
14886 %%EndResource
14887 % --END ENCODER codablockf--
14888
14889 % --BEGIN ENCODER code16k--
14890 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix--
14891 % --DESC: Code 16K
14892 % --EXAM: Abcd-1234567890-wxyZ
14893 % --EXOP:
14894 % --RNDR: renmatrix
14895 %%BeginResource: uk.co.terryburton.bwipp code16k 0.0 2025111800 170320 175640
14896 %%BeginData: 740 ASCII Lines
14897 /setpacking where {pop currentpacking true setpacking} if
14898 10 dict
14899 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
14900 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
14901 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
14902 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
14903 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
14904 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
14905 begin
14906 /code16k {
14907
14908 20 dict begin
14909
14910 /ctx null def
14911 /dontdraw false def
14912 /sam -1 def
14913 /rows 0 def
14914 /rowheight 8 def
14915 /sepheight 1 def
14916 /raw false def
14917 /parse false def
14918 /parsefnc false def
14919
14920 //processoptions exec /options exch def
14921 /barcode exch def
14922
14923 rows 0 ne rows 2 lt rows 16 gt or and {
14924 /bwipp.code16kBadRows (Code 16K must have 2 to 16 rows) //raiseerror exec
14925 } if
14926
14927 rowheight 8 lt {
14928 /bwipp.code16kBadRowHeight (Code 16K must have rowheight of at least 8) //raiseerror exec
14929 } if
14930
14931 sepheight 1 lt {
14932 /bwipp.code16kBadSepHeight (Code 16K must have sepheight of at least 1) //raiseerror exec
14933 } if
14934
14935 sam -1 ne {
14936 true
14937 1 {
14938 sam dup 12 lt exch 99 gt or { pop false exit } if
14939 sam 10 mod 2 lt { pop false exit } if
14940 sam 10 idiv sam 10 mod gt { pop false exit } if
14941 } repeat
14942 not {
14943 /bwipp.code16kBadSAM (SAM must be formatted as "NM" for Nth of M symbols, from 2 to 9 symbols) //raiseerror exec
14944 } if
14945 } if
14946
14947 /code16k //loadctx exec
14948
14949 sam -1 ne {/rows 16 def} if
14950
14951 % Convert input into bytes accounting for FNC characters
14952 {
14953 /swa -1 def /swb -2 def /swc -3 def
14954 /sa1 -4 def /sb1 -5 def /sc1 -6 def
14955 /sa2 -7 def /sb2 -8 def /sc2 -9 def
14956 /pad -10 def /sb3 -11 def /sc3 -12 def
14957 /fn1 -13 def /fn2 -14 def /fn3 -15 def /fn4 -16 def
14958
14959 % Character maps for each state
14960 /charmaps [
14961 % A B C A B C A B C
14962 [ 32 32 (00) ] [ (!) (!) (01) ] [ (") (") (02) ] % 0-2
14963 [ (#) (#) (03) ] [ ($) ($) (04) ] [ (%) (%) (05) ] % 3-5
14964 [ (&) (&) (06) ] [ (') (') (07) ] [ 40 40 (08) ] % 6-8
14965 [ 41 41 (09) ] [ (*) (*) (10) ] [ (+) (+) (11) ] % 9-11
14966 [ (,) (,) (12) ] [ (-) (-) (13) ] [ (.) (.) (14) ] % 12-14
14967 [ (/) (/) (15) ] [ (0) (0) (16) ] [ (1) (1) (17) ] % 15-17
14968 [ (2) (2) (18) ] [ (3) (3) (19) ] [ (4) (4) (20) ] % 18-20
14969 [ (5) (5) (21) ] [ (6) (6) (22) ] [ (7) (7) (23) ] % 21-23
14970 [ (8) (8) (24) ] [ (9) (9) (25) ] [ (:) (:) (26) ] % 24-26
14971 [ (;) (;) (27) ] [ (<) (<) (28) ] [ (=) (=) (29) ] % 27-29
14972 [ (>) (>) (30) ] [ (?) (?) (31) ] [ (@) (@) (32) ] % 30-32
14973 [ (A) (A) (33) ] [ (B) (B) (34) ] [ (C) (C) (35) ] % 33-35
14974 [ (D) (D) (36) ] [ (E) (E) (37) ] [ (F) (F) (38) ] % 36-38
14975 [ (G) (G) (39) ] [ (H) (H) (40) ] [ (I) (I) (41) ] % 39-41
14976 [ (J) (J) (42) ] [ (K) (K) (43) ] [ (L) (L) (44) ] % 42-44
14977 [ (M) (M) (45) ] [ (N) (N) (46) ] [ (O) (O) (47) ] % 45-47
14978 [ (P) (P) (48) ] [ (Q) (Q) (49) ] [ (R) (R) (50) ] % 48-50
14979 [ (S) (S) (51) ] [ (T) (T) (52) ] [ (U) (U) (53) ] % 51-53
14980 [ (V) (V) (54) ] [ (W) (W) (55) ] [ (X) (X) (56) ] % 54-56
14981 [ (Y) (Y) (57) ] [ (Z) (Z) (58) ] [ ([) ([) (59) ] % 57-59
14982 [ 92 92 (60) ] [ (]) (]) (61) ] [ (^) (^) (62) ] % 60-62
14983 [ (_) (_) (63) ] [ 0 (`) (64) ] [ 1 (a) (65) ] % 63-65
14984 [ 2 (b) (66) ] [ 3 (c) (67) ] [ 4 (d) (68) ] % 66-68
14985 [ 5 (e) (69) ] [ 6 (f) (70) ] [ 7 (g) (71) ] % 69-71
14986 [ 8 (h) (72) ] [ 9 (i) (73) ] [ 10 (j) (74) ] % 72-74
14987 [ 11 (k) (75) ] [ 12 (l) (76) ] [ 13 (m) (77) ] % 75-77
14988 [ 14 (n) (78) ] [ 15 (o) (79) ] [ 16 (p) (80) ] % 78-80
14989 [ 17 (q) (81) ] [ 18 (r) (82) ] [ 19 (s) (83) ] % 81-83
14990 [ 20 (t) (84) ] [ 21 (u) (85) ] [ 22 (v) (86) ] % 84-86
14991 [ 23 (w) (87) ] [ 24 (x) (88) ] [ 25 (y) (89) ] % 87-89
14992 [ 26 (z) (90) ] [ 27 ({) (91) ] [ 28 (|) (92) ] % 90-92
14993 [ 29 (}) (93) ] [ 30 (~) (94) ] [ 31 127 (95) ] % 93-95
14994 [ fn3 fn3 (96) ] [ fn2 fn2 (97) ] [ sb1 sa1 (98) ] % 96-98
14995 [ swc swc (99) ] [ swb fn4 swb ] [ fn4 swa swa ] % 99-101
14996 [ fn1 fn1 fn1 ] [ pad pad pad ] [ sb2 sa2 sb1 ] % 102-104
14997 [ sc2 sc2 sb2 ] [ sc3 sc3 sb3 ] % 105-106
14998 ] def
14999
15000 % Invert charmaps to give character to value maps for each state
15001 /charvals [ 109 dict 109 dict 109 dict ] def
15002 0 1 charmaps length 1 sub {
15003 /i exch def
15004 /encs charmaps i get def
15005 0 1 2 {
15006 /j exch def
15007 encs j get dup type /stringtype eq {0 get} if % convert string to ASCII if required
15008 charvals j get exch i put
15009 } for
15010 } for
15011 /seta charvals 0 get def
15012 /setb charvals 1 get def
15013 /setc charvals 2 get def
15014 } ctxdef
15015
15016 raw {
15017
15018 /cws barcode length array def
15019 /i 0 def /j 0 def
15020 { % loop
15021 i barcode length 3 sub ge {exit} if
15022 barcode i get 94 ne {exit} if
15023 barcode i 1 add 3 getinterval false 1 index {
15024 dup 48 lt exch 57 gt or { pop true } if
15025 } forall { pop exit } if
15026 cvi /cw exch def
15027 cws j cw put
15028 /i i 4 add def
15029 /j j 1 add def
15030 } loop
15031 i barcode length ne {
15032 /bwipp.code16kBadRawFormat (raw data must be formatted as ^NNN) //raiseerror exec
15033 } if
15034 /cws cws 0 j getinterval def
15035
15036 } {
15037
15038 % Parse the input
15039 /fncvals <<
15040 /parse parse
15041 /parsefnc parsefnc
15042 /eci true
15043 (FNC1) fn1
15044 (FNC2) fn2
15045 (FNC3) fn3
15046 % (FNC4) fn4 Not user accessible as encoded automatically
15047 >> def
15048 /msg barcode fncvals //parseinput exec def
15049 /msglen msg length def
15050
15051 % Standard and extended ASCII runlength at position
15052 /numSA [ msglen {0} repeat 0 ] def
15053 /numEA [ msglen {0} repeat 0 ] def
15054 msglen 1 sub -1 0 {
15055 /i exch def
15056 msg i get 0 ge {
15057 msg i get 128 ge {
15058 numEA i numEA i 1 add get 1 add put
15059 } {
15060 numSA i numSA i 1 add get 1 add put
15061 } ifelse
15062 } if
15063 } for
15064
15065 % FNC4 codeword insertion for extended ASCII
15066 /ea false def /msgtmp [] def
15067 0 1 msglen 1 sub {
15068 /i exch def
15069 /c msg i get def
15070 ea c 128 lt xor not c 0 ge and { % Other mode required
15071 ea {numSA} {numEA} ifelse i get dup % Runlength of other mode
15072 i add msglen eq {3} {5} ifelse % Does run terminate symbol
15073 lt { % Shift
15074 /msgtmp [ msgtmp aload pop fn4 ] def
15075 } { % Latch
15076 /msgtmp [ msgtmp aload pop fn4 fn4 ] def
15077 /ea ea not def
15078 } ifelse
15079 } if
15080 /msgtmp [ msgtmp aload pop c 0 ge {c 127 and} {c} ifelse ] def
15081 } for
15082 /msg msgtmp def
15083 /msglen msg length def
15084
15085 % Determine digit runlength and characters from given position
15086 /numsscr {
15087 /n 0 def /s 0 def
15088 /p exch def {
15089 p msglen ge {exit} if
15090 msg p get
15091 dup setc exch known not {pop exit} if
15092 fn1 eq {
15093 % FNC1 in odd position of run like two digits
15094 s 2 mod 0 eq {/s s 1 add def} {exit} ifelse
15095 } if
15096 /n n 1 add def
15097 /s s 1 add def
15098 /p p 1 add def
15099 } loop
15100 n s
15101 } def
15102
15103 % Encoding for each alphabet
15104 /enca {
15105 seta exch get cws exch j exch put
15106 /j j 1 add def
15107 } def
15108 /encb {
15109 setb exch get cws exch j exch put
15110 /j j 1 add def
15111 } def
15112 /encc {
15113 dup type /arraytype ne {
15114 setc exch get
15115 } {
15116 aload pop 48 sub exch 48 sub 10 mul add
15117 } ifelse
15118 cws exch j exch put
15119 /j j 1 add def
15120 } def
15121
15122 % Character exclusively in either alphabet A or B
15123 /anotb {dup seta exch known exch setb exch known not and} def
15124 /bnota {dup setb exch known exch seta exch known not and} def
15125
15126 % Pre-compute relative position of next anotb and next bnota characters
15127 /nextanotb [ msg length {0} repeat 9999 ] def
15128 /nextbnota [ msg length {0} repeat 9999 ] def
15129 msg length 1 sub -1 0 {
15130 /i exch def
15131 msg i get anotb {
15132 nextanotb i 0 put
15133 } {
15134 nextanotb i nextanotb i 1 add get 1 add put
15135 } ifelse
15136 msg i get bnota {
15137 nextbnota i 0 put
15138 } {
15139 nextbnota i nextbnota i 1 add get 1 add put
15140 } ifelse
15141 } for
15142
15143 % Does a-only come before b-only after given position and vice versa
15144 /abeforeb {dup nextanotb exch get exch nextbnota exch get lt} def
15145 /bbeforea {dup nextbnota exch get exch nextanotb exch get lt} def
15146
15147 /cws barcode length 2 mul 3 add array def
15148
15149 % Select mode and encode first characters
15150 /i 0 def /j 0 def
15151 { % common exit
15152 % extended data length
15153 sam -1 ne {
15154 % encode one and two
15155 cws 0 sam 10 idiv 1 sub put
15156 cws 1 sam 10 mod 1 sub put
15157 /j 2 def
15158 /cset (setb) def
15159 /mode 7 def
15160 exit
15161 } if
15162 % empty => b
15163 msglen 0 eq {
15164 /cset (setb) def
15165 /mode 1 def
15166 exit
15167 } if
15168 % FNC1 . 2+ nums => c fnc1
15169 msglen 2 ge {
15170 msg 0 get fn1 eq 1 numsscr exch pop 2 ge and {
15171 /cset (setc) def
15172 /mode 4 def
15173 /i 1 def
15174 exit
15175 } if
15176 } if
15177 % FNC1 => b fnc1
15178 msg 0 get fn1 eq {
15179 /cset (setb) def
15180 /mode 3 def
15181 /i 1 def
15182 exit
15183 } if
15184 msglen 2 ge {
15185 % 2+ even nums => c
15186 0 numsscr exch pop dup 2 ge exch 2 mod 0 eq and {
15187 /cset (setc) def
15188 /mode 2 def
15189 exit
15190 } if
15191 % 3+ odd nums => c sb1 encode
15192 0 numsscr exch pop dup 3 ge exch 2 mod 1 eq and {
15193 msg 0 get encb
15194 /cset (setc) def
15195 /mode 5 def
15196 /i 1 def
15197 exit
15198 } if
15199 % b . 2+ even nums => c sb1 encode
15200 setb msg 0 get known
15201 1 numsscr exch pop dup 2 ge exch 2 mod 0 eq and and {
15202 msg 0 get encb
15203 /cset (setc) def
15204 /mode 5 def
15205 /i 1 def
15206 exit
15207 } if
15208 % b . 3+ odd nums => c sb2 encode
15209 setb msg 0 get known
15210 1 numsscr exch pop dup 3 ge exch 2 mod 1 eq and and {
15211 msg 0 get encb
15212 msg 1 get encb
15213 /cset (setc) def
15214 /mode 6 def
15215 /i 2 def
15216 exit
15217 } if
15218 % b . b . 2+ even nums => c sb2 encode
15219 setb msg 0 get known
15220 setb msg 1 get known and
15221 2 numsscr exch pop dup 2 ge exch 2 mod 0 eq and and {
15222 msg 0 get encb
15223 msg 1 get encb
15224 /cset (setc) def
15225 /mode 6 def
15226 /i 2 def
15227 exit
15228 } if
15229 } if
15230 % anotb before bnota => a
15231 0 abeforeb {
15232 /cset (seta) def
15233 /mode 0 def
15234 exit
15235 } if
15236 % otherwise => b
15237 /cset (setb) def
15238 /mode 1 def
15239 exit
15240 } loop
15241
15242 { % Encode remainder
15243 i msglen eq {exit} if
15244
15245 i numsscr /nums exch def /nchars exch def
15246
15247 % Determine switches and shifts
15248 { % common exit
15249 cset (seta) eq {
15250 % bnota . anotb before bnota => sb1 encode
15251 i msglen 1 sub lt {
15252 msg i get bnota
15253 i 1 add abeforeb and {
15254 sb1 enca
15255 msg i get encb
15256 /i i 1 add def
15257 exit
15258 } if
15259 } if
15260 % bnota . bnota . anotb before bnota => sb2 encode
15261 i msglen 2 sub lt {
15262 msg i get bnota
15263 msg i 1 add get bnota and
15264 i 2 add abeforeb and {
15265 sb2 enca
15266 msg i get encb
15267 msg i 1 add get encb
15268 /i i 2 add def
15269 exit
15270 } if
15271 } if
15272 % bnota => swb
15273 msg i get bnota {
15274 swb enca
15275 /cset (setb) def
15276 exit
15277 } if
15278 % 4 nums . a => sc2 encode
15279 i msglen 4 sub lt {
15280 nums 4 eq
15281 seta msg i 4 add get known and {
15282 sc2 enca
15283 2 {
15284 msg i get fn1 eq {
15285 fn1 encc
15286 /i i 1 add def
15287 } {
15288 msg i 2 getinterval encc
15289 /i i 2 add def
15290 } ifelse
15291 } repeat
15292 exit
15293 } if
15294 } if
15295 % 6 nums . a => sc3 encode
15296 i msglen 6 sub lt {
15297 nums 6 eq
15298 seta msg i 6 add get known and {
15299 sc3 enca
15300 3 {
15301 msg i get fn1 eq {
15302 fn1 encc
15303 /i i 1 add def
15304 } {
15305 msg i 2 getinterval encc
15306 /i i 2 add def
15307 } ifelse
15308 } repeat
15309 exit
15310 } if
15311 } if
15312 % 4+ even nums => swc
15313 nums 4 ge nums 2 mod 0 eq and {
15314 swc enca
15315 /cset (setc) def
15316 exit
15317 } if
15318 % otherwise => encode
15319 msg i get enca
15320 /i i 1 add def
15321 exit
15322 } if
15323 cset (setb) eq {
15324 % anotb . bnota before anotb => sa1 encode
15325 i msglen 1 sub lt {
15326 msg i get anotb
15327 i 1 add bbeforea and {
15328 sa1 encb
15329 msg i get enca
15330 /i i 1 add def
15331 exit
15332 } if
15333 } if
15334 % anotb . anotb . bnota before anotb => sa2 encode
15335 i msglen 2 sub lt {
15336 msg i get anotb
15337 msg i 1 add get anotb and
15338 i 2 add bbeforea and {
15339 sa2 encb
15340 msg i get enca
15341 msg i 1 add get enca
15342 /i i 2 add def
15343 exit
15344 } if
15345 } if
15346 % anotb => swa
15347 msg i get anotb {
15348 swa encb
15349 /cset (seta) def
15350 exit
15351 } if
15352 % 4 nums . b => sc2 encode
15353 i msglen 4 sub lt {
15354 nums 4 eq
15355 setb msg i 4 add get known and {
15356 sc2 encb
15357 2 {
15358 msg i get fn1 eq {
15359 fn1 encc
15360 /i i 1 add def
15361 } {
15362 msg i 2 getinterval encc
15363 /i i 2 add def
15364 } ifelse
15365 } repeat
15366 exit
15367 } if
15368 } if
15369 % 6 nums . b => sc3 encode
15370 i msglen 6 sub lt {
15371 nums 6 eq
15372 setb msg i 6 add get known and {
15373 sc3 encb
15374 3 {
15375 msg i get fn1 eq {
15376 fn1 encc
15377 /i i 1 add def
15378 } {
15379 msg i 2 getinterval encc
15380 /i i 2 add def
15381 } ifelse
15382 } repeat
15383 exit
15384 } if
15385 } if
15386 % 4+ even nums => swc
15387 nums 4 ge nums 2 mod 0 eq and {
15388 swc encb
15389 /cset (setc) def
15390 exit
15391 } if
15392 % otherwise => encode
15393 msg i get encb
15394 /i i 1 add def
15395 exit
15396 } if
15397 cset (setc) eq {
15398 % 2+ nums => encode
15399 nums 2 ge {
15400 msg i get fn1 eq {
15401 fn1 encc
15402 /i i 1 add def
15403 } {
15404 msg i 2 getinterval encc
15405 /i i 2 add def
15406 } ifelse
15407 exit
15408 } if
15409 % b . 2+ even nums => sb1 encode
15410 i msglen 1 sub lt {
15411 setb msg i get known
15412 i 1 add numsscr exch pop dup 2 ge exch 2 mod 0 eq and and {
15413 sb1 encc
15414 msg i get encb
15415 /i i 1 add def
15416 exit
15417 } if
15418 } if
15419 % b . 3+ odd nums => sb2 encode
15420 i msglen 1 sub lt {
15421 setb msg i get known
15422 i 1 add numsscr exch pop dup 3 ge exch 2 mod 1 eq and and {
15423 sb2 encc
15424 msg i get encb
15425 msg i 1 add get encb
15426 /i i 2 add def
15427 exit
15428 } if
15429 } if
15430 % b . b . 2+ even nums => sb2 encode
15431 i msglen 2 sub lt {
15432 setb msg i get known
15433 setb msg i 1 add get known and
15434 i 2 add numsscr exch pop dup 2 ge exch 2 mod 0 eq and and {
15435 sb2 encc
15436 msg i get encb
15437 msg i 1 add get encb
15438 /i i 2 add def
15439 exit
15440 } if
15441 } if
15442 % b . b . 3+ odd nums => sb3 encode
15443 i msglen 3 sub lt {
15444 setb msg i get known
15445 setb msg i 1 add get known and
15446 i 2 add numsscr exch pop dup 3 ge exch 2 mod 1 eq and and {
15447 sb3 encc
15448 msg i get encb
15449 msg i 1 add get encb
15450 msg i 2 add get encb
15451 /i i 3 add def
15452 exit
15453 } if
15454 } if
15455 % b . b . b . 2+ even nums => sb3 encode
15456 i msglen 3 sub lt {
15457 setb msg i get known
15458 setb msg i 1 add get known and
15459 setb msg i 2 add get known and
15460 i 3 add numsscr exch pop dup 2 ge exch 2 mod 0 eq and and {
15461 sb3 encc
15462 msg i get encb
15463 msg i 1 add get encb
15464 msg i 2 add get encb
15465 /i i 3 add def
15466 exit
15467 } if
15468 } if
15469 % anotb before bnota => swa
15470 i abeforeb {
15471 swa encc
15472 /cset (seta) def
15473 exit
15474 } if
15475 % otherwise => swb
15476 swb encc
15477 /cset (setb) def
15478 exit
15479 } if
15480 exit
15481 } loop
15482
15483 } loop
15484 /cws cws 0 j getinterval def
15485 } ifelse
15486
15487 % Basic metrics for the each symbol
15488 % r dcws
15489 {
15490 /metrics [
15491 [ 2 7 ]
15492 [ 3 12 ]
15493 [ 4 17 ]
15494 [ 5 22 ]
15495 [ 6 27 ]
15496 [ 7 32 ]
15497 [ 8 37 ]
15498 [ 9 42 ]
15499 [ 10 47 ]
15500 [ 11 52 ]
15501 [ 12 57 ]
15502 [ 13 62 ]
15503 [ 14 67 ]
15504 [ 15 72 ]
15505 [ 16 77 ]
15506 ] def
15507 } ctxdef
15508
15509 % Select metrics of an appropriate symbol
15510 /urows rows def
15511 metrics {
15512 /m exch def
15513 /r m 0 get def % Columns in symbol
15514 /dcws m 1 get def % Data codewords in symbol
15515 /okay true def
15516 urows 0 ne urows r ne and {/okay false def} if
15517 cws length dcws gt {/okay false def} if
15518 okay {exit} if
15519 } forall
15520
15521 okay not {
15522 /bwipp.code16kNoValidSymbol (Maximum length exceeded or data too large for given options) //raiseerror exec
15523 } if
15524
15525 % Extend cws to ncws codewords by addition of pad characters
15526 /cws [ cws aload pop dcws cws length sub {103} repeat ] def
15527
15528 % Add the start character
15529 /cws [ r 2 sub 7 mul mode add cws aload pop ] def
15530
15531 % Calculate the check characters
15532 0 0 1 dcws {dup 2 add exch cws exch get mul add} for
15533 107 mod /c1 exch def
15534 0 0 1 dcws {dup 1 add exch cws exch get mul add} for
15535 c1 dcws 2 add mul add 107 mod /c2 exch def
15536 /cws [ cws aload pop c1 c2 ] def
15537
15538 options /debugcws known { /bwipp.debugcws cws //raiseerror exec } if
15539
15540 % Create an array containing the character mappings
15541 {
15542 /encs
15543 [ (212222) (222122) (222221) (121223) (121322) (131222) (122213)
15544 (122312) (132212) (221213) (221312) (231212) (112232) (122132)
15545 (122231) (113222) (123122) (123221) (223211) (221132) (221231)
15546 (213212) (223112) (312131) (311222) (321122) (321221) (312212)
15547 (322112) (322211) (212123) (212321) (232121) (111323) (131123)
15548 (131321) (112313) (132113) (132311) (211313) (231113) (231311)
15549 (112133) (112331) (132131) (113123) (113321) (133121) (313121)
15550 (211331) (231131) (213113) (213311) (213131) (311123) (311321)
15551 (331121) (312113) (312311) (332111) (314111) (221411) (431111)
15552 (111224) (111422) (121124) (121421) (141122) (141221) (112214)
15553 (112412) (122114) (122411) (142112) (142211) (241211) (221114)
15554 (413111) (241112) (134111) (111242) (121142) (121241) (114212)
15555 (124112) (124211) (411212) (421112) (421211) (212141) (214121)
15556 (412121) (111143) (111341) (131141) (114113) (114311) (411113)
15557 (411311) (113141) (114131) (311141) (411131) (211412) (211214)
15558 (211232) (211133)
15559 ] def
15560
15561 % Start/stop character encodings
15562 /startencs [
15563 (3211) (2221) (2122) (1411) (1132) (1231) (1114) (3112)
15564 (3211) (2221) (2122) (1411) (1132) (1231) (1114) (3112)
15565 ] def
15566 /stopencsodd [
15567 (3211) (2221) (2122) (1411) (1132) (1231) (1114) (3112)
15568 (1132) (1231) (1114) (3112) (3211) (2221) (2122) (1411)
15569 ] def
15570 /stopencseven [
15571 (2122) (1411) (1132) (1231) (1114) (3112) (1132) (1231)
15572 (1114) (3112) (3211) (2221) (2122) (1411) (3211) (2221)
15573 ] def
15574 } ctxdef
15575
15576 sam -1 eq sam 10 idiv 2 mod 1 eq or {
15577 /stopencs stopencsodd def
15578 } {
15579 /stopencs stopencseven def
15580 } ifelse
15581
15582 % Derive the bits for each row
15583 /rowbits r array def
15584 0 1 r 1 sub {
15585 /i exch def
15586 /sbs [
15587 10
15588 startencs i get {48 sub} forall
15589 1
15590 cws i 5 mul 5 getinterval {
15591 encs exch get {48 sub} forall
15592 } forall
15593 stopencs i get {48 sub} forall
15594 1
15595 ] def
15596 mark
15597 1 sbs {1 index 0 eq {{1}} {{0}} ifelse repeat} forall
15598 counttomark 1 sub array astore exch pop exch pop
15599 rowbits i 3 -1 roll put
15600 } for
15601
15602 % Populate the bitmap
15603 /pixs [
15604 81 sepheight mul {1} repeat
15605 0 1 r 2 sub {
15606 /i exch def
15607 rowheight {rowbits i get aload pop} repeat
15608 sepheight {10 {0} repeat 70 {1} repeat 0} repeat
15609 } for
15610 rowheight {rowbits r 1 sub get aload pop} repeat
15611 81 sepheight mul {1} repeat
15612 ] def
15613
15614 % Return the arguments
15615 <<
15616 /ren /renmatrix
15617 /pixs pixs
15618 /pixx 81
15619 /pixy pixs length 81 idiv
15620 /height pixs length 81 idiv 72 div
15621 /width 81 72 div
15622 /opt options
15623 >>
15624
15625 dontdraw not //renmatrix if
15626
15627 //unloadctx exec
15628
15629 end
15630
15631 }
15632 [/barcode] {null def} forall
15633 bind def
15634 /code16k dup load /uk.co.terryburton.bwipp defineresource pop
15635 end
15636 /setpacking where {pop setpacking} if
15637 %%EndData
15638 %%EndResource
15639 % --END ENCODER code16k--
15640
15641 % --BEGIN ENCODER code49--
15642 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix--
15643 % --DESC: Code 49
15644 % --EXAM: MULTIPLE ROWS IN CODE 49
15645 % --EXOP:
15646 % --RNDR: renmatrix
15647 %%BeginResource: uk.co.terryburton.bwipp code49 0.0 2025111800 271722 291269
15648 %%BeginData: 1096 ASCII Lines
15649 /setpacking where {pop currentpacking true setpacking} if
15650 10 dict
15651 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
15652 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
15653 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
15654 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
15655 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
15656 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
15657 begin
15658 /code49 {
15659
15660 20 dict begin
15661
15662 /ctx null def
15663 /dontdraw false def
15664 /sam -1 def
15665 /append false def
15666 /rows 0 def
15667 /rowheight 8 def
15668 /sepheight 1 def
15669 /parse false def
15670 /parsefnc false def
15671
15672 //processoptions exec /options exch def
15673 /barcode exch def
15674
15675 rows 0 ne rows 2 lt rows 8 gt or and {
15676 /bwipp.code49badRows (Code 49 must have 2 to 8 rows) //raiseerror exec
15677 } if
15678
15679 rowheight 8 lt {
15680 /bwipp.code49badRowHeight (Code 49 must have rowheight of at least 8) //raiseerror exec
15681 } if
15682
15683 sepheight 1 lt {
15684 /bwipp.code49badSepHeight (Code 49 must have sepheight of at least 1) //raiseerror exec
15685 } if
15686
15687 append sam -1 ne and {
15688 /bwipp.code49samAndAppend (sam and append cannot be specified together) //raiseerror exec
15689 } if
15690
15691 sam -1 ne {
15692 true
15693 1 {
15694 sam dup 12 lt exch 99 gt or { pop false exit } if
15695 sam 10 mod 2 lt { pop false exit } if
15696 sam 10 idiv sam 10 mod gt { pop false exit } if
15697 } repeat
15698 not {
15699 /bwipp.code49badSAM (SAM must be formatted as "NM" for Nth of M symbols, from 2 to 9 symbols) //raiseerror exec
15700 } if
15701 } if
15702
15703 /code49 //loadctx exec
15704
15705 {
15706 /s1 -1 def /s2 -2 def /fn1 -3 def /fn2 -4 def /fn3 -5 def /ns -6 def
15707 } ctxdef
15708
15709 % Parse the input
15710 /fncvals <<
15711 /parse parse
15712 /parsefnc parsefnc
15713 (FNC1) fn1
15714 (FNC2) fn2
15715 (FNC3) fn3
15716 >> def
15717 /msg barcode fncvals //parseinput exec def
15718 /msglen msg length def
15719
15720 msg {
15721 127 gt {
15722 /bwipp.code49badCharacter (Code 49 can only support ASCII characters with values 0 to 127) //raiseerror exec
15723 } if
15724 } forall
15725
15726 {
15727 % Character encodings
15728 /charmap [
15729 (0) (1) (2) (3) (4) (5) (6) (7) (8) (9)
15730 (A) (B) (C) (D) (E) (F) (G) (H) (I) (J) (K) (L) (M)
15731 (N) (O) (P) (Q) (R) (S) (T) (U) (V) (W) (X) (Y) (Z)
15732 (-) (.) ( ) ($) (/) (+) (%)
15733 s1 s2 fn1 fn2 fn3 ns
15734 ] def
15735
15736 % Invert charmap to give character to value map
15737 /charvals 49 dict def
15738 0 1 48 {
15739 /i exch def
15740 charmap i get
15741 dup type /stringtype eq {0 get} if % convert string to ASCII if required
15742 charvals exch i put
15743 } for
15744
15745 % Shifted character encodings
15746 /combos
15747 [ (1 ) (1A) (1B) (1C) (1D) (1E) (1F) (1G) (1H) (1I) (1J) (1K) (1L) (1M) (1N) (1O)
15748 (1P) (1Q) (1R) (1S) (1T) (1U) (1V) (1W) (1X) (1Y) (1Z) (11) (12) (13) (14) (15)
15749 ( ) (16) (17) (18) ( $) ( %) (19) (10) (1-) (1.) (1$) ( +) (1/) ( -) ( .) ( /)
15750 ( 0) ( 1) ( 2) ( 3) ( 4) ( 5) ( 6) ( 7) ( 8) ( 9) (1+) (21) (22) (23) (24) (25)
15751 (26) ( A) ( B) ( C) ( D) ( E) ( F) ( G) ( H) ( I) ( J) ( K) ( L) ( M) ( N) ( O)
15752 ( P) ( Q) ( R) ( S) ( T) ( U) ( V) ( W) ( X) ( Y) ( Z) (27) (28) (29) (20) (2-)
15753 (2.) (2A) (2B) (2C) (2D) (2E) (2F) (2G) (2H) (2I) (2J) (2K) (2L) (2M) (2N) (2O)
15754 (2P) (2Q) (2R) (2S) (2T) (2U) (2V) (2W) (2X) (2Y) (2Z) (2$) (2/) (2+) (2%) (2 )
15755 ] def
15756 0 1 127 {
15757 /i exch def
15758 combos i get dup 0 get /c1 exch def 1 get /c2 exch def
15759 c1 49 eq { % s1 char
15760 charvals i [ charvals s1 get charvals c2 get ] put
15761 } if
15762 c1 50 eq { % s2 char
15763 charvals i [ charvals s2 get charvals c2 get ] put
15764 } if
15765 } for
15766 } ctxdef
15767
15768 /encodealpha {
15769 charvals exch get
15770 dup type /arraytype ne {1 array astore} if
15771 dup cws exch j exch putinterval
15772 length j add /j exch def
15773 } def
15774
15775 /base48 {
15776 0 exch {48 sub exch 10 mul add} forall
15777 [ 3 1 roll exch 1 sub {dup 48 mod exch 48 idiv} repeat ]
15778 [ exch dup length 1 sub -1 0 {1 index exch get exch} for pop ]
15779 dup cws exch j exch putinterval
15780 length j add /j exch def
15781 } def
15782
15783 /encodenumeric {
15784 /nums exch def
15785 /pre nums length dup 5 mod dup 2 ne {sub} {sub 5 sub} ifelse def
15786 0 5 pre 1 sub {nums exch 5 getinterval 3 exch base48} for
15787 /nums nums pre nums length pre sub getinterval def
15788 nums length
15789 dup 1 eq {nums i get encodealpha} if
15790 dup 3 eq {2 nums base48} if
15791 dup 4 eq {3 [49 48 nums aload pop] base48} if
15792 7 eq {
15793 3 [49 48 nums 0 4 getinterval aload pop] base48
15794 2 nums 4 3 getinterval base48
15795 } if
15796 } def
15797
15798 % Pre-compute alphanumeric and numeric runlengths
15799 /numericruns [ msglen {0} repeat 0 ] def
15800 msglen 1 sub -1 0 {
15801 /i exch def
15802 msg i get
15803 dup 48 ge exch 57 le and {
15804 numericruns i numericruns i 1 add get 1 add put
15805 } {
15806 numericruns i 0 put
15807 } ifelse
15808 } for
15809
15810 /cws msglen 2 mul 1 add array def
15811
15812 {
15813 /samval [
15814 12 22
15815 13 23 33
15816 14 24 34 44
15817 15 25 35 45 55
15818 16 26 36 46 56 66
15819 17 27 37 47 57 67 77
15820 18 28 38 48 58 68 78 88
15821 19 29 39 49 59 69 79 89 99
15822 ] def
15823 } ctxdef
15824
15825 % Autoselect and encode the starting mode
15826 { % common exit
15827 append { % Concatenate alphanumeric mode
15828 /mode 1 def
15829 /method (alpha) def
15830 /i 0 def /j 0 def
15831 exit
15832 } if
15833 sam -1 ne { % Group alphanumeric mode
15834 /mode 3 def
15835 cws 0 0 1 43 { dup samval exch get sam ne {pop} if } for 1 add put
15836 /method (alpha) def
15837 /i 0 def /j 1 def
15838 exit
15839 } if
15840 numericruns 0 get 5 ge { % Numeric mode
15841 /mode 2 def
15842 /method (numeric) def /i 0 def /j 0 def
15843 exit
15844 } if
15845 charvals msg 0 get get
15846 dup type /arraytype ne { % Regular alphanumeric mode
15847 pop
15848 /mode 0 def
15849 /method (alpha) def
15850 /i 0 def /j 0 def
15851 exit
15852 } if
15853 % Alphanumeric mode starting shift 1 (mode=4) or shift 2 (mode=5)
15854 0 get 43 eq {4} {5} ifelse /mode exch def
15855 cws 0 charvals msg 0 get get 1 get put
15856 /method (alpha) def
15857 /i 1 def /j 1 def
15858 exit
15859 } loop
15860
15861 % Encode remainder
15862 {
15863 i msglen eq {exit} if
15864 { % not a loop but common exit point
15865 method (alpha) eq {
15866 numericruns i get 5 ge {
15867 ns encodealpha
15868 /method (numeric) def
15869 exit
15870 } if
15871 msg i get encodealpha
15872 /i i 1 add def
15873 exit
15874 } if
15875 method (numeric) eq {
15876 numericruns i get 5 lt {
15877 ns encodealpha
15878 /method (alpha) def
15879 exit
15880 } if
15881 msg i numericruns i get getinterval encodenumeric
15882 /i i numericruns i get add def
15883 exit
15884 } if
15885 } loop
15886 } loop
15887 /cws cws 0 j getinterval def
15888
15889 % Basic metrics for the each symbol
15890 % r dcws
15891 {
15892 /metrics [
15893 [ 2 9 ]
15894 [ 3 16 ]
15895 [ 4 23 ]
15896 [ 5 30 ]
15897 [ 6 37 ]
15898 [ 7 42 ]
15899 [ 8 49 ]
15900 ] def
15901 } ctxdef
15902
15903 % Select metrics of an appropriate symbol
15904 /urows rows def
15905 metrics {
15906 /m exch def
15907 /r m 0 get def % Columns in symbol
15908 /dcws m 1 get def % Data codewords in symbol
15909 /okay true def
15910 urows 0 ne urows r ne and {/okay false def} if
15911 cws length dcws gt {/okay false def} if
15912 okay {exit} if
15913 } forall
15914
15915 okay not {
15916 /bwipp.code49noValidSymbol (Maximum length exceeded) //raiseerror exec
15917 } if
15918
15919 % Extend cws to ncws codewords by addition of pad characters
15920 /cws [ cws aload pop dcws cws length sub {48} repeat ] def
15921
15922 % Populate code character array and add row check characters
15923 /ccs r 8 mul array def
15924 /j 0 def
15925 0 1 r 2 sub {
15926 /i exch def
15927 /cc cws j 7 getinterval def
15928 ccs i 8 mul cc putinterval
15929 ccs i 8 mul 7 add 0 cc {add} forall 49 mod put
15930 /j j 7 add def
15931 } for
15932 j dcws lt {
15933 ccs ccs length 8 sub cws j dcws j sub getinterval putinterval
15934 } if
15935
15936 % Place row count character
15937 /cr7 r 2 sub 7 mul mode add def
15938 ccs ccs length 2 sub cr7 put
15939
15940 % Calculate the symbol check characters
15941 {
15942 [ 1 9 31 26 2 12 17 23 37 18 22 6 27 44 15 43 39
15943 11 13 5 41 33 36 8 4 32 3 19 40 25 29 10 24 30 ]
15944 dup [ exch 20 exch 0 32 getinterval aload pop ] /weightx exch def
15945 dup [ exch 16 exch 1 32 getinterval aload pop ] /weighty exch def
15946 [ exch 38 exch 2 32 getinterval aload pop ] /weightz exch def
15947 } ctxdef
15948 /calccheck {
15949 /weights exch def
15950 /score 0 def
15951 0 1 r 1 sub 8 mul 2 idiv 1 sub {
15952 /i exch def
15953 ccs i 2 mul get 49 mul ccs i 2 mul 1 add get add
15954 weights i 1 add get mul /score exch score add def
15955 } for
15956 score
15957 } def
15958 /lastrow ccs ccs length 8 sub 8 getinterval def
15959
15960 % wr1 check character
15961 r 7 ge {
15962 cr7 weightz 0 get mul weightz calccheck add 2401 mod
15963 dup 49 idiv exch 49 mod 2 array astore
15964 lastrow 0 3 -1 roll putinterval
15965 } if
15966 /wr1 lastrow 0 get 49 mul lastrow 1 get add def
15967
15968 % wr2 check character
15969 cr7 weighty 0 get mul weighty calccheck add
15970 wr1 weighty r 4 mul 3 sub get mul add
15971 2401 mod dup /wr2 exch def
15972 dup 49 idiv exch 49 mod 2 array astore
15973 lastrow 2 3 -1 roll putinterval
15974
15975 % wr3 check character
15976 cr7 weightx 0 get mul weightx calccheck add
15977 wr1 weightx r 4 mul 3 sub get mul add
15978 wr2 weightx r 4 mul 2 sub get mul add
15979 2401 mod
15980 dup 49 idiv exch 49 mod 2 array astore
15981 lastrow 4 3 -1 roll putinterval
15982
15983 % Place last row check character
15984 ccs ccs length 8 sub 7 getinterval 0 exch {add} forall 49 mod
15985 ccs ccs length 1 sub 3 -1 roll put
15986
15987 options /debugcws known { /bwipp.debugcws ccs //raiseerror exec } if
15988
15989 {
15990 /patterns [
15991 [ % Even parity
15992 (11521132) (25112131) (14212132) (25121221) (14221222) (12412132) (23321221)
15993 (12421222) (21521221) (15112222) (15121312) (13312222) (24221311) (13321312)
15994 (11512222) (22421311) (11521312) (25112311) (14212312) (23312311) (12412312)
15995 (21512311) (16121131) (14321131) (12521131) (15212131) (15221221) (13412131)
15996 (13421221) (11612131) (16112221) (16121311) (14312221) (14321311) (12512221)
15997 (12521311) (15212311) (13412311) (11612311) (11131135) (31131133) (51131131)
15998 (21122134) (41122132) (21131224) (41131222) (11113135) (31113133) (51113131)
15999 (11122225) (31122223) (51122221) (11131315) (31131313) (51131311) (21113224)
16000 (41113222) (21122314) (41122312) (11113315) (31113313) (51113311) (12131134)
16001 (32131132) (21231133) (41231131) (22122133) (42122131) (11222134) (22131223)
16002 (42131221) (11231224) (31231222) (12113134) (32113132) (12122224) (32122222)
16003 (12131314) (32131312) (21231313) (41231311) (22113223) (42113221) (11213224)
16004 (22122313) (42122311) (11222314) (31222312) (12113314) (32113312) (21213313)
16005 (41213311) (13131133) (33131131) (22231132) (11331133) (31331131) (23122132)
16006 (12222133) (23131222) (12231223) (32231221) (21331222) (13113133) (33113131)
16007 (13122223) (33122221) (11313133) (13131313) (33131311) (11322223) (22231312)
16008 (11331313) (31331311) (23113222) (12213223) (23122312) (12222313) (32222311)
16009 (21322312) (13113313) (33113311) (22213312) (11313313) (31313311) (14131132)
16010 (23231131) (12331132) (21431131) (24122131) (13222132) (24131221) (13231222)
16011 (11422132) (22331221) (11431222) (14113132) (14122222) (12313132) (14131312)
16012 (12322222) (23231311) (12331312) (21431311) (24113221) (13213222) (24122311)
16013 (13222312) (11413222) (22322311) (11422312) (14113312) (23213311) (12313312)
16014 (21413311) (15131131) (13331131) (14222131) (14231221) (12422131) (12431221)
16015 (15113131) (15122221) (13313131) (15131311) (13322221) (11513131) (13331311)
16016 (11522221) (14213221) (14222311) (12413221) (12422311) (15113311) (13313311)
16017 (11513311) (11141134) (31141132) (21132133) (41132131) (21141223) (41141221)
16018 (11123134) (31123132) (11132224) (31132222) (11141314) (31141312) (21114133)
16019 (41114131) (21123223) (41123221) (21132313) (41132311) (11114224) (31114222)
16020 (11123314) (31123312) (21114313) (41114311) (12141133) (32141131) (21241132)
16021 (22132132) (11232133) (22141222) (11241223) (31241221) (12123133) (32123131)
16022 (12132223) (32132221) (12141313) (32141311) (21241312) (22114132) (11214133)
16023 (22123222) (11223223) (22132312) (11232313) (31232311) (12114223) (32114221)
16024 (12123313) (32123311) (21223312) (22114312) (11214313) (31214311) (13141132)
16025 (22241131) (11341132) (23132131) (12232132) (23141221) (12241222) (21341221)
16026 (13123132) (13132222) (11323132) (13141312) (11332222) (22241311) (11341312)
16027 (23114131) (12214132) (23123221) (12223222) (23132311) (12232312) (21332311)
16028 (13114222) (13123312) (11314222) (22223311) (11323312) (23114311) (12214312)
16029 (21314311) (14141131) (12341131) (13232131) (13241221) (11432131) (14123131)
16030 (14132221) (12323131) (14141311) (12332221) (12341311) (13214131) (13223221)
16031 (11414131) (13232311) (11423221) (11432311) (14114221) (14123311) (12314221)
16032 (12323311) (13214311) (11414311) (11151133) (31151131) (21142132) (21151222)
16033 (11133133) (31133131) (11142223) (31142221) (11151313) (31151311) (21124132)
16034 (21133222) (21142312) (11115133) (31115131) (11124223) (31124221) (11133313)
16035 (31133311) (21115222) (21124312) (12151132) (21251131) (22142131) (11242132)
16036 (22151221) (11251222) (12133132) (12142222) (12151312) (21251311) (22124131)
16037 (11224132) (22133221) (11233222) (22142311) (11242312) (12115132) (12124222)
16038 (12133312) (21233311) (22115221) (11215222) (22124311) (11224312) (13151131)
16039 (12242131) (12251221) (13133131) (13142221) (11333131) (13151311) (11342221)
16040 (12224131) (12233221) (12242311) (13115131) (13124221) (11315131) (13133311)
16041 (11324221) (11333311) (12215221) (12224311) (11161132) (21152131) (21161221)
16042 (11143132) (11152222) (11161312) (21134131) (21143221) (21152311) (11125132)
16043 (11134222) (11143312) (21116131) (21125221) (21134311) (12161131) (11252131)
16044 (12143131) (12152221) (12161311) (11234131) (11243221) (11252311) (12125131)
16045 (12134221) (12143311) (11216131) (11225221) (11234311) (11111236) (31111234)
16046 (51111232) (21111325) (41111323) (61111321) (11111416) (31111414) (51111412)
16047 (31211143) (51211141) (12111235) (32111233) (52111231) (21211234) (41211232)
16048 (22111324) (42111322) (11211325) (31211323) (51211321) (12111415) (32111413)
16049 (52111411) (21211414) (41211412) (12211144) (32211142) (21311143) (41311141)
16050 (13111234) (33111232) (22211233) (42211231) (11311234) (31311232) (23111323)
16051 (43111321) (12211324) (32211322) (21311323) (41311321) (13111414) (33111412)
16052 (22211413) (42211411) (11311414) (31311412) (13211143) (33211141) (22311142)
16053 (11411143) (31411141) (14111233) (34111231) (23211232) (12311233) (32311231)
16054 (21411232) (24111322) (13211323) (33211321) (22311322) (11411323) (31411321)
16055 (14111413) (34111411) (23211412) (12311413) (32311411) (21411412) (14211142)
16056 (23311141) (12411142) (21511141) (15111232) (24211231) (13311232) (22411231)
16057 (11511232) (25111321) (14211322) (23311321) (12411322) (21511321) (15111412)
16058 (24211411) (13311412) (22411411) (11511412) (15211141) (13411141) (11611141)
16059 (16111231) (14311231) (12511231) (15211321) (13411321) (11611321) (16111411)
16060 (14311411) (12511411) (21121144) (41121142) (11112145) (31112143) (51112141)
16061 (11121235) (31121233) (51121231) (21112234) (41112232) (21121324) (41121322)
16062 (11112325) (31112323) (51112321) (11121415) (31121413) (51121411) (21112414)
16063 (41112412) (22121143) (42121141) (11221144) (31221142) (12112144) (32112142)
16064 (12121234) (32121232) (21221233) (41221231) (22112233) (42112231) (11212234)
16065 (22121323) (42121321) (11221324) (31221322) (12112324) (32112322) (12121414)
16066 (32121412) (21221413) (41221411) (22112413) (42112411) (11212414) (31212412)
16067 (23121142) (12221143) (32221141) (21321142) (13112143) (33112141) (13121233)
16068 (33121231) (11312143) (22221232) (11321233) (31321231) (23112232) (12212233)
16069 (23121322) (12221323) (32221321) (21321322) (13112323) (33112321) (13121413)
16070 (33121411) (11312323) (22221412) (11321413) (31321411) (23112412) (12212413)
16071 (32212411) (21312412) (24121141) (13221142) (22321141) (11421142) (14112142)
16072 (14121232) (12312142) (23221231) (12321232) (21421231) (24112231) (13212232)
16073 (24121321) (13221322) (11412232) (22321321) (11421322) (14112322) (14121412)
16074 (12312322) (23221411) (12321412) (21421411) (24112411) (13212412) (22312411)
16075 (11412412) (14221141) (12421141) (15112141) (15121231) (13312141) (13321231)
16076 (11512141) (11521231) (14212231) (14221321) (12412231) (12421321) (15112321)
16077 (15121411) (13312321) (13321411) (11512321) (11521411) (14212411) (12412411)
16078 (21131143) (41131141) (11122144) (31122142) (11131234) (31131232) (21113143)
16079 (41113141) (21122233) (41122231) (21131323) (41131321) (11113234) (31113232)
16080 (11122324) (31122322) (11131414) (31131412) (21113323) (41113321) (21122413)
16081 (41122411) (11113414) (31113412) (22131142) (11231143) (31231141) (12122143)
16082 (32122141) (12131233) (32131231) (21231232) (22113142) (11213143) (22122232)
16083 (11222233) (22131322) (11231323) (31231321) (12113233) (32113231) (12122323)
16084 (32122321) (12131413) (32131411) (21231412) (22113322) (11213323) (22122412)
16085 (11222413) (31222411) (12113413) (32113411) (21213412) (23131141) (12231142)
16086 (21331141) (13122142) (13131232) (11322142) (22231231) (11331232) (23113141)
16087 (12213142) (23122231) (12222232) (23131321) (12231322) (21331321) (13113232)
16088 (13122322) (11313232) (13131412) (11322322) (22231411) (11331412) (23113321)
16089 (12213322) (23122411) (12222412) (21322411) (13113412) (22213411) (11313412)
16090 (13231141) (11431141) (14122141) (14131231) (12322141) (12331231) (13213141)
16091 (13222231) (11413141) (13231321) (11422231) (11431321) (14113231) (14122321)
16092 (12313231) (14131411) (12322321) (12331411) (13213321) (13222411) (11413321)
16093 (11422411) (14113411) (12313411) (21141142) (11132143) (31132141) (11141233)
16094 (31141231) (21123142) (21132232) (21141322) (11114143) (31114141) (11123233)
16095 (31123231) (11132323) (31132321) (11141413) (31141411) (21114232) (21123322)
16096 (21132412) (11114323) (31114321) (11123413) (31123411) (22141141) (11241142)
16097 (12132142) (12141232) (21241231) (22123141) (11223142) (22132231) (11232232)
16098 (22141321) (11241322) (12114142) (12123232) (12132322) (12141412) (21241411)
16099 (22114231) (11214232) (22123321) (11223322) (22132411) (11232412) (12114322)
16100 (12123412) (21223411) (12241141) (13132141) (13141231) (11332141) (11341231)
16101 (12223141) (12232231) (12241321) (13114141) (13123231) (11314141) (13132321)
16102 (11323231) (13141411) (11332321) (11341411) (12214231) (12223321) (12232411)
16103 (13114321) (13123411) (11314321) (11323411) (21151141) (11142142) (11151232)
16104 (21133141) (21142231) (21151321) (11124142) (11133232) (11142322) (11151412)
16105 (21115141) (21124231) (21133321) (21142411) (11115232) (11124322) (11133412)
16106 (11251141) (12142141) (12151231) (11233141) (11242231) (11251321) (12124141)
16107 (12133231) (12142321) (12151411) (11215141) (11224231) (11233321) (11242411)
16108 (12115231) (12124321) (12133411) (11152141) (11161231) (11134141) (11143231)
16109 (11152321) (11161411) (11116141) (11125231) (11134321) (11143411) (21111244)
16110 (41111242) (11111335) (31111333) (51111331) (21111424) (41111422) (11111515)
16111 (31111513) (51111511) (21211153) (41211151) (22111243) (42111241) (11211244)
16112 (31211242) (12111334) (32111332) (21211333) (41211331) (22111423) (42111421)
16113 (11211424) (31211422) (12111514) (32111512) (21211513) (41211511) (22211152)
16114 (11311153) (31311151) (23111242) (12211243) (32211241) (21311242) (13111333)
16115 (33111331) (22211332) (11311333) (31311331) (23111422) (12211423) (32211421)
16116 (21311422) (13111513) (33111511) (22211512) (11311513) (31311511) (23211151)
16117 (12311152) (21411151) (24111241) (13211242) (22311241) (11411242) (14111332)
16118 (23211331) (12311332) (21411331) (24111421) (13211422) (22311421) (11411422)
16119 (14111512) (23211511) (12311512) (21411511) (13311151) (11511151) (14211241)
16120 (12411241) (15111331) (13311331) (11511331) (14211421) (12411421) (15111511)
16121 (13311511) (11511511) (31121152) (21112153) (41112151) (21121243) (41121241)
16122 (11112244) (31112242) (11121334) (31121332) (21112333) (41112331) (21121423)
16123 (41121421) (11112424) (31112422) (11121514) (31121512) (21112513) (41112511)
16124 (12121153) (32121151) (21221152) (22112152) (11212153) (22121242) (11221243)
16125 (31221241) (12112243) (32112241) (12121333) (32121331) (21221332) (22112332)
16126 (11212333) (22121422) (11221423) (31221421) (12112423) (32112421) (12121513)
16127 (32121511) (21221512) (22112512) (11212513) (31212511) (13121152) (22221151)
16128 (11321152) (23112151) (12212152) (23121241) (12221242) (21321241) (13112242)
16129 (13121332) (11312242) (22221331) (11321332) (23112331) (12212332) (23121421)
16130 (12221422) (21321421) (13112422) (13121512) (11312422) (22221511) (11321512)
16131 (23112511) (12212512) (21312511) (14121151) (12321151) (13212151) (13221241)
16132 (11412151) (11421241) (14112241) (14121331) (12312241) (12321331) (13212331)
16133 (13221421) (11412331) (11421421) (14112421) (14121511) (12312421) (12321511)
16134 (13212511) (11412511) (11131153) (31131151) (21122152) (21131242) (11113153)
16135 (31113151) (11122243) (31122241) (11131333) (31131331) (21113242) (21122332)
16136 (21131422) (11113333) (31113331) (11122423) (31122421) (11131513) (31131511)
16137 (21113422) (21122512) (12131152) (21231151) (22122151) (11222152) (22131241)
16138 (11231242) (12113152) (12122242) (12131332) (21231331) (22113241) (11213242)
16139 (22122331) (11222332) (22131421) (11231422) (12113332) (12122422) (12131512)
16140 (21231511) (22113421) (11213422) (22122511) (11222512) (13131151) (11331151)
16141 (12222151) (12231241) (13113151) (13122241) (11313151) (13131331) (11322241)
16142 (11331331) (12213241) (12222331) (12231421) (13113331) (13122421) (11313331)
16143 (13131511) (11322421) (11331511) (12213421) (12222511) (11141152) (21132151)
16144 (21141241) (11123152) (11132242) (11141332) (21114151) (21123241) (21132331)
16145 (21141421) (11114242) (11123332) (11132422) (11141512) (21114331) (21123421)
16146 (21132511) (12141151) (11232151) (11241241) (12123151) (12132241) (12141331)
16147 (11214151) (11223241) (11232331) (11241421) (12114241) (12123331) (12132421)
16148 (12141511) (11214331) (11223421) (11232511) (11151151) (11133151) (11142241)
16149 (11151331) (11115151) (11124241) (11133331) (11142421) (11151511) (11111254)
16150 (31111252) (21111343) (41111341) (11111434) (31111432) (21111523) (41111521)
16151 (11111614) (31111612) (31211161) (12111253) (32111251) (21211252) (22111342)
16152 (11211343) (31211341) (12111433) (32111431) (21211432) (22111522) (11211523)
16153 (31211521) (12111613) (32111611) (21211612) (12211162) (21311161) (13111252)
16154 (22211251) (11311252) (23111341) (12211342) (21311341) (13111432) (22211431)
16155 (11311432) (23111521) (12211522) (21311521) (13111612) (22211611) (11311612)
16156 (13211161) (11411161) (14111251) (12311251) (13211341) (11411341) (14111431)
16157 (12311431) (13211521) (11411521) (14111611) (12311611) (21121162) (11112163)
16158 (31112161) (11121253) (31121251) (21112252) (21121342) (11112343) (31112341)
16159 (11121433) (31121431) (21112432) (21121522) (11112523) (31112521) (11121613)
16160 (31121611) (22121161) (11221162) (12112162) (12121252) (21221251) (22112251)
16161 (11212252) (22121341) (11221342) (12112342) (12121432) (21221431) (22112431)
16162 (11212432) (22121521) (11221522) (12112522) (12121612) (21221611) (12221161)
16163 (13112161) (13121251) (11312161) (11321251) (32121115) (52121113) (21221116)
16164 (41221114) (61221112) (22112116) (42112114) (31212115) (51212113) (13121116)
16165 (33121114) (22221115) (42221113) (11321116) (31321114) (51321112) (23112115)
16166 (43112113) (12212116) (32212114) (52212112) (21312115) (41312113) (61312111)
16167 (14121115) (34121113) (23221114) (43221112) (12321115) (32321113) (52321111)
16168 (21421114) (41421112) (24112114) (13212115) (33212113) (22312114) (42312112)
16169 (11412115) (31412113) (51412111) (15121114) (24221113) (13321114) (33321112)
16170 (22421113) (42421111) (11521114) (31521112) (25112113) (14212114) (34212112)
16171 (23312113) (43312111) (12412114) (32412112) (21512113) (41512111) (16121113)
16172 (25221112) (14321113) (34321111) (23421112) (12521113) (32521111) (15212113)
16173 (24312112) (13412113) (33412111) (22512112) (11612113) (31612111) (31131115)
16174 (51131113) (21122116) (41122114) (61122112) (31113115) (51113113) (12131116)
16175 (32131114) (52131112) (21231115) (41231113) (61231111) (22122115) (42122113)
16176 (11222116) (31222114) (51222112) (12113116) (32113114) (52113112) (21213115)
16177 (41213113) (61213111) (13131115) (33131113) (22231114) (42231112) (11331115)
16178 (31331113) (51331111) (23122114) (43122112) (12222115) (32222113) (52222111)
16179 (21322114) (41322112) (13113115) (33113113) (22213114) (42213112) (11313115)
16180 (31313113) (51313111) (14131114) (34131112) (23231113) (43231111) (12331114)
16181 (32331112) (21431113) (41431111) (24122113) (13222114) (33222112) (22322113)
16182 (42322111) (11422114) (31422112) (14113114) (34113112) (23213113) (43213111)
16183 (12313114) (32313112) (21413113) (41413111) (15131113) (24231112) (13331113)
16184 (33331111) (22431112) (25122112) (14222113) (34222111) (23322112) (12422113)
16185 (32422111) (21522112) (15113113) (24213112) (13313113) (33313111) (22413112)
16186 (11513113) (31513111) (16131112) (25231111) (14331112) (23431111) (15222112)
16187 (24322111) (13422112) (22522111) (16113112) (25213111) (14313112) (23413111)
16188 (12513112) (21613111) (11141116) (31141114) (51141112) (21132115) (41132113)
16189 (61132111) (11123116) (31123114) (51123112) (21114115) (41114113) (61114111)
16190 (12141115) (32141113) (52141111) (21241114) (41241112) (22132114) (42132112)
16191 (11232115) (31232113) (51232111) (12123115) (32123113) (52123111) (21223114)
16192 (41223112) (22114114) (42114112) (11214115) (31214113) (51214111) (13141114)
16193 (33141112) (22241113) (42241111) (11341114) (31341112) (23132113) (43132111)
16194 (12232114) (32232112) (21332113) (41332111) (13123114) (33123112) (22223113)
16195 (42223111) (11323114) (31323112) (23114113) (43114111) (12214114) (32214112)
16196 (21314113) (41314111) (14141113) (34141111) (23241112) (12341113) (32341111)
16197 (24132112) (13232113) (33232111) (22332112) (11432113) (31432111) (14123113)
16198 (34123111) (23223112) (12323113) (32323111) (21423112) (24114112) (13214113)
16199 (33214111) (22314112) (11414113) (31414111) (15141112) (24241111) (13341112)
16200 (25132111) (14232112) (23332111) (12432112) (15123112) (24223111) (13323112)
16201 (22423111) (11523112) (25114111) (14214112) (23314111) (12414112) (21514111)
16202 (16141111) (14341111) (15232111) (13432111) (16123111) (14323111) (12523111)
16203 (15214111) (13414111) (11614111) (11151115) (31151113) (51151111) (21142114)
16204 (41142112) (11133115) (31133113) (51133111) (21124114) (41124112) (11115115)
16205 (31115113) (51115111) (12151114) (32151112) (21251113) (41251111) (22142113)
16206 (42142111) (11242114) (31242112) (12133114) (32133112) (21233113) (41233111)
16207 (22124113) (42124111) (11224114) (31224112) (12115114) (32115112) (21215113)
16208 (41215111) (13151113) (33151111) (22251112) (23142112) (12242113) (32242111)
16209 (21342112) (13133113) (33133111) (22233112) (11333113) (31333111) (23124112)
16210 (12224113) (32224111) (21324112) (13115113) (33115111) (22215112) (11315113)
16211 (31315111) (14151112) (23251111) (24142111) (13242112) (22342111) (14133112)
16212 (23233111) (12333112) (21433111) (24124111) (13224112) (22324111) (11424112)
16213 (14115112) (23215111) (12315112) (21415111) (15151111) (14242111) (15133111)
16214 (13333111) (14224111) (12424111) (15115111) (13315111) (11515111) (11161114)
16215 (31161112) (21152113) (41152111) (11143114) (31143112) (21134113) (41134111)
16216 (11125114) (31125112) (21116113) (41116111) (12161113) (32161111) (22152112)
16217 (11252113) (31252111) (12143113) (32143111) (21243112) (22134112) (11234113)
16218 (31234111) (12125113) (32125111) (21225112) (22116112) (11216113) (31216111)
16219 (13161112) (23152111) (12252112) (13143112) (22243111) (11343112) (23134111)
16220 (12234112) (21334111) (13125112) (22225111) (11325112) (23116111) (12216112)
16221 (21316111) (14161111) (13252111) (14143111) (12343111) (13234111) (11434111)
16222 (14125111) (12325111) (13216111) (11416111) (31111216) (51111214) (31211125)
16223 (51211123) (32111215) (52111213) (21211216) (41211214) (61211212) (12211126)
16224 (32211124) (52211122) (21311125) (41311123) (61311121) (13111216) (33111214)
16225 (22211215) (42211213) (11311216) (31311214) (51311212) (13211125) (33211123)
16226 (22311124) (42311122) (11411125) (31411123) (51411121) (14111215) (34111213)
16227 (23211214) (43211212) (12311215) (32311213) (52311211) (21411214) (41411212)
16228 (14211124) (34211122) (23311123) (43311121) (12411124) (32411122) (21511123)
16229 (41511121) (15111214) (24211213) (13311214) (33311212) (22411213) (42411211)
16230 (11511214) (31511212) (15211123) (24311122) (13411123) (33411121) (22511122)
16231 (11611123) (31611121) (16111213) (25211212) (14311213) (34311211) (23411212)
16232 (12511213) (32511211) (21611212) (21121126) (41121124) (61121122) (31112125)
16233 (51112123) (31121215) (51121213) (21112216) (41112214) (61112212) (22121125)
16234 (42121123) (11221126) (31221124) (51221122) (12112126) (32112124) (52112122)
16235 (12121216) (32121214) (52121212) (21221215) (41221213) (61221211) (22112215)
16236 (42112213) (11212216) (31212214) (51212212) (23121124) (43121122) (12221125)
16237 (32221123) (52221121) (21321124) (41321122) (13112125) (33112123) (13121215)
16238 (33121213) (11312125) (22221214) (42221212) (11321215) (31321213) (51321211)
16239 (23112214) (43112212) (12212215) (32212213) (52212211) (21312214) (41312212)
16240 (24121123) (13221124) (33221122) (22321123) (42321121) (11421124) (31421122)
16241 (14112124) (34112122) (14121214) (34121212) (12312124) (23221213) (43221211)
16242 (12321214) (32321212) (21421213) (41421211) (24112213) (13212214) (33212212)
16243 (22312213) (42312211) (11412214) (31412212) (25121122) (14221123) (34221121)
16244 (23321122) (12421123) (32421121) (21521122) (15112123) (15121213) (13312123)
16245 (24221212) (13321213) (33321211) (11512123) (22421212) (11521213) (31521211)
16246 (25112212) (14212213) (34212211) (23312212) (12412213) (32412211) (21512212)
16247 (15221122) (24321121) (13421122) (22521121) (16112122) (16121212) (14312122)
16248 (25221211) (14321212) (12512122) (23421211) (12521212) (15212212) (24312211)
16249 (13412212) (22512211) (11612212) (21131125) (41131123) (61131121) (11122126)
16250 (31122124) (51122122) (11131216) (31131214) (51131212) (21113125) (41113123)
16251 (61113121) (21122215) (41122213) (61122211) (11113216) (31113214) (51113212)
16252 (22131124) (42131122) (11231125) (31231123) (51231121) (12122125) (32122123)
16253 (52122121) (12131215) (32131213) (52131211) (21231214) (41231212) (22113124)
16254 (42113122) (11213125) (22122214) (42122212) (11222215) (31222213) (51222211)
16255 (12113215) (32113213) (52113211) (21213214) (41213212) (23131123) (43131121)
16256 (12231124) (32231122) (21331123) (41331121) (13122124) (33122122) (13131214)
16257 (33131212) (11322124) (22231213) (42231211) (11331214) (31331212) (23113123)
16258 (43113121) (12213124) (23122213) (43122211) (12222214) (32222212) (21322213)
16259 (41322211) (13113214) (33113212) (22213213) (42213211) (11313214) (31313212)
16260 (24131122) (13231123) (33231121) (22331122) (11431123) (31431121) (14122123)
16261 (34122121) (14131213) (34131211) (12322123) (23231212) (12331213) (32331211)
16262 (21431212) (24113122) (13213123) (24122212) (13222213) (33222211) (11413123)
16263 (22322212) (11422213) (31422211) (14113213) (34113211) (23213212) (12313213)
16264 (32313211) (21413212) (25131121) (14231122) (23331121) (12431122) (15122122)
16265 (15131212) (13322122) (24231211) (13331212) (11522122) (22431211) (25113121)
16266 (14213122) (25122211) (14222212) (12413122) (23322211) (12422212) (21522211)
16267 (15113212) (24213211) (13313212) (22413211) (11513212) (15231121) (13431121)
16268 (16122121) (16131211) (14322121) (14331211) (12522121) (15213121) (15222211)
16269 (13413121) (13422211) (11613121) (16113211) (14313211) (12513211) (21141124)
16270 (41141122) (11132125) (31132123) (51132121) (11141215) (31141213) (51141211)
16271 (21123124) (41123122) (21132214) (41132212) (11114125) (31114123) (51114121)
16272 (11123215) (31123213) (51123211) (21114214) (41114212) (22141123) (42141121)
16273 (11241124) (31241122) (12132124) (32132122) (12141214) (32141212) (21241213)
16274 (41241211) (22123123) (42123121) (11223124) (22132213) (42132211) (11232214)
16275 (31232212) (12114124) (32114122) (12123214) (32123212) (21223213) (41223211)
16276 (22114213) (42114211) (11214214) (31214212) (23141122) (12241123) (32241121)
16277 (21341122) (13132123) (33132121) (13141213) (33141211) (11332123) (22241212)
16278 (11341213) (31341211) (23123122) (12223123) (23132212) (12232213) (32232211)
16279 (21332212) (13114123) (33114121) (13123213) (33123211) (11314123) (22223212)
16280 (11323213) (31323211) (23114212) (12214213) (32214211) (21314212) (24141121)
16281 (13241122) (22341121) (14132122) (14141212) (12332122) (23241211) (12341212)
16282 (24123121) (13223122) (24132211) (13232212) (11423122) (22332211) (11432212)
16283 (14114122) (14123212) (12314122) (23223211) (12323212) (21423211) (24114211)
16284 (13214212) (22314211) (11414212) (14241121) (15132121) (15141211) (13332121)
16285 (13341211) (14223121) (14232211) (12423121) (12432211) (15114121) (15123211)
16286 (13314121) (13323211) (11514121) (11523211) (14214211) (12414211) (21151123)
16287 (41151121) (11142124) (31142122) (11151214) (31151212) (21133123) (41133121)
16288 (21142213) (41142211) (11124124) (31124122) (11133214) (31133212) (21115123)
16289 (41115121) (21124213) (41124211) (11115214) (31115212) (22151122) (11251123)
16290 (31251121) (12142123) (32142121) (12151213) (32151211) (21251212) (22133122)
16291 (11233123) (22142212) (11242213) (31242211) (12124123) (32124121) (12133213)
16292 (32133211) (21233212) (22115122) (11215123) (22124212) (11224213) (31224211)
16293 (12115213) (32115211) (21215212) (23151121) (12251122) (13142122) (13151212)
16294 (11342122) (22251211) (23133121) (12233122) (23142211) (12242212) (21342211)
16295 (13124122) (13133212) (11324122) (22233211) (11333212) (23115121) (12215122)
16296 (23124211) (12224212) (21324211) (13115212) (22215211) (11315212) (13251121)
16297 (14142121) (14151211) (12342121) (13233121) (13242211) (11433121) (14124121)
16298 (14133211) (12324121) (12333211) (13215121) (13224211) (11415121) (11424211)
16299 (14115211) (12315211) (21161122) (11152123) (31152121) (11161213) (31161211)
16300 (21143122) (21152212) (11134123) (31134121) (11143213) (31143211) (21125122)
16301 (21134212) (11116123) (31116121) (11125213) (31125211) (22161121) (12152122)
16302 (12161212) (22143121) (11243122) (22152211) (11252212) (12134122) (12143212)
16303 (21243211) (22125121) (11225122) (22134211) (11234212) (12116122) (12125212)
16304 (21225211) (13152121) (13161211) (12243121) (12252211) (13134121) (13143211)
16305 (11334121) (11343211) (12225121) (12234211) (13116121) (13125211) (11316121)
16306 (11325211) (21111226) (41111224) (61111222) (31111315) (51111313) (21211135)
16307 (41211133) (61211131) (22111225) (42111223) (11211226) (31211224) (51211222)
16308 (12111316) (32111314) (52111312) (21211315) (41211313) (61211311) (22211134)
16309 (42211132) (11311135) (31311133) (51311131) (23111224) (43111222) (12211225)
16310 (32211223) (52211221) (21311224) (41311222) (13111315) (33111313) (22211314)
16311 (42211312) (11311315) (31311313) (51311311) (23211133) (43211131) (12311134)
16312 (32311132) (21411133) (41411131) (24111223) (13211224) (33211222) (22311223)
16313 (42311221) (11411224) (31411222) (14111314) (34111312) (23211313) (43211311)
16314 (12311314) (32311312) (21411313) (41411311) (24211132) (13311133) (33311131)
16315 (22411132) (11511133) (31511131) (25111222) (14211223) (34211221) (23311222)
16316 (12411223) (32411221) (21511222) (15111313) (24211312) (13311313) (33311311)
16317 (22411312) (11511313) (31511311) (25211131) (14311132) (23411131) (12511132)
16318 (21611131) (15211222) (24311221) (13411222) (22511221) (11611222) (16111312)
16319 (25211311) (14311312) (23411311) (12511312) (21611311) (31121134) (51121132)
16320 (21112135) (41112133) (61112131) (21121225) (41121223) (61121221) (11112226)
16321 (31112224) (51112222) (11121316) (31121314) (51121312) (21112315) (41112313)
16322 (61112311) (12121135) (32121133) (52121131) (21221134) (41221132) (22112134)
16323 (42112132) (11212135) (22121224) (42121222) (11221225) (31221223) (51221221)
16324 (12112225) (32112223) (52112221) (12121315) (32121313) (52121311) (21221314)
16325 (41221312) (22112314) (42112312) (11212315) (31212313) (51212311) (13121134)
16326 (33121132) (22221133) (42221131) (11321134) (31321132) (23112133) (43112131)
16327 (12212134) (23121223) (43121221) (12221224) (32221222) (21321223) (41321221)
16328 (13112224) (33112222) (13121314) (33121312) (11312224) (22221313) (42221311)
16329 (11321314) (31321312) (23112313) (43112311) (12212314) (32212312) (21312313)
16330 (41312311) (14121133) (34121131) (23221132) (12321133) (32321131) (21421132)
16331 (24112132) (13212133) (24121222) (13221223) (33221221) (11412133) (22321222)
16332 (11421223) (31421221) (14112223) (34112221) (14121313) (34121311) (12312223)
16333 (23221312) (12321313) (32321311) (21421312) (24112312) (13212313) (33212311)
16334 (22312312) (11412313) (31412311) (15121132) (24221131) (13321132) (22421131)
16335 ] [ % Odd parity
16336 (22121116) (42121114) (31221115) (51221113) (32112115) (52112113) (21212116)
16337 (41212114) (61212112) (23121115) (43121113) (12221116) (32221114) (52221112)
16338 (21321115) (41321113) (61321111) (13112116) (33112114) (22212115) (42212113)
16339 (11312116) (31312114) (51312112) (24121114) (13221115) (33221113) (22321114)
16340 (42321112) (11421115) (31421113) (51421111) (14112115) (34112113) (23212114)
16341 (43212112) (12312115) (32312113) (52312111) (21412114) (41412112) (25121113)
16342 (14221114) (34221112) (23321113) (43321111) (12421114) (32421112) (21521113)
16343 (41521111) (15112114) (24212113) (13312114) (33312112) (22412113) (42412111)
16344 (11512114) (31512112) (15221113) (24321112) (13421113) (33421111) (22521112)
16345 (16112113) (25212112) (14312113) (34312111) (23412112) (12512113) (32512111)
16346 (21612112) (21131116) (41131114) (61131112) (31122115) (51122113) (21113116)
16347 (41113114) (61113112) (22131115) (42131113) (11231116) (31231114) (51231112)
16348 (12122116) (32122114) (52122112) (21222115) (41222113) (61222111) (22113115)
16349 (42113113) (11213116) (31213114) (51213112) (23131114) (43131112) (12231115)
16350 (32231113) (52231111) (21331114) (41331112) (13122115) (33122113) (22222114)
16351 (42222112) (11322115) (31322113) (51322111) (23113114) (43113112) (12213115)
16352 (32213113) (52213111) (21313114) (41313112) (24131113) (13231114) (33231112)
16353 (22331113) (42331111) (11431114) (31431112) (14122114) (34122112) (23222113)
16354 (43222111) (12322114) (32322112) (21422113) (41422111) (24113113) (13213114)
16355 (33213112) (22313113) (42313111) (11413114) (31413112) (25131112) (14231113)
16356 (34231111) (23331112) (12431113) (32431111) (15122113) (24222112) (13322113)
16357 (33322111) (22422112) (11522113) (31522111) (25113112) (14213113) (34213111)
16358 (23313112) (12413113) (32413111) (21513112) (15231112) (24331111) (13431112)
16359 (16122112) (25222111) (14322112) (23422111) (12522112) (15213112) (24313111)
16360 (13413112) (22513111) (11613112) (21141115) (41141113) (61141111) (11132116)
16361 (31132114) (51132112) (21123115) (41123113) (61123111) (11114116) (31114114)
16362 (51114112) (22141114) (42141112) (11241115) (31241113) (51241111) (12132115)
16363 (32132113) (52132111) (21232114) (41232112) (22123114) (42123112) (11223115)
16364 (31223113) (51223111) (12114115) (32114113) (52114111) (21214114) (41214112)
16365 (23141113) (43141111) (12241114) (32241112) (21341113) (41341111) (13132114)
16366 (33132112) (22232113) (42232111) (11332114) (31332112) (23123113) (43123111)
16367 (12223114) (32223112) (21323113) (41323111) (13114114) (33114112) (22214113)
16368 (42214111) (11314114) (31314112) (24141112) (13241113) (33241111) (22341112)
16369 (14132113) (34132111) (23232112) (12332113) (32332111) (21432112) (24123112)
16370 (13223113) (33223111) (22323112) (11423113) (31423111) (14114113) (34114111)
16371 (23214112) (12314113) (32314111) (21414112) (25141111) (14241112) (23341111)
16372 (15132112) (24232111) (13332112) (22432111) (25123111) (14223112) (23323111)
16373 (12423112) (21523111) (15114112) (24214111) (13314112) (22414111) (11514112)
16374 (15241111) (16132111) (14332111) (15223111) (13423111) (16114111) (14314111)
16375 (12514111) (21151114) (41151112) (11142115) (31142113) (51142111) (21133114)
16376 (41133112) (11124115) (31124113) (51124111) (21115114) (41115112) (22151113)
16377 (42151111) (11251114) (31251112) (12142114) (32142112) (21242113) (41242111)
16378 (22133113) (42133111) (11233114) (31233112) (12124114) (32124112) (21224113)
16379 (41224111) (22115113) (42115111) (11215114) (31215112) (23151112) (12251113)
16380 (32251111) (13142113) (33142111) (22242112) (11342113) (31342111) (23133112)
16381 (12233113) (32233111) (21333112) (13124113) (33124111) (22224112) (11324113)
16382 (31324111) (23115112) (12215113) (32215111) (21315112) (24151111) (13251112)
16383 (14142112) (23242111) (12342112) (24133111) (13233112) (22333111) (11433112)
16384 (14124112) (23224111) (12324112) (21424111) (24115111) (13215112) (22315111)
16385 (11415112) (14251111) (15142111) (13342111) (14233111) (12433111) (15124111)
16386 (13324111) (11524111) (14215111) (12415111) (21161113) (41161111) (11152114)
16387 (31152112) (21143113) (41143111) (11134114) (31134112) (21125113) (41125111)
16388 (11116114) (31116112) (22161112) (12152113) (32152111) (21252112) (22143112)
16389 (11243113) (31243111) (12134113) (32134111) (21234112) (22125112) (11225113)
16390 (31225111) (12116113) (32116111) (21216112) (23161111) (13152112) (22252111)
16391 (23143111) (12243112) (21343111) (13134112) (22234111) (11334112) (23125111)
16392 (12225112) (21325111) (13116112) (22216111) (11316112) (14152111) (13243111)
16393 (14134111) (12334111) (13225111) (11425111) (14116111) (12316111) (41111215)
16394 (61111213) (21211126) (41211124) (61211122) (22111216) (42111214) (31211215)
16395 (51211213) (22211125) (42211123) (11311126) (31311124) (51311122) (23111215)
16396 (43111213) (12211216) (32211214) (52211212) (21311215) (41311213) (61311211)
16397 (23211124) (43211122) (12311125) (32311123) (52311121) (21411124) (41411122)
16398 (24111214) (13211215) (33211213) (22311214) (42311212) (11411215) (31411213)
16399 (51411211) (24211123) (13311124) (33311122) (22411123) (42411121) (11511124)
16400 (31511122) (25111213) (14211214) (34211212) (23311213) (43311211) (12411214)
16401 (32411212) (21511213) (41511211) (25211122) (14311123) (34311121) (23411122)
16402 (12511123) (32511121) (21611122) (15211213) (24311212) (13411213) (33411211)
16403 (22511212) (11611213) (31611211) (31121125) (51121123) (21112126) (41112124)
16404 (61112122) (21121216) (41121214) (61121212) (31112215) (51112213) (12121126)
16405 (32121124) (52121122) (21221125) (41221123) (61221121) (22112125) (42112123)
16406 (11212126) (22121215) (42121213) (11221216) (31221214) (51221212) (12112216)
16407 (32112214) (52112212) (21212215) (41212213) (61212211) (13121125) (33121123)
16408 (22221124) (42221122) (11321125) (31321123) (51321121) (23112124) (43112122)
16409 (12212125) (23121214) (43121212) (12221215) (32221213) (52221211) (21321214)
16410 (41321212) (13112215) (33112213) (22212214) (42212212) (11312215) (31312213)
16411 (51312211) (14121124) (34121122) (23221123) (43221121) (12321124) (32321122)
16412 (21421123) (41421121) (24112123) (13212124) (24121213) (13221214) (33221212)
16413 (11412124) (22321213) (42321211) (11421214) (31421212) (14112214) (34112212)
16414 (23212213) (43212211) (12312214) (32312212) (21412213) (41412211) (15121123)
16415 (24221122) (13321123) (33321121) (22421122) (11521123) (31521121) (25112122)
16416 (14212123) (25121212) (14221213) (34221211) (12412123) (23321212) (12421213)
16417 (32421211) (21521212) (15112213) (24212212) (13312213) (33312211) (22412212)
16418 (11512213) (31512211) (16121122) (25221121) (14321122) (23421121) (12521122)
16419 (15212122) (15221212) (13412122) (24321211) (13421212) (11612122) (22521211)
16420 (16112212) (25212211) (14312212) (23412211) (12512212) (21612211) (11131126)
16421 (31131124) (51131122) (21122125) (41122123) (61122121) (21131215) (41131213)
16422 (61131211) (11113126) (31113124) (51113122) (11122216) (31122214) (51122212)
16423 (21113215) (41113213) (61113211) (12131125) (32131123) (52131121) (21231124)
16424 (41231122) (22122124) (42122122) (11222125) (22131214) (42131212) (11231215)
16425 (31231213) (51231211) (12113125) (32113123) (52113121) (12122215) (32122213)
16426 (52122211) (21222214) (41222212) (22113214) (42113212) (11213215) (31213213)
16427 (51213211) (13131124) (33131122) (22231123) (42231121) (11331124) (31331122)
16428 (23122123) (43122121) (12222124) (23131213) (43131211) (12231214) (32231212)
16429 (21331213) (41331211) (13113124) (33113122) (13122214) (33122212) (11313124)
16430 (22222213) (42222211) (11322214) (31322212) (23113213) (43113211) (12213214)
16431 (32213212) (21313213) (41313211) (14131123) (34131121) (23231122) (12331123)
16432 (32331121) (21431122) (24122122) (13222123) (24131212) (13231213) (33231211)
16433 (11422123) (22331212) (11431213) (31431211) (14113123) (34113121) (14122213)
16434 (34122211) (12313123) (23222212) (12322213) (32322211) (21422212) (24113212)
16435 (13213213) (33213211) (22313212) (11413213) (31413211) (15131122) (24231121)
16436 (13331122) (22431121) (25122121) (14222122) (25131211) (14231212) (12422122)
16437 (23331211) (12431212) (15113122) (15122212) (13313122) (24222211) (13322212)
16438 (11513122) (22422211) (11522212) (25113211) (14213212) (23313211) (12413212)
16439 (21513211) (16131121) (14331121) (15222121) (15231211) (13422121) (13431211)
16440 (16113121) (16122211) (14313121) (14322211) (12513121) (12522211) (15213211)
16441 (13413211) (11613211) (11141125) (31141123) (51141121) (21132124) (41132122)
16442 (21141214) (41141212) (11123125) (31123123) (51123121) (11132215) (31132213)
16443 (51132211) (21114124) (41114122) (21123214) (41123212) (11114215) (31114213)
16444 (51114211) (12141124) (32141122) (21241123) (41241121) (22132123) (42132121)
16445 (11232124) (22141213) (42141211) (11241214) (31241212) (12123124) (32123122)
16446 (12132214) (32132212) (21232213) (41232211) (22114123) (42114121) (11214124)
16447 (22123213) (42123211) (11223214) (31223212) (12114214) (32114212) (21214213)
16448 (41214211) (13141123) (33141121) (22241122) (11341123) (31341121) (23132122)
16449 (12232123) (23141212) (12241213) (32241211) (21341212) (13123123) (33123121)
16450 (13132213) (33132211) (11323123) (22232212) (11332213) (31332211) (23114122)
16451 (12214123) (23123212) (12223213) (32223211) (21323212) (13114213) (33114211)
16452 (22214212) (11314213) (31314211) (14141122) (23241121) (12341122) (24132121)
16453 (13232122) (24141211) (13241212) (11432122) (22341211) (14123122) (14132212)
16454 (12323122) (23232211) (12332212) (21432211) (24114121) (13214122) (24123211)
16455 (13223212) (11414122) (22323211) (11423212) (14114212) (23214211) (12314212)
16456 (21414211) (15141121) (13341121) (14232121) (14241211) (12432121) (15123121)
16457 (15132211) (13323121) (13332211) (11523121) (14214121) (14223211) (12414121)
16458 (12423211) (15114211) (13314211) (11514211) (11151124) (31151122) (21142123)
16459 (41142121) (21151213) (41151211) (11133124) (31133122) (11142214) (31142212)
16460 (21124123) (41124121) (21133213) (41133211) (11115124) (31115122) (11124214)
16461 (31124212) (21115213) (41115211) (12151123) (32151121) (21251122) (22142122)
16462 (11242123) (22151212) (11251213) (31251211) (12133123) (32133121) (12142213)
16463 (32142211) (21242212) (22124122) (11224123) (22133212) (11233213) (31233211)
16464 (12115123) (32115121) (12124213) (32124211) (21224212) (22115212) (11215213)
16465 (31215211) (13151122) (22251121) (23142121) (12242122) (23151211) (12251212)
16466 (13133122) (13142212) (11333122) (22242211) (11342212) (23124121) (12224122)
16467 (23133211) (12233212) (21333211) (13115122) (13124212) (11315122) (22224211)
16468 (11324212) (23115211) (12215212) (21315211) (14151121) (13242121) (13251211)
16469 (14133121) (14142211) (12333121) (12342211) (13224121) (13233211) (11424121)
16470 (11433211) (14115121) (14124211) (12315121) (12324211) (13215211) (11415211)
16471 (11161123) (31161121) (21152122) (21161212) (11143123) (31143121) (11152213)
16472 (31152211) (21134122) (21143212) (11125123) (31125121) (11134213) (31134211)
16473 (21116122) (21125212) (12161122) (22152121) (11252122) (22161211) (12143122)
16474 (12152212) (21252211) (22134121) (11234122) (22143211) (11243212) (12125122)
16475 (12134212) (21234211) (22116121) (11216122) (22125211) (11225212) (13161121)
16476 (12252121) (13143121) (13152211) (11343121) (12234121) (12243211) (13125121)
16477 (13134211) (11325121) (11334211) (12216121) (12225211) (31111225) (51111223)
16478 (21111316) (41111314) (61111312) (31211134) (51211132) (12111226) (32111224)
16479 (52111222) (21211225) (41211223) (61211221) (22111315) (42111313) (11211316)
16480 (31211314) (51211312) (12211135) (32211133) (52211131) (21311134) (41311132)
16481 (13111225) (33111223) (22211224) (42211222) (11311225) (31311223) (51311221)
16482 (23111314) (43111312) (12211315) (32211313) (52211311) (21311314) (41311312)
16483 (13211134) (33211132) (22311133) (42311131) (11411134) (31411132) (14111224)
16484 (34111222) (23211223) (43211221) (12311224) (32311222) (21411223) (41411221)
16485 (24111313) (13211314) (33211312) (22311313) (42311311) (11411314) (31411312)
16486 (14211133) (34211131) (23311132) (12411133) (32411131) (21511132) (15111223)
16487 (24211222) (13311223) (33311221) (22411222) (11511223) (31511221) (25111312)
16488 (14211313) (34211311) (23311312) (12411313) (32411311) (21511312) (15211132)
16489 (24311131) (13411132) (22511131) (11611132) (16111222) (25211221) (14311222)
16490 (23411221) (12511222) (21611221) (15211312) (24311311) (13411312) (22511311)
16491 (11611312) (21121135) (41121133) (61121131) (11112136) (31112134) (51112132)
16492 (11121226) (31121224) (51121222) (21112225) (41112223) (61112221) (21121315)
16493 (41121313) (61121311) (11112316) (31112314) (51112312) (22121134) (42121132)
16494 (11221135) (31221133) (51221131) (12112135) (32112133) (52112131) (12121225)
16495 (32121223) (52121221) (21221224) (41221222) (22112224) (42112222) (11212225)
16496 (22121314) (42121312) (11221315) (31221313) (51221311) (12112315) (32112313)
16497 (52112311) (21212314) (41212312) (23121133) (43121131) (12221134) (32221132)
16498 (21321133) (41321131) (13112134) (33112132) (13121224) (33121222) (11312134)
16499 (22221223) (42221221) (11321224) (31321222) (23112223) (43112221) (12212224)
16500 (23121313) (43121311) (12221314) (32221312) (21321313) (41321311) (13112314)
16501 (33112312) (22212313) (42212311) (11312314) (31312312) (24121132) (13221133)
16502 (33221131) (22321132) (11421133) (31421131) (14112133) (34112131) (14121223)
16503 (34121221) (12312133) (23221222) (12321223) (32321221) (21421222) (24112222)
16504 (13212223) (24121312) (13221313) (33221311) (11412223) (22321312) (11421313)
16505 (31421311) (14112313) (34112311) (23212312) (12312313) (32312311) (21412312)
16506 (25121131) (14221132) (23321131) (12421132) (21521131) (15112132) (15121222)
16507 (13312132) (24221221) (13321222) (11512132) (22421221) (11521222) (25112221)
16508 (14212222) (25121311) (14221312) (12412222) (23321311) (12421312) (21521311)
16509 (15112312) (24212311) (13312312) (22412311) (11512312) (15221131) (13421131)
16510 (16112131) (16121221) (14312131) (14321221) (12512131) (12521221) (15212221)
16511 (15221311) (13412221) (13421311) (11612221) (16112311) (14312311) (12512311)
16512 (21131134) (41131132) (11122135) (31122133) (51122131) (11131225) (31131223)
16513 (51131221) (21113134) (41113132) (21122224) (41122222) (21131314) (41131312)
16514 (11113225) (31113223) (51113221) (11122315) (31122313) (51122311) (21113314)
16515 (41113312) (22131133) (42131131) (11231134) (31231132) (12122134) (32122132)
16516 (12131224) (32131222) (21231223) (41231221) (22113133) (42113131) (11213134)
16517 (22122223) (42122221) (11222224) (22131313) (42131311) (11231314) (31231312)
16518 (12113224) (32113222) (12122314) (32122312) (21222313) (41222311) (22113313)
16519 (42113311) (11213314) (31213312) (23131132) (12231133) (32231131) (21331132)
16520 (13122133) (33122131) (13131223) (33131221) (11322133) (22231222) (11331223)
16521 (31331221) (23113132) (12213133) (23122222) (12222223) (23131312) (12231313)
16522 (32231311) (21331312) (13113223) (33113221) (13122313) (33122311) (11313223)
16523 (22222312) (11322313) (31322311) (23113312) (12213313) (32213311) (21313312)
16524 (24131131) (13231132) (22331131) (11431132) (14122132) (14131222) (12322132)
16525 (23231221) (12331222) (21431221) (24113131) (13213132) (24122221) (13222222)
16526 (24131311) (11413132) (13231312) (11422222) (22331311) (11431312) (14113222)
16527 (14122312) (12313222) (23222311) (12322312) (21422311) (24113311) (13213312)
16528 (22313311) (11413312) (14231131) (12431131) (15122131) (15131221) (13322131)
16529 (13331221) (11522131) (14213131) (14222221) (12413131) (14231311) (12422221)
16530 (12431311) (15113221) (15122311) (13313221) (13322311) (11513221) (11522311)
16531 (14213311) (12413311) (21141133) (41141131) (11132134) (31132132) (11141224)
16532 (31141222) (21123133) (41123131) (21132223) (41132221) (21141313) (41141311)
16533 (11114134) (31114132) (11123224) (31123222) (11132314) (31132312) (21114223)
16534 (41114221) (21123313) (41123311) (11114314) (31114312) (22141132) (11241133)
16535 (31241131) (12132133) (32132131) (12141223) (32141221) (21241222) (22123132)
16536 (11223133) (22132222) (11232223) (22141312) (11241313) (31241311) (12114133)
16537 (32114131) (12123223) (32123221) (12132313) (32132311) (21232312) (22114222)
16538 (11214223) (22123312) (11223313) (31223311) (12114313) (32114311) (21214312)
16539 (23141131) (12241132) (21341131) (13132132) (13141222) (11332132) (22241221)
16540 (11341222) (23123131) (12223132) (23132221) (12232222) (23141311) (12241312)
16541 (21341311) (13114132) (13123222) (11314132) (13132312) (11323222) (22232311)
16542 (11332312) (23114221) (12214222) (23123311) (12223312) (21323311) (13114312)
16543 (22214311) (11314312) (13241131) (14132131) (14141221) (12332131) (12341221)
16544 (13223131) (13232221) (11423131) (13241311) (11432221) (14114131) (14123221)
16545 (12314131) (14132311) (12323221) (12332311) (13214221) (13223311) (11414221)
16546 (11423311) (14114311) (12314311) (21151132) (11142133) (31142131) (11151223)
16547 (31151221) (21133132) (21142222) (21151312) (11124133) (31124131) (11133223)
16548 (31133221) (11142313) (31142311) (21115132) (21124222) (21133312) (11115223)
16549 (31115221) (11124313) (31124311) (22151131) (11251132) (12142132) (12151222)
16550 (21251221) (22133131) (11233132) (22142221) (11242222) (22151311) (11251312)
16551 (12124132) (12133222) (12142312) (21242311) (22115131) (11215132) (22124221)
16552 (11224222) (22133311) (11233312) (12115222) (12124312) (21224311) (12251131)
16553 (13142131) (13151221) (11342131) (12233131) (12242221) (12251311) (13124131)
16554 (13133221) (11324131) (13142311) (11333221) (11342311) (12215131) (12224221)
16555 (12233311) (13115221) (13124311) (11315221) (11324311) (21161131) (11152132)
16556 (11161222) (21143131) (21152221) (21161311) (11134132) (11143222) (11152312)
16557 (21125131) (21134221) (21143311) (11116132) (11125222) (11134312) (12152131)
16558 (12161221) (11243131) (11252221) (12134131) (12143221) (12152311) (11225131)
16559 (11234221) (11243311) (12116131) (12125221) (12134311) (21111235) (41111233)
16560 (61111231) (11111326) (31111324) (51111322) (21111415) (41111413) (61111411)
16561 (21211144) (41211142) (22111234) (42111232) (11211235) (31211233) (51211231)
16562 (12111325) (32111323) (52111321) (21211324) (41211322) (22111414) (42111412)
16563 (11211415) (31211413) (51211411) (22211143) (42211141) (11311144) (31311142)
16564 (23111233) (43111231) (12211234) (32211232) (21311233) (41311231) (13111324)
16565 (33111322) (22211323) (42211321) (11311324) (31311322) (23111413) (43111411)
16566 (12211414) (32211412) (21311413) (41311411) (23211142) (12311143) (32311141)
16567 (21411142) (24111232) (13211233) (33211231) (22311232) (11411233) (31411231)
16568 (14111323) (34111321) (23211322) (12311323) (32311321) (21411322) (24111412)
16569 (13211413) (33211411) (22311412) (11411413) (31411411) (24211141) (13311142)
16570 (22411141) (11511142) (25111231) (14211232) (23311231) (12411232) (21511231)
16571 (15111322) (24211321) (13311322) (22411321) (11511322) (25111411) (14211412)
16572 (23311411) (12411412) (21511411) (14311141) (12511141) (15211231) (13411231)
16573 (11611231) (16111321) (14311321) (12511321) (15211411) (13411411) (11611411)
16574 (31121143) (51121141) (21112144) (41112142) (21121234) (41121232) (11112235)
16575 (31112233) (51112231) (11121325) (31121323) (51121321) (21112324) (41112322)
16576 (21121414) (41121412) (11112415) (31112413) (51112411) (12121144) (32121142)
16577 (21221143) (41221141) (22112143) (42112141) (11212144) (22121233) (42121231)
16578 (11221234) (31221232) (12112234) (32112232) (12121324) (32121322) (21221323)
16579 (41221321) (22112323) (42112321) (11212324) (22121413) (42121411) (11221414)
16580 (31221412) (12112414) (32112412) (21212413) (41212411) (13121143) (33121141)
16581 (22221142) (11321143) (31321141) (23112142) (12212143) (23121232) (12221233)
16582 (32221231) (21321232) (13112233) (33112231) (13121323) (33121321) (11312233)
16583 (22221322) (11321323) (31321321) (23112322) (12212323) (23121412) (12221413)
16584 (32221411) (21321412) (13112413) (33112411) (22212412) (11312413) (31312411)
16585 (14121142) (23221141) (12321142) (21421141) (24112141) (13212142) (24121231)
16586 (13221232) (11412142) (22321231) (11421232) (14112232) (14121322) (12312232)
16587 (23221321) (12321322) (21421321) (24112321) (13212322) (24121411) (13221412)
16588 (11412322) (22321411) (11421412) (14112412) (23212411) (12312412) (21412411)
16589 (15121141) (13321141) (11521141) (14212141) (14221231) (12412141) (12421231)
16590 (15112231) (15121321) (13312231) (13321321) (11512231) (11521321) (14212321)
16591 (14221411) (12412321) (12421411) (15112411) (13312411) (11512411) (11131144)
16592 (31131142) (21122143) (41122141) (21131233) (41131231) (11113144) (31113142)
16593 (11122234) (31122232) (11131324) (31131322) (21113233) (41113231) (21122323)
16594 (41122321) (21131413) (41131411) (11113324) (31113322) (11122414) (31122412)
16595 (21113413) (41113411) (12131143) (32131141) (21231142) (22122142) (11222143)
16596 (22131232) (11231233) (31231231) (12113143) (32113141) (12122233) (32122231)
16597 (12131323) (32131321) (21231322) (22113232) (11213233) (22122322) (11222323)
16598 (22131412) (11231413) (31231411) (12113323) (32113321) (12122413) (32122411)
16599 (21222412) (22113412) (11213413) (31213411) (13131142) (22231141) (11331142)
16600 (23122141) (12222142) (23131231) (12231232) (21331231) (13113142) (13122232)
16601 (11313142) (13131322) (11322232) (22231321) (11331322) (23113231) (12213232)
16602 (23122321) (12222322) (23131411) (12231412) (21331411) (13113322) (13122412)
16603 (11313322) (22222411) (11322412) (23113411) (12213412) (21313411) (14131141)
16604 (12331141) (13222141) (13231231) (11422141) (11431231) (14113141) (14122231)
16605 (12313141) (14131321) (12322231) (12331321) (13213231) (13222321) (11413231)
16606 (13231411) (11422321) (11431411) (14113321) (14122411) (12313321) (12322411)
16607 (13213411) (11413411) (11141143) (31141141) (21132142) (21141232) (11123143)
16608 (31123141) (11132233) (31132231) (11141323) (31141321) (21114142) (21123232)
16609 (21132322) (21141412) (11114233) (31114231) (11123323) (31123321) (11132413)
16610 (31132411) (21114322) (21123412) (12141142) (21241141) (22132141) (11232142)
16611 (22141231) (11241232) (12123142) (12132232) (12141322) (21241321) (22114141)
16612 (11214142) (22123231) (11223232) (22132321) (11232322) (22141411) (11241412)
16613 (12114232) (12123322) (12132412) (21232411) (22114321) (11214322) (22123411)
16614 (11223412) (13141141) (11341141) (12232141) (12241231) (13123141) (13132231)
16615 (11323141) (13141321) (11332231) (11341321) (12214141) (12223231) (12232321)
16616 (12241411) (13114231) (13123321) (11314231) (13132411) (11323321) (11332411)
16617 (12214321) (12223411) (11151142) (21142141) (21151231) (11133142) (11142232)
16618 (11151322) (21124141) (21133231) (21142321) (21151411) (11115142) (11124232)
16619 (11133322) (11142412) (21115231) (21124321) (21133411) (12151141) (11242141)
16620 (11251231) (12133141) (12142231) (12151321) (11224141) (11233231) (11242321)
16621 (11251411) (12115141) (12124231) (12133321) (12142411) (11215231) (11224321)
16622 (11233411) (11161141) (11143141) (11152231) (11161321) (11125141) (11134231)
16623 (11143321) (11152411) (11111245) (31111243) (51111241) (21111334) (41111332)
16624 (11111425) (31111423) (51111421) (21111514) (41111512) (31211152) (12111244)
16625 (32111242) (21211243) (41211241) (22111333) (42111331) (11211334) (31211332)
16626 (12111424) (32111422) (21211423) (41211421) (22111513) (42111511) (11211514)
16627 (31211512) (12211153) (32211151) (21311152) (13111243) (33111241) (22211242)
16628 (11311243) (31311241) (23111332) (12211333) (32211331) (21311332) (13111423)
16629 (33111421) (22211422) (11311423) (31311421) (23111512) (12211513) (32211511)
16630 (21311512) (13211152) (22311151) (11411152) (14111242) (23211241) (12311242)
16631 (21411241) (24111331) (13211332) (22311331) (11411332) (14111422) (23211421)
16632 (12311422) (21411421) (24111511) (13211512) (22311511) (11411512) (14211151)
16633 (12411151) (15111241) (13311241) (11511241) (14211331) (12411331) (15111421)
16634 (13311421) (11511421) (14211511) (12411511) (21121153) (41121151) (11112154)
16635 (31112152) (11121244) (31121242) (21112243) (41112241) (21121333) (41121331)
16636 (11112334) (31112332) (11121424) (31121422) (21112423) (41112421) (21121513)
16637 (41121511) (11112514) (31112512) (22121152) (11221153) (31221151) (12112153)
16638 (32112151) (12121243) (32121241) (21221242) (22112242) (11212243) (22121332)
16639 (11221333) (31221331) (12112333) (32112331) (12121423) (32121421) (21221422)
16640 (22112422) (11212423) (22121512) (11221513) (31221511) (12112513) (32112511)
16641 (21212512) (23121151) (12221152) (21321151) (13112152) (13121242) (11312152)
16642 (22221241) (11321242) (23112241) (12212242) (23121331) (12221332) (21321331)
16643 (13112332) (13121422) (11312332) (22221421) (11321422) (23112421) (12212422)
16644 (23121511) (12221512) (21321511) (13112512) (22212511) (11312512) (13221151)
16645 (11421151) (14112151) (14121241) (12312151) (12321241) (13212241) (13221331)
16646 (11412241) (11421331) (14112331) (14121421) (12312331) (12321421) (13212421)
16647 (13221511) (11412421) (11421511) (14112511) (12312511) (21131152) (11122153)
16648 (31122151) (11131243) (31131241) (21113152) (21122242) (21131332) (11113243)
16649 (31113241) (11122333) (31122331) (11131423) (31131421) (21113332) (21122422)
16650 (21131512) (11113423) (31113421) (11122513) (31122511) (22131151) (11231152)
16651 (12122152) (12131242) (21231241) (22113151) (11213152) (22122241) (11222242)
16652 (22131331) (11231332) (12113242) (12122332) (12131422) (21231421) (22113331)
16653 (11213332) (22122421) (11222422) (22131511) (11231512) (12113422) (12122512)
16654 (21222511) (12231151) (13122151) (13131241) (11322151) (11331241) (12213151)
16655 (12222241) (12231331) (13113241) (13122331) (11313241) (13131421) (11322331)
16656 (11331421) (12213331) (12222421) (12231511) (13113421) (13122511) (11313421)
16657 (11322511) (21141151) (11132152) (11141242) (21123151) (21132241) (21141331)
16658 (11114152) (11123242) (11132332) (11141422) (21114241) (21123331) (21132421)
16659 (21141511) (11114332) (11123422) (11132512) (11241151) (12132151) (12141241)
16660 (11223151) (11232241) (11241331) (12114151) (12123241) (12132331) (12141421)
16661 (11214241) (11223331) (11232421) (11241511) (12114331) (12123421) (12132511)
16662 (11142151) (11151241) (11124151) (11133241) (11142331) (11151421) (11115241)
16663 (11124331) (11133421) (11142511) (21111253) (41111251) (11111344) (31111342)
16664 (21111433) (41111431) (11111524) (31111522) (21111613) (41111611) (21211162)
16665 (22111252) (11211253) (31211251) (12111343) (32111341) (21211342) (22111432)
16666 (11211433) (31211431) (12111523) (32111521) (21211522) (22111612) (11211613)
16667 (31211611) (22211161) (11311162) (23111251) (12211252) (21311251) (13111342)
16668 (22211341) (11311342) (23111431) (12211432) (21311431) (13111522) (22211521)
16669 (11311522) (23111611) (12211612) (21311611) (12311161) (13211251) (11411251)
16670 (14111341) (12311341) (13211431) (11411431) (14111521) (12311521) (13211611)
16671 (11411611) (31121161) (21112162) (21121252) (11112253) (31112251) (11121343)
16672 (31121341) (21112342) (21121432) (11112433) (31112431) (11121523) (31121521)
16673 (21112522) (21121612) (12121162) (21221161) (22112161) (11212162) (22121251)
16674 (11221252) (12112252) (12121342) (21221341) (22112341) (11212342) (22121431)
16675 (11221432) (12112432) (12121522) (21221521) (22112521) (11212522) (22121611)
16676 (11221612) (13121161) (11321161) (12212161) (12221251) (13112251) (13121341)
16677 (11312251) (11321341) (12212341) (12221431) (13112431) (13121521) (11312431)
16678 (11321521) (12212521) (12221611) (11131162) (21122161) (21131251) (11113162)
16679 ]
16680 ] def
16681
16682 /parity [
16683 (1001) (0101) (1100) (0011) (1010) (0110) (1111) (0000)
16684 ] def
16685 } ctxdef
16686
16687 % Derive the bits for each row
16688 /rowbits r array def
16689 0 1 r 1 sub {
16690 /i exch def
16691 /p i r 1 sub ne {parity i get} {(0000)} ifelse def
16692 /ccrow ccs i 8 mul 8 getinterval def
16693 /scrow [
16694 0 2 7 {ccrow exch 2 getinterval aload pop exch 49 mul add} for
16695 ] def
16696 /sbs [
16697 10 1 1
16698 0 1 3 {
16699 /j exch def
16700 patterns p j get 48 sub get scrow j get get {48 sub} forall
16701 } for
16702 4 1
16703 ] def
16704 mark
16705 1 sbs {1 index 0 eq {{1}} {{0}} ifelse repeat} forall
16706 counttomark 1 sub array astore exch pop exch pop
16707 rowbits i 3 -1 roll put
16708 } for
16709
16710 % Populate the bitmap
16711 /pixs [
16712 81 sepheight mul {1} repeat
16713 0 1 r 2 sub {
16714 /i exch def
16715 rowheight {rowbits i get aload pop} repeat
16716 sepheight {10 {0} repeat 70 {1} repeat 0} repeat
16717 } for
16718 rowheight {rowbits r 1 sub get aload pop} repeat
16719 81 sepheight mul {1} repeat
16720 ] def
16721
16722 % Return the arguments
16723 <<
16724 /ren /renmatrix
16725 /pixs pixs
16726 /pixx 81
16727 /pixy pixs length 81 idiv
16728 /height pixs length 81 idiv 72 div
16729 /width 81 72 div
16730 /opt options
16731 >>
16732
16733 dontdraw not //renmatrix if
16734
16735 //unloadctx exec
16736
16737 end
16738
16739 }
16740 [/barcode] {null def} forall
16741 bind def
16742 /code49 dup load /uk.co.terryburton.bwipp defineresource pop
16743 end
16744 /setpacking where {pop setpacking} if
16745 %%EndData
16746 %%EndResource
16747 % --END ENCODER code49--
16748
16749 % --BEGIN ENCODER channelcode--
16750 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear--
16751 % --DESC: Channel Code
16752 % --EXAM: 3493
16753 % --EXOP: height=0.5 includetext
16754 % --RNDR: renlinear
16755 %%BeginResource: uk.co.terryburton.bwipp channelcode 0.0 2025111800 136095 135116
16756 %%BeginData: 252 ASCII Lines
16757 /setpacking where {pop currentpacking true setpacking} if
16758 10 dict
16759 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
16760 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
16761 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
16762 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
16763 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
16764 begin
16765 /channelcode {
16766
16767 20 dict begin % Confine variables to local scope
16768
16769 /ctx null def
16770 /dontdraw false def
16771 /shortfinder false def
16772 /includetext false def
16773 /includecheck false def
16774 /height 1.0 def
16775
16776 //processoptions exec /options exch def
16777 /barcode exch def
16778
16779 /channelcode //loadctx exec
16780
16781 % Validate the input
16782 barcode length 2 lt barcode length 7 gt or {
16783 /bwipp.channelcodeBadLength (Channel Code must be 2 to 7 digits) //raiseerror exec
16784 } if
16785 barcode {
16786 dup 48 lt exch 57 gt or {
16787 /bwipp.channelcodeBadCharacter (Channel Code must contain only digits) //raiseerror exec
16788 } if
16789 } forall
16790 barcode cvi [ 26 292 3493 44072 576688 7742862 ] barcode length 2 sub get gt {
16791 /bwipp.channelcodeTooBig (The Channel Code value is too big for the number of channels) //raiseerror exec
16792 } if
16793
16794 % Tail-call optimisation FTW!
16795 /loops1 { /s2max s1max 1 add s1 sub def /b1 1 def
16796 s1 1 eq {nextb1} {loopb1} ifelse } def
16797 /loopb1 { /b2max b1max 1 add b1 sub def /s2 1 def loops2 } def
16798 /loops2 { /s3max s2max 1 add s2 sub def /b2 1 def
16799 s1 b1 add s2 add 3 eq {nextb2} {loopb2} ifelse } def
16800 /loopb2 { /b3max b2max 1 add b2 sub def /s3 1 def loops3 } def
16801 /loops3 { /s4max s3max 1 add s3 sub def /b3 1 def
16802 b1 s2 add b2 add s3 add 4 eq {nextb3} {loopb3} ifelse } def
16803 /loopb3 { /b4max b3max 1 add b3 sub def /s4 1 def loops4 } def
16804 /loops4 { /s5max s4max 1 add s4 sub def /b4 1 def
16805 b2 s3 add b3 add s4 add 4 eq {nextb4} {loopb4} ifelse } def
16806 /loopb4 { /b5max b4max 1 add b4 sub def /s5 1 def loops5 } def
16807 /loops5 { /s6max s5max 1 add s5 sub def /b5 1 def
16808 b3 s4 add b4 add s5 add 4 eq {nextb5} {loopb5} ifelse } def
16809 /loopb5 { /b6max b5max 1 add b5 sub def /s6 1 def loops6 } def
16810 /loops6 { /s7max s6max 1 add s6 sub def /b6 1 def
16811 b4 s5 add b5 add s6 add 4 eq {nextb6} {loopb6} ifelse } def
16812 /loopb6 { /b7max b6max 1 add b6 sub def /s7 1 def loops7 } def
16813 /loops7 { /s8 s7max 1 add s7 sub def /b7 1 def
16814 b5 s6 add b6 add s7 add 4 eq {nextb7} {loopb7} ifelse } def
16815 /loopb7 { /b8 b7max 1 add b7 sub def
16816 b6 s7 add b7 add s8 add b8 add 5 eq {nextb7} {chkchr} ifelse } def
16817 /chkchr {
16818 value target eq {
16819 [s1 b1 s2 b2 s3 b3 s4 b4 s5 b5 s6 b6 s7 b7 s8 b8] exit
16820 } if
16821 /value value 1 add def
16822 nextb7
16823 } def
16824 /nextb7 { /b7 b7 1 add def b7 b7max le {loopb7} {nexts7} ifelse } def
16825 /nexts7 { /s7 s7 1 add def s7 s7max le {loops7} {nextb6} ifelse } def
16826 /nextb6 { /b6 b6 1 add def b6 b6max le {loopb6} {nexts6} ifelse } def
16827 /nexts6 { /s6 s6 1 add def s6 s6max le {loops6} {nextb5} ifelse } def
16828 /nextb5 { /b5 b5 1 add def b5 b5max le {loopb5} {nexts5} ifelse } def
16829 /nexts5 { /s5 s5 1 add def s5 s5max le {loops5} {nextb4} ifelse } def
16830 /nextb4 { /b4 b4 1 add def b4 b4max le {loopb4} {nexts4} ifelse } def
16831 /nexts4 { /s4 s4 1 add def s4 s4max le {loops4} {nextb3} ifelse } def
16832 /nextb3 { /b3 b3 1 add def b3 b3max le {loopb3} {nexts3} ifelse } def
16833 /nexts3 { /s3 s3 1 add def s3 s3max le {loops3} {nextb2} ifelse } def
16834 /nextb2 { /b2 b2 1 add def b2 b2max le {loopb2} {nexts2} ifelse } def
16835 /nexts2 { /s2 s2 1 add def s2 s2max le {loops2} {nextb1} ifelse } def
16836 /nextb1 { /b1 b1 1 add def b1 b1max le {loopb1} {nexts1} ifelse } def
16837 /nexts1 { /s1 s1 1 add def s1 s1max le {loops1} if } def
16838
16839 {
16840 /memo [ % Accelerate generation of bar patterns
16841 [ % CH3
16842 [ 0 [1 1 1 1 1 2 1 2] [1 1 1 1 1 1 1 3] [1 1 1 1 1 3 2] [1 1 1 1 1 3 3] ]
16843 ]
16844 [ % CH4
16845 [ 0 [1 1 1 1 2 1 1 3] [1 1 1 1 1 1 1 4] [1 1 1 1 4 3 3] [1 1 1 1 4 4 4] ]
16846 ]
16847 [ % CH5
16848 [ 0 [1 1 1 2 1 1 2 3] [1 1 1 1 1 1 1 5] [1 1 1 5 4 4 4] [1 1 1 5 5 5 5] ]
16849 ]
16850 [ % CH6
16851 [ 0 [1 1 2 1 1 2 1 4] [1 1 1 1 1 1 1 6] [1 1 6 5 5 5 4] [1 1 6 6 6 6 6] ]
16852 ]
16853 [ % CH7
16854 [ 0 [1 2 1 1 2 1 1 5] [1 1 1 1 1 1 1 7] [1 7 6 6 6 5 5] [1 7 7 7 7 7 7] ]
16855 [ 150000 [1 3 1 1 2 4 1 1] [1 1 3 1 2 3 2 1] [1 7 5 5 5 4 1] [1 7 7 5 5 4 2] ]
16856 [ 300000 [1 1 4 2 1 1 1 3] [1 2 4 1 1 1 2 2] [1 7 7 4 3 3 3] [1 7 6 3 3 3 3] ]
16857 [ 450000 [1 1 4 1 1 4 1 1] [1 3 2 1 2 1 2 2] [1 7 7 4 4 4 1] [1 7 5 4 4 3 3] ]
16858 ]
16859 [ % CH8
16860 [ 0 [2 1 1 2 1 1 2 5] [1 1 1 1 1 1 1 8] [8 7 7 7 6 6 6] [8 8 8 8 8 8 8] ]
16861 [ 150000 [2 1 1 2 1 1 5 2] [1 1 2 1 5 2 1 2] [8 7 7 7 6 6 6] [8 8 8 7 7 3 2] ]
16862 [ 300000 [2 1 1 4 2 2 2 1] [1 1 4 2 1 2 1 3] [8 7 7 7 4 3 2] [8 8 8 5 4 4 3] ]
16863 [ 450000 [2 2 2 1 1 3 1 3] [1 1 2 1 1 2 4 3] [8 7 6 5 5 5 3] [8 8 8 7 7 7 6] ]
16864 [ 600000 [2 3 1 1 4 2 1 1] [1 1 3 1 3 1 2 3] [8 7 5 5 5 2 1] [8 8 8 6 6 4 4] ]
16865 [ 750000 [2 1 3 1 2 3 2 1] [1 2 1 1 3 4 1 2] [8 7 7 5 5 4 2] [8 8 7 7 7 5 2] ]
16866 [ 900000 [2 2 1 4 1 2 2 1] [1 2 1 2 1 5 1 2] [8 7 6 6 3 3 2] [8 8 7 7 6 6 2] ]
16867 [ 1050000 [2 4 1 1 1 2 2 2] [1 2 1 2 1 3 1 4] [8 7 4 4 4 4 3] [8 8 7 7 6 6 4] ]
16868 [ 1200000 [2 2 1 5 2 1 1 1] [1 3 1 3 2 1 1 3] [8 7 6 6 2 1 1] [8 8 6 6 4 3 3] ]
16869 [ 1350000 [2 2 1 3 3 1 1 2] [1 4 1 2 1 1 4 1] [8 7 6 6 4 2 2] [8 8 5 5 4 4 4] ]
16870 [ 1500000 [3 1 2 2 2 1 1 3] [1 1 1 1 2 2 4 3] [8 6 6 5 4 3 3] [8 8 8 8 8 7 6] ]
16871 [ 1650000 [3 2 1 2 3 1 2 1] [1 1 1 1 3 2 4 2] [8 6 5 5 4 2 2] [8 8 8 8 8 6 5] ]
16872 [ 1800000 [3 1 1 3 2 3 1 1] [1 2 1 1 3 4 2 1] [8 6 6 6 4 3 1] [8 8 7 7 7 5 2] ]
16873 [ 1950000 [3 2 1 2 1 2 2 2] [1 2 4 1 2 2 1 2] [8 6 5 5 4 4 3] [8 8 7 4 4 3 2] ]
16874 [ 2100000 [3 1 2 1 4 2 1 1] [1 4 1 2 1 1 2 3] [8 6 6 5 5 2 1] [8 8 5 5 4 4 4] ]
16875 [ 2250000 [4 1 1 4 1 1 2 1] [1 1 4 2 1 1 1 4] [8 5 5 5 2 2 2] [8 8 8 5 4 4 4] ]
16876 [ 2400000 [4 3 1 2 1 2 1 1] [1 2 4 2 2 2 1 1] [8 5 3 3 2 2 1] [8 8 7 4 3 2 1] ]
16877 [ 2550000 [5 1 1 1 1 1 3 2] [1 2 2 4 3 1 1 1] [8 4 4 4 4 4 4] [8 8 7 6 3 1 1] ]
16878 [ 2700000 [1 1 3 6 1 1 1 1] [2 1 1 2 1 1 6 1] [8 8 8 6 1 1 1] [8 7 7 7 6 6 6] ]
16879 [ 2850000 [1 1 1 2 2 3 2 3] [2 1 3 3 2 1 1 2] [8 8 8 8 7 6 4] [8 7 7 5 3 2 2] ]
16880 [ 3000000 [1 2 3 3 3 1 1 1] [2 1 1 1 5 1 2 2] [8 8 7 5 3 1 1] [8 7 7 7 7 3 3] ]
16881 [ 3150000 [1 3 1 2 2 2 3 1] [2 1 1 3 2 1 3 2] [8 8 6 6 5 4 3] [8 7 7 7 5 4 4] ]
16882 [ 3300000 [1 5 1 1 3 1 1 2] [2 1 1 4 3 2 1 1] [8 8 4 4 4 2 2] [8 7 7 7 4 2 1] ]
16883 [ 3450000 [1 1 2 2 2 5 1 1] [2 2 2 2 3 1 1 2] [8 8 8 7 6 5 1] [8 7 6 5 4 2 2] ]
16884 [ 3600000 [1 2 1 1 3 4 2 1] [2 2 3 1 1 1 2 3] [8 8 7 7 7 5 2] [8 7 6 4 4 4 4] ]
16885 [ 3750000 [1 1 2 1 1 5 3 1] [2 3 1 1 4 1 2 1] [8 8 8 7 7 7 3] [8 7 5 5 5 2 2] ]
16886 [ 3900000 [1 3 1 2 4 2 1 1] [2 3 3 1 1 1 2 2] [8 8 6 6 5 2 1] [8 7 5 3 3 3 3] ]
16887 [ 4050000 [1 3 1 2 3 1 2 2] [2 6 2 1 1 1 1 1] [8 8 6 6 5 3 3] [8 7 2 1 1 1 1] ]
16888 [ 4200000 [2 1 1 2 1 2 2 4] [2 1 3 1 3 3 1 1] [8 7 7 7 6 6 5] [8 7 7 5 5 3 1] ]
16889 [ 4350000 [2 2 1 4 1 2 2 1] [2 1 4 1 3 1 2 1] [8 7 6 6 3 3 2] [8 7 7 4 4 2 2] ]
16890 [ 4500000 [2 1 1 1 2 1 3 4] [2 2 2 1 2 1 3 2] [8 7 7 7 7 6 6] [8 7 6 5 5 4 4] ]
16891 [ 4650000 [2 4 2 1 2 2 1 1] [2 2 2 1 2 1 2 3] [8 7 4 3 3 2 1] [8 7 6 5 5 4 4] ]
16892 [ 4800000 [2 3 2 1 1 2 2 2] [2 4 1 2 1 1 3 1] [8 7 5 4 4 4 3] [8 7 4 4 3 3 3] ]
16893 [ 4950000 [3 2 2 1 2 1 1 3] [2 1 1 2 1 1 1 6] [8 6 5 4 4 3 3] [8 7 7 7 6 6 6] ]
16894 [ 5100000 [3 2 1 1 1 3 3 1] [2 2 3 2 1 1 3 1] [8 6 5 5 5 5 3] [8 7 6 4 3 3 3] ]
16895 [ 5250000 [4 1 2 1 2 2 1 2] [2 1 4 1 2 1 1 3] [8 5 5 4 4 3 2] [8 7 7 4 4 3 3] ]
16896 [ 5400000 [5 1 2 1 2 1 1 2] [2 2 1 1 4 1 3 1] [8 4 4 3 3 2 2] [8 7 6 6 6 3 3] ]
16897 [ 5550000 [1 1 4 4 1 2 1 1] [3 1 2 1 1 3 2 2] [8 8 8 5 2 2 1] [8 6 6 5 5 5 3] ]
16898 [ 5700000 [1 2 1 1 2 1 3 4] [3 1 4 1 2 2 1 1] [8 8 7 7 7 6 6] [8 6 6 3 3 2 1] ]
16899 [ 5850000 [1 1 3 3 2 2 2 1] [3 2 1 1 2 1 4 1] [8 8 8 6 4 3 2] [8 6 5 5 5 4 4] ]
16900 [ 6000000 [1 4 3 1 1 2 1 2] [3 2 2 1 2 2 1 2] [8 8 5 3 3 3 2] [8 6 5 4 4 3 2] ]
16901 [ 6150000 [2 1 1 4 1 2 1 3] [3 1 1 2 1 2 1 4] [8 7 7 7 4 4 3] [8 6 6 6 5 5 4] ]
16902 [ 6300000 [2 2 2 1 3 2 2 1] [3 1 4 1 3 1 1 1] [8 7 6 5 5 3 2] [8 6 6 3 3 1 1] ]
16903 [ 6450000 [2 5 1 3 1 1 1 1] [3 2 1 1 2 3 1 2] [8 7 3 3 1 1 1] [8 6 5 5 5 4 2] ]
16904 [ 6600000 [3 2 3 1 2 1 2 1] [3 1 3 2 2 1 1 2] [8 6 5 3 3 2 2] [8 6 6 4 3 2 2] ]
16905 [ 6750000 [4 1 2 2 1 1 3 1] [3 2 1 3 1 1 3 1] [8 5 5 4 3 3 3] [8 6 5 5 3 3 3] ]
16906 [ 6900000 [1 2 1 4 2 2 2 1] [4 1 1 2 2 2 2 1] [8 8 7 7 4 3 2] [8 5 5 5 4 3 2] ]
16907 [ 7050000 [1 2 5 2 1 2 1 1] [4 2 1 3 2 1 1 1] [8 8 7 3 2 2 1] [8 5 4 4 2 1 1] ]
16908 [ 7200000 [2 2 2 1 3 1 3 1] [4 1 3 1 3 1 1 1] [8 7 6 5 5 3 3] [8 5 5 3 3 1 1] ]
16909 [ 7350000 [3 1 4 2 1 1 1 2] [4 2 2 1 1 1 2 2] [8 6 6 3 2 2 2] [8 5 4 3 3 3 3] ]
16910 [ 7500000 [1 1 1 4 1 1 3 3] [5 2 1 2 2 1 1 1] [8 8 8 8 5 5 5] [8 4 3 3 2 1 1] ]
16911 [ 7650000 [5 2 1 2 1 2 1 1] [5 2 2 1 1 2 1 1] [8 4 3 3 2 2 1] [8 4 3 2 2 2 1] ]
16912 ]
16913 ] def
16914 } ctxdef
16915
16916 /encode {
16917 /chan exch def
16918 /target exch def
16919
16920 % Lookup memoized starting value close to the target
16921 memo chan 3 sub get {
16922 /m exch def
16923 m 0 get target gt {exit} if
16924 /mv m 0 get def
16925 /mb m 1 get def
16926 /ms m 2 get def
16927 /mbmax m 3 get def
16928 /msmax m 4 get def
16929 } forall
16930 /value mv def
16931 mb aload pop [/b8 /b7 /b6 /b5 /b4 /b3 /b2 /b1] {exch def} forall
16932 ms aload pop [/s8 /s7 /s6 /s5 /s4 /s3 /s2 /s1] {exch def} forall
16933 mbmax aload pop [/b7max /b6max /b5max /b4max /b3max /b2max /b1max] {exch def} forall
16934 msmax aload pop [/s7max /s6max /s5max /s4max /s3max /s2max /s1max] {exch def} forall
16935
16936 1 {chkchr} repeat 8 chan sub 2 mul dup 16 exch sub getinterval
16937
16938 } def
16939
16940 /barlen barcode length def
16941
16942 % Determine finder
16943 /finder shortfinder { [ 1 1 1 1 1 ] } { [ 1 1 1 1 1 1 1 1 1 ] } ifelse def
16944
16945 % Encode the main data
16946 /data barcode cvi barlen 1 add encode def
16947
16948 % Determine check data
16949 {
16950 /mod23map [
16951 [] []
16952 [ 13 12 4 9 3 1 ]
16953 [ 8 2 12 3 18 16 4 1 ]
16954 [ 11 16 17 8 20 4 10 2 5 1 ]
16955 [ 1 4 16 18 3 12 2 8 9 13 6 1 ]
16956 [ 20 16 22 13 15 12 5 4 17 9 21 3 7 1 ]
16957 [ 2 6 18 8 1 3 9 4 12 13 16 2 6 18 8 1 ]
16958 ] def
16959 } ctxdef
16960 /check [] def
16961 includecheck {
16962 /mod23 mod23map barlen get def
16963 0
16964 0 1 data length 1 sub {
16965 dup data exch get 1 sub exch mod23 exch get mul add
16966 } for
16967 23 mod 3 encode /check exch def
16968 } if
16969
16970 % Construct the symbol
16971 /sbs [
16972 finder aload pop
16973 data aload pop
16974 check aload pop
16975 ] def
16976
16977 % Create the human readable text
16978 /txt barlen array def
16979 0 1 barlen 1 sub {
16980 /i exch def
16981 txt i [barcode i 1 getinterval 0 0 () 0] put
16982 } for
16983
16984 % Return the arguments
16985 <<
16986 /ren /renlinear
16987 /sbs sbs
16988 /bhs [sbs length 1 add 2 idiv {height} repeat]
16989 /bbs [sbs length 1 add 2 idiv {0} repeat]
16990 /txt txt
16991 /textxalign (center)
16992 /borderleft 1.0
16993 /borderright 2.0
16994 /opt options
16995 >>
16996
16997 dontdraw not //renlinear if
16998
16999 //unloadctx exec
17000
17001 end
17002
17003 }
17004 [/barcode] {null def} forall
17005 bind def
17006 /channelcode dup load /uk.co.terryburton.bwipp defineresource pop
17007 end
17008 /setpacking where {pop setpacking} if
17009 %%EndData
17010 %%EndResource
17011 % --END ENCODER channelcode--
17012
17013 % --BEGIN ENCODER flattermarken--
17014 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear--
17015 % --DESC: Flattermarken
17016 % --EXAM: 11099
17017 % --EXOP: inkspread=-0.25 showborder borderleft=0 borderright=0
17018 % --RNDR: renlinear
17019 %%BeginResource: uk.co.terryburton.bwipp flattermarken 0.0 2025111800 65374 65193
17020 %%BeginData: 82 ASCII Lines
17021 /setpacking where {pop currentpacking true setpacking} if
17022 10 dict
17023 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
17024 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
17025 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
17026 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
17027 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
17028 begin
17029 /flattermarken {
17030
17031 20 dict begin % Confine variable to local scope
17032
17033 /ctx null def
17034 /dontdraw false def
17035 /includetext false def % Enable/disable text
17036 /textfont /Courier def
17037 /textsize 10.0 def
17038 /textyoffset -7.0 def
17039 /height 0.3 def
17040
17041 //processoptions exec /options exch def
17042 /barcode exch def
17043
17044 /flattermarken //loadctx exec
17045
17046 % Validate the input
17047 barcode {
17048 dup 48 lt exch 57 gt or {
17049 /bwipp.flattermarkenBadCharacter (Flattermarken must contain only digits) //raiseerror exec
17050 } if
17051 } forall
17052
17053 {
17054 % Create an array containing the character mappings
17055 /encs
17056 [ (0018) (0117) (0216) (0315) (0414) (0513) (0612) (0711) (0810)
17057 (0900)
17058 ] def
17059
17060 % Create a string of the available characters
17061 /barchars (1234567890) def
17062 } ctxdef
17063
17064 /barlen barcode length def % Length of the code
17065
17066 /sbs barlen 4 mul string def
17067 /txt barlen array def
17068
17069 0 1 barlen 1 sub {
17070 /i exch def
17071 % Lookup the encoding for the each barcode character
17072 barcode i 1 getinterval barchars exch search
17073 pop % Discard true leaving pre
17074 length /indx exch def % indx is the length of pre
17075 pop pop % Discard seek and post
17076 /enc encs indx get def % Get the indxth encoding
17077 sbs i 4 mul enc putinterval % Put encoded digit into sbs
17078 txt i [barcode i 1 getinterval i 9 mul textyoffset textfont textsize] put
17079 } for
17080
17081 % Return the arguments
17082 <<
17083 /ren /renlinear
17084 /sbs [sbs {48 sub} forall]
17085 /bhs [sbs length 1 add 2 idiv {height} repeat]
17086 /bbs [sbs length 1 add 2 idiv {0} repeat]
17087 /txt txt
17088 /opt options
17089 >>
17090
17091 dontdraw not //renlinear if
17092
17093 //unloadctx exec
17094
17095 end
17096
17097 }
17098 [/barcode] {null def} forall
17099 bind def
17100 /flattermarken dup load /uk.co.terryburton.bwipp defineresource pop
17101 end
17102 /setpacking where {pop setpacking} if
17103 %%EndData
17104 %%EndResource
17105 % --END ENCODER flattermarken--
17106
17107 % --BEGIN ENCODER raw--
17108 % --REQUIRES preamble raiseerror processoptions rendertext renlinear--
17109 % --DESC: Custom 1D symbology
17110 % --EXAM: 331132131313411122131311333213114131131221323
17111 % --EXOP: height=0.5
17112 % --RNDR: renlinear
17113 %%BeginResource: uk.co.terryburton.bwipp raw 0.0 2025111800 52900 56260
17114 %%BeginData: 43 ASCII Lines
17115 /setpacking where {pop currentpacking true setpacking} if
17116 10 dict
17117 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
17118 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
17119 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
17120 begin
17121 /raw {
17122
17123 20 dict begin % Confine variables to local scope
17124
17125 /ctx null def
17126 /dontdraw false def
17127 /height 1.0 def
17128
17129 //processoptions exec /options exch def
17130 /barcode exch def
17131
17132 % Validate input
17133 barcode {
17134 dup 49 lt exch 57 gt or {
17135 /bwipp.rawBadCharacter (Raw must contain only digits 1 to 9) //raiseerror exec
17136 } if
17137 } forall
17138
17139 % Return the arguments
17140 <<
17141 /ren /renlinear
17142 /sbs [barcode {48 sub} forall]
17143 /bhs [barcode length 1 add 2 idiv {height} repeat]
17144 /bbs [barcode length 1 add 2 idiv {0} repeat]
17145 /opt options
17146 >>
17147
17148 dontdraw not //renlinear if
17149
17150 end
17151
17152 }
17153 [/barcode] {null def} forall
17154 bind def
17155 /raw dup load /uk.co.terryburton.bwipp defineresource pop
17156 end
17157 /setpacking where {pop setpacking} if
17158 %%EndData
17159 %%EndResource
17160 % --END ENCODER raw--
17161
17162 % --BEGIN ENCODER daft--
17163 % --REQUIRES preamble raiseerror processoptions rendertext renlinear--
17164 % --DESC: Custom 4 state symbology
17165 % --EXAM: FATDAFTDAD
17166 % --EXOP:
17167 % --RNDR: renlinear
17168 %%BeginResource: uk.co.terryburton.bwipp daft 0.0 2025111800 56511 59689
17169 %%BeginData: 71 ASCII Lines
17170 /setpacking where {pop currentpacking true setpacking} if
17171 10 dict
17172 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
17173 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
17174 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
17175 begin
17176 /daft {
17177
17178 20 dict begin
17179
17180 /ctx null def
17181 /dontdraw false def
17182 /height 0.175 def
17183
17184 //processoptions exec /options exch def
17185 /barcode exch def
17186
17187 barcode () eq {
17188 /bwipp.daftEmptyData (The data must not be empty) //raiseerror exec
17189 } if
17190
17191 barcode {
17192 dup 68 ne exch dup 65 ne exch dup 70 ne exch 84 ne and and and {
17193 /bwipp.daftBadCharacter (DAFT must contain only characters D, A, F and T) //raiseerror exec
17194 } if
17195 } forall
17196
17197 /barlen barcode length def
17198
17199 /bbs barlen array def
17200 /bhs barlen array def
17201 0 1 barlen 1 sub {
17202 /i exch def
17203 /enc barcode i 1 getinterval def
17204 enc (D) eq {
17205 bbs i 0 height mul 8 div put
17206 bhs i 5 height mul 8 div put
17207 } if
17208 enc (A) eq {
17209 bbs i 3 height mul 8 div put
17210 bhs i 5 height mul 8 div put
17211 } if
17212 enc (F) eq {
17213 bbs i 0 height mul 8 div put
17214 bhs i 8 height mul 8 div put
17215 } if
17216 enc (T) eq {
17217 bbs i 3 height mul 8 div put
17218 bhs i 2 height mul 8 div put
17219 } if
17220 } for
17221
17222 % Return the arguments
17223 <<
17224 /ren /renlinear
17225 /bbs bbs
17226 /bhs bhs
17227 /sbs [bhs length 1 sub {1.44 1.872} repeat 1.44]
17228 /opt options
17229 >>
17230
17231 dontdraw not //renlinear if
17232
17233 end
17234
17235 }
17236 [/barcode] {null def} forall
17237 bind def
17238 /daft dup load /uk.co.terryburton.bwipp defineresource pop
17239 end
17240 /setpacking where {pop setpacking} if
17241 %%EndData
17242 %%EndResource
17243 % --END ENCODER daft--
17244
17245 % --BEGIN ENCODER symbol--
17246 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear renmatrix--
17247 % --DESC: Miscellaneous symbols
17248 % --EXAM: fima
17249 % --EXOP: backgroundcolor=DD000011
17250 % --RNDR: renlinear renmatrix
17251 %%BeginResource: uk.co.terryburton.bwipp symbol 0.0 2025111800 75858 75219
17252 %%BeginData: 87 ASCII Lines
17253 /setpacking where {pop currentpacking true setpacking} if
17254 10 dict
17255 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
17256 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
17257 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
17258 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
17259 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
17260 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
17261 begin
17262 /symbol {
17263
17264 20 dict begin
17265
17266 /ctx null def
17267 /dontdraw false def
17268
17269 //processoptions exec /options exch def
17270 /barcode exch def
17271
17272 /symbol //loadctx exec
17273
17274 { % context
17275
17276 /fimasbs [2.25 2.25 2.25 11.25 2.25 11.25 2.25 2.25 2.25] def
17277 /fimabhs [fimasbs length 2 idiv 1 add {.625} repeat] def
17278 /fimabbs [fimasbs length 2 idiv 1 add {0 } repeat] def
17279
17280 /fimbsbs [2.25 6.75 2.25 2.25 2.25 6.25 2.25 2.25 2.25 6.75 2.25] def
17281 /fimbbhs [fimbsbs length 2 idiv 1 add {.625} repeat] def
17282 /fimbbbs [fimbsbs length 2 idiv 1 add {0 } repeat] def
17283
17284 /fimcsbs [2.25 2.25 2.25 6.75 2.25 6.75 2.25 6.75 2.25 2.25 2.25] def
17285 /fimcbhs [fimcsbs length 2 idiv 1 add {.625} repeat] def
17286 /fimcbbs [fimcsbs length 2 idiv 1 add {0 } repeat] def
17287
17288 /fimdsbs [2.25 2.25 2.25 2.25 2.25 6.75 2.25 6.75 2.25 2.25 2.25 2.25 2.25] def
17289 /fimdbhs [fimdsbs length 2 idiv 1 add {.625} repeat] def
17290 /fimdbbs [fimdsbs length 2 idiv 1 add {0 } repeat] def
17291
17292 /fimesbs [2.25 6.75 2.25 15.75 2.25 6.75 2.25] def
17293 /fimebhs [fimesbs length 2 idiv 1 add {.625} repeat] def
17294 /fimebbs [fimesbs length 2 idiv 1 add {0 } repeat] def
17295
17296 /zebrasbs [100 { 1 1 } repeat 1] def
17297 /zebrabhs [zebrasbs length 2 idiv 1 add {1} repeat] def
17298 /zebrabbs [zebrasbs length 2 idiv 1 add {0} repeat] def
17299
17300 /checksize 199 def
17301 /checkpixs [ checksize dup mul 2 idiv {1 0} repeat 1 ] def
17302
17303 /renmap <<
17304 /renlinear //renlinear
17305 /renmatrix //renmatrix
17306 >> def
17307
17308 } ctxdef
17309
17310 /symbols <<
17311 /fima { << /ren /renlinear /sbs fimasbs /bhs fimabhs /bbs fimabbs >> }
17312 /fimb { << /ren /renlinear /sbs fimbsbs /bhs fimbbhs /bbs fimbbbs >> }
17313 /fimc { << /ren /renlinear /sbs fimcsbs /bhs fimcbhs /bbs fimcbbs >> }
17314 /fimd { << /ren /renlinear /sbs fimdsbs /bhs fimdbhs /bbs fimdbbs >> }
17315 /fime { << /ren /renlinear /sbs fimesbs /bhs fimebhs /bbs fimebbs >> }
17316 /zebra { << /ren /renlinear /sbs zebrasbs /bhs zebrabhs /bbs zebrabbs >> }
17317 /check { << /ren /renmatrix /pixs checkpixs /pixx checksize /pixy checksize /height checksize 72 div /width checksize 72 div >> }
17318 >> def
17319
17320 % Valiate input
17321 symbols barcode known not {
17322 /bwipp.symbolUnknownSymbol (Unknown symbol name provided) //raiseerror exec
17323 } if
17324
17325 symbols barcode get exec
17326 dup /opt options put
17327
17328 dontdraw not { dup /ren get renmap exch get exec } if
17329
17330 //unloadctx exec
17331
17332 end
17333
17334 }
17335 [/barcode] {null def} forall
17336 bind def
17337 /symbol dup load /uk.co.terryburton.bwipp defineresource pop
17338 end
17339 /setpacking where {pop setpacking} if
17340 %%EndData
17341 %%EndResource
17342 % --END ENCODER symbol--
17343
17344 % --BEGIN ENCODER pdf417--
17345 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix--
17346 % --DESC: PDF417
17347 % --EXAM: This is PDF417
17348 % --EXOP: columns=2
17349 % --RNDR: renmatrix
17350 %%BeginResource: uk.co.terryburton.bwipp pdf417 0.0 2025111800 218322 226803
17351 %%BeginData: 981 ASCII Lines
17352 /setpacking where {pop currentpacking true setpacking} if
17353 10 dict
17354 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
17355 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
17356 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
17357 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
17358 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
17359 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
17360 begin
17361 /pdf417 {
17362
17363 20 dict begin
17364
17365 /ctx null def
17366 /dontdraw false def
17367 /compact false def
17368 /eclevel -1 def
17369 /fixedeclevel false def
17370 /columns 0 def
17371 /rows 0 def
17372 /rowmult 3 def
17373 /ccc false def
17374 /raw false def
17375 /parse false def
17376 /parsefnc false def
17377
17378 //processoptions exec /options exch def
17379 /barcode exch def
17380
17381 barcode () eq {
17382 /bwipp.pdf417emptyData (The data must not be empty) //raiseerror exec
17383 } if
17384
17385 eclevel -1 ne eclevel 0 lt eclevel 8 gt or and {
17386 /bwipp.pdf417InvalidErrorCorrectionLevel (Valid error correction levels are 0 to 8) //raiseerror exec
17387 } if
17388
17389 ccc raw and {
17390 /bwipp.pdf417cccAndRaw (Cannot combine ccc and raw) //raiseerror exec
17391 } if
17392
17393 ccc compact and {
17394 /bwipp.pdf417cccAndCompact (Cannot combine ccc and compact) //raiseerror exec
17395 } if
17396
17397 rows 0 ne rows 3 lt rows 90 gt or and {
17398 /bwipp.pdf417invalidRows (There must be between 3 and 90 rows) //raiseerror exec
17399 } if
17400
17401 columns 0 ne columns 1 lt columns 30 gt or and {
17402 /bwipp.pdf417invalidColumns (There must be between 1 and 30 columns) //raiseerror exec
17403 } if
17404
17405 rowmult 0 le {
17406 /bwipp.pdf417badRowMult (The row multiplier must be greater than zero) //raiseerror exec
17407 } if
17408
17409 /pdf417 //loadctx exec
17410
17411 {
17412 % Modes and text submodes
17413 /T 0 def /N 1 def /B 2 def
17414 /A 0 def /L 1 def /M 2 def /P 3 def
17415
17416 % Special function characters for mode switching
17417 /tl -1 def /nl -2 def /bl -3 def /bl6 -4 def /bs -5 def
17418
17419 % Special function characters for text mode
17420 /al -6 def /ll -7 def /ml -8 def /pl -9 def /as -10 def /ps -11 def
17421
17422 % Character maps for each state
17423 /charmaps [
17424 % A L M P
17425 [ (A) (a) (0) (;) ] % 0
17426 [ (B) (b) (1) (<) ] % 1
17427 [ (C) (c) (2) (>) ] % 2
17428 [ (D) (d) (3) (@) ] % 3
17429 [ (E) (e) (4) ([) ] % 4
17430 [ (F) (f) (5) 92 ] % 5
17431 [ (G) (g) (6) (]) ] % 6
17432 [ (H) (h) (7) (_) ] % 7
17433 [ (I) (i) (8) (`) ] % 8
17434 [ (J) (j) (9) (~) ] % 9
17435 [ (K) (k) (&) (!) ] % 10
17436 [ (L) (l) 13 13 ] % 11
17437 [ (M) (m) 9 9 ] % 12
17438 [ (N) (n) (,) (,) ] % 13
17439 [ (O) (o) (:) (:) ] % 14
17440 [ (P) (p) (#) 10 ] % 15
17441 [ (Q) (q) (-) (-) ] % 16
17442 [ (R) (r) (.) (.) ] % 17
17443 [ (S) (s) ($) ($) ] % 18
17444 [ (T) (t) (/) (/) ] % 19
17445 [ (U) (u) (+) (") ] % 20
17446 [ (V) (v) (%) (|) ] % 21
17447 [ (W) (w) (*) (*) ] % 22
17448 [ (X) (x) (=) 40 ] % 23
17449 [ (Y) (y) (^) 41 ] % 24
17450 [ (Z) (z) pl (?) ] % 25
17451 [ ( ) ( ) ( ) ({) ] % 26
17452 [ ll as ll (}) ] % 27
17453 [ ml ml al (') ] % 28
17454 [ ps ps ps al ] % 29
17455 ] def
17456
17457 % Invert charmaps to give character to value maps for each state
17458 /charvals [ 30 dict 30 dict 30 dict 30 dict ] def
17459 /alltext 104 dict def
17460 0 1 charmaps length 1 sub {
17461 /i exch def
17462 /encs charmaps i get def
17463 0 1 3 {
17464 /j exch def
17465 encs j get dup type /stringtype eq {0 get} if % convert string to ASCII if required
17466 dup charvals j get exch i put
17467 alltext exch -1 put
17468 } for
17469 } for
17470
17471 /e 10000 def % "Empty"
17472
17473 /latlen [ % Bit length of latch between submodes
17474 % To: A L M P From
17475 [ 0 1 1 2 ] % A
17476 [ 2 0 1 2 ] % L
17477 [ 1 1 0 1 ] % M
17478 [ 1 2 2 0 ] % P
17479 ] def
17480
17481 /latseq [ % Latch sequences between submodes
17482 % To: A L M P From
17483 [ [] [ll] [ml] [ml pl] ] % A
17484 [ [ml al] [] [ml] [ml pl] ] % L
17485 [ [al] [ll] [] [pl] ] % M
17486 [ [al] [al ll] [al ml] [] ] % P
17487 ] def
17488
17489 /shftlen [ % Bit length of shift to submode
17490 % To: A L M P From
17491 [ e e e 1 ] % A
17492 [ 1 e e 1 ] % L
17493 [ e e e 1 ] % M
17494 [ e e e e ] % P
17495 ] def
17496
17497 /latchcws <<
17498 tl 900 bl 901 bl6 924 nl 902 bs 913
17499 >> def
17500 } ctxdef
17501
17502 % Convert input into array of codewords
17503 raw {
17504 /datcws barcode length array def
17505 /i 0 def /j 0 def
17506 { % loop
17507 i barcode length 3 sub ge {exit} if
17508 barcode i get 94 ne {exit} if
17509 barcode i 1 add 3 getinterval false 1 index {
17510 dup 48 lt exch 57 gt or { pop true } if
17511 } forall { pop exit } if
17512 cvi /cw exch def
17513 datcws j cw put
17514 /i i 4 add def
17515 /j j 1 add def
17516 } loop
17517 i barcode length ne {
17518 /bwipp.pdf417badRawFormat (raw data must be formatted as ^NNN) //raiseerror exec
17519 } if
17520 /datcws datcws 0 j getinterval def
17521 } if
17522
17523 /encb {
17524 /in exch def
17525 /inlen in length def
17526 /out inlen 6 idiv 5 mul inlen 6 mod add array def
17527 0 1 inlen 6 idiv 1 sub {
17528 /k exch def
17529 /msbs [ in k 6 mul 3 getinterval aload pop ] def
17530 /mscs [
17531 msbs aload pop exch 256 mul add exch 65536 mul add
17532 3 {dup 900 mod exch 900 idiv} repeat
17533 ] def
17534 /lsbs [ in k 6 mul 3 add 3 getinterval aload pop ] def
17535 /lscs [
17536 lsbs aload pop exch 256 mul add exch 65536 mul add
17537 3 {dup 900 mod exch 900 idiv} repeat
17538 ] def
17539 lscs 0 get mscs 0 get 316 mul add
17540 out k 5 mul 4 add 2 index 900 mod put
17541 900 idiv lscs 1 get add mscs 0 get 641 mul add mscs 1 get 316 mul add
17542 out k 5 mul 3 add 2 index 900 mod put
17543 900 idiv lscs 2 get add mscs 0 get 20 mul add mscs 1 get 641 mul add mscs 2 get 316 mul add
17544 out k 5 mul 2 add 2 index 900 mod put
17545 900 idiv lscs 3 get add mscs 1 get 20 mul add mscs 2 get 641 mul add
17546 out k 5 mul 1 add 2 index 900 mod put
17547 900 idiv mscs 2 get 20 mul add
17548 out k 5 mul 3 -1 roll 900 mod put
17549 } for
17550 /rem inlen 6 mod def
17551 rem 0 ne {
17552 out out length rem sub
17553 [ in inlen rem sub rem getinterval aload pop ]
17554 putinterval
17555 } if
17556 out
17557 } def
17558
17559 ccc {
17560 /barlen barcode length def
17561 /datcws barlen 6 idiv 5 mul barlen 6 mod add 2 add array def
17562 datcws 0 920 put
17563 datcws 1 barlen 6 mod 0 eq {924} {901} ifelse put
17564 datcws 2 [ barcode {} forall ] encb putinterval
17565 } if
17566
17567 raw not ccc not and {
17568
17569 % Parse the input
17570 /fncvals <<
17571 /parse parse
17572 /parsefnc parsefnc
17573 /eci true
17574 % Predates FNC non-data codewords, but supports ECI
17575 >> def
17576 /msg barcode fncvals //parseinput exec def
17577 /msglen msg length def
17578
17579 % Determine runlengths of digits
17580 /numdigits [ msglen {0} repeat 0 ] def
17581 /numtext [ msglen {0} repeat 0 ] def
17582 /numbytes [ msglen {0} repeat 0 ] def
17583 /iseci [ msglen {0} repeat 0 ] def
17584 msglen 1 sub -1 0 {
17585 /i exch def
17586 msg i get dup 48 ge exch 57 le and {
17587 numdigits i numdigits i 1 add get 1 add put
17588 } if
17589 alltext msg i get known numdigits i get 13 lt and {
17590 numtext i numtext i 1 add get 1 add put
17591 } if
17592 msg i get 0 ge numtext i get 5 lt and numdigits i get 13 lt and {
17593 numbytes i numbytes i 1 add get 1 add put
17594 } if
17595 iseci i msg i get -1000000 le put
17596 } for
17597 /numdigits numdigits 0 msglen getinterval def
17598 /numtext numtext 0 msglen getinterval def
17599 /numbytes numbytes 0 msglen getinterval def
17600
17601 /seq [] def /seqlen 0 def /state T def /p 0 def { % loop
17602 p msglen eq {exit} if
17603 iseci p get {
17604 /eci msg p get def
17605 /seq [
17606 seq aload pop
17607 [ eci ]
17608 ] def
17609 /p p 1 add def
17610 /seqlen seqlen eci -1810900 le {2} {eci -1000900 le {3} {2} ifelse} ifelse add def
17611 } {
17612 /n numdigits p get def
17613 n 13 ge n msglen eq n 8 ge and or { % 13+ digits or all-numeric and 8+ digits
17614 /seq [
17615 seq aload pop
17616 nl
17617 [ msg p n getinterval aload pop ]
17618 ] def
17619 /state N def
17620 /p p n add def
17621 /seqlen seqlen 1 add n add def
17622 } { % next
17623 /t numtext p get def
17624 t 5 ge {
17625 /seq [
17626 seq aload pop
17627 state T ne {
17628 tl
17629 } if
17630 [ msg p t getinterval aload pop ]
17631 ] def
17632 /state T def
17633 /p p t add def
17634 /seqlen seqlen 1 add t add def % ish
17635 } { % next
17636 /b numbytes p get def
17637 b 1 eq state T eq and {
17638 /seq [
17639 seq aload pop
17640 bs
17641 [ msg p get ]
17642 ] def
17643 /p p b add def
17644 /seqlen seqlen 2 add def
17645 } { % next
17646 /seq [
17647 seq aload pop
17648 b 6 mod 0 ne {bl} {bl6} ifelse
17649 [ msg p b getinterval aload pop ]
17650 ] def
17651 /state B def
17652 /p p b add def
17653 /seqlen seqlen 1 add b add def
17654 } ifelse } ifelse } ifelse } ifelse
17655 } loop
17656
17657 % Submode encoding functions
17658 /enca {charvals A get exch get} def
17659 /encl {charvals L get exch get} def
17660 /encm {charvals M get exch get} def
17661 /encp {charvals P get exch get} def
17662 /textencfuncs [ /enca /encl /encm /encp ] def
17663
17664 /addtotext {
17665 text exch l exch put
17666 /l l 1 add def
17667 } def
17668
17669 /enct {
17670 /in exch def
17671
17672 /curlen [ e e e e ] def
17673 curlen submode 0 put
17674 /curseq [ [] [] [] [] ] def
17675
17676 % Derive the optimal sequences ending in each submode
17677 in {
17678
17679 /char exch def
17680
17681 % Check for optimisations in the current sequences by latching from x to y
17682 { % loop
17683 /imp false def
17684 [ A L M P ] {
17685 /x exch def
17686 [ A L M P ] {
17687 /y exch def
17688 /cost curlen x get latlen x get y get add def
17689 cost curlen y get lt {
17690 curlen y cost put
17691 curseq y [
17692 curseq x get aload pop
17693 latseq x get y get aload pop
17694 ] put
17695 /imp true def
17696 } if
17697 } forall
17698 } forall
17699 imp not {exit} if % Repeat unless no improvement
17700 } loop
17701
17702 % Determine optimal next sequences for each valid encoding
17703 /nxtlen [ e e e e ] def
17704 /nxtseq 4 array def
17705
17706 [ A L M P ] {
17707 /x exch def
17708
17709 { % loop for common exit
17710
17711 charvals x get char known not {exit} if
17712
17713 % Extend directly
17714 /cost curlen x get 1 add def
17715 cost nxtlen x get lt {
17716 nxtlen x cost put
17717 nxtseq x [ curseq x get aload pop char ] put
17718 } if
17719
17720 % Optimise for direct shifts from y to x
17721 [ A L M P ] {
17722 /y exch def
17723 x y ne {
17724 /cost curlen y get shftlen y get x get add 1 add def
17725 cost nxtlen y get lt {
17726 nxtlen y cost put
17727 nxtseq y [
17728 curseq y get aload pop
17729 x A eq {as} {ps} ifelse
17730 char
17731 ] put
17732 } if
17733 } if
17734 } forall
17735
17736 exit
17737 } loop
17738
17739 } forall
17740
17741 /curlen nxtlen def
17742 /curseq nxtseq def
17743
17744 } forall
17745
17746 % Select the optimal sequence
17747 /minseq e def
17748 [ A L M P ] {
17749 /k exch def
17750 curlen k get minseq lt {
17751 /minseq curlen k get def
17752 /txtseq curseq k get def
17753 } if
17754 } forall
17755
17756 % Encode the sequence
17757 /text minseq array def
17758 /k 0 def /l 0 def {
17759 k txtseq length ge {exit} if
17760
17761 /char txtseq k get def
17762
17763 % Encode character
17764 char textencfuncs submode get load exec addtotext
17765 /k k 1 add def
17766
17767 % Encode shifted next character
17768 char as eq char ps eq or {
17769 txtseq k get char as eq {enca} {encp} ifelse addtotext
17770 /k k 1 add def
17771 } if
17772
17773 % Latches to new submode
17774 char al eq {/submode A def} if
17775 char ll eq {/submode L def} if
17776 char ml eq {/submode M def} if
17777 char pl eq {/submode P def} if
17778 } loop
17779
17780 text length 2 mod 1 eq {
17781 submode P eq {
17782 /pad al encp def
17783 /submode A def
17784 } {
17785 % Need to check whether a ps shift can be used to pad
17786 /nextecitext false def
17787 % If have one or more ECIs next followed by text sequence (array)
17788 i 1 add 1 seq length 1 sub {
17789 /ti exch def
17790 seq ti get type /arraytype ne { /nextecitext false def exit } if
17791 seq ti get 0 get -1000000 gt { exit } if
17792 /nextecitext true def
17793 } for
17794 nextecitext { % Then don't use ps as it would affect first char of text sequence
17795 submode A eq {
17796 charvals L get seq ti get 0 get known { % Check whether to use ll or ml latch
17797 /pad ll enca def
17798 /submode L def
17799 } {
17800 /pad ml enca def
17801 /submode M def
17802 } ifelse
17803 } {
17804 submode M eq {
17805 charvals L get seq ti get 0 get known { % Check whether to use ll, pl or al latch
17806 /pad ll encm def
17807 /submode L def
17808 } {
17809 charvals P get seq ti get 0 get known {
17810 /pad pl encm def
17811 /submode P def
17812 } {
17813 /pad al encm def
17814 /submode A def
17815 } ifelse } ifelse
17816 } { % L
17817 /pad ml encl def % Only latch available
17818 /submode M def
17819 } ifelse } ifelse
17820 } { % Otherwise use standard ps shift pad
17821 /pad ps textencfuncs submode get load exec def
17822 } ifelse
17823 } ifelse
17824 /text [ text aload pop pad ] def
17825 } if
17826
17827 /out text length 2 idiv array def
17828 0 1 out length 1 sub {
17829 /k exch def
17830 out k text k 2 mul get 30 mul text k 2 mul 1 add get add put
17831 } for
17832
17833 out
17834
17835 } def
17836
17837 /encn {
17838 /in exch def
17839 /out [] def
17840 0 44 in length 1 sub {
17841 /k exch def
17842 /gmod [
17843 1 in k in length k sub dup 44 gt {pop 44} if getinterval
17844 {48 sub} forall
17845 ] def
17846 /cwn [] def {
17847 /dv 900 def
17848 /gmul [] def /val 0 def {
17849 gmod length 0 eq {exit} if
17850 /val val 10 mul gmod 0 get add def
17851 /gmod gmod 1 gmod length 1 sub getinterval def
17852 val dv lt {
17853 gmul length 0 ne {
17854 /gmul [ gmul aload pop 0 ] def
17855 } if
17856 } {
17857 /gmul [ gmul aload pop val dv idiv ] def
17858 } ifelse
17859 /val val dv mod def
17860 } loop
17861 /dv val def
17862 /cwn [ dv cwn aload pop ] def
17863 /gmod gmul def
17864 gmul length 0 eq {exit} if
17865 } loop
17866 /out [ out aload pop cwn aload pop ] def
17867 } for
17868 out
17869 } def
17870
17871 /ence {
17872 0 get neg 1000000 sub
17873 dup 000899 le { % ECI 000000 - 000899
17874 927 exch 2 array astore
17875 } { dup 810899 le { % ECI 000900 - 810899
17876 926 exch dup 900 idiv 1 sub exch 900 mod 3 array astore
17877 } { dup 811799 le { % ECI 810900 - 811799
17878 925 exch 810900 sub 2 array astore
17879 } {
17880 /bwipp.pdf417badECI (PDF417 supports ECIs 000000 to 811799) //raiseerror exec
17881 } ifelse } ifelse } ifelse
17882 } def
17883
17884 /encfuncs [ /enct /encn /encb ] def
17885
17886 /addtocws {
17887 dup datcws j 3 -1 roll putinterval
17888 length j add /j exch def
17889 } def
17890
17891 % Encode the sequence
17892 /state T def /submode A def
17893 /datcws seqlen array def
17894 /i 0 def /j 0 def {
17895 i seq length ge {exit} if
17896 /chars seq i get def
17897 chars type /arraytype eq {
17898 chars 0 get -1000000 le { % ECI
17899 chars ence addtocws
17900 } { % Encode data according to mode
17901 chars encfuncs state get load exec addtocws
17902 } ifelse
17903 } { % Encode the latch to new state or byte shift
17904 [ latchcws chars get ] addtocws
17905 chars tl eq {/state T def /submode A def} if
17906 chars nl eq {/state N def} if
17907 chars bl eq chars bl6 eq or {/state B def} if
17908 chars bs eq {
17909 /i i 1 add def
17910 seq i get encb addtocws
17911 } if
17912 } ifelse
17913 /i i 1 add def
17914 } loop
17915 /datcws datcws 0 j getinterval def
17916 } if
17917 /m datcws length def
17918
17919 m 926 gt {
17920 /bwipp.pdf417dataTooLong (The data is too long) //raiseerror exec
17921 } if
17922
17923 % Determine the error correction level if unspecified
17924 eclevel -1 eq {
17925 m 40 le {/eclevel 2 def} if
17926 m 41 ge m 160 le and {/eclevel 3 def} if
17927 m 161 ge m 320 le and {/eclevel 4 def} if
17928 m 321 ge {/eclevel 5 def} if
17929 } if
17930
17931 % Reduce the error level so that it does not cause an excessive number of codewords
17932 fixedeclevel not {
17933 /maxeclevel 928 1 sub m sub ln 2 ln div cvi 1 sub def
17934 eclevel maxeclevel gt {/eclevel maxeclevel def} if
17935 } if
17936
17937 % To determine size of matrix, number of columns if given by user...
17938 /k 2 eclevel 1 add exp cvi def
17939 columns 0 eq {/columns m k add 3 div sqrt round cvi def} if
17940 /c columns 1 ge {columns} {1} ifelse def
17941
17942 % ... and rows is greater of those required and that given by user within limits
17943 /r m k add 1 add columns div ceiling cvi def % Required
17944 r rows lt rows 90 le and {/r rows def} if
17945 r 3 lt {/r 3 def} if
17946
17947 % Symbol cannot exceed 90 rows
17948 r 90 gt {
17949 /bwipp.pdf417insufficientCapacity (Insufficient capacity in the symbol) //raiseerror exec
17950 } if
17951
17952 % Opportunistically raise the error level if a better fit to the matrix is possible
17953 fixedeclevel not {
17954 /maxeclevel c r mul 1 sub m sub ln 2 ln div cvi 1 sub 8 2 copy gt {exch} if pop def
17955 maxeclevel eclevel gt {
17956 /eclevel maxeclevel def
17957 /k 2 eclevel 1 add exp cvi def
17958 } if
17959 } if
17960
17961 % Create codewords array with one extra working space element and add padding
17962 /n c r mul k sub def
17963 /cws c r mul 1 add array def
17964 cws 0 n put
17965 cws 1 datcws putinterval
17966 cws m 1 add [ n m sub 1 sub {900} repeat ] putinterval
17967 cws n [ k {0} repeat 0 ] putinterval
17968
17969 % Calculate the log and anti-log tables
17970 {
17971 /rsalog [ 1 928 {dup 3 mul 929 mod} repeat ] def
17972 /rslog 929 array def
17973 1 1 928 {dup rsalog exch get exch rslog 3 1 roll put} for
17974 } ctxdef
17975
17976 % Function to calculate the product in the field
17977 /rsprod {
17978 2 copy 0 ne exch 0 ne and {
17979 rslog exch get exch rslog exch get add 928 mod rsalog exch get
17980 } {
17981 pop pop 0
17982 } ifelse
17983 } def
17984
17985 % Generate the coefficients
17986 /coeffs [ 1 k {0} repeat ] def
17987 1 1 k {
17988 /i exch def
17989 coeffs i coeffs i 1 sub get put
17990 i 1 sub -1 1 {
17991 /j exch def
17992 coeffs j coeffs j 1 sub get coeffs j get rsalog i get rsprod add 929 mod put
17993 } for
17994 coeffs 0 coeffs 0 get rsalog i get rsprod put
17995 } for
17996 /coeffs coeffs 0 coeffs length 1 sub getinterval def
17997 coeffs length 1 sub -2 0 {coeffs exch 2 copy get 929 exch sub put} for
17998
17999 % Derive the error codewords
18000 0 1 n 1 sub {
18001 /t exch cws exch get cws n get add 929 mod def
18002 0 1 k 1 sub {
18003 /j exch def
18004 cws n j add cws n j add 1 add get 929 t coeffs k j sub 1 sub get mul 929 mod sub add 929 mod put
18005 } for
18006 } for
18007 n 1 n k add { dup cws exch 929 cws 5 -1 roll get sub 929 mod put } for
18008
18009 % Trim the working space from the end of the codewords
18010 /cws cws 0 cws length 1 sub getinterval def
18011
18012 options /debugcws known { /bwipp.debugcws cws //raiseerror exec } if
18013
18014 % Base 10 encoding of the bar space successions for the codewords in each cluster
18015 {
18016 /clusters [
18017 [
18018 120256 125680 128380 120032 125560 128318 108736 119920 108640 86080 108592 86048
18019 110016 120560 125820 109792 120440 125758 88256 109680 88160 89536 110320 120700
18020 89312 110200 120638 89200 110140 89840 110460 89720 110398 89980 128506 119520
18021 125304 128190 107712 119408 125244 107616 119352 84032 107568 119324 84000 107544
18022 83984 108256 119672 125374 85184 108144 119612 85088 108088 119582 85040 108060
18023 85728 108408 119742 85616 108348 85560 108318 85880 108478 85820 85790 107200
18024 119152 125116 107104 119096 125086 83008 107056 119068 82976 107032 82960 82952
18025 83648 107376 119228 83552 107320 119198 83504 107292 83480 83468 83824 107452
18026 83768 107422 83740 83900 106848 118968 125022 82496 106800 118940 82464 106776
18027 118926 82448 106764 82440 106758 82784 106936 119006 82736 106908 82712 106894
18028 82700 82694 106974 82830 82240 106672 118876 82208 106648 118862 82192 106636
18029 82184 106630 82180 82352 82328 82316 82080 118830 106572 106566 82050 117472
18030 124280 127678 103616 117360 124220 103520 117304 124190 75840 103472 75808 104160
18031 117624 124350 76992 104048 117564 76896 103992 76848 76824 77536 104312 117694
18032 77424 104252 77368 77340 77688 104382 77628 77758 121536 126320 128700 121440
18033 126264 128670 111680 121392 126236 111648 121368 126222 111632 121356 103104 117104
18034 124092 112320 103008 117048 124062 112224 121656 126366 93248 74784 102936 117006
18035 93216 112152 93200 75456 103280 117180 93888 75360 103224 117150 93792 112440
18036 121758 93744 75288 93720 75632 103356 94064 75576 103326 94008 112542 93980
18037 75708 94140 75678 94110 121184 126136 128606 111168 121136 126108 111136 121112
18038 126094 111120 121100 111112 111108 102752 116920 123998 111456 102704 116892 91712
18039 74272 121244 116878 91680 74256 102668 91664 111372 102662 74244 74592 102840
18040 116958 92000 74544 102812 91952 111516 102798 91928 74508 74502 74680 102878
18041 92088 74652 92060 74638 92046 92126 110912 121008 126044 110880 120984 126030
18042 110864 120972 110856 120966 110852 110850 74048 102576 116828 90944 74016 102552
18043 116814 90912 111000 121038 90896 73992 102534 90888 110982 90884 74160 102620
18044 91056 74136 102606 91032 111054 91020 74118 91014 91100 91086 110752 120920
18045 125998 110736 120908 110728 120902 110724 110722 73888 102488 116782 90528 73872
18046 102476 90512 110796 102470 90504 73860 90500 73858 73944 90584 90572 90566
18047 120876 120870 110658 102444 73800 90312 90308 90306 101056 116080 123580 100960
18048 116024 70720 100912 115996 70688 100888 70672 70664 71360 101232 116156 71264
18049 101176 116126 71216 101148 71192 71180 71536 101308 71480 101278 71452 71612
18050 71582 118112 124600 127838 105024 118064 124572 104992 118040 124558 104976 118028
18051 104968 118022 100704 115896 123486 105312 100656 115868 79424 70176 118172 115854
18052 79392 105240 100620 79376 70152 79368 70496 100792 115934 79712 70448 118238
18053 79664 105372 100750 79640 70412 79628 70584 100830 79800 70556 79772 70542
18054 70622 79838 122176 126640 128860 122144 126616 128846 122128 126604 122120 126598
18055 122116 104768 117936 124508 113472 104736 126684 124494 113440 122264 126670 113424
18056 104712 117894 113416 122246 104706 69952 100528 115804 78656 69920 100504 115790
18057 96064 78624 104856 117966 96032 113560 122318 100486 96016 78600 104838 96008
18058 69890 70064 100572 78768 70040 100558 96176 78744 104910 96152 113614 70022
18059 78726 70108 78812 70094 96220 78798 122016 126552 128814 122000 126540 121992
18060 126534 121988 121986 104608 117848 124462 113056 104592 126574 113040 122060 117830
18061 113032 104580 113028 104578 113026 69792 100440 115758 78240 69776 100428 95136
18062 78224 104652 100422 95120 113100 69764 95112 78212 69762 78210 69848 100462
18063 78296 69836 95192 78284 69830 95180 78278 69870 95214 121936 126508 121928
18064 126502 121924 121922 104528 117804 112848 104520 117798 112840 121958 112836 104514
18065 112834 69712 100396 78032 69704 100390 94672 78024 104550 94664 112870 69698
18066 94660 78018 94658 78060 94700 94694 126486 121890 117782 104484 104482 69672
18067 77928 94440 69666 77922 99680 68160 99632 68128 99608 115342 68112 99596
18068 68104 99590 68448 99768 115422 68400 99740 68376 99726 68364 68358 68536
18069 99806 68508 68494 68574 101696 116400 123740 101664 116376 101648 116364 101640
18070 116358 101636 67904 99504 115292 72512 67872 116444 115278 72480 101784 116430
18071 72464 67848 99462 72456 101766 67842 68016 99548 72624 67992 99534 72600
18072 101838 72588 67974 68060 72668 68046 72654 118432 124760 127918 118416 124748
18073 118408 124742 118404 118402 101536 116312 105888 101520 116300 105872 118476 116294
18074 105864 101508 105860 101506 105858 67744 99416 72096 67728 116334 80800 72080
18075 101580 99398 80784 105932 67716 80776 72068 67714 72066 67800 99438 72152
18076 67788 80856 72140 67782 80844 72134 67822 72174 80878 126800 128940 126792
18077 128934 126788 126786 118352 124716 122576 126828 124710 122568 126822 122564 118338
18078 122562 101456 116268 105680 101448 116262 114128 105672 118374 114120 122598 101442
18079 114116 105666 114114 67664 99372 71888 67656 99366 80336 71880 101478 97232
18080 80328 105702 67650 97224 114150 71874 97220 67692 71916 67686 80364 71910
18081 97260 80358 97254 126760 128918 126756 126754 118312 124694 122472 126774 122468
18082 118306 122466 101416 116246 105576 101412 113896 105572 101410 113892 105570 113890
18083 67624 99350 71784 101430 80104 71780 67618 96744 80100 71778 96740 80098
18084 96738 71798 96758 126738 122420 122418 105524 113780 113778 71732 79988 96500
18085 96498 66880 66848 98968 66832 66824 66820 66992 66968 66956 66950 67036
18086 67022 100000 99984 115532 99976 115526 99972 99970 66720 98904 69024 100056
18087 98892 69008 100044 69000 100038 68996 66690 68994 66776 98926 69080 100078
18088 69068 66758 69062 66798 69102 116560 116552 116548 116546 99920 102096 116588
18089 115494 102088 116582 102084 99906 102082 66640 68816 66632 98854 73168 68808
18090 66628 73160 68804 66626 73156 68802 66668 68844 66662 73196 68838 73190
18091 124840 124836 124834 116520 118632 124854 118628 116514 118626 99880 115478 101992
18092 116534 106216 101988 99874 106212 101986 106210 66600 98838 68712 99894 72936
18093 68708 66594 81384 72932 68706 81380 72930 66614 68726 72950 81398 128980
18094 128978 124820 126900 124818 126898 116500 118580 116498 122740 118578 122738 99860
18095 101940 99858 106100 101938 114420
18096 ] [
18097 128352 129720 125504 128304 129692 125472 128280 129678 125456 128268 125448 128262
18098 125444 125792 128440 129758 120384 125744 128412 120352 125720 128398 120336 125708
18099 120328 125702 120324 120672 125880 128478 110144 120624 125852 110112 120600 125838
18100 110096 120588 110088 120582 110084 110432 120760 125918 89664 110384 120732 89632
18101 110360 120718 89616 110348 89608 110342 89952 110520 120798 89904 110492 89880
18102 110478 89868 90040 110558 90012 89998 125248 128176 129628 125216 128152 129614
18103 125200 128140 125192 128134 125188 125186 119616 125360 128220 119584 125336 128206
18104 119568 125324 119560 125318 119556 119554 108352 119728 125404 108320 119704 125390
18105 108304 119692 108296 119686 108292 108290 85824 108464 119772 85792 108440 119758
18106 85776 108428 85768 108422 85764 85936 108508 85912 108494 85900 85894 85980
18107 85966 125088 128088 129582 125072 128076 125064 128070 125060 125058 119200 125144
18108 128110 119184 125132 119176 125126 119172 119170 107424 119256 125166 107408 119244
18109 107400 119238 107396 107394 83872 107480 119278 83856 107468 83848 107462 83844
18110 83842 83928 107502 83916 83910 83950 125008 128044 125000 128038 124996 124994
18111 118992 125036 118984 125030 118980 118978 106960 119020 106952 119014 106948 106946
18112 82896 106988 82888 106982 82884 82882 82924 82918 124968 128022 124964 124962
18113 118888 124982 118884 118882 106728 118902 106724 106722 82408 106742 82404 82402
18114 124948 124946 118836 118834 106612 106610 124224 127664 129372 124192 127640 129358
18115 124176 127628 124168 127622 124164 124162 117568 124336 127708 117536 124312 127694
18116 117520 124300 117512 124294 117508 117506 104256 117680 124380 104224 117656 124366
18117 104208 117644 104200 117638 104196 104194 77632 104368 117724 77600 104344 117710
18118 77584 104332 77576 104326 77572 77744 104412 77720 104398 77708 77702 77788
18119 77774 128672 129880 93168 128656 129868 92664 128648 129862 92412 128644 128642
18120 124064 127576 129326 126368 124048 129902 126352 128716 127558 126344 124036 126340
18121 124034 126338 117152 124120 127598 121760 117136 124108 121744 126412 124102 121736
18122 117124 121732 117122 121730 103328 117208 124142 112544 103312 117196 112528 121804
18123 117190 112520 103300 112516 103298 112514 75680 103384 117230 94112 75664 103372
18124 94096 112588 103366 94088 75652 94084 75650 75736 103406 94168 75724 94156
18125 75718 94150 75758 128592 129836 91640 128584 129830 91388 128580 91262 128578
18126 123984 127532 126160 123976 127526 126152 128614 126148 123970 126146 116944 124012
18127 121296 116936 124006 121288 126182 121284 116930 121282 102864 116972 111568 102856
18128 116966 111560 121318 111556 102850 111554 74704 102892 92112 74696 102886 92104
18129 111590 92100 74690 92098 74732 92140 74726 92134 128552 129814 90876 128548
18130 90750 128546 123944 127510 126056 128566 126052 123938 126050 116840 123958 121064
18131 116836 121060 116834 121058 102632 116854 111080 121078 111076 102626 111074 74216
18132 102646 91112 74212 91108 74210 91106 74230 91126 128532 90494 128530 123924
18133 126004 123922 126002 116788 120948 116786 120946 102516 110836 102514 110834 73972
18134 90612 73970 90610 128522 123914 125978 116762 120890 102458 110714 123552 127320
18135 129198 123536 127308 123528 127302 123524 123522 116128 123608 127342 116112 123596
18136 116104 123590 116100 116098 101280 116184 123630 101264 116172 101256 116166 101252
18137 101250 71584 101336 116206 71568 101324 71560 101318 71556 71554 71640 101358
18138 71628 71622 71662 127824 129452 79352 127816 129446 79100 127812 78974 127810
18139 123472 127276 124624 123464 127270 124616 127846 124612 123458 124610 115920 123500
18140 118224 115912 123494 118216 124646 118212 115906 118210 100816 115948 105424 100808
18141 115942 105416 118246 105412 100802 105410 70608 100844 79824 70600 100838 79816
18142 105446 79812 70594 79810 70636 79852 70630 79846 129960 95728 113404 129956
18143 95480 113278 129954 95356 95294 127784 129430 78588 128872 129974 95996 78462
18144 128868 127778 95870 128866 123432 127254 124520 123428 126696 128886 123426 126692
18145 124514 126690 115816 123446 117992 115812 122344 117988 115810 122340 117986 122338
18146 100584 115830 104936 100580 113640 104932 100578 113636 104930 113634 70120 100598
18147 78824 70116 96232 78820 70114 96228 78818 96226 70134 78838 129940 94968
18148 113022 129938 94844 94782 127764 78206 128820 127762 95102 128818 123412 124468
18149 123410 126580 124466 126578 115764 117876 115762 122100 117874 122098 100468 104692
18150 100466 113140 104690 113138 69876 78324 69874 95220 78322 95218 129930 94588
18151 94526 127754 128794 123402 124442 126522 115738 117818 121978 100410 104570 112890
18152 69754 78074 94714 94398 123216 127148 123208 127142 123204 123202 115408 123244
18153 115400 123238 115396 115394 99792 115436 99784 115430 99780 99778 68560 99820
18154 68552 99814 68548 68546 68588 68582 127400 129238 72444 127396 72318 127394
18155 123176 127126 123752 123172 123748 123170 123746 115304 123190 116456 115300 116452
18156 115298 116450 99560 115318 101864 99556 101860 99554 101858 68072 99574 72680
18157 68068 72676 68066 72674 68086 72694 129492 80632 105854 129490 80508 80446
18158 127380 72062 127924 127378 80766 127922 123156 123700 123154 124788 123698 124786
18159 115252 116340 115250 118516 116338 118514 99444 101620 99442 105972 101618 105970
18160 67828 72180 67826 80884 72178 80882 97008 114044 96888 113982 96828 96798
18161 129482 80252 130010 97148 80190 97086 127370 127898 128954 123146 123674 124730
18162 126842 115226 116282 118394 122618 99386 101498 105722 114170 67706 71930 80378
18163 96632 113854 96572 96542 80062 96702 96444 96414 96350 123048 123044 123042
18164 115048 123062 115044 115042 99048 115062 99044 99042 67048 99062 67044 67042
18165 67062 127188 68990 127186 123028 123316 123026 123314 114996 115572 114994 115570
18166 98932 100084 98930 100082 66804 69108 66802 69106 129258 73084 73022 127178
18167 127450 123018 123290 123834 114970 115514 116602 98874 99962 102138 66682 68858
18168 73210 81272 106174 81212 81182 72894 81342 97648 114364 97592 114334 97564
18169 97550 81084 97724 81054 97694 97464 114270 97436 97422 80990 97502 97372
18170 97358 97326 114868 114866 98676 98674 66292 66290 123098 114842 115130 98618
18171 99194 66170 67322 69310 73404 73374 81592 106334 81564 81550 73310 81630
18172 97968 114524 97944 114510 97932 97926 81500 98012 81486 97998 97880 114478
18173 97868 97862 81454 97902 97836 97830 69470 73564 73550 81752 106414 81740
18174 81734 73518 81774 81708 81702
18175 ] [
18176 109536 120312 86976 109040 120060 86496 108792 119934 86256 108668 86136 129744
18177 89056 110072 129736 88560 109820 129732 88312 109694 129730 88188 128464 129772
18178 89592 128456 129766 89340 128452 89214 128450 125904 128492 125896 128486 125892
18179 125890 120784 125932 120776 125926 120772 120770 110544 120812 110536 120806 110532
18180 84928 108016 119548 84448 107768 119422 84208 107644 84088 107582 84028 129640
18181 85488 108284 129636 85240 108158 129634 85116 85054 128232 129654 85756 128228
18182 85630 128226 125416 128246 125412 125410 119784 125430 119780 119778 108520 119798
18183 108516 108514 83424 107256 119166 83184 107132 83064 107070 83004 82974 129588
18184 83704 107390 129586 83580 83518 128116 83838 128114 125172 125170 119284 119282
18185 107508 107506 82672 106876 82552 106814 82492 82462 129562 82812 82750 128058
18186 125050 119034 82296 106686 82236 82206 82366 82108 82078 76736 103920 117500
18187 76256 103672 117374 76016 103548 75896 103486 75836 129384 77296 104188 129380
18188 77048 104062 129378 76924 76862 127720 129398 77564 127716 77438 127714 124392
18189 127734 124388 124386 117736 124406 117732 117730 104424 117750 104420 104418 112096
18190 121592 126334 92608 111856 121468 92384 111736 121406 92272 111676 92216 111646
18191 92188 75232 103160 117118 93664 74992 103036 93424 112252 102974 93304 74812
18192 93244 74782 93214 129332 75512 103294 129908 129330 93944 75388 129906 93820
18193 75326 93758 127604 75646 128756 127602 94078 128754 124148 126452 124146 126450
18194 117236 121844 117234 121842 103412 103410 91584 111344 121212 91360 111224 121150
18195 91248 111164 91192 111134 91164 91150 74480 102780 91888 74360 102718 91768
18196 111422 91708 74270 91678 129306 74620 129850 92028 74558 91966 127546 128634
18197 124026 126202 116986 121338 102906 90848 110968 121022 90736 110908 90680 110878
18198 90652 90638 74104 102590 91000 74044 90940 74014 90910 74174 91070 90480
18199 110780 90424 110750 90396 90382 73916 90556 73886 90526 90296 110686 90268
18200 90254 73822 90334 90204 90190 71136 101112 116094 70896 100988 70776 100926
18201 70716 70686 129204 71416 101246 129202 71292 71230 127348 71550 127346 123636
18202 123634 116212 116210 101364 101362 79296 105200 118140 79072 105080 118078 78960
18203 105020 78904 104990 78876 78862 70384 100732 79600 70264 100670 79480 105278
18204 79420 70174 79390 129178 70524 129466 79740 70462 79678 127290 127866 123514
18205 124666 115962 118266 100858 113376 122232 126654 95424 113264 122172 95328 113208
18206 122142 95280 113180 95256 113166 95244 78560 104824 117950 95968 78448 104764
18207 95856 113468 104734 95800 78364 95772 78350 95758 70008 100542 78712 69948
18208 96120 78652 69918 96060 78622 96030 70078 78782 96190 94912 113008 122044
18209 94816 112952 122014 94768 112924 94744 112910 94732 94726 78192 104636 95088
18210 78136 104606 95032 113054 95004 78094 94990 69820 78268 69790 95164 78238
18211 95134 94560 112824 121950 94512 112796 94488 112782 94476 94470 78008 104542
18212 94648 77980 94620 77966 94606 69726 78046 94686 94384 112732 94360 112718
18213 94348 94342 77916 94428 77902 94414 94296 112686 94284 94278 77870 94318
18214 94252 94246 68336 99708 68216 99646 68156 68126 68476 68414 127162 123258
18215 115450 99834 72416 101752 116414 72304 101692 72248 101662 72220 72206 67960
18216 99518 72568 67900 72508 67870 72478 68030 72638 80576 105840 118460 80480
18217 105784 118430 80432 105756 80408 105742 80396 80390 72048 101564 80752 71992
18218 101534 80696 71964 80668 71950 80654 67772 72124 67742 80828 72094 80798
18219 114016 122552 126814 96832 113968 122524 96800 113944 122510 96784 113932 96776
18220 113926 96772 80224 105656 118366 97120 80176 105628 97072 114076 105614 97048
18221 80140 97036 80134 97030 71864 101470 80312 71836 97208 80284 71822 97180
18222 80270 97166 67678 71902 80350 97246 96576 113840 122460 96544 113816 122446
18223 96528 113804 96520 113798 96516 96514 80048 105564 96688 80024 105550 96664
18224 113870 96652 80006 96646 71772 80092 71758 96732 80078 96718 96416 113752
18225 122414 96400 113740 96392 113734 96388 96386 79960 105518 96472 79948 96460
18226 79942 96454 71726 79982 96494 96336 113708 96328 113702 96324 96322 79916
18227 96364 79910 96358 96296 113686 96292 96290 79894 96310 66936 99006 66876
18228 66846 67006 68976 100028 68920 99998 68892 68878 66748 69052 66718 69022
18229 73056 102072 116574 73008 102044 72984 102030 72972 72966 68792 99934 73144
18230 68764 73116 68750 73102 66654 68830 73182 81216 106160 118620 81184 106136
18231 118606 81168 106124 81160 106118 81156 81154 72880 101980 81328 72856 101966
18232 81304 106190 81292 72838 81286 68700 72924 68686 81372 72910 81358 114336
18233 122712 126894 114320 122700 114312 122694 114308 114306 81056 106072 118574 97696
18234 81040 106060 97680 114380 106054 97672 81028 97668 81026 97666 72792 101934
18235 81112 72780 97752 81100 72774 97740 81094 97734 68654 72814 81134 97774
18236 114256 122668 114248 122662 114244 114242 80976 106028 97488 80968 106022 97480
18237 114278 97476 80962 97474 72748 81004 72742 97516 80998 97510 114216 122646
18238 114212 114210 80936 106006 97384 80932 97380 80930 97378 72726 80950 97398
18239 114196 114194 80916 97332 80914 97330 66236 66206 67256 99166 67228 67214
18240 66142 67294 69296 100188 69272 100174 69260 69254 67164 69340 67150 69326
18241 73376 102232 116654 73360 102220 73352 102214 73348 73346 69208 100142 73432
18242 102254 73420 69190 73414 67118 69230 73454 106320 118700 106312 118694 106308
18243 106306 73296 102188 81616 106348 102182 81608 73284 81604 73282 81602 69164
18244 73324 69158 81644 73318 81638 122792 126934 122788 122786 106280 118678 114536
18245 106276 114532 106274 114530 73256 102166 81512 73252 98024 81508 73250 98020
18246 81506 98018 69142 73270 81526 98038 122772 122770 106260 114484 106258 114482
18247 73236 81460 73234 97908 81458 97906 122762 106250 114458 73226 81434 97850
18248 66396 66382 67416 99246 67404 67398 66350 67438 69456 100268 69448 100262
18249 69444 69442 67372 69484 67366 69478 102312 116694 102308 102306 69416 100246
18250 73576 102326 73572 69410 73570 67350 69430 73590 118740 118738 102292 106420
18251 102290 106418 69396 73524 69394 81780 73522 81778 118730 102282 106394 69386
18252 73498 81722 66476 66470 67496 99286 67492 67490 66454 67510 100308 100306
18253 67476 69556 67474 69554 116714
18254 ]
18255 ] def
18256 } ctxdef
18257
18258 % Return the 17 bits for a codeword in a given cluster
18259 /cwtobits {
18260 clusters exch get exch get /v exch def
18261 [ 17 {0} repeat v 2 17 string cvrs {48 sub} forall ]
18262 dup length 17 sub 17 getinterval
18263 } def
18264
18265 % Populate bitmap for the image
18266 compact {
18267 /rwid 17 c mul 17 add 17 add 1 add def
18268 } {
18269 /rwid 17 c mul 17 add 17 add 17 add 18 add def
18270 } ifelse
18271 /pixs rwid r mul rowmult mul array def
18272
18273 0 1 r 1 sub {
18274 /i exch def
18275
18276 i 3 mod 0 eq {
18277 /lcw i 3 idiv 30 mul r 1 sub 3 idiv add def
18278 /rcw i 3 idiv 30 mul c add 1 sub def
18279 } if
18280 i 3 mod 1 eq {
18281 /lcw i 3 idiv 30 mul eclevel 3 mul add r 1 sub 3 mod add def
18282 /rcw i 3 idiv 30 mul r 1 sub 3 idiv add def
18283 } if
18284 i 3 mod 2 eq {
18285 /lcw i 3 idiv 30 mul c add 1 sub def
18286 /rcw i 3 idiv 30 mul eclevel 3 mul add r 1 sub 3 mod add def
18287 } if
18288
18289 [
18290 1 1 1 1 1 1 1 1 0 1 0 1 0 1 0 0 0
18291 lcw i 3 mod cwtobits aload pop
18292 cws c i mul c getinterval { i 3 mod cwtobits aload pop } forall
18293 compact {
18294 1
18295 } {
18296 rcw i 3 mod cwtobits aload pop
18297 1 1 1 1 1 1 1 0 1 0 0 0 1 0 1 0 0 1
18298 } ifelse
18299 ]
18300 0 1 rowmult 1 sub {
18301 i rowmult mul add rwid mul pixs exch 2 index putinterval
18302 } for
18303 pop
18304 } for
18305
18306 % Return the arguments
18307 <<
18308 /ren /renmatrix
18309 /pixs pixs
18310 /pixx rwid
18311 /pixy r rowmult mul
18312 /height r rowmult mul 72 div
18313 /width rwid 72 div
18314 /borderleft 2.0
18315 /borderright 2.0
18316 /bordertop 2.0
18317 /borderbottom 2.0
18318 /opt options
18319 >>
18320
18321 dontdraw not //renmatrix if
18322
18323 //unloadctx exec
18324
18325 end
18326
18327 }
18328 [/barcode] {null def} forall
18329 bind def
18330 /pdf417 dup load /uk.co.terryburton.bwipp defineresource pop
18331 end
18332 /setpacking where {pop setpacking} if
18333 %%EndData
18334 %%EndResource
18335 % --END ENCODER pdf417--
18336
18337 % --BEGIN ENCODER pdf417compact--
18338 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix pdf417--
18339 % --DESC: Compact PDF417
18340 % --EXAM: This is compact PDF417
18341 % --EXOP: columns=2
18342 % --RNDR: renmatrix
18343 %%BeginResource: uk.co.terryburton.bwipp pdf417compact 0.0 2025111800 66100 65909
18344 %%BeginData: 36 ASCII Lines
18345 /setpacking where {pop currentpacking true setpacking} if
18346 10 dict
18347 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
18348 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
18349 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
18350 dup /pdf417 dup /uk.co.terryburton.bwipp findresource put
18351 begin
18352 /pdf417compact {
18353
18354 20 dict begin % Confine variables to local scope
18355
18356 /ctx null def
18357 /dontdraw false def
18358
18359 //processoptions exec /options exch def
18360 /barcode exch def
18361
18362 % Get the result of encoding with pdf417 with compact option
18363 options (dontdraw) true put
18364 options (compact) true put
18365
18366 /args barcode options //pdf417 exec def
18367
18368 args (opt) options put
18369 args
18370
18371 dontdraw not //renmatrix if
18372
18373 end
18374
18375 }
18376 [/barcode] {null def} forall
18377 bind def
18378 /pdf417compact dup load /uk.co.terryburton.bwipp defineresource pop
18379 end
18380 /setpacking where {pop setpacking} if
18381 %%EndData
18382 %%EndResource
18383 % --END ENCODER pdf417compact--
18384
18385 % --BEGIN ENCODER micropdf417--
18386 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix--
18387 % --DESC: MicroPDF417
18388 % --EXAM: MicroPDF417
18389 % --EXOP:
18390 % --RNDR: renmatrix
18391 %%BeginResource: uk.co.terryburton.bwipp micropdf417 0.0 2025111800 236418 251699
18392 %%BeginData: 1107 ASCII Lines
18393 /setpacking where {pop currentpacking true setpacking} if
18394 10 dict
18395 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
18396 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
18397 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
18398 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
18399 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
18400 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
18401 begin
18402 /micropdf417 {
18403
18404 20 dict begin
18405
18406 /ctx null def
18407 /dontdraw false def
18408 /version (unset) def
18409 /columns 0 def
18410 /rows 0 def
18411 /rowmult 2 def
18412 /cca false def
18413 /ccb false def
18414 /raw false def
18415 /parse false def
18416 /parsefnc false def
18417
18418 //processoptions exec /options exch def
18419 /barcode exch def
18420
18421 barcode () eq {
18422 /bwipp.micropdf417emptyData (The data must not be empty) //raiseerror exec
18423 } if
18424
18425 rowmult 0 le {
18426 /bwipp.micropdf417badRowMult (The row multiplier must be greater than zero) //raiseerror exec
18427 } if
18428
18429 cca ccb and cca raw and ccb raw and or or {
18430 /bwipp.micropdf417ccaAndCcb (Cannot combine cca, ccb and raw) //raiseerror exec
18431 } if
18432
18433 % Parse version=RxC into rows and columns
18434 version (unset) ne {
18435 version (x) search {
18436 exch pop
18437 2 copy 2 array astore {
18438 true
18439 1 index length 0 eq { pop false } if
18440 exch {
18441 dup 48 lt exch 57 gt or { pop false } if
18442 } forall
18443 not {
18444 /bwipp.micropdf417BadVersionBadRowOrColumn (version must be formatted as RxC) //raiseerror exec
18445 } if
18446 } forall
18447 /rows exch cvi def
18448 /columns exch cvi def
18449 } {
18450 pop /bwipp.micropdf417badVersionFormat (version must be formatted as RxC) //raiseerror exec
18451 } ifelse
18452 } if
18453
18454 /micropdf417 //loadctx exec
18455
18456 {
18457 % Modes and text submodes
18458 /T 0 def /N 1 def /B 2 def
18459 /A 0 def /L 1 def /M 2 def /P 3 def
18460
18461 % Special function characters for mode switching
18462 /tl -1 def /nl -2 def /bl -3 def /bl6 -4 def /bs -5 def
18463
18464 % Special function characters for text mode
18465 /al -6 def /ll -7 def /ml -8 def /pl -9 def /as -10 def /ps -11 def
18466
18467 % Special function characters for 05/06 macros
18468 /m05 -12 def /m06 -13 def
18469
18470 % Character maps for each state
18471 /charmaps [
18472 % A L M P
18473 [ (A) (a) (0) (;) ] % 0
18474 [ (B) (b) (1) (<) ] % 1
18475 [ (C) (c) (2) (>) ] % 2
18476 [ (D) (d) (3) (@) ] % 3
18477 [ (E) (e) (4) ([) ] % 4
18478 [ (F) (f) (5) 92 ] % 5
18479 [ (G) (g) (6) (]) ] % 6
18480 [ (H) (h) (7) (_) ] % 7
18481 [ (I) (i) (8) (`) ] % 8
18482 [ (J) (j) (9) (~) ] % 9
18483 [ (K) (k) (&) (!) ] % 10
18484 [ (L) (l) 13 13 ] % 11
18485 [ (M) (m) 9 9 ] % 12
18486 [ (N) (n) (,) (,) ] % 13
18487 [ (O) (o) (:) (:) ] % 14
18488 [ (P) (p) (#) 10 ] % 15
18489 [ (Q) (q) (-) (-) ] % 16
18490 [ (R) (r) (.) (.) ] % 17
18491 [ (S) (s) ($) ($) ] % 18
18492 [ (T) (t) (/) (/) ] % 19
18493 [ (U) (u) (+) (") ] % 20
18494 [ (V) (v) (%) (|) ] % 21
18495 [ (W) (w) (*) (*) ] % 22
18496 [ (X) (x) (=) 40 ] % 23
18497 [ (Y) (y) (^) 41 ] % 24
18498 [ (Z) (z) pl (?) ] % 25
18499 [ ( ) ( ) ( ) ({) ] % 26
18500 [ ll as ll (}) ] % 27
18501 [ ml ml al (') ] % 28
18502 [ ps ps ps al ] % 29
18503 ] def
18504
18505 % Invert charmaps to give character to value maps for each state
18506 /charvals [ 30 dict 30 dict 30 dict 30 dict ] def
18507 /alltext 104 dict def
18508 0 1 charmaps length 1 sub {
18509 /i exch def
18510 /encs charmaps i get def
18511 0 1 3 {
18512 /j exch def
18513 encs j get dup type /stringtype eq {0 get} if % convert string to ASCII if required
18514 dup charvals j get exch i put
18515 alltext exch -1 put
18516 } for
18517 } for
18518
18519 /e 10000 def % "Empty"
18520
18521 /latlen [ % Bit length of latch between submodes
18522 % To: A L M P From
18523 [ 0 1 1 2 ] % A
18524 [ 2 0 1 2 ] % L
18525 [ 1 1 0 1 ] % M
18526 [ 1 2 2 0 ] % P
18527 ] def
18528
18529 /latseq [ % Latch sequences between submodes
18530 % To: A L M P From
18531 [ [] [ll] [ml] [ml pl] ] % A
18532 [ [ml al] [] [ml] [ml pl] ] % L
18533 [ [al] [ll] [] [pl] ] % M
18534 [ [al] [al ll] [al ml] [] ] % P
18535 ] def
18536
18537 /shftlen [ % Bit length of shift to submode
18538 % To: A L M P From
18539 [ e e e 1 ] % A
18540 [ 1 e e 1 ] % L
18541 [ e e e 1 ] % M
18542 [ e e e e ] % P
18543 ] def
18544 } ctxdef
18545
18546 % Convert input into array of codewords
18547 raw cca or {
18548 /datcws barcode length array def
18549 /i 0 def /j 0 def
18550 { % loop
18551 i barcode length 3 sub ge {exit} if
18552 barcode i get 94 ne {exit} if
18553 barcode i 1 add 3 getinterval false 1 index {
18554 dup 48 lt exch 57 gt or { pop true } if
18555 } forall { pop exit } if
18556 cvi /cw exch def
18557 datcws j cw put
18558 /i i 4 add def
18559 /j j 1 add def
18560 } loop
18561 i barcode length ne {
18562 /bwipp.micropdf417badCcaRawFormat (cca and raw data must be formatted as ^NNN) //raiseerror exec
18563 } if
18564 /datcws datcws 0 j getinterval def
18565 } if
18566
18567 /encb {
18568 /in exch def
18569 /inlen in length def
18570 /out inlen 6 idiv 5 mul inlen 6 mod add array def
18571 0 1 inlen 6 idiv 1 sub {
18572 /k exch def
18573 /msbs [ in k 6 mul 3 getinterval aload pop ] def
18574 /mscs [
18575 msbs aload pop exch 256 mul add exch 65536 mul add
18576 3 {dup 900 mod exch 900 idiv} repeat
18577 ] def
18578 /lsbs [ in k 6 mul 3 add 3 getinterval aload pop ] def
18579 /lscs [
18580 lsbs aload pop exch 256 mul add exch 65536 mul add
18581 3 {dup 900 mod exch 900 idiv} repeat
18582 ] def
18583 lscs 0 get mscs 0 get 316 mul add
18584 out k 5 mul 4 add 2 index 900 mod put
18585 900 idiv lscs 1 get add mscs 0 get 641 mul add mscs 1 get 316 mul add
18586 out k 5 mul 3 add 2 index 900 mod put
18587 900 idiv lscs 2 get add mscs 0 get 20 mul add mscs 1 get 641 mul add mscs 2 get 316 mul add
18588 out k 5 mul 2 add 2 index 900 mod put
18589 900 idiv lscs 3 get add mscs 1 get 20 mul add mscs 2 get 641 mul add
18590 out k 5 mul 1 add 2 index 900 mod put
18591 900 idiv mscs 2 get 20 mul add
18592 out k 5 mul 3 -1 roll 900 mod put
18593 } for
18594 /rem inlen 6 mod def
18595 rem 0 ne {
18596 out out length rem sub
18597 [ in inlen rem sub rem getinterval aload pop ]
18598 putinterval
18599 } if
18600 out
18601 } def
18602
18603 ccb {
18604 /barlen barcode length def
18605 /datcws barlen 6 idiv 5 mul barlen 6 mod add 2 add array def
18606 datcws 0 920 put
18607 datcws 1 barlen 6 mod 0 eq {924} {901} ifelse put
18608 datcws 2 [ barcode {} forall ] encb putinterval
18609 } if
18610
18611 raw not cca not and ccb not and {
18612
18613 % Parse the input
18614 /fncvals <<
18615 /parse parse
18616 /parsefnc parsefnc
18617 % (MAC5) m05 Encoded automatically
18618 % (MAC6) m06 Encoded automatically
18619 % Predates FNC non-data codewords, but supports ECI
18620 /eci true
18621 >> def
18622 /msg barcode fncvals //parseinput exec def
18623 /msglen msg length def
18624
18625 % Macro 05/06 compression of [)>{RS}05/06{GS}...{RS}{EOT} structured data
18626 msglen 9 ge {
18627 msg 0 7 getinterval aload pop
18628 29 eq exch pop exch 48 eq and exch % [)>{RS}0*{GS}...
18629 30 eq and exch 62 eq and exch 41 eq and exch 91 eq and {
18630 msg msglen 2 sub 2 getinterval aload pop
18631 4 eq exch 30 eq and { % ...{RS}{EOT}
18632 msg 5 get 53 eq { % ...5...
18633 /msg [ m05 msg 7 msg length 9 sub getinterval aload pop ] def
18634 } {
18635 msg 5 get 54 eq { % ...6...
18636 /msg [ m06 msg 7 msg length 9 sub getinterval aload pop ] def
18637 } if
18638 } ifelse
18639 } if
18640 } if
18641 } if
18642 /msglen msg length def
18643
18644 % Determine runlengths of digits
18645 /numdigits [ msglen {0} repeat 0 ] def
18646 /numtext [ msglen {0} repeat 0 ] def
18647 /numbytes [ msglen {0} repeat 0 ] def
18648 /iseci [ msglen {0} repeat ] def
18649 msglen 1 sub -1 0 {
18650 /i exch def
18651 msg i get dup 48 ge exch 57 le and {
18652 numdigits i numdigits i 1 add get 1 add put
18653 } if
18654 alltext msg i get known numdigits i get 13 lt and {
18655 numtext i numtext i 1 add get 1 add put
18656 } if
18657 msg i get 0 ge numtext i get 5 lt and numdigits i get 13 lt and {
18658 numbytes i numbytes i 1 add get 1 add put
18659 } if
18660 iseci i msg i get -1000000 le put
18661 } for
18662 /numdigits numdigits 0 msglen getinterval def
18663 /numtext numtext 0 msglen getinterval def
18664 /numbytes numbytes 0 msglen getinterval def
18665
18666 /seq [] def /seqlen 0 def /state B def /p 0 def { % loop
18667 p msglen eq {exit} if
18668 p 0 eq msg p get dup m05 eq exch m06 eq or and {
18669 /seq [
18670 seq aload pop
18671 msg p get m05 eq { m05 } { m06 } ifelse
18672 ] def
18673 /p p 1 add def
18674 /seqlen seqlen 1 add def
18675 } {
18676 iseci p get {
18677 /eci msg p get def
18678 /seq [
18679 seq aload pop
18680 [ eci ]
18681 ] def
18682 /p p 1 add def
18683 /seqlen seqlen eci -1810900 le {2} {eci -1000900 le {3} {2} ifelse} ifelse add def
18684 } {
18685 /n numdigits p get def
18686 n 13 ge n msglen eq n 8 ge and or { % 13+ digits or all-numeric and 8+ digits
18687 /seq [
18688 seq aload pop
18689 nl
18690 [ msg p n getinterval aload pop ]
18691 ] def
18692 /state N def
18693 /p p n add def
18694 /seqlen seqlen 1 add n add def
18695 } { % next
18696 /t numtext p get def
18697 t 5 ge {
18698 /seq [
18699 seq aload pop
18700 state T ne {
18701 tl
18702 } if
18703 [ msg p t getinterval aload pop ]
18704 ] def
18705 /state T def
18706 /p p t add def
18707 /seqlen seqlen 1 add t add def % ish
18708 } { % next
18709 /b numbytes p get def
18710 b 1 eq state T eq and {
18711 /seq [
18712 seq aload pop
18713 bs
18714 [ msg p get ]
18715 ] def
18716 /p p b add def
18717 /seqlen seqlen 2 add def
18718 } { % next
18719 /seq [
18720 seq aload pop
18721 b 6 mod 0 ne {bl} {bl6} ifelse
18722 [ msg p b getinterval aload pop ]
18723 ] def
18724 /state B def
18725 /p p b add def
18726 /seqlen seqlen 1 add b add def
18727 } ifelse } ifelse } ifelse } ifelse } ifelse
18728 } loop
18729
18730 /latchcws <<
18731 tl 900 bl 901 bl6 924 nl 902 bs 913 m05 916 m06 917
18732 >> def
18733
18734 % Submode encoding functions
18735 /enca {charvals A get exch get} def
18736 /encl {charvals L get exch get} def
18737 /encm {charvals M get exch get} def
18738 /encp {charvals P get exch get} def
18739 /textencfuncs [ /enca /encl /encm /encp ] def
18740
18741 /addtotext {
18742 text exch l exch put
18743 /l l 1 add def
18744 } def
18745
18746 /enct {
18747
18748 /in exch def
18749
18750 /curlen [ e e e e ] def
18751 curlen submode 0 put
18752 /curseq [ [] [] [] [] ] def
18753
18754 % Derive the optimal sequences ending in each submode
18755 in {
18756
18757 /char exch def
18758
18759 % Check for optimisations in the current sequences by latching from x to y
18760 { % loop
18761 /imp false def
18762 [ A L M P ] {
18763 /x exch def
18764 [ A L M P ] {
18765 /y exch def
18766 /cost curlen x get latlen x get y get add def
18767 cost curlen y get lt {
18768 curlen y cost put
18769 curseq y [
18770 curseq x get aload pop
18771 latseq x get y get aload pop
18772 ] put
18773 /imp true def
18774 } if
18775 } forall
18776 } forall
18777 imp not {exit} if % Repeat unless no improvement
18778 } loop
18779
18780 % Determine optimal next sequences for each valid encoding
18781 /nxtlen [ e e e e ] def
18782 /nxtseq 4 array def
18783
18784 [ A L M P ] {
18785 /x exch def
18786
18787 { % loop for common exit
18788
18789 charvals x get char known not {exit} if
18790
18791 % Extend directly
18792 /cost curlen x get 1 add def
18793 cost nxtlen x get lt {
18794 nxtlen x cost put
18795 nxtseq x [ curseq x get aload pop char ] put
18796 } if
18797
18798 % Optimise for direct shifts from y to x
18799 [ A L M P ] {
18800 /y exch def
18801 x y ne {
18802 /cost curlen y get shftlen y get x get add 1 add def
18803 cost nxtlen y get lt {
18804 nxtlen y cost put
18805 nxtseq y [
18806 curseq y get aload pop
18807 x A eq {as} {ps} ifelse
18808 char
18809 ] put
18810 } if
18811 } if
18812 } forall
18813
18814 exit
18815 } loop
18816
18817 } forall
18818
18819 /curlen nxtlen def
18820 /curseq nxtseq def
18821
18822 } forall
18823
18824 % Select the optimal sequence
18825 /minseq e def
18826 [ A L M P ] {
18827 /k exch def
18828 curlen k get minseq lt {
18829 /minseq curlen k get def
18830 /txtseq curseq k get def
18831 } if
18832 } forall
18833
18834 % Encode the sequence
18835 /text minseq array def
18836 /k 0 def /l 0 def {
18837 k txtseq length ge {exit} if
18838
18839 /char txtseq k get def
18840
18841 % Encode character
18842 char textencfuncs submode get load exec addtotext
18843 /k k 1 add def
18844
18845 % Encode shifted next character
18846 char as eq char ps eq or {
18847 txtseq k get char as eq {enca} {encp} ifelse addtotext
18848 /k k 1 add def
18849 } if
18850
18851 % Latches to new submode
18852 char al eq {/submode A def} if
18853 char ll eq {/submode L def} if
18854 char ml eq {/submode M def} if
18855 char pl eq {/submode P def} if
18856 } loop
18857
18858 text length 2 mod 1 eq {
18859 submode P eq {
18860 /pad al encp def
18861 /submode A def
18862 } {
18863 % Need to check whether a ps shift can be used to pad
18864 /nextecitext false def
18865 % If have one or more ECIs next followed by text sequence (array)
18866 i 1 add 1 seq length 1 sub {
18867 /ti exch def
18868 seq ti get type /arraytype ne { /nextecitext false def exit } if
18869 seq ti get 0 get -1000000 gt { exit } if
18870 /nextecitext true def
18871 } for
18872 nextecitext { % Then don't use ps as it would affect first char of text sequence
18873 submode A eq {
18874 charvals L get seq ti get 0 get known { % Check whether to use ll or ml latch
18875 /pad ll enca def
18876 /submode L def
18877 } {
18878 /pad ml enca def
18879 /submode M def
18880 } ifelse
18881 } {
18882 submode M eq {
18883 charvals L get seq ti get 0 get known { % Check whether to use ll, pl or al latch
18884 /pad ll encm def
18885 /submode L def
18886 } {
18887 charvals P get seq ti get 0 get known {
18888 /pad pl encm def
18889 /submode P def
18890 } {
18891 /pad al encm def
18892 /submode A def
18893 } ifelse } ifelse
18894 } { % L
18895 /pad ml encl def % Only latch available
18896 /submode M def
18897 } ifelse } ifelse
18898 } { % Otherwise use standard ps shift pad
18899 /pad ps textencfuncs submode get load exec def
18900 } ifelse
18901 } ifelse
18902 /text [ text aload pop pad ] def
18903 } if
18904
18905 /out text length 2 idiv array def
18906 0 1 out length 1 sub {
18907 /k exch def
18908 out k text k 2 mul get 30 mul text k 2 mul 1 add get add put
18909 } for
18910
18911 out
18912
18913 } def
18914
18915 /encn {
18916 /in exch def
18917 /out [] def
18918 0 44 in length 1 sub {
18919 /k exch def
18920 /gmod [
18921 1 in k in length k sub dup 44 gt {pop 44} if getinterval
18922 {48 sub} forall
18923 ] def
18924 /cwn [] def {
18925 /dv 900 def
18926 /gmul [] def /val 0 def {
18927 gmod length 0 eq {exit} if
18928 /val val 10 mul gmod 0 get add def
18929 /gmod gmod 1 gmod length 1 sub getinterval def
18930 val dv lt {
18931 gmul length 0 ne {
18932 /gmul [ gmul aload pop 0 ] def
18933 } if
18934 } {
18935 /gmul [ gmul aload pop val dv idiv ] def
18936 } ifelse
18937 /val val dv mod def
18938 } loop
18939 /dv val def
18940 /cwn [ dv cwn aload pop ] def
18941 /gmod gmul def
18942 gmul length 0 eq {exit} if
18943 } loop
18944 /out [ out aload pop cwn aload pop ] def
18945 } for
18946 out
18947 } def
18948
18949 /ence {
18950 0 get neg 1000000 sub
18951 dup 000899 le { % ECI 000000 - 000899
18952 927 exch 2 array astore
18953 } { dup 810899 le { % ECI 000900 - 810899
18954 926 exch dup 900 idiv 1 sub exch 900 mod 3 array astore
18955 } { dup 811799 le { % ECI 810900 - 811799
18956 925 exch 810900 sub 2 array astore
18957 } {
18958 /bwipp.pdf417badECI (PDF417 supports ECIs 000000 to 811799) //raiseerror exec
18959 } ifelse } ifelse } ifelse
18960 } def
18961
18962 /encfuncs [ /enct /encn /encb ] def
18963
18964 /addtocws {
18965 dup datcws j 3 -1 roll putinterval
18966 length j add /j exch def
18967 } def
18968
18969 % Encode the sequence
18970 % No need to set state as seq will always begin with a latch, unlike for pdf417
18971 /datcws seqlen array def
18972 /i 0 def /j 0 def {
18973 i seq length ge {exit} if
18974 /chars seq i get def
18975 chars type /arraytype eq { % Encode data according to mode
18976 chars 0 get -1000000 le { % ECI
18977 chars ence addtocws
18978 } { % Encode data according to mode
18979 chars encfuncs state get load exec addtocws
18980 } ifelse
18981 } { % Encode the latch to new state, byte shift or macro
18982 [ latchcws chars get ] addtocws
18983 chars tl eq {/state T def /submode A def} if
18984 chars nl eq {/state N def} if
18985 chars bl eq chars bl6 eq or {/state B def} if
18986 chars bs eq {
18987 /i i 1 add def
18988 seq i get encb addtocws
18989 } if
18990 chars m05 eq {
18991 i 1 add seq length lt {
18992 seq i 1 add get nl eq { % Latch to numeric mode is implied
18993 /i i 1 add def
18994 } if
18995 } if
18996 /state N def
18997 } if
18998 chars m06 eq {
18999 i 1 add seq length lt {
19000 seq i 1 add get tl eq { % Latch to mixed text submode is implied
19001 /i i 1 add def
19002 } if
19003 } if
19004 /state T def /submode M def
19005 } if
19006 } ifelse
19007 /i i 1 add def
19008 } loop
19009 /datcws datcws 0 j getinterval def
19010 } if
19011
19012 {
19013 % Basic metrics for the each symbol
19014 % c r ecw rl rc rr
19015 /ccametrics [
19016 [ 2 5 4 39 0 19 ]
19017 [ 2 6 4 1 0 33 ]
19018 [ 2 7 5 32 0 12 ]
19019 [ 2 8 5 8 0 40 ]
19020 [ 2 9 6 14 0 46 ]
19021 [ 2 10 6 43 0 23 ]
19022 [ 2 12 7 20 0 52 ]
19023 [ 3 4 4 11 43 23 ]
19024 [ 3 5 5 1 33 13 ]
19025 [ 3 6 6 5 37 17 ]
19026 [ 3 7 7 15 47 27 ]
19027 [ 3 8 7 21 1 33 ]
19028 [ 4 3 4 40 20 52 ]
19029 [ 4 4 5 43 23 3 ]
19030 [ 4 5 6 46 26 6 ]
19031 [ 4 6 7 34 14 46 ]
19032 [ 4 7 8 29 9 41 ]
19033 ] def
19034
19035 % Basic metrics for the each symbol
19036 % c r ecw rl rc rr
19037 /nonccametrics [
19038 [ 1 11 7 1 0 9 ]
19039 [ 1 14 7 8 0 8 ]
19040 [ 1 17 7 36 0 36 ]
19041 [ 1 20 8 19 0 19 ]
19042 [ 1 24 8 9 0 17 ]
19043 [ 1 28 8 25 0 33 ]
19044 [ 2 8 8 1 0 1 ]
19045 [ 2 11 9 1 0 9 ]
19046 [ 2 14 9 8 0 8 ]
19047 [ 2 17 10 36 0 36 ]
19048 [ 2 20 11 19 0 19 ]
19049 [ 2 23 13 9 0 17 ]
19050 [ 2 26 15 27 0 35 ]
19051 [ 3 6 12 1 1 1 ]
19052 [ 3 8 14 7 7 7 ]
19053 [ 3 10 16 15 15 15 ]
19054 [ 3 12 18 25 25 25 ]
19055 [ 3 15 21 37 37 37 ]
19056 [ 3 20 26 1 17 33 ]
19057 [ 3 26 32 1 9 17 ]
19058 [ 3 32 38 21 29 37 ]
19059 [ 3 38 44 15 31 47 ]
19060 [ 3 44 50 1 25 49 ]
19061 [ 4 4 8 47 19 43 ]
19062 [ 4 6 12 1 1 1 ]
19063 [ 4 8 14 7 7 7 ]
19064 [ 4 10 16 15 15 15 ]
19065 [ 4 12 18 25 25 25 ]
19066 [ 4 15 21 37 37 37 ]
19067 [ 4 20 26 1 17 33 ]
19068 [ 4 26 32 1 9 17 ]
19069 [ 4 32 38 21 29 37 ]
19070 [ 4 38 44 15 31 47 ]
19071 [ 4 44 50 1 25 49 ]
19072 ] def
19073 } ctxdef
19074
19075 /metrics cca {ccametrics} {nonccametrics} ifelse def
19076
19077 % Select metrics of an appropriate symbol
19078 /urows rows def
19079 /ucols columns def
19080 metrics {
19081 /m exch def
19082 /c m 0 get def % Columns in symbol
19083 /r m 1 get def % Rows in symbol
19084 /k m 2 get def % Error correction codewords
19085 /rapl m 3 get def % Left row address pattern
19086 /rapc m 4 get def % Centre row address pattern
19087 /rapr m 5 get def % Right row address pattern
19088 /ncws r c mul k sub def % Data codewords
19089 /okay true def
19090 datcws length ncws gt {/okay false def} if
19091 urows 0 ne urows r ne and {/okay false def} if
19092 ucols 0 ne ucols c ne and {/okay false def} if
19093 okay {exit} if
19094 } forall
19095
19096 okay not {
19097 /bwipp.micropdf417noValidSymbol (Maximum length exceeded or invalid size) //raiseerror exec
19098 } if
19099
19100 % Create codewords array with one extra working space element and add padding
19101 /m datcws length def
19102 /n c r mul k sub def
19103 /cws c r mul 1 add array def
19104 cws 0 datcws putinterval
19105 cws m [ n m sub {900} repeat ] putinterval
19106 cws n [ k {0} repeat 0 ] putinterval
19107
19108 % Calculate the log and anti-log tables
19109 {
19110 /rsalog [ 1 928 {dup 3 mul 929 mod} repeat ] def
19111 /rslog 929 array def
19112 1 1 928 {dup rsalog exch get exch rslog 3 1 roll put} for
19113 } ctxdef
19114
19115 % Function to calculate the product in the field
19116 /rsprod {
19117 2 copy 0 ne exch 0 ne and {
19118 rslog exch get exch rslog exch get add 928 mod rsalog exch get
19119 } {
19120 pop pop 0
19121 } ifelse
19122 } def
19123
19124 % Generate the coefficients
19125 /coeffs [ 1 k {0} repeat ] def
19126 1 1 k {
19127 /i exch def
19128 coeffs i coeffs i 1 sub get put
19129 i 1 sub -1 1 {
19130 /j exch def
19131 coeffs j coeffs j 1 sub get coeffs j get rsalog i get rsprod add 929 mod put
19132 } for
19133 coeffs 0 coeffs 0 get rsalog i get rsprod put
19134 } for
19135 /coeffs coeffs 0 coeffs length 1 sub getinterval def
19136 coeffs length 1 sub -2 0 {coeffs exch 2 copy get 929 exch sub put} for
19137
19138 % Derive the error codewords
19139 0 1 n 1 sub {
19140 /t exch cws exch get cws n get add 929 mod def
19141 0 1 k 1 sub {
19142 /j exch def
19143 cws n j add cws n j add 1 add get 929 t coeffs k j sub 1 sub get mul 929 mod sub add 929 mod put
19144 } for
19145 } for
19146 n 1 n k add { dup cws exch 929 cws 5 -1 roll get sub 929 mod put } for
19147
19148 % Trim the working space from the end of the codewords
19149 /cws cws 0 cws length 1 sub getinterval def
19150
19151 options /debugcws known { /bwipp.debugcws cws //raiseerror exec } if
19152
19153 {
19154 % Base 10 encoding of the bar space successions for the codewords in each cluster
19155 /clusters [
19156 [
19157 120256 125680 128380 120032 125560 128318 108736 119920 108640 86080 108592 86048
19158 110016 120560 125820 109792 120440 125758 88256 109680 88160 89536 110320 120700
19159 89312 110200 120638 89200 110140 89840 110460 89720 110398 89980 128506 119520
19160 125304 128190 107712 119408 125244 107616 119352 84032 107568 119324 84000 107544
19161 83984 108256 119672 125374 85184 108144 119612 85088 108088 119582 85040 108060
19162 85728 108408 119742 85616 108348 85560 108318 85880 108478 85820 85790 107200
19163 119152 125116 107104 119096 125086 83008 107056 119068 82976 107032 82960 82952
19164 83648 107376 119228 83552 107320 119198 83504 107292 83480 83468 83824 107452
19165 83768 107422 83740 83900 106848 118968 125022 82496 106800 118940 82464 106776
19166 118926 82448 106764 82440 106758 82784 106936 119006 82736 106908 82712 106894
19167 82700 82694 106974 82830 82240 106672 118876 82208 106648 118862 82192 106636
19168 82184 106630 82180 82352 82328 82316 82080 118830 106572 106566 82050 117472
19169 124280 127678 103616 117360 124220 103520 117304 124190 75840 103472 75808 104160
19170 117624 124350 76992 104048 117564 76896 103992 76848 76824 77536 104312 117694
19171 77424 104252 77368 77340 77688 104382 77628 77758 121536 126320 128700 121440
19172 126264 128670 111680 121392 126236 111648 121368 126222 111632 121356 103104 117104
19173 124092 112320 103008 117048 124062 112224 121656 126366 93248 74784 102936 117006
19174 93216 112152 93200 75456 103280 117180 93888 75360 103224 117150 93792 112440
19175 121758 93744 75288 93720 75632 103356 94064 75576 103326 94008 112542 93980
19176 75708 94140 75678 94110 121184 126136 128606 111168 121136 126108 111136 121112
19177 126094 111120 121100 111112 111108 102752 116920 123998 111456 102704 116892 91712
19178 74272 121244 116878 91680 74256 102668 91664 111372 102662 74244 74592 102840
19179 116958 92000 74544 102812 91952 111516 102798 91928 74508 74502 74680 102878
19180 92088 74652 92060 74638 92046 92126 110912 121008 126044 110880 120984 126030
19181 110864 120972 110856 120966 110852 110850 74048 102576 116828 90944 74016 102552
19182 116814 90912 111000 121038 90896 73992 102534 90888 110982 90884 74160 102620
19183 91056 74136 102606 91032 111054 91020 74118 91014 91100 91086 110752 120920
19184 125998 110736 120908 110728 120902 110724 110722 73888 102488 116782 90528 73872
19185 102476 90512 110796 102470 90504 73860 90500 73858 73944 90584 90572 90566
19186 120876 120870 110658 102444 73800 90312 90308 90306 101056 116080 123580 100960
19187 116024 70720 100912 115996 70688 100888 70672 70664 71360 101232 116156 71264
19188 101176 116126 71216 101148 71192 71180 71536 101308 71480 101278 71452 71612
19189 71582 118112 124600 127838 105024 118064 124572 104992 118040 124558 104976 118028
19190 104968 118022 100704 115896 123486 105312 100656 115868 79424 70176 118172 115854
19191 79392 105240 100620 79376 70152 79368 70496 100792 115934 79712 70448 118238
19192 79664 105372 100750 79640 70412 79628 70584 100830 79800 70556 79772 70542
19193 70622 79838 122176 126640 128860 122144 126616 128846 122128 126604 122120 126598
19194 122116 104768 117936 124508 113472 104736 126684 124494 113440 122264 126670 113424
19195 104712 117894 113416 122246 104706 69952 100528 115804 78656 69920 100504 115790
19196 96064 78624 104856 117966 96032 113560 122318 100486 96016 78600 104838 96008
19197 69890 70064 100572 78768 70040 100558 96176 78744 104910 96152 113614 70022
19198 78726 70108 78812 70094 96220 78798 122016 126552 128814 122000 126540 121992
19199 126534 121988 121986 104608 117848 124462 113056 104592 126574 113040 122060 117830
19200 113032 104580 113028 104578 113026 69792 100440 115758 78240 69776 100428 95136
19201 78224 104652 100422 95120 113100 69764 95112 78212 69762 78210 69848 100462
19202 78296 69836 95192 78284 69830 95180 78278 69870 95214 121936 126508 121928
19203 126502 121924 121922 104528 117804 112848 104520 117798 112840 121958 112836 104514
19204 112834 69712 100396 78032 69704 100390 94672 78024 104550 94664 112870 69698
19205 94660 78018 94658 78060 94700 94694 126486 121890 117782 104484 104482 69672
19206 77928 94440 69666 77922 99680 68160 99632 68128 99608 115342 68112 99596
19207 68104 99590 68448 99768 115422 68400 99740 68376 99726 68364 68358 68536
19208 99806 68508 68494 68574 101696 116400 123740 101664 116376 101648 116364 101640
19209 116358 101636 67904 99504 115292 72512 67872 116444 115278 72480 101784 116430
19210 72464 67848 99462 72456 101766 67842 68016 99548 72624 67992 99534 72600
19211 101838 72588 67974 68060 72668 68046 72654 118432 124760 127918 118416 124748
19212 118408 124742 118404 118402 101536 116312 105888 101520 116300 105872 118476 116294
19213 105864 101508 105860 101506 105858 67744 99416 72096 67728 116334 80800 72080
19214 101580 99398 80784 105932 67716 80776 72068 67714 72066 67800 99438 72152
19215 67788 80856 72140 67782 80844 72134 67822 72174 80878 126800 128940 126792
19216 128934 126788 126786 118352 124716 122576 126828 124710 122568 126822 122564 118338
19217 122562 101456 116268 105680 101448 116262 114128 105672 118374 114120 122598 101442
19218 114116 105666 114114 67664 99372 71888 67656 99366 80336 71880 101478 97232
19219 80328 105702 67650 97224 114150 71874 97220 67692 71916 67686 80364 71910
19220 97260 80358 97254 126760 128918 126756 126754 118312 124694 122472 126774 122468
19221 118306 122466 101416 116246 105576 101412 113896 105572 101410 113892 105570 113890
19222 67624 99350 71784 101430 80104 71780 67618 96744 80100 71778 96740 80098
19223 96738 71798 96758 126738 122420 122418 105524 113780 113778 71732 79988 96500
19224 96498 66880 66848 98968 66832 66824 66820 66992 66968 66956 66950 67036
19225 67022 100000 99984 115532 99976 115526 99972 99970 66720 98904 69024 100056
19226 98892 69008 100044 69000 100038 68996 66690 68994 66776 98926 69080 100078
19227 69068 66758 69062 66798 69102 116560 116552 116548 116546 99920 102096 116588
19228 115494 102088 116582 102084 99906 102082 66640 68816 66632 98854 73168 68808
19229 66628 73160 68804 66626 73156 68802 66668 68844 66662 73196 68838 73190
19230 124840 124836 124834 116520 118632 124854 118628 116514 118626 99880 115478 101992
19231 116534 106216 101988 99874 106212 101986 106210 66600 98838 68712 99894 72936
19232 68708 66594 81384 72932 68706 81380 72930 66614 68726 72950 81398 128980
19233 128978 124820 126900 124818 126898 116500 118580 116498 122740 118578 122738 99860
19234 101940 99858 106100 101938 114420
19235 ] [
19236 128352 129720 125504 128304 129692 125472 128280 129678 125456 128268 125448 128262
19237 125444 125792 128440 129758 120384 125744 128412 120352 125720 128398 120336 125708
19238 120328 125702 120324 120672 125880 128478 110144 120624 125852 110112 120600 125838
19239 110096 120588 110088 120582 110084 110432 120760 125918 89664 110384 120732 89632
19240 110360 120718 89616 110348 89608 110342 89952 110520 120798 89904 110492 89880
19241 110478 89868 90040 110558 90012 89998 125248 128176 129628 125216 128152 129614
19242 125200 128140 125192 128134 125188 125186 119616 125360 128220 119584 125336 128206
19243 119568 125324 119560 125318 119556 119554 108352 119728 125404 108320 119704 125390
19244 108304 119692 108296 119686 108292 108290 85824 108464 119772 85792 108440 119758
19245 85776 108428 85768 108422 85764 85936 108508 85912 108494 85900 85894 85980
19246 85966 125088 128088 129582 125072 128076 125064 128070 125060 125058 119200 125144
19247 128110 119184 125132 119176 125126 119172 119170 107424 119256 125166 107408 119244
19248 107400 119238 107396 107394 83872 107480 119278 83856 107468 83848 107462 83844
19249 83842 83928 107502 83916 83910 83950 125008 128044 125000 128038 124996 124994
19250 118992 125036 118984 125030 118980 118978 106960 119020 106952 119014 106948 106946
19251 82896 106988 82888 106982 82884 82882 82924 82918 124968 128022 124964 124962
19252 118888 124982 118884 118882 106728 118902 106724 106722 82408 106742 82404 82402
19253 124948 124946 118836 118834 106612 106610 124224 127664 129372 124192 127640 129358
19254 124176 127628 124168 127622 124164 124162 117568 124336 127708 117536 124312 127694
19255 117520 124300 117512 124294 117508 117506 104256 117680 124380 104224 117656 124366
19256 104208 117644 104200 117638 104196 104194 77632 104368 117724 77600 104344 117710
19257 77584 104332 77576 104326 77572 77744 104412 77720 104398 77708 77702 77788
19258 77774 128672 129880 93168 128656 129868 92664 128648 129862 92412 128644 128642
19259 124064 127576 129326 126368 124048 129902 126352 128716 127558 126344 124036 126340
19260 124034 126338 117152 124120 127598 121760 117136 124108 121744 126412 124102 121736
19261 117124 121732 117122 121730 103328 117208 124142 112544 103312 117196 112528 121804
19262 117190 112520 103300 112516 103298 112514 75680 103384 117230 94112 75664 103372
19263 94096 112588 103366 94088 75652 94084 75650 75736 103406 94168 75724 94156
19264 75718 94150 75758 128592 129836 91640 128584 129830 91388 128580 91262 128578
19265 123984 127532 126160 123976 127526 126152 128614 126148 123970 126146 116944 124012
19266 121296 116936 124006 121288 126182 121284 116930 121282 102864 116972 111568 102856
19267 116966 111560 121318 111556 102850 111554 74704 102892 92112 74696 102886 92104
19268 111590 92100 74690 92098 74732 92140 74726 92134 128552 129814 90876 128548
19269 90750 128546 123944 127510 126056 128566 126052 123938 126050 116840 123958 121064
19270 116836 121060 116834 121058 102632 116854 111080 121078 111076 102626 111074 74216
19271 102646 91112 74212 91108 74210 91106 74230 91126 128532 90494 128530 123924
19272 126004 123922 126002 116788 120948 116786 120946 102516 110836 102514 110834 73972
19273 90612 73970 90610 128522 123914 125978 116762 120890 102458 110714 123552 127320
19274 129198 123536 127308 123528 127302 123524 123522 116128 123608 127342 116112 123596
19275 116104 123590 116100 116098 101280 116184 123630 101264 116172 101256 116166 101252
19276 101250 71584 101336 116206 71568 101324 71560 101318 71556 71554 71640 101358
19277 71628 71622 71662 127824 129452 79352 127816 129446 79100 127812 78974 127810
19278 123472 127276 124624 123464 127270 124616 127846 124612 123458 124610 115920 123500
19279 118224 115912 123494 118216 124646 118212 115906 118210 100816 115948 105424 100808
19280 115942 105416 118246 105412 100802 105410 70608 100844 79824 70600 100838 79816
19281 105446 79812 70594 79810 70636 79852 70630 79846 129960 95728 113404 129956
19282 95480 113278 129954 95356 95294 127784 129430 78588 128872 129974 95996 78462
19283 128868 127778 95870 128866 123432 127254 124520 123428 126696 128886 123426 126692
19284 124514 126690 115816 123446 117992 115812 122344 117988 115810 122340 117986 122338
19285 100584 115830 104936 100580 113640 104932 100578 113636 104930 113634 70120 100598
19286 78824 70116 96232 78820 70114 96228 78818 96226 70134 78838 129940 94968
19287 113022 129938 94844 94782 127764 78206 128820 127762 95102 128818 123412 124468
19288 123410 126580 124466 126578 115764 117876 115762 122100 117874 122098 100468 104692
19289 100466 113140 104690 113138 69876 78324 69874 95220 78322 95218 129930 94588
19290 94526 127754 128794 123402 124442 126522 115738 117818 121978 100410 104570 112890
19291 69754 78074 94714 94398 123216 127148 123208 127142 123204 123202 115408 123244
19292 115400 123238 115396 115394 99792 115436 99784 115430 99780 99778 68560 99820
19293 68552 99814 68548 68546 68588 68582 127400 129238 72444 127396 72318 127394
19294 123176 127126 123752 123172 123748 123170 123746 115304 123190 116456 115300 116452
19295 115298 116450 99560 115318 101864 99556 101860 99554 101858 68072 99574 72680
19296 68068 72676 68066 72674 68086 72694 129492 80632 105854 129490 80508 80446
19297 127380 72062 127924 127378 80766 127922 123156 123700 123154 124788 123698 124786
19298 115252 116340 115250 118516 116338 118514 99444 101620 99442 105972 101618 105970
19299 67828 72180 67826 80884 72178 80882 97008 114044 96888 113982 96828 96798
19300 129482 80252 130010 97148 80190 97086 127370 127898 128954 123146 123674 124730
19301 126842 115226 116282 118394 122618 99386 101498 105722 114170 67706 71930 80378
19302 96632 113854 96572 96542 80062 96702 96444 96414 96350 123048 123044 123042
19303 115048 123062 115044 115042 99048 115062 99044 99042 67048 99062 67044 67042
19304 67062 127188 68990 127186 123028 123316 123026 123314 114996 115572 114994 115570
19305 98932 100084 98930 100082 66804 69108 66802 69106 129258 73084 73022 127178
19306 127450 123018 123290 123834 114970 115514 116602 98874 99962 102138 66682 68858
19307 73210 81272 106174 81212 81182 72894 81342 97648 114364 97592 114334 97564
19308 97550 81084 97724 81054 97694 97464 114270 97436 97422 80990 97502 97372
19309 97358 97326 114868 114866 98676 98674 66292 66290 123098 114842 115130 98618
19310 99194 66170 67322 69310 73404 73374 81592 106334 81564 81550 73310 81630
19311 97968 114524 97944 114510 97932 97926 81500 98012 81486 97998 97880 114478
19312 97868 97862 81454 97902 97836 97830 69470 73564 73550 81752 106414 81740
19313 81734 73518 81774 81708 81702
19314 ] [
19315 109536 120312 86976 109040 120060 86496 108792 119934 86256 108668 86136 129744
19316 89056 110072 129736 88560 109820 129732 88312 109694 129730 88188 128464 129772
19317 89592 128456 129766 89340 128452 89214 128450 125904 128492 125896 128486 125892
19318 125890 120784 125932 120776 125926 120772 120770 110544 120812 110536 120806 110532
19319 84928 108016 119548 84448 107768 119422 84208 107644 84088 107582 84028 129640
19320 85488 108284 129636 85240 108158 129634 85116 85054 128232 129654 85756 128228
19321 85630 128226 125416 128246 125412 125410 119784 125430 119780 119778 108520 119798
19322 108516 108514 83424 107256 119166 83184 107132 83064 107070 83004 82974 129588
19323 83704 107390 129586 83580 83518 128116 83838 128114 125172 125170 119284 119282
19324 107508 107506 82672 106876 82552 106814 82492 82462 129562 82812 82750 128058
19325 125050 119034 82296 106686 82236 82206 82366 82108 82078 76736 103920 117500
19326 76256 103672 117374 76016 103548 75896 103486 75836 129384 77296 104188 129380
19327 77048 104062 129378 76924 76862 127720 129398 77564 127716 77438 127714 124392
19328 127734 124388 124386 117736 124406 117732 117730 104424 117750 104420 104418 112096
19329 121592 126334 92608 111856 121468 92384 111736 121406 92272 111676 92216 111646
19330 92188 75232 103160 117118 93664 74992 103036 93424 112252 102974 93304 74812
19331 93244 74782 93214 129332 75512 103294 129908 129330 93944 75388 129906 93820
19332 75326 93758 127604 75646 128756 127602 94078 128754 124148 126452 124146 126450
19333 117236 121844 117234 121842 103412 103410 91584 111344 121212 91360 111224 121150
19334 91248 111164 91192 111134 91164 91150 74480 102780 91888 74360 102718 91768
19335 111422 91708 74270 91678 129306 74620 129850 92028 74558 91966 127546 128634
19336 124026 126202 116986 121338 102906 90848 110968 121022 90736 110908 90680 110878
19337 90652 90638 74104 102590 91000 74044 90940 74014 90910 74174 91070 90480
19338 110780 90424 110750 90396 90382 73916 90556 73886 90526 90296 110686 90268
19339 90254 73822 90334 90204 90190 71136 101112 116094 70896 100988 70776 100926
19340 70716 70686 129204 71416 101246 129202 71292 71230 127348 71550 127346 123636
19341 123634 116212 116210 101364 101362 79296 105200 118140 79072 105080 118078 78960
19342 105020 78904 104990 78876 78862 70384 100732 79600 70264 100670 79480 105278
19343 79420 70174 79390 129178 70524 129466 79740 70462 79678 127290 127866 123514
19344 124666 115962 118266 100858 113376 122232 126654 95424 113264 122172 95328 113208
19345 122142 95280 113180 95256 113166 95244 78560 104824 117950 95968 78448 104764
19346 95856 113468 104734 95800 78364 95772 78350 95758 70008 100542 78712 69948
19347 96120 78652 69918 96060 78622 96030 70078 78782 96190 94912 113008 122044
19348 94816 112952 122014 94768 112924 94744 112910 94732 94726 78192 104636 95088
19349 78136 104606 95032 113054 95004 78094 94990 69820 78268 69790 95164 78238
19350 95134 94560 112824 121950 94512 112796 94488 112782 94476 94470 78008 104542
19351 94648 77980 94620 77966 94606 69726 78046 94686 94384 112732 94360 112718
19352 94348 94342 77916 94428 77902 94414 94296 112686 94284 94278 77870 94318
19353 94252 94246 68336 99708 68216 99646 68156 68126 68476 68414 127162 123258
19354 115450 99834 72416 101752 116414 72304 101692 72248 101662 72220 72206 67960
19355 99518 72568 67900 72508 67870 72478 68030 72638 80576 105840 118460 80480
19356 105784 118430 80432 105756 80408 105742 80396 80390 72048 101564 80752 71992
19357 101534 80696 71964 80668 71950 80654 67772 72124 67742 80828 72094 80798
19358 114016 122552 126814 96832 113968 122524 96800 113944 122510 96784 113932 96776
19359 113926 96772 80224 105656 118366 97120 80176 105628 97072 114076 105614 97048
19360 80140 97036 80134 97030 71864 101470 80312 71836 97208 80284 71822 97180
19361 80270 97166 67678 71902 80350 97246 96576 113840 122460 96544 113816 122446
19362 96528 113804 96520 113798 96516 96514 80048 105564 96688 80024 105550 96664
19363 113870 96652 80006 96646 71772 80092 71758 96732 80078 96718 96416 113752
19364 122414 96400 113740 96392 113734 96388 96386 79960 105518 96472 79948 96460
19365 79942 96454 71726 79982 96494 96336 113708 96328 113702 96324 96322 79916
19366 96364 79910 96358 96296 113686 96292 96290 79894 96310 66936 99006 66876
19367 66846 67006 68976 100028 68920 99998 68892 68878 66748 69052 66718 69022
19368 73056 102072 116574 73008 102044 72984 102030 72972 72966 68792 99934 73144
19369 68764 73116 68750 73102 66654 68830 73182 81216 106160 118620 81184 106136
19370 118606 81168 106124 81160 106118 81156 81154 72880 101980 81328 72856 101966
19371 81304 106190 81292 72838 81286 68700 72924 68686 81372 72910 81358 114336
19372 122712 126894 114320 122700 114312 122694 114308 114306 81056 106072 118574 97696
19373 81040 106060 97680 114380 106054 97672 81028 97668 81026 97666 72792 101934
19374 81112 72780 97752 81100 72774 97740 81094 97734 68654 72814 81134 97774
19375 114256 122668 114248 122662 114244 114242 80976 106028 97488 80968 106022 97480
19376 114278 97476 80962 97474 72748 81004 72742 97516 80998 97510 114216 122646
19377 114212 114210 80936 106006 97384 80932 97380 80930 97378 72726 80950 97398
19378 114196 114194 80916 97332 80914 97330 66236 66206 67256 99166 67228 67214
19379 66142 67294 69296 100188 69272 100174 69260 69254 67164 69340 67150 69326
19380 73376 102232 116654 73360 102220 73352 102214 73348 73346 69208 100142 73432
19381 102254 73420 69190 73414 67118 69230 73454 106320 118700 106312 118694 106308
19382 106306 73296 102188 81616 106348 102182 81608 73284 81604 73282 81602 69164
19383 73324 69158 81644 73318 81638 122792 126934 122788 122786 106280 118678 114536
19384 106276 114532 106274 114530 73256 102166 81512 73252 98024 81508 73250 98020
19385 81506 98018 69142 73270 81526 98038 122772 122770 106260 114484 106258 114482
19386 73236 81460 73234 97908 81458 97906 122762 106250 114458 73226 81434 97850
19387 66396 66382 67416 99246 67404 67398 66350 67438 69456 100268 69448 100262
19388 69444 69442 67372 69484 67366 69478 102312 116694 102308 102306 69416 100246
19389 73576 102326 73572 69410 73570 67350 69430 73590 118740 118738 102292 106420
19390 102290 106418 69396 73524 69394 81780 73522 81778 118730 102282 106394 69386
19391 73498 81722 66476 66470 67496 99286 67492 67490 66454 67510 100308 100306
19392 67476 69556 67474 69554 116714
19393 ]
19394 ] def
19395
19396 % Row address patterns
19397 /raps [
19398 [ % Left and right
19399 802 930 946 818 882 890 826 954 922 986 970 906 778
19400 794 786 914 978 982 980 916 948 932 934 942 940 936
19401 808 812 814 806 822 950 918 790 788 820 884 868 870
19402 878 876 872 840 856 860 862 846 844 836 838 834 866
19403 ] [ % Centre
19404 718 590 622 558 550 566 534 530 538 570 562 546 610
19405 626 634 762 754 758 630 628 612 614 582 578 706 738
19406 742 740 748 620 556 552 616 744 712 716 708 710 646
19407 654 652 668 664 696 688 656 720 592 600 604 732 734
19408 ]
19409 ] def
19410 } ctxdef
19411
19412 % Return the 17 bits for a codeword in a given cluster
19413 /cwtobits {
19414 clusters exch get exch get /v exch def
19415 [ 17 {0} repeat v 2 17 string cvrs {48 sub} forall ]
19416 dup length 17 sub 17 getinterval
19417 } def
19418
19419 % Return the 10 bits for a row address pattern
19420 /raptobits {
19421 raps exch get exch get /v exch def
19422 [ 10 {0} repeat v 2 10 string cvrs {48 sub} forall ]
19423 dup length 10 sub 10 getinterval
19424 } def
19425
19426 % Populate bitmap for the image
19427 /rwid [38 55 82 99] c 1 sub get def
19428 c 3 eq cca and {/rwid 72 def} if
19429 /pixs rwid r mul rowmult mul array def
19430
19431 0 1 r 1 sub {
19432 /i exch def
19433 /clst i rapl add 1 sub 3 mod def
19434 [
19435 c 1 eq {
19436 i rapl add 1 sub 52 mod 0 raptobits aload pop
19437 cws i get clst cwtobits aload pop
19438 i rapr add 1 sub 52 mod 0 raptobits aload pop
19439 } if
19440 c 2 eq {
19441 i rapl add 1 sub 52 mod 0 raptobits aload pop
19442 cws i 2 mul get clst cwtobits aload pop
19443 cws i 2 mul 1 add get clst cwtobits aload pop
19444 i rapr add 1 sub 52 mod 0 raptobits aload pop
19445 } if
19446 c 3 eq {
19447 cca not {
19448 i rapl add 1 sub 52 mod 0 raptobits aload pop
19449 } if
19450 cws i 3 mul get clst cwtobits aload pop
19451 i rapc add 1 sub 52 mod 1 raptobits aload pop
19452 cws i 3 mul 1 add get clst cwtobits aload pop
19453 cws i 3 mul 2 add get clst cwtobits aload pop
19454 i rapr add 1 sub 52 mod 0 raptobits aload pop
19455 } if
19456 c 4 eq {
19457 i rapl add 1 sub 52 mod 0 raptobits aload pop
19458 cws i 4 mul get clst cwtobits aload pop
19459 cws i 4 mul 1 add get clst cwtobits aload pop
19460 i rapc add 1 sub 52 mod 1 raptobits aload pop
19461 cws i 4 mul 2 add get clst cwtobits aload pop
19462 cws i 4 mul 3 add get clst cwtobits aload pop
19463 i rapr add 1 sub 52 mod 0 raptobits aload pop
19464 } if
19465 1
19466 ]
19467 0 1 rowmult 1 sub {
19468 i rowmult mul add rwid mul pixs exch 2 index putinterval
19469 } for
19470 pop
19471 } for
19472
19473 % Return the arguments
19474 <<
19475 /ren /renmatrix
19476 /pixs pixs
19477 /pixx rwid
19478 /pixy r rowmult mul
19479 /height r rowmult mul 72 div
19480 /width rwid 72 div
19481 /borderleft 1.0
19482 /borderright 1.0
19483 /bordertop 1.0
19484 /borderbottom 1.0
19485 /opt options
19486 >>
19487
19488 dontdraw not //renmatrix if
19489
19490 //unloadctx exec
19491
19492 end
19493
19494 }
19495 [/barcode] {null def} forall
19496 bind def
19497 /micropdf417 dup load /uk.co.terryburton.bwipp defineresource pop
19498 end
19499 /setpacking where {pop setpacking} if
19500 %%EndData
19501 %%EndResource
19502 % --END ENCODER micropdf417--
19503
19504 % --BEGIN ENCODER datamatrix--
19505 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix--
19506 % --DESC: Data Matrix
19507 % --EXAM: This is Data Matrix!
19508 % --EXOP:
19509 % --RNDR: renmatrix
19510 %%BeginResource: uk.co.terryburton.bwipp datamatrix 0.0 2025111800 220209 249460
19511 %%BeginData: 959 ASCII Lines
19512 /setpacking where {pop currentpacking true setpacking} if
19513 10 dict
19514 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
19515 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
19516 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
19517 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
19518 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
19519 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
19520 begin
19521 /datamatrix {
19522
19523 20 dict begin
19524
19525 /ctx null def
19526 /dontdraw false def
19527 /columns 0 def
19528 /rows 0 def
19529 /format (unset) def % square or rectangle
19530 /version (unset) def
19531 /parse false def
19532 /parsefnc false def
19533 /c40headerlength -1 def
19534 /raw false def
19535 /dmre false def
19536
19537 //processoptions exec /options exch def
19538 /barcode exch def
19539
19540 barcode () eq {
19541 /bwipp.datamatrixEmptyData (The data must not be empty) //raiseerror exec
19542 } if
19543
19544 version (unset) ne rows 0 ne columns 0 ne or and {
19545 /bwipp.datamatrixVersionRowsCols (rows and columns must not be given if version is specified) //raiseerror exec
19546 } if
19547
19548 % Parse version=RxC into rows and columns
19549 version (unset) ne {
19550 version (x) search {
19551 exch pop
19552 2 copy 2 array astore {
19553 true
19554 1 index length 0 eq { pop false } if
19555 exch {
19556 dup 48 lt exch 57 gt or { pop false } if
19557 } forall
19558 not {
19559 /bwipp.datamatrixVersionBadRowOrColumn (version must be formatted as RxC) //raiseerror exec
19560 } if
19561 } forall
19562 /rows exch cvi def
19563 /columns exch cvi def
19564 /format rows columns eq { (square) } { (rectangle) } ifelse def
19565 } {
19566 pop /bwipp.datamatrixVersionFormat (version must be formatted as RxC) //raiseerror exec
19567 } ifelse
19568 } {
19569 format (unset) eq {
19570 /format dmre { (rectangle) } { (square) } ifelse def
19571 } if
19572 } ifelse
19573
19574 format (square) ne format (rectangle) ne and {
19575 /bwipp.datamatrixInvalidFormat (The format must be either square or rectangle) //raiseerror exec
19576 } if
19577
19578 /datamatrix //loadctx exec
19579
19580 % Basic metrics for the each symbol
19581 % rows cols regh regv rscw rsbl dmre
19582 {
19583 /metrics [
19584 % Standard square symbols
19585 [ 10 10 1 1 5 1 0 ]
19586 [ 12 12 1 1 7 1 0 ]
19587 [ 14 14 1 1 10 1 0 ]
19588 [ 16 16 1 1 12 1 0 ]
19589 [ 18 18 1 1 14 1 0 ]
19590 [ 20 20 1 1 18 1 0 ]
19591 [ 22 22 1 1 20 1 0 ]
19592 [ 24 24 1 1 24 1 0 ]
19593 [ 26 26 1 1 28 1 0 ]
19594 [ 32 32 2 2 36 1 0 ]
19595 [ 36 36 2 2 42 1 0 ]
19596 [ 40 40 2 2 48 1 0 ]
19597 [ 44 44 2 2 56 1 0 ]
19598 [ 48 48 2 2 68 1 0 ]
19599 [ 52 52 2 2 84 2 0 ]
19600 [ 64 64 4 4 112 2 0 ]
19601 [ 72 72 4 4 144 4 0 ]
19602 [ 80 80 4 4 192 4 0 ]
19603 [ 88 88 4 4 224 4 0 ]
19604 [ 96 96 4 4 272 4 0 ]
19605 [ 104 104 4 4 336 6 0 ]
19606 [ 120 120 6 6 408 6 0 ]
19607 [ 132 132 6 6 496 8 0 ]
19608 [ 144 144 6 6 620 10 0 ]
19609 % Optional rectangular symbols
19610 [ 8 18 1 1 7 1 0 ]
19611 [ 8 32 1 2 11 1 0 ]
19612 [ 8 48 1 2 15 1 1 ]
19613 [ 8 64 1 4 18 1 1 ]
19614 [ 8 80 1 4 22 1 1 ]
19615 [ 8 96 1 4 28 1 1 ]
19616 [ 8 120 1 6 32 1 1 ]
19617 [ 8 144 1 6 36 1 1 ]
19618 [ 12 26 1 1 14 1 0 ]
19619 [ 12 36 1 2 18 1 0 ]
19620 [ 12 64 1 4 27 1 1 ]
19621 [ 12 88 1 4 36 1 1 ]
19622 [ 16 36 1 2 24 1 0 ]
19623 [ 16 48 1 2 28 1 0 ]
19624 [ 16 64 1 4 36 1 1 ]
19625 [ 20 36 1 2 28 1 1 ]
19626 [ 20 44 1 2 34 1 1 ]
19627 [ 20 64 1 4 42 1 1 ]
19628 [ 22 48 1 2 38 1 1 ]
19629 [ 24 48 1 2 41 1 1 ]
19630 [ 24 64 1 4 46 1 1 ]
19631 [ 26 40 1 2 38 1 1 ]
19632 [ 26 48 1 2 42 1 1 ]
19633 [ 26 64 1 4 50 1 1 ]
19634 ] def
19635 } ctxdef
19636
19637 % Create array of codewords remaining to make a full symbol
19638 /urows rows def
19639 /ucols columns def
19640 /fullcws [] def
19641 metrics {
19642 /m exch def
19643 /rows m 0 get def % Rows in symbol
19644 /cols m 1 get def % Columns in symbol
19645 /regh m 2 get def % Horizontal regions
19646 /regv m 3 get def % Vertical regions
19647 /rscw m 4 get def % Error correction codewords
19648 /rsbl m 5 get def % Error correction blocks
19649 /doly m 6 get def % DMRE-only model
19650 /mrows rows 2 regh mul sub def % Rows in the mapping matrix
19651 /mcols cols 2 regv mul sub def % Columns in the mapping matrix
19652 /ncws mrows mcols mul 8 idiv rscw sub def % Data codewords
19653 /okay true def
19654 urows 0 ne urows rows ne and {/okay false def} if
19655 ucols 0 ne ucols cols ne and {/okay false def} if
19656 format (square) eq rows cols ne and {/okay false def} if
19657 format (rectangle) eq rows cols eq and {/okay false def} if
19658 dmre not doly 1 eq and {/okay false def} if
19659 okay {/fullcws [ fullcws aload pop ncws ] def} if
19660 } forall
19661 /numremcws [ 1558 {10000} repeat ] def
19662 fullcws {numremcws exch 1 sub 1 put} forall
19663 1556 -1 0 {
19664 /i exch def
19665 numremcws i get 1 ne {
19666 numremcws i numremcws i 1 add get 1 add put
19667 } if
19668 } for
19669
19670 {
19671 % Special characters
19672 /fnc1 -1 def /prog -2 def /m05 -3 def /m06 -4 def
19673 /lC -5 def /lB -6 def /lX -7 def /lT -8 def /lE -9 def /unl -10 def
19674 /sapp -11 def /usft -12 def /sft1 -13 def /sft2 -14 def /sft3 -15 def /eci -16 def /pad -17 def
19675 /unlcw 254 def
19676
19677 /Avals <<
19678 0 1 128 {dup 1 add} for
19679 pad 129
19680 0 1 99 { % Double digits
19681 dup 10 2 string cvrs (00) 2 string copy dup 2 3 index length sub 4 -1 roll putinterval
19682 exch 130 add
19683 } for
19684 229 [ lC lB fnc1 sapp prog usft m05 m06 lX lT lE eci ] {exch 1 add dup} forall pop
19685 >> def
19686 /Avals <<
19687 Avals {[exch]} forall
19688 >> def
19689
19690 /CNvals <<
19691 sft1 0
19692 sft2 1
19693 sft3 2
19694 32 3
19695 48 1 57 {dup 44 sub} for % 0-9
19696 65 1 90 {dup 51 sub} for % A-Z
19697 >> def
19698 /C1vals << 0 1 31 {dup} for >> def
19699 /C2vals <<
19700 33 1 47 {dup 33 sub} for
19701 58 1 64 {dup 43 sub} for
19702 91 1 95 {dup 69 sub} for
19703 fnc1 27
19704 usft 30
19705 >> def
19706 /C3vals << 96 1 127 {dup 96 sub} for >> def
19707 /Cvals <<
19708 CNvals {[exch]} forall
19709 C1vals {[exch CNvals sft1 get exch]} forall
19710 C2vals {[exch CNvals sft2 get exch]} forall
19711 C3vals {[exch CNvals sft3 get exch]} forall
19712 >> def
19713
19714 /TNvals <<
19715 sft1 0
19716 sft2 1
19717 sft3 2
19718 32 3
19719 48 1 57 {dup 44 sub} for % 0-9
19720 97 1 122 {dup 83 sub} for % a-z
19721 >> def
19722 /T1vals << 0 1 31 {dup} for >> def
19723 /T2vals <<
19724 33 1 47 {dup 33 sub} for
19725 58 1 64 {dup 43 sub} for
19726 91 1 95 {dup 69 sub} for
19727 fnc1 27
19728 usft 30
19729 >> def
19730 /T3vals <<
19731 96 0
19732 65 1 90 {dup 64 sub} for
19733 123 1 127 {dup 96 sub} for
19734 >> def
19735 /Tvals <<
19736 TNvals {[exch]} forall
19737 T1vals {[exch TNvals sft1 get exch]} forall
19738 T2vals {[exch TNvals sft2 get exch]} forall
19739 T3vals {[exch TNvals sft3 get exch]} forall
19740 >> def
19741
19742 % Extended ASCII mappings
19743 128 1 255 {
19744 /i exch def
19745 Avals i [ Avals usft get aload pop Avals i 128 sub get aload pop ] put
19746 Cvals i [ Cvals usft get aload pop Cvals i 128 sub get aload pop ] put
19747 Tvals i [ Tvals usft get aload pop Tvals i 128 sub get aload pop ] put
19748 } for
19749
19750 /Xvals <<
19751 13 0
19752 42 1
19753 62 2
19754 32 3
19755 48 1 57 {dup 44 sub} for
19756 65 1 90 {dup 51 sub} for
19757 >> def
19758 /Xvals <<
19759 Xvals {[exch]} forall
19760 >> def
19761
19762 /Evals <<
19763 64 1 94 {dup 64 sub} for
19764 unl 31
19765 32 1 63 {dup} for
19766 >> def
19767 /Evals <<
19768 Evals {[exch]} forall
19769 >> def
19770
19771 /Bvals <<
19772 0 1 255 {dup} for
19773 >> def
19774 /Bvals <<
19775 Bvals {[exch]} forall
19776 >> def
19777
19778 /encvals [ Avals Cvals Tvals Xvals Evals Bvals ] def
19779
19780 /A 0 def /C 1 def /T 2 def /X 3 def /E 4 def /B 5 def
19781 } ctxdef
19782
19783 raw {
19784
19785 /cws barcode length array def
19786 /i 0 def /j 0 def
19787 { % loop
19788 i barcode length eq {exit} if
19789 /cw barcode i 1 add 3 getinterval cvi def
19790 cws j cw put
19791 /i i 4 add def
19792 /j j 1 add def
19793 } loop
19794 /cws cws 0 j getinterval def
19795
19796 } {
19797
19798 % Parse the input
19799 /fncvals <<
19800 /parse parse
19801 /parsefnc parsefnc
19802 /eci true
19803 (FNC1) fnc1
19804 (PROG) prog
19805 % (MAC5) m05 Encoded automatically
19806 % (MAC6) m06 Encoded automatically
19807 >> def
19808 /msg barcode fncvals //parseinput exec def
19809 /msglen msg length def
19810
19811 % Macro 05/06 compression of [)>{RS}05/06{GS}...{RS}{EOT} structured data
19812 msglen 9 ge {
19813 msg 0 7 getinterval aload pop
19814 29 eq exch pop exch 48 eq and exch % [)>{RS}0*{GS}...
19815 30 eq and exch 62 eq and exch 41 eq and exch 91 eq and {
19816 msg msglen 2 sub 2 getinterval aload pop
19817 4 eq exch 30 eq and { % ...{RS}{EOT}
19818 msg 5 get 53 eq { % ...5...
19819 /msg [ m05 msg 7 msg length 9 sub getinterval aload pop ] def
19820 } {
19821 msg 5 get 54 eq { % ...6...
19822 /msg [ m06 msg 7 msg length 9 sub getinterval aload pop ] def
19823 } if
19824 } ifelse
19825 } if
19826 } if
19827 } if
19828 /msglen msg length def
19829
19830 /numD [ msglen {0} repeat 0 ] def
19831 /nextXterm [ msglen {0} repeat 9999 ] def
19832 /nextNonX [ msglen {0} repeat 9999 ] def
19833 /isECI [ msglen {false} repeat false ] def
19834 msglen 1 sub -1 0 {
19835 /i exch def
19836 /barchar msg i get def
19837 barchar 48 ge barchar 57 le and {
19838 numD i numD i 1 add get 1 add put
19839 } if
19840 barchar 13 eq barchar 42 eq or barchar 62 eq or {
19841 nextXterm i 0 put
19842 } {
19843 nextXterm i nextXterm i 1 add get 1 add put
19844 } ifelse
19845 Xvals barchar known not {
19846 nextNonX i 0 put
19847 } {
19848 nextNonX i nextNonX i 1 add get 1 add put
19849 } ifelse
19850 isECI i barchar -1000000 le put
19851 } for
19852 /nextXterm [nextXterm {dup 10000 gt {pop 10000} if} forall] def
19853 /nextNonX [nextNonX {dup 10000 gt {pop 10000} if} forall] def
19854
19855 /isD {char 48 ge char 57 le and} def
19856 /isC {CNvals char known} def
19857 /isT {TNvals char known} def
19858 /isX {Xvals char known} def
19859 /isE {Evals char known} def
19860 /isEA {char 127 gt} def
19861 /isFN {char 0 lt} def
19862 /XtermFirst {dup nextXterm exch get exch nextNonX exch get lt} def
19863
19864 % TODO To avoid roundoff, consider increasing the scores by a scale factor of 12 to convert to integers
19865 /lookup {
19866 /ac 1.0 def /cc 2.0 def /tc 2.0 def /xc 2.0 def /ec 2.0 def /bc 2.25 def
19867 mode A eq {/ac 0.0 def /cc 1.0 def /tc 1.0 def /xc 1.0 def /ec 1.0 def /bc 1.25 def} if
19868 mode C eq {/cc 0.0 def} if
19869 mode T eq {/tc 0.0 def} if
19870 mode X eq {/xc 0.0 def} if
19871 mode E eq {/ec 0.0 def} if
19872 mode B eq {/bc 0.0 def} if
19873 1 { % common exit
19874 isECI i get {A exit} if % ECI only in ASCII
19875 c40headerlength -1 ne i c40headerlength lt and {C exit} if % C40 only for c40headerlength characters
19876 /k 0 def { % loop
19877 i k add msglen eq {
19878 [/ac /cc /tc /xc /ec /bc] {dup load ceiling def} forall
19879 true [ cc tc xc ec bc] {ac exch le and} forall {A exit} if
19880 true [ac cc tc xc ec ] {bc exch lt and} forall {B exit} if
19881 true [ac cc tc xc bc] {ec exch lt and} forall {E exit} if
19882 true [ac cc xc ec bc] {tc exch lt and} forall {T exit} if
19883 true [ac cc tc ec bc] {xc exch lt and} forall {X exit} if
19884 C exit
19885 } if
19886 /char msg i k add get def
19887 /ac ac isD {1 2 div add} {isEA {ceiling 2 add} {ceiling 1 add} ifelse} ifelse def
19888 /cc cc isC {2 3 div add} {isEA { 8 3 div add } { 4 3 div add } ifelse} ifelse def
19889 /tc tc isT {2 3 div add} {isEA { 8 3 div add } { 4 3 div add } ifelse} ifelse def
19890 /xc xc isX {2 3 div add} {isEA {13 3 div add } {10 3 div add } ifelse} ifelse def
19891 /ec ec isE {3 4 div add} {isEA {17 4 div add } {13 4 div add } ifelse} ifelse def
19892 /bc bc isFN {4 add} {1 add} ifelse def
19893 k 4 ge {
19894 true [ cc tc xc ec bc] {ac 1 add exch le and} forall {A exit} if
19895 bc 1 add ac le {B exit} if
19896 true [ cc tc xc ec ] {bc 1 add exch lt and} forall {B exit} if
19897 true [ac cc tc xc bc] {ec 1 add exch lt and} forall {E exit} if
19898 true [ac cc xc ec bc] {tc 1 add exch lt and} forall {T exit} if
19899 true [ac cc tc ec bc] {xc 1 add exch lt and} forall {X exit} if
19900 true [ac tc ec bc] {cc 1 add exch lt and} forall {
19901 cc xc lt {C exit} if
19902 cc xc eq {i k add 1 add XtermFirst {X exit} {C exit} ifelse} if
19903 } if
19904 } if
19905 /k k 1 add def
19906 } loop
19907 } repeat
19908 } def
19909
19910 /addtocws {
19911 dup cws exch j exch putinterval
19912 /j exch length j add def
19913 } def
19914
19915 /ECItocws {
19916 neg 1000000 sub
19917 dup 000126 le { % ECI 000000 - 000126
19918 1 add
19919 1 array astore
19920 } { dup 016382 le { % ECI 000127 - 016382
19921 127 sub
19922 dup 254 idiv 128 add exch
19923 254 mod 1 add
19924 2 array astore
19925 } { % ECI 016383 - 999999
19926 16383 sub
19927 dup 64516 idiv 192 add exch
19928 dup 254 idiv 254 mod 1 add exch
19929 254 mod 1 add
19930 3 array astore
19931 } ifelse } ifelse
19932 } def
19933
19934 /encA {
19935 1 { % Common exit
19936 isECI i get {
19937 Avals eci get addtocws
19938 msg i get ECItocws addtocws
19939 /i i 1 add def
19940 exit
19941 } if
19942 numD i get 2 ge {
19943 2 string dup 0 msg i get put dup 1 msg i 1 add get put Avals exch get addtocws
19944 /i i 2 add def
19945 exit
19946 } if
19947 /newmode lookup def
19948 newmode mode ne {
19949 Avals [-1 lC lT lX lE lB] newmode get get addtocws
19950 /mode newmode def
19951 exit
19952 } if
19953 Avals msg i get get addtocws
19954 /i i 1 add def
19955 exit
19956 } repeat
19957 } def
19958
19959 /CTXvalstocws {
19960 /in exch def
19961 mark
19962 0 3 in length 1 sub {
19963 in exch 3 getinterval 0 exch {add 40 mul} forall 40 idiv 1 add
19964 dup 256 idiv exch 256 mod
19965 } for
19966 counttomark array astore exch pop
19967 } def
19968
19969 /encCTX {
19970 /p 0 def
19971 /ctxvals 2500 array def
19972 /done false def
19973
19974 % Lookup the values for each character
19975 {
19976 i msglen eq {exit} if
19977 encvals mode get msg i get known not {exit} if
19978 p 3 mod 0 eq {
19979 p 0 gt {
19980 /newmode lookup def
19981 newmode mode ne {
19982 ctxvals 0 p getinterval CTXvalstocws addtocws
19983 [unlcw] addtocws
19984 newmode A ne {
19985 Avals [-1 lC lT lX lE lB] newmode get get addtocws
19986 } if
19987 /mode newmode def
19988 /done true def
19989 exit
19990 } if
19991 } if
19992 msglen i sub 3 le { % Check end of data conditions
19993 /remcws numremcws j p 3 idiv 2 mul add get def
19994 /remvals [
19995 msg i msglen i sub getinterval {
19996 dup encvals mode get exch known {
19997 encvals mode get exch get aload pop
19998 } { % Unencodable X12 characters
19999 pop -1 -1 -1 -1
20000 } ifelse
20001 } forall
20002 ] def
20003 remcws 2 eq remvals length 3 eq and {
20004 % Encode and omit unlatch
20005 [
20006 ctxvals 0 p getinterval aload pop
20007 remvals aload pop
20008 ] CTXvalstocws addtocws
20009 /mode A def
20010 /i msglen def
20011 /done true def
20012 exit
20013 } if
20014 remcws 2 eq remvals length 2 eq and mode X ne and {
20015 % Encode with sft1 as third value, omit unlatch
20016 [
20017 ctxvals 0 p getinterval aload pop
20018 remvals aload pop
20019 encvals mode get sft1 get aload pop
20020 ] CTXvalstocws addtocws
20021 /mode A def
20022 /i msglen def
20023 /done true def
20024 exit
20025 } if
20026 remcws 2 eq remvals length 1 eq and {
20027 % Unlatch to ASCII
20028 ctxvals 0 p getinterval CTXvalstocws addtocws
20029 [unlcw] addtocws
20030 Avals msg i get get addtocws
20031 /mode A def
20032 /i msglen def
20033 /done true def
20034 exit
20035 } if
20036 remcws 1 eq remvals length 1 eq and {
20037 % Implied unlatch to ASCII
20038 ctxvals 0 p getinterval CTXvalstocws addtocws
20039 Avals msg i get get addtocws
20040 /mode A def
20041 /i msglen def
20042 /done true def
20043 exit
20044 } if
20045 } if
20046 } if
20047 encvals mode get msg i get get
20048 dup ctxvals exch p exch putinterval
20049 /p exch length p add def
20050 /i i 1 add def
20051 } loop
20052
20053 % Backtrack to a boundary and return to ASCII
20054 done not {
20055 {
20056 p 3 mod 0 eq {exit} if
20057 /i i 1 sub def
20058 /p p encvals mode get msg i get get length sub def
20059 } loop
20060 [
20061 ctxvals 0 p getinterval aload pop
20062 ] CTXvalstocws addtocws
20063 [unlcw] addtocws
20064 /mode A def
20065 % Encode something to avoid latching immediately back
20066 i msglen ne isECI i get not and {
20067 numD i get 2 ge {
20068 2 string dup 0 msg i get put dup 1 msg i 1 add get put Avals exch get addtocws
20069 /i i 2 add def
20070 } {
20071 Avals msg i get get addtocws
20072 /i i 1 add def
20073 } ifelse
20074 } if
20075 } if
20076
20077 } def
20078
20079 /Evalstocws {
20080 /in exch def
20081 /inlen in length def
20082 /outlen in length 4 div 3 mul ceiling cvi def
20083 /in [ in aload pop 0 0 0 ] def
20084 mark
20085 0 4 inlen 1 sub {
20086 in exch 4 getinterval 0 exch {or 6 bitshift} forall -6 bitshift
20087 dup -16 bitshift 255 and exch
20088 dup -8 bitshift 255 and exch
20089 255 and
20090 } for
20091 counttomark array astore exch pop
20092 0 outlen getinterval
20093 } def
20094
20095 /encE {
20096 /p 0 def
20097 /edifactvals 2100 array def
20098
20099 % Lookup the values for each character
20100 {
20101 i msglen eq {exit} if
20102 Evals msg i get known not {exit} if
20103 p 4 mod 0 eq {
20104 msglen i sub 2 le { % Check end of data condition
20105 /remcws numremcws j p 4 idiv 3 mul add get def
20106 /remvals [
20107 msg i msglen i sub getinterval {
20108 Avals exch get aload pop
20109 } forall
20110 ] def
20111 remcws 1 eq remcws 2 eq or remvals length remcws le and {
20112 % Implied unlatch to ASCII
20113 edifactvals 0 p getinterval Evalstocws addtocws
20114 remvals addtocws
20115 /mode A def
20116 /i msglen def
20117 exit
20118 } if
20119 } if
20120 lookup mode ne {exit} if
20121 } if
20122 Evals msg i get get
20123 dup edifactvals exch p exch putinterval
20124 /p exch length p add def
20125 /i i 1 add def
20126 } loop
20127
20128 % Unlatch and pad with zeros until boundary
20129 mode A ne {
20130 /remcws numremcws j p 4 idiv 3 mul add 1 sub get 1 sub def
20131 p 4 mod 0 ne i msglen ne or remcws 3 ge or { % Unlatch unless less than 3 codewords remain
20132 Evals unl get
20133 dup edifactvals exch p exch putinterval
20134 /p exch length p add def
20135 } if
20136 edifactvals 0 p getinterval Evalstocws addtocws
20137 /mode A def
20138 % Encode something to avoid latching immediately back
20139 i msglen ne isECI i get not and {
20140 numD i get 2 ge {
20141 2 string dup 0 msg i get put dup 1 msg i 1 add get put Avals exch get addtocws
20142 /i i 2 add def
20143 } {
20144 Avals msg i get get addtocws
20145 /i i 1 add def
20146 } ifelse
20147 } if
20148 } if
20149
20150 } def
20151
20152 /encB {
20153 /p 0 def /bvals 1558 array def {
20154 i msglen eq {exit} if
20155 lookup mode ne {exit} if
20156 bvals p msg i get put
20157 /p p 1 add def
20158 /i i 1 add def
20159 } loop
20160 /remcws numremcws j p add get 1 sub def
20161 /bvals [
20162 remcws 0 eq i msglen eq and { % Terminates symbol
20163 0
20164 } {
20165 p 250 lt {p} {p 250 idiv 249 add p 250 mod} ifelse
20166 } ifelse
20167 bvals 0 p getinterval aload pop
20168 ] def
20169 0 1 bvals length 1 sub { % Pseudo-randomise based on codeword position
20170 /p exch def
20171 j p add 1 add 149 mul 255 mod 1 add bvals p get add
20172 dup 256 ge {256 sub} if
20173 bvals exch p exch put
20174 } for
20175 bvals addtocws
20176 /mode A def
20177 } def
20178
20179 % Derive the codewords
20180 /cws 1558 array def
20181 /mode A def /i 0 def /j 0 def {
20182 i msglen ge {exit} if
20183 [ /encA /encCTX /encCTX /encCTX /encE /encB ] mode get load exec
20184 } loop
20185 /cws cws 0 j getinterval def
20186
20187 } ifelse
20188
20189 % Extend codewords to fill symbol with pseudo-randomised pad characters
20190 /datlen cws length def
20191 /remcws numremcws j 1 sub get 1 sub def
20192 remcws 0 gt {
20193 /cws [ cws aload pop remcws {129} repeat ] def
20194 datlen 1 add 1 datlen remcws add 1 sub {
20195 /i exch def
20196 i 1 add 149 mul 253 mod 1 add 129 add
20197 dup 254 gt {254 sub} if
20198 cws exch i exch put
20199 } for
20200 } if
20201
20202 options /debugcws known { /bwipp.debugcws cws //raiseerror exec } if
20203
20204 % Lookup symbol metrics based on number of codewords and user specification
20205 metrics {
20206 /m exch def
20207 /rows m 0 get def % Rows in symbol
20208 /cols m 1 get def % Columns in symbol
20209 /regh m 2 get def % Horizontal regions
20210 /regv m 3 get def % Vertical regions
20211 /rscw m 4 get def % Error correction codewords
20212 /rsbl m 5 get def % Error correction blocks
20213 /doly m 6 get def % DMRE-only model
20214 /mrows rows 2 regh mul sub def % Rows in the mapping matrix
20215 /mcols cols 2 regv mul sub def % Columns in the mapping matrix
20216 /rrows mrows regh idiv def % Rows per region
20217 /rcols mcols regv idiv def % Columns per region
20218 /ncws mrows mcols mul 8 idiv rscw sub def % Data codewords
20219 /okay true def
20220 cws length ncws ne {/okay false def} if
20221 urows 0 ne urows rows ne and {/okay false def} if
20222 ucols 0 ne ucols cols ne and {/okay false def} if
20223 format (square) eq rows cols ne and {/okay false def} if
20224 format (rectangle) eq rows cols eq and {/okay false def} if
20225 dmre not doly 1 eq and {/okay false def} if
20226 okay {exit} if
20227 } forall
20228
20229 okay not {
20230 /bwipp.datamatrixNoValidSymbol (Maximum length exceeded or invalid size) //raiseerror exec
20231 } if
20232
20233 % De-interleave the codewords into blocks
20234 /cwbs rsbl array def % Array of data codeword blocks
20235 /ecbs rsbl array def % Array of error correction blocks
20236 0 1 rsbl 1 sub {
20237 /i exch def
20238 cws length 1558 ne {
20239 /cwbsize cws length rsbl idiv def
20240 } {
20241 i 7 le {/cwbsize 156 def} {/cwbsize 155 def} ifelse
20242 } ifelse
20243 /cwb cwbsize array def
20244 0 1 cwbsize 1 sub {
20245 /j exch def
20246 cwb j cws j rsbl mul i add get put
20247 } for
20248 cwbs i cwb put
20249 ecbs i [ rscw rsbl idiv {0} repeat ] put
20250 } for
20251
20252 % Calculate the log and anti-log tables
20253 {
20254 /rsalog [ 1 255 { dup 2 mul dup 256 ge {301 xor} if } repeat ] def
20255 /rslog 256 array def
20256 1 1 255 {dup rsalog exch get exch rslog 3 1 roll put} for
20257 } ctxdef
20258
20259 % Function to calculate the product in the field
20260 /rsprod {
20261 2 copy 0 ne exch 0 ne and {
20262 rslog exch get exch rslog exch get add 255 mod rsalog exch get
20263 } {
20264 pop pop 0
20265 } ifelse
20266 } def
20267
20268 % Generate the coefficients
20269 /coeffs [ 1 rscw rsbl idiv {0} repeat ] def
20270 1 1 rscw rsbl idiv {
20271 /i exch def
20272 coeffs i coeffs i 1 sub get put
20273 i 1 sub -1 1 {
20274 /j exch def
20275 coeffs j coeffs j 1 sub get coeffs j get rsalog i get rsprod xor put
20276 } for
20277 coeffs 0 coeffs 0 get rsalog i get rsprod put
20278 } for
20279 /coeffs coeffs 0 coeffs length 1 sub getinterval def
20280
20281 % Calculate the error correction codewords for each block
20282 0 1 cwbs length 1 sub {
20283 /i exch def
20284 /cwb cwbs i get def
20285 /ecb ecbs i get def
20286 0 1 cwb length 1 sub {
20287 /t exch cwb exch get ecb 0 get xor def
20288 ecb length 1 sub -1 0 {
20289 /j exch def
20290 /p ecb length j sub 1 sub def
20291 ecb p t coeffs j get rsprod put
20292 j 0 gt { ecb p ecb p 1 add get ecb p get xor put } if
20293 } for
20294 } for
20295 } for
20296
20297 % Strange fixup for 144x144 symbols
20298 ncws 1558 eq {
20299 /ecbs [
20300 ecbs 8 2 getinterval aload pop
20301 ecbs 0 8 getinterval aload pop
20302 ] def
20303 } if
20304
20305 % Extend codewords with the interleaved error correction codes
20306 /cws [ cws aload pop rscw {0} repeat ] def
20307 0 1 rscw 1 sub {
20308 /i exch def
20309 cws ncws i add ecbs i rsbl mod get i rsbl idiv get put
20310 } for
20311
20312 % Place the codewords into the matrix
20313 /module {
20314 % cw row col shape
20315 4 -1 roll
20316 (00000000) 8 string copy dup 3 -1 roll 2 8 string cvrs
20317 dup length 8 exch sub exch putinterval
20318 7 -1 0 {1 index exch get 48 sub exch} for pop
20319 11 -3 roll
20320 % 1 2 4 8 16 32 64 128 row col shape
20321 { % Place each bit of the codeword in the shape, MSB first
20322 exec
20323 1 index 0 lt {
20324 exch mrows add exch
20325 4 mrows 4 add 8 mod sub add
20326 } if
20327 dup 0 lt {
20328 mcols add exch
20329 4 mcols 4 add 8 mod sub add exch
20330 } if
20331 1 index mrows ge {
20332 exch mrows sub exch
20333 } if
20334 exch mcols mul add
20335 mmat exch 5 -1 roll put
20336 } forall
20337 } def
20338
20339 % Placement patterns
20340 /dmn [
20341 { 2 copy 2 sub exch 2 sub exch } { 2 copy 1 sub exch 2 sub exch }
20342 { 2 copy 2 sub exch 1 sub exch } { 2 copy 1 sub exch 1 sub exch }
20343 { 2 copy exch 1 sub exch } { 2 copy 2 sub }
20344 { 2 copy 1 sub } { 2 copy }
20345 ] def
20346
20347 /dmc1 [
20348 { mrows 1 sub 0 } { mrows 1 sub 1 }
20349 { mrows 1 sub 2 } { 0 mcols 2 sub }
20350 { 0 mcols 1 sub } { 1 mcols 1 sub }
20351 { 2 mcols 1 sub } { 3 mcols 1 sub }
20352 ] def
20353
20354 /dmc2 [
20355 { mrows 3 sub 0 } { mrows 2 sub 0 }
20356 { mrows 1 sub 0 } { 0 mcols 4 sub }
20357 { 0 mcols 3 sub } { 0 mcols 2 sub }
20358 { 0 mcols 1 sub } { 1 mcols 1 sub }
20359 ] def
20360
20361 /dmc3 [
20362 { mrows 3 sub 0 } { mrows 2 sub 0 }
20363 { mrows 1 sub 0 } { 0 mcols 2 sub }
20364 { 0 mcols 1 sub } { 1 mcols 1 sub }
20365 { 2 mcols 1 sub } { 3 mcols 1 sub }
20366 ] def
20367
20368 /dmc4 [
20369 { mrows 1 sub 0 } { mrows 1 sub mcols 1 sub }
20370 { 0 mcols 3 sub } { 0 mcols 2 sub }
20371 { 0 mcols 1 sub } { 1 mcols 3 sub }
20372 { 1 mcols 2 sub } { 1 mcols 1 sub }
20373 ] def
20374
20375 /mmat [ mrows mcols mul {-1} repeat ] def
20376 cws length 1 sub -1 0 {cws exch get} for % Reverse cws onto stack
20377 4 0 % Starting row and column
20378 { % loop
20379 2 copy 0 eq exch mrows eq and {
20380 dmc1 module
20381 } if
20382 2 copy 0 eq exch mrows 2 sub eq and mcols 4 mod 0 ne and {
20383 dmc2 module
20384 } if
20385 2 copy 0 eq exch mrows 2 sub eq and mcols 8 mod 4 eq and {
20386 dmc3 module
20387 } if
20388 2 copy 2 eq exch mrows 4 add eq and mcols 8 mod 0 eq and {
20389 dmc4 module
20390 } if
20391
20392 { % loop for sweeping upwards
20393 2 copy 0 ge exch mrows lt and {
20394 2 copy exch mcols mul add mmat exch get -1 eq {
20395 dmn module
20396 } if
20397 } if
20398 2 add exch 2 sub exch
20399 2 copy mcols lt exch 0 ge and not {exit} if
20400 } loop
20401 3 add exch 1 add exch
20402
20403 { % loop for sweeping downwards
20404 2 copy mcols lt exch 0 ge and {
20405 2 copy exch mcols mul add mmat exch get -1 eq {
20406 dmn module
20407 } if
20408 } if
20409 2 sub exch 2 add exch
20410 2 copy 0 ge exch mrows lt and not {exit} if
20411 } loop
20412 1 add exch 3 add exch
20413
20414 2 copy mcols lt exch mrows lt or not {pop pop exit} if
20415
20416 } loop
20417
20418 % Set checker pattern if required
20419 mmat mrows mcols mul 1 sub get -1 eq {
20420 mmat mrows mcols 1 sub mul 2 sub [1 0] putinterval
20421 mmat mrows mcols mul 2 sub [0 1] putinterval
20422 } if
20423
20424 % Place the modules onto a pixel map between alignment patterns
20425 /pixs rows cols mul array def
20426 /cwpos 0 def
20427 0 1 rows 1 sub {
20428 /i exch def
20429 i rrows 2 add mod 0 eq { pixs i cols mul [ cols 2 idiv {1 0} repeat ] putinterval } if
20430 i rrows 2 add mod rrows 1 add eq { pixs i cols mul [ cols {1} repeat ] putinterval } if
20431 i rrows 2 add mod 0 ne i rrows 2 add mod rrows 1 add ne and {
20432 0 1 cols 1 sub {
20433 /j exch def
20434 j rcols 2 add mod 0 eq { pixs i cols mul j add 1 put } if
20435 j rcols 2 add mod rcols 1 add eq { pixs i cols mul j add i 2 mod put } if
20436 j rcols 2 add mod 0 ne j rcols 2 add mod rcols 1 add ne and {
20437 pixs i cols mul j add mmat cwpos get put
20438 /cwpos cwpos 1 add def
20439 } if
20440 } for
20441 } if
20442 } for
20443
20444 % Return the arguments
20445 <<
20446 /ren /renmatrix
20447 /pixs pixs
20448 /pixx cols
20449 /pixy rows
20450 /height rows 2 mul 72 div
20451 /width cols 2 mul 72 div
20452 /borderleft 1.0
20453 /borderright 1.0
20454 /bordertop 1.0
20455 /borderbottom 1.0
20456 /opt options
20457 >>
20458
20459 dontdraw not //renmatrix if
20460
20461 //unloadctx exec
20462
20463 end
20464
20465 }
20466 [/barcode] {null def} forall
20467 bind def
20468 /datamatrix dup load /uk.co.terryburton.bwipp defineresource pop
20469 end
20470 /setpacking where {pop setpacking} if
20471 %%EndData
20472 %%EndResource
20473 % --END ENCODER datamatrix--
20474
20475 % --BEGIN ENCODER datamatrixrectangular--
20476 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix datamatrix--
20477 % --DESC: Data Matrix Rectangular
20478 % --EXAM: 1234
20479 % --EXOP:
20480 % --RNDR: renmatrix
20481 %%BeginResource: uk.co.terryburton.bwipp datamatrixrectangular 0.0 2025111800 66156 69389
20482 %%BeginData: 36 ASCII Lines
20483 /setpacking where {pop currentpacking true setpacking} if
20484 10 dict
20485 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
20486 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
20487 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
20488 dup /datamatrix dup /uk.co.terryburton.bwipp findresource put
20489 begin
20490 /datamatrixrectangular {
20491
20492 20 dict begin % Confine variables to local scope
20493
20494 /ctx null def
20495 /dontdraw false def
20496
20497 //processoptions exec /options exch def
20498 /barcode exch def
20499
20500 % Get the result of encoding with datamatrix with format=rectangle
20501 options (dontdraw) true put
20502 options (format) (rectangle) put
20503
20504 /args barcode options //datamatrix exec def
20505
20506 args (opt) options put
20507 args
20508
20509 dontdraw not //renmatrix if
20510
20511 end
20512
20513 }
20514 [/barcode] {null def} forall
20515 bind def
20516 /datamatrixrectangular dup load /uk.co.terryburton.bwipp defineresource pop
20517 end
20518 /setpacking where {pop setpacking} if
20519 %%EndData
20520 %%EndResource
20521 % --END ENCODER datamatrixrectangular--
20522
20523 % --BEGIN ENCODER datamatrixrectangularextension--
20524 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix datamatrix--
20525 % --DESC: Data Matrix Rectangular Extension
20526 % --EXAM: 1234
20527 % --EXOP: version=8x96
20528 % --RNDR: renmatrix
20529 %%BeginResource: uk.co.terryburton.bwipp datamatrixrectangularextension 0.0 2025111800 66565 69789
20530 %%BeginData: 36 ASCII Lines
20531 /setpacking where {pop currentpacking true setpacking} if
20532 20 dict
20533 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
20534 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
20535 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
20536 dup /datamatrix dup /uk.co.terryburton.bwipp findresource put
20537 begin
20538 /datamatrixrectangularextension {
20539
20540 20 dict begin
20541
20542 /ctx null def
20543 /dontdraw false def
20544
20545 //processoptions exec /options exch def
20546 /barcode exch def
20547
20548 % Get the result of encoding with datamatrix
20549 options (dontdraw) true put
20550 options (dmre) true put
20551
20552 /args barcode options //datamatrix exec def
20553
20554 args (opt) options put
20555 args
20556
20557 dontdraw not //renmatrix if
20558
20559 end
20560
20561 }
20562 [/barcode] {null def} forall
20563 bind def
20564 /datamatrixrectangularextension dup load /uk.co.terryburton.bwipp defineresource pop
20565 end
20566 /setpacking where {pop setpacking} if
20567 %%EndData
20568 %%EndResource
20569 % --END ENCODER datamatrixrectangularextension--
20570
20571 % --BEGIN ENCODER mailmark--
20572 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix datamatrix--
20573 % --DESC: Royal Mail Mailmark
20574 % --EXAM: JGB 012100123412345678AB19XY1A 0 www.xyz.com
20575 % --EXOP: type=29
20576 % --RNDR: renmatrix
20577 %%BeginResource: uk.co.terryburton.bwipp mailmark 0.0 2025111800 70907 74021
20578 %%BeginData: 74 ASCII Lines
20579 /setpacking where {pop currentpacking true setpacking} if
20580 10 dict
20581 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
20582 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
20583 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
20584 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
20585 dup /datamatrix dup /uk.co.terryburton.bwipp findresource put
20586 begin
20587 /mailmark {
20588
20589 20 dict begin % Confine variables to local scope
20590
20591 /ctx null def
20592 /type (unset) def % 7, 9 or 29
20593 /parse false def
20594 /dontdraw false def
20595
20596 //processoptions exec /options exch def
20597 /barcode exch def
20598
20599 % Parse ordinals of the form ^NNN to ASCII
20600 /fncvals <<
20601 /parse parse
20602 /parseonly true
20603 /parsefnc false
20604 >> def
20605 /barcode barcode fncvals //parseinput exec def
20606 /barlen barcode length def
20607 options (parse) undef
20608
20609 % Map the given type to a format and version of Data Matrix
20610 /type load dup (7) ne exch dup (9) ne exch (29) ne and and {
20611 /bwipp.mailmarkBadType (Royal Mail Mailmark type must be 7, 9 or 29) //raiseerror exec
20612 } if
20613 <<
20614 (7) (24x24)
20615 (9) (32x32)
20616 (29) (16x48)
20617 >> /type load get /version exch def
20618
20619 <<
20620 (7) (square)
20621 (9) (square)
20622 (29) (rectangle)
20623 >> /type load get /format exch def
20624
20625 % Validate the input
20626 barcode length 45 lt {
20627 /bwipp.mailmarkBadLength (Royal Mail Mailmark must contain at least 45 characters of Mailmark formatted data, including any required space padding) //raiseerror exec
20628 } if
20629 barcode 0 4 getinterval (JGB ) ne {
20630 /bwipp.mailmarkBadIndicator (Royal Mail Mailmark must begin with JGB<space> identifier) //raiseerror exec
20631 } if
20632
20633 % Get the result of encoding with datamatrix
20634 options (dontdraw) true put
20635 options (version) version put
20636 options (format) format put
20637 options (c40headerlength) 45 put
20638 /args barcode options //datamatrix exec def
20639
20640 args (opt) options put
20641 args
20642
20643 dontdraw not //renmatrix if
20644
20645 end
20646
20647 }
20648 [/barcode] {null def} forall
20649 bind def
20650 /mailmark dup load /uk.co.terryburton.bwipp defineresource pop
20651 end
20652 /setpacking where {pop setpacking} if
20653 %%EndData
20654 %%EndResource
20655 % --END ENCODER mailmark--
20656
20657 % --BEGIN ENCODER qrcode--
20658 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix--
20659 % --DESC: QR Code
20660 % --EXAM: http://goo.gl/0bis
20661 % --EXOP: eclevel=M
20662 % --RNDR: renmatrix
20663 %%BeginResource: uk.co.terryburton.bwipp qrcode 0.0 2025111800 380409 413946
20664 %%BeginData: 1430 ASCII Lines
20665 /setpacking where {pop currentpacking true setpacking} if
20666 10 dict
20667 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
20668 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
20669 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
20670 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
20671 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
20672 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
20673 begin
20674 /qrcode {
20675
20676 20 dict begin
20677
20678 /ctx null def
20679 /dontdraw false def
20680 /format (unset) def % full or micro. rMQR symbols are specified using version
20681 /version (unset) def % 1-40 or M1-M4 or R7x43, etc
20682 /eclevel (unset) def % full: L, M, Q, H; micro: L, M, Q; rmqr: M, H
20683 /fixedeclevel false def
20684 /parse false def
20685 /parsefnc false def
20686 /mask -1 def
20687 /suppresskanjimode false def
20688
20689 //processoptions exec /options exch def
20690 /barcode exch def
20691
20692 /qrcode //loadctx exec
20693
20694 barcode () eq {
20695 /bwipp.qrcodeEmptyData (The data must not be empty) //raiseerror exec
20696 } if
20697
20698 % If version is supplied and format is not given then set format to correspond
20699 version (unset) ne {
20700 format (unset) eq {
20701 (full)
20702 version 0 1 getinterval (M) eq { pop (micro) } if
20703 version 0 1 getinterval (R) eq { pop (rmqr) } if
20704 /format exch def
20705 } if
20706 } {
20707 format (unset) eq { /format (full) def } if % Default to full
20708 } ifelse
20709
20710 format (full) ne format (micro) ne format (rmqr) ne and and {
20711 /bwipp.qrcodeInvalidFormat (The format must be either full, micro or rmqr) //raiseerror exec
20712 } if
20713
20714 format (rmqr) eq version (unset) eq and {
20715 /bwipp.qrcodeRMQRwithoutVersion (A version must be provided for RMQR) //raiseerror exec
20716 } if
20717
20718 % Default error correction level
20719 eclevel (unset) eq {/eclevel format (micro) ne {(M)} {(L)} ifelse def} if
20720
20721 eclevel (L) ne eclevel (M) ne eclevel (Q) ne eclevel (H) ne and and and {
20722 /bwipp.qrcodeInvalidEClevel (Error correction level must be either L, M, Q, or H) //raiseerror exec
20723 } if
20724
20725 mask -1 ne format (rmqr) eq and {
20726 /bwipp.qrcodeRMQRmask (A mask cannot be supplied for RMQR) //raiseerror exec
20727 } if
20728
20729 mask -1 ne {
20730 mask 1 lt mask format (full) eq {8} {4} ifelse gt or {
20731 /bwipp.qrcodeBadMask (An invalid mask was supplied) //raiseerror exec
20732 } if
20733 } if
20734
20735 % Parse the input
20736 /fn1 -1 def
20737 /fncvals <<
20738 /parse parse
20739 /parsefnc parsefnc
20740 /eci true
20741 (FNC1) fn1
20742 >> def
20743 /msg barcode fncvals //parseinput exec def
20744 /msglen msg length def
20745
20746 % If FNC1 in first position then escape % as %%
20747 /fnc1first false def
20748 msglen 0 gt {
20749 msg 0 get fn1 eq {
20750 /fnc1first true def
20751 /msg [ msg 1 msglen 1 sub getinterval { dup 37 eq {dup} if } forall ] def
20752 /msglen msg length def
20753 } if
20754 } if
20755
20756 { % context
20757
20758 % Enumerate vergrps
20759 [
20760 /v1to9 /v10to26 /v27to40
20761 /vM1 /vM2 /vM3 /vM4
20762 /vR7x43 /vR7x59 /vR7x77 /vR7x99 /vR7x139
20763 /vR9x43 /vR9x59 /vR9x77 /vR9x99 /vR9x139
20764 /vR11x27 /vR11x43 /vR11x59 /vR11x77 /vR11x99 /vR11x139
20765 /vR13x27 /vR13x43 /vR13x59 /vR13x77 /vR13x99 /vR13x139
20766 /vR15x43 /vR15x59 /vR15x77 /vR15x99 /vR15x139
20767 /vR17x43 /vR17x59 /vR17x77 /vR17x99 /vR17x139
20768 ] 0 exch {1 index def 1 add} forall pop
20769
20770 % Convert from input into message bitstream
20771 %
20772 % Modes: (N)umeric, (A)lphanumeric, (B)yte, (K)anji, (E)CI
20773 %
20774 /N 0 def /A 1 def /B 2 def /K 3 def /E 4 def
20775
20776 /Nexcl <<
20777 [
20778 16#30 1 16#39 {} for
20779 ] {-1} forall
20780 >> def
20781
20782 /Aexcl <<
20783 [
20784 16#20 16#24 16#25 16#2A 16#2B 16#2D 16#2E 16#2F 16#3A
20785 16#41 1 16#5A {} for
20786 fn1
20787 ] {-1} forall
20788 >> def
20789
20790 % Binary exclusives calculated from "not others"
20791
20792 /Kexcl <<
20793 [
20794 16#81 1 16#9F {} for
20795 16#E0 1 16#EB {} for
20796 ] {-1} forall
20797 >> def
20798
20799 /mids [
20800 % N A B K E
20801 [ (0001) (0010) (0100) (1000) (0111) ] % v1to9
20802 [ (0001) (0010) (0100) (1000) (0111) ] % v10to26
20803 [ (0001) (0010) (0100) (1000) (0111) ] % v27to40
20804 [ () -1 -1 -1 -1 ] % vM1
20805 [ (0) (1) -1 -1 -1 ] % vM2
20806 [ (00) (01) (10) (11) -1 ] % vM3
20807 [ (000) (001) (010) (011) -1 ] % vM4
20808 32 {
20809 [ (001) (010) (011) (100) (111) ] % rMQR
20810 } repeat
20811 ] def
20812
20813 /cclens [ % N A B K
20814 [ 10 9 8 8 ] % v1to9
20815 [ 12 11 16 10 ] % v10to26
20816 [ 14 13 16 12 ] % v27to40
20817 [ 3 -1 -1 -1 ] % vM1
20818 [ 4 3 -1 -1 ] % vM2
20819 [ 5 4 4 3 ] % vM3
20820 [ 6 5 5 4 ] % vM4
20821 [ 4 3 3 2 ] % vR7x43
20822 [ 5 5 4 3 ] % vR7x59
20823 [ 6 5 5 4 ] % vR7x77
20824 [ 7 6 5 5 ] % vR7x99
20825 [ 7 6 6 5 ] % vR7x139
20826 [ 5 5 4 3 ] % vR9x43
20827 [ 6 5 5 4 ] % vR9x59
20828 [ 7 6 5 5 ] % vR9x77
20829 [ 7 6 6 5 ] % vR9x99
20830 [ 8 7 6 6 ] % vR9x139
20831 [ 4 4 3 2 ] % vR11x27
20832 [ 6 5 5 4 ] % vR11x43
20833 [ 7 6 5 5 ] % vR11x59
20834 [ 7 6 6 5 ] % vR11x77
20835 [ 8 7 6 6 ] % vR11x99
20836 [ 8 7 7 6 ] % vR11x139
20837 [ 5 5 4 3 ] % vR13x27
20838 [ 6 6 5 5 ] % vR13x43
20839 [ 7 6 6 5 ] % vR13x59
20840 [ 7 7 6 6 ] % vR13x77
20841 [ 8 7 7 6 ] % vR13x99
20842 [ 8 8 7 7 ] % vR13x139
20843 [ 7 6 6 5 ] % vR15x43
20844 [ 7 7 6 5 ] % vR15x59
20845 [ 8 7 7 6 ] % vR15x77
20846 [ 8 7 7 6 ] % vR15x99
20847 [ 9 8 7 7 ] % vR15x139
20848 [ 7 6 6 5 ] % vR17x43
20849 [ 8 7 6 6 ] % vR17x59
20850 [ 8 7 7 6 ] % vR17x77
20851 [ 8 8 7 6 ] % vR17x99
20852 [ 9 8 8 7 ] % vR17x139
20853 ] def
20854
20855 /termlens [
20856 3 {
20857 4 % Full
20858 } repeat
20859 3 % vM1
20860 5 % vM2
20861 7 % vM3
20862 9 % vM4
20863 32 {
20864 3 % rMQR
20865 } repeat
20866 ] def
20867
20868 /padstrs [ (11101100) (00010001) ] def
20869
20870 % Alphanumeric character to value map
20871 /charmap (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:) def
20872 /charvals 44 dict def
20873 0 1 44 {dup charmap exch get exch charvals 3 1 roll put} for
20874
20875 } ctxdef
20876
20877 % Encoding functions
20878 /tobin {
20879 string dup length 1 sub 0 exch 1 exch {1 index exch 48 put} for
20880 dup 3 -1 roll 2 2 index length string cvrs dup length 2 index length exch sub exch putinterval
20881 } def
20882
20883 /encA {
20884 /in exch def
20885 fnc1first { % FNC1 as %
20886 /in [ in { dup fn1 eq {pop 37} if } forall ] def
20887 } if
20888 /out in length 11 mul 2 idiv 1 add string def
20889 /k 0 def /m 0 def {
20890 k in length eq {exit} if
20891 k in length 1 sub lt {
20892 charvals in k get get 45 mul charvals in k 1 add get get add 11 tobin
20893 /k k 2 add def
20894 } { % Final character
20895 charvals in k get get 6 tobin
20896 /k k 1 add def
20897 } ifelse
20898 dup out exch m exch putinterval
20899 length m add /m exch def
20900 } loop
20901 out 0 m getinterval
20902 } def
20903
20904 /encN {
20905 /in exch def
20906 /out in length 10 mul 3 idiv 1 add string def
20907 /k 0 def /m 0 def {
20908 k in length eq {exit} if
20909 k in length 2 sub lt {
20910 in k 3 getinterval 0 exch {exch 10 mul 48 sub add} forall 10 tobin
20911 /k k 3 add def
20912 } {
20913 k in length 2 sub eq { % Two final digits
20914 in k 2 getinterval 0 exch {exch 10 mul 48 sub add} forall 7 tobin
20915 /k k 2 add def
20916 } { % One final digit
20917 in k 1 getinterval 0 exch {exch 10 mul 48 sub add} forall 4 tobin
20918 /k k 1 add def
20919 } ifelse
20920 } ifelse
20921 dup out exch m exch putinterval
20922 length m add /m exch def
20923 } loop
20924 out 0 m getinterval
20925 } def
20926
20927 /encB {
20928 /in exch def
20929 fnc1first { % FNC1 as GS
20930 /in [ in { dup fn1 eq {pop 29} if } forall ] def
20931 } if
20932 /out in length 8 mul string def
20933 0 1 in length 1 sub {
20934 /k exch def
20935 in k get cvi 8 tobin
20936 out k 8 mul 3 -1 roll putinterval
20937 } for
20938 out
20939 } def
20940
20941 /encK {
20942 /in exch def
20943 /out in length 2 idiv 13 mul string def
20944 /k 0 def /m 0 def {
20945 k in length eq {exit} if
20946 in k get 256 mul in k 1 add get add
20947 dup 16#E040 lt {16#8140} {16#C140} ifelse sub
20948 dup -8 bitshift 16#C0 mul exch 16#00FF and add
20949 13 tobin dup out exch m exch putinterval
20950 length m add /m exch def
20951 /k k 2 add def
20952 } loop
20953 out
20954 } def
20955
20956 /encE {
20957 0 get neg 1000000 sub
20958 dup 000127 le { % ECI 000000 - 000127
20959 8 tobin
20960 } { dup 016383 le { % ECI 000128 - 016383
20961 2#1000000000000000 add 16 tobin
20962 } { % ECI 016384 - 999999
20963 2#110000000000000000000000 add 24 tobin
20964 } ifelse } ifelse
20965 } def
20966
20967 /encfuncs [ /encN /encA /encB /encK /encE ] def
20968
20969 /addtobits {
20970 dup bits j 3 -1 roll putinterval
20971 length j add /j exch def
20972 } def
20973
20974 /numNs [ msglen {0} repeat 0 ] def
20975 /numAs [ msglen {0} repeat 0 ] def
20976 /numAorNs [ msglen {0} repeat 0 ] def
20977 /numBs [ msglen {0} repeat 0 ] def
20978 /numKs [ msglen {0} repeat 0 ] def
20979 /nextNs [ msglen {0} repeat 9999 ] def
20980 /nextBs [ msglen {0} repeat 9999 ] def
20981 /nextAs [ msglen {0} repeat 9999 ] def
20982 /nextKs [ msglen {0} repeat 9999 ] def
20983 /isECI msglen array def
20984 msglen 1 sub -1 0 {
20985 /i exch def
20986 /barchar msg i get def
20987 Kexcl barchar known suppresskanjimode not and {
20988 i 1 add msglen lt { barchar 256 mul msg i 1 add get add } { 0 } ifelse
20989 dup % Double byte:
20990 dup dup 16#8140 ge exch 16#9FFC le and exch % 8140-9FFC or
20991 dup 16#E040 ge exch 16#EBBF le and or exch % E040-EBBF
20992 16#FF and % Low byte:
20993 dup dup 16#40 ge exch 16#FC le and exch 16#7F ne % 40-FC except !7F
20994 and and {
20995 nextKs i 0 put
20996 numKs i numKs i 2 add get 1 add put
20997 } {
20998 nextKs i nextKs i 1 add get 1 add put
20999 } ifelse
21000 } {
21001 nextKs i nextKs i 1 add get 1 add put
21002 } ifelse
21003 Nexcl barchar known {
21004 nextNs i 0 put
21005 numNs i numNs i 1 add get 1 add put
21006 numAorNs i numAorNs i 1 add get 1 add put
21007 } {
21008 nextNs i nextNs i 1 add get 1 add put
21009 } ifelse
21010 Aexcl barchar known {
21011 nextAs i 0 put
21012 numAs i numAs i 1 add get 1 add put
21013 numAorNs i numAorNs i 1 add get 1 add put
21014 } {
21015 nextAs i nextAs i 1 add get 1 add put
21016 } ifelse
21017 isECI i barchar -1000000 le put
21018 } for
21019 0 1 msglen 1 sub { % Scan forward to set any "2nd byte 1st byte" Kanji matches to zero
21020 /i exch def
21021 numKs i get 0 gt {
21022 numKs i 1 add 0 put
21023 nextKs i 1 add nextKs i 1 add get 1 add put
21024 } if
21025 } for
21026 msglen 1 sub -1 0 { % Finally scan backwards again to set numBs/nextBs from "not others"
21027 /i exch def
21028 numNs i get numAs i get numKs i get add add 0 eq isECI i get not and {
21029 nextBs i 0 put
21030 numBs i numBs i 1 add get 1 add put
21031 } {
21032 nextBs i nextBs i 1 add get 1 add put
21033 } ifelse
21034 } for
21035
21036 /KbeforeB {numK exch ver get ge nextBs numK 2 mul i add get 0 eq and} def
21037 /KbeforeA {numK exch ver get ge nextAs numK 2 mul i add get 0 eq and} def
21038 /KbeforeN {numK exch ver get ge nextNs numK 2 mul i add get 0 eq and} def
21039 /KbeforeE {numK exch ver get ge numK 2 mul i add msglen eq and} def
21040 /AbeforeK {numA exch ver get ge nextKs numA i add get 0 eq and} def
21041 /AbeforeB {numA exch ver get ge nextBs numA i add get 0 eq and} def
21042 /AbeforeN {numA exch ver get ge nextNs numA i add get 0 eq and} def
21043 /AbeforeE {numA exch ver get ge numA i add msglen eq and} def
21044 /NbeforeK {numN exch ver get ge nextKs numN i add get 0 eq and} def
21045 /NbeforeB {numN exch ver get ge nextBs numN i add get 0 eq and} def
21046 /NbeforeA {numN exch ver get ge nextAs numN i add get 0 eq and} def
21047 /NbeforeE {numN exch ver get ge numN i add msglen eq and} def
21048 /AorNbeforeB {numAorN exch ver get ge nextBs numAorN i add get 0 eq and} def
21049 /AorNbeforeE {numAorN exch ver get ge numAorN i add msglen eq and} def
21050
21051 /nextNslt { nextNs i get msglen ge { pop true } { numNs nextNs i get i add get exch ver get lt } ifelse } def
21052
21053 % Elements of the encoded message have differing lengths based on the
21054 % resulting symbol size. The symbol sizes with different element lengths
21055 % are batched into vergrps. To pick the smallest symbol that holds our
21056 % content we encode the message according to each available vergrp, based
21057 % on the format of symbol.
21058
21059 % Determine which groups we need to encode
21060 {
21061 /versetmap <<
21062 (full) <<
21063 0 1 9 { 10 2 string cvrs v1to9 } for
21064 10 1 26 { 10 2 string cvrs v10to26 } for
21065 27 1 40 { 10 2 string cvrs v27to40 } for
21066 >>
21067 (micro) <<
21068 (M1) vM1 (M2) vM2 (M3) vM3 (M4) vM4
21069 >>
21070 (rmqr) <<
21071 (R7x43) vR7x43 (R7x59) vR7x59 (R7x77) vR7x77 (R7x99) vR7x99 (R7x139) vR7x139
21072 (R9x43) vR9x43 (R9x59) vR9x59 (R9x77) vR9x77 (R9x99) vR9x99 (R9x139) vR9x139
21073 (R11x27) vR11x27 (R11x43) vR11x43 (R11x59) vR11x59 (R11x77) vR11x77 (R11x99) vR11x99 (R11x139) vR11x139
21074 (R13x27) vR13x27 (R13x43) vR13x43 (R13x59) vR13x59 (R13x77) vR13x77 (R13x99) vR13x99 (R13x139) vR13x139
21075 (R15x43) vR15x43 (R15x59) vR15x59 (R15x77) vR15x77 (R15x99) vR15x99 (R15x139) vR15x139
21076 (R17x43) vR17x43 (R17x59) vR17x59 (R17x77) vR17x77 (R17x99) vR17x99 (R17x139) vR17x139
21077 >>
21078 >> def
21079 /versetfull [v1to9 v10to26 v27to40] def
21080 /versetmicro [vM1 vM2 vM3 vM4] def
21081 } ctxdef
21082 version (unset) ne {
21083 % A specific version of symbol is given so encode in just the corresponding vergrp
21084 versetmap format get version 2 copy known not {
21085 pop pop
21086 format (full) eq {
21087 /bwipp.qrcodeInvalidFullVersion (Valid versions for QR Code symbols are 1 to 40) //raiseerror exec
21088 } {
21089 format (micro) eq {
21090 /bwipp.qrcodeInvalidMicroVersion (Valid versions for Micro QR Code symbols are M1 to M4) //raiseerror exec
21091 } { % rmqr
21092 /bwipp.qrcodeInvalidRMQRversion (Invalid version for an RMQR symbol) //raiseerror exec
21093 } ifelse } ifelse
21094 } if
21095 get [ exch ] /verset exch def
21096 } {
21097 % Just the format is specified so encode in each vergrp for the type of symbol
21098 format (full) eq { /verset versetfull def } if
21099 format (micro) eq { /verset versetmicro def } if
21100 % rMQR symbols are accessed with an explicit version
21101 } ifelse
21102
21103 % Encode unterminated bitstream for each compatible vergrp separately
21104 /msgbits [ 39 {-1} repeat ] def
21105 /e 10000 def
21106
21107 % Number of before characters per vergrp, depending on current mode, for optimising modes
21108 % Generated by contrib/development/build-qr-mode-optim-arrs.php
21109 % Full Micro R7 R9 R11 R13 R15 R17
21110 {
21111 /mode0forceKB [ 1 1 1 e e 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] def
21112 /mode0forceA [ 1 1 1 e 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] def
21113 /mode0forceN [ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] def
21114
21115 /mode0NbeforeB [ 4 4 5 e e 2 3 2 2 3 3 3 2 3 3 3 3 2 3 3 3 3 3 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3] def
21116
21117 /modeBKbeforeB [ 9 12 13 e e 4 6 4 5 6 6 6 5 6 6 6 7 4 6 6 6 7 7 5 6 6 7 7 7 6 6 7 7 7 6 7 7 7 8] def
21118 /modeBKbeforeA [ 8 10 11 e e 4 5 4 5 5 6 6 5 5 6 6 6 4 5 6 6 6 6 5 6 6 6 6 7 6 6 6 6 7 6 6 6 7 7] def
21119 /modeBKbeforeN [ 8 9 11 e e 3 5 3 4 5 5 5 4 5 5 5 6 3 5 5 5 6 6 4 5 5 6 6 6 5 5 6 6 7 5 6 6 6 7] def
21120 /modeBKbeforeE [ 5 5 6 e e 2 3 2 3 3 3 3 3 3 3 3 4 2 3 3 3 4 4 3 3 3 4 4 4 3 3 4 4 4 3 4 4 4 4] def
21121
21122 /modeBAbeforeK [11 12 14 e e 5 7 5 6 7 8 8 6 7 8 8 8 6 7 8 8 8 8 6 8 8 8 8 9 8 8 8 8 9 8 8 8 9 9] def
21123 /modeBAbeforeB [11 15 16 e e 6 7 6 7 7 8 8 7 7 8 8 8 6 7 8 8 8 9 7 8 8 8 9 9 8 8 9 9 9 8 8 9 9 10] def
21124 /modeBAbeforeN [12 13 15 e e 6 8 6 7 8 8 8 7 8 8 8 9 6 8 8 8 9 9 7 8 8 9 9 10 8 9 9 9 10 8 9 9 10 10] def
21125 /modeBAbeforeE [ 6 7 8 e e 3 4 3 4 4 4 4 4 4 4 4 5 4 4 4 4 5 5 4 4 4 5 5 5 4 5 5 5 5 4 5 5 5 5] def
21126
21127 /modeBNbeforeK [ 6 7 8 e e 3 4 3 4 4 5 5 4 4 5 5 5 3 4 5 5 5 5 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5] def
21128 /modeBNbeforeB [ 6 8 9 e e 3 4 3 4 4 5 5 4 4 5 5 5 3 4 5 5 5 5 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 6] def
21129 /modeBNbeforeA [ 6 7 8 e e 3 4 3 4 4 5 5 4 4 5 5 5 4 4 5 5 5 5 4 5 5 5 5 5 5 5 5 5 6 5 5 5 5 6] def
21130 /modeBNbeforeE [ 3 4 4 e e 2 3 2 2 3 3 3 2 3 3 3 3 2 3 3 3 3 3 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3] def
21131
21132 /modeANbeforeA [13 15 17 e 5 7 9 7 8 9 9 9 8 9 9 9 11 7 9 9 9 11 11 8 9 9 10 11 11 9 10 11 11 11 9 11 11 11 11] def
21133 /modeANbeforeB [13 17 18 e e 7 9 7 8 9 9 9 8 9 9 9 10 7 9 9 9 10 11 8 9 9 9 11 11 9 9 11 11 11 9 10 11 11 11] def
21134 /modeANbeforeE [ 7 8 9 e 3 4 5 4 5 5 5 5 5 5 5 5 6 4 5 5 5 6 6 5 5 5 5 6 6 5 5 6 6 6 5 6 6 6 6] def
21135 } ctxdef
21136
21137 verset {
21138 /ver exch def
21139
21140 % Derive optimal sequence
21141 /mode -1 def /seq [] def /i 0 def {
21142 i msglen ge {exit} if
21143 /numK numKs i get def
21144 /numB numBs i get def
21145 /numA numAs i get def
21146 /numN numNs i get def
21147 /numAorN numAorNs i get def
21148 /eci isECI i get def
21149 ver vM1 eq numA 1 ge and {/seq -1 def exit} if
21150 ver vM1 eq numB 1 ge and {/seq -1 def exit} if
21151 ver vM1 eq numK 1 ge and {/seq -1 def exit} if
21152 ver vM1 eq eci and {/seq -1 def exit} if
21153 ver vM2 eq numB 1 ge and {/seq -1 def exit} if
21154 ver vM2 eq numK 1 ge and {/seq -1 def exit} if
21155 ver vM2 eq eci and {/seq -1 def exit} if
21156 ver vM3 eq eci and {/seq -1 def exit} if
21157 ver vM4 eq eci and {/seq -1 def exit} if
21158 { % common exit
21159 eci {
21160 E exit
21161 } if
21162 mode -1 eq { % Set initial mode (or mode after ECI)
21163 mode0forceKB KbeforeA {K exit} if
21164 mode0forceKB KbeforeN {K exit} if
21165 modeBKbeforeE KbeforeB {K exit} if % Re-using modeB KbeforeE array
21166 mode0forceKB KbeforeE {K exit} if
21167 numK 1 ge {B exit} if
21168 mode0NbeforeB NbeforeK {N exit} if
21169 mode0NbeforeB NbeforeB {N exit} if
21170 mode0forceKB NbeforeB {B exit} if
21171 modeANbeforeE NbeforeA {N exit} if % Re-using modeA NbeforeE array
21172 mode0forceN NbeforeE {N exit} if
21173 modeBAbeforeE AbeforeK {A exit} if % Re-using modeB AbeforeE array
21174 modeBAbeforeE AorNbeforeB {A exit} if % Re-using modeB AbeforeE array
21175 mode0forceA AorNbeforeE {A exit} if
21176 B exit
21177 } if
21178 mode B eq {
21179 modeBKbeforeB KbeforeB {K exit} if
21180 modeBKbeforeA KbeforeA {K exit} if
21181 modeBKbeforeN KbeforeN {K exit} if
21182 modeBKbeforeE KbeforeE {K exit} if
21183 modeBAbeforeK AbeforeK {A exit} if
21184 modeBAbeforeB AbeforeB {A exit} if
21185 modeBAbeforeN AbeforeN {A exit} if
21186 modeBAbeforeE AbeforeE {A exit} if
21187 modeBNbeforeK NbeforeK {N exit} if
21188 modeBNbeforeB NbeforeB {N exit} if
21189 modeBNbeforeA NbeforeA {N exit} if
21190 modeBNbeforeE NbeforeE {N exit} if
21191 modeBAbeforeE AorNbeforeE numAorN modeBAbeforeN ver get le and { % If A/N sequence at end and short
21192 modeBNbeforeA nextNslt {A exit} if % And next N sequence shorter than NbeforeA
21193 } if
21194 B exit
21195 } if
21196 mode A eq {
21197 numK 1 ge {K exit} if
21198 numB 1 ge {B exit} if
21199 modeANbeforeA NbeforeA {N exit} if
21200 modeANbeforeB NbeforeB {N exit} if
21201 modeANbeforeE NbeforeE {N exit} if
21202 numA 1 ge numN 1 ge or {A exit} if
21203 B exit
21204 } if
21205 mode N eq {
21206 numK 1 ge {K exit} if
21207 numB 1 ge {B exit} if
21208 numA 1 ge {A exit} if
21209 numN 1 ge {N exit} if
21210 B exit
21211 } if
21212 mode K eq {
21213 numB 1 ge {B exit} if
21214 numA 1 ge {A exit} if
21215 numN 1 ge {N exit} if
21216 numK 1 ge {K exit} if
21217 B exit
21218 } if
21219 } loop
21220 dup K eq fnc1first and {pop B} if % No kanji with fnc1first
21221 dup mode eq { % Same mode encode directly
21222 pop
21223 /dat msg i mode K eq {2} {1} ifelse getinterval def
21224 /seq [
21225 seq aload pop
21226 [ exch aload pop dat aload pop ]
21227 ] def
21228 } { % Change mode
21229 /mode exch def
21230 mode K eq {K msg i numK 2 mul getinterval} if
21231 mode B eq {B msg i numB getinterval} if
21232 mode A eq {A msg i numA getinterval} if
21233 mode N eq {N msg i numN getinterval} if
21234 mode E eq {E msg i 1 getinterval /mode -1 def} if
21235 /dat exch def /sw exch def
21236 /seq [ seq aload pop sw dat ] def
21237 } ifelse
21238 /i i dat length add def
21239 } loop
21240
21241 % Encode the sequence
21242 { % common exit
21243 seq -1 eq {exit} if % Sequence not available
21244 /bits 23648 string def
21245 /j 0 def
21246 fnc1first {
21247 ver vR7x43 lt { (0101) } { (101) } ifelse addtobits
21248 } if
21249 /abort false def
21250 0 2 seq length 1 sub {
21251 /i exch def
21252 /mode seq i get def
21253 mids ver get mode get addtobits
21254 /chars seq i 1 add get def
21255 /charslen chars length mode K eq {2 idiv} if def
21256 mode E ne {
21257 /cclen cclens ver get mode get def
21258 charslen 2 cclen exp cvi ge { % Too many characters for cc indicator
21259 /abort true def exit
21260 } if
21261 charslen cclen tobin addtobits
21262 } if
21263 chars encfuncs mode get load exec addtobits
21264 } for
21265 abort {exit} if
21266 /bits bits 0 j getinterval def
21267 msgbits ver bits put
21268 exit
21269 } loop
21270 } forall
21271
21272 % Lookup the most appropriate symbol specification
21273 {
21274 /metrics [
21275 % format vers vergrp rows cols align modules error codewords error correction blocks
21276 % L M Q H L1 L2 M1 M2 Q1 Q2 H1 H2
21277 [ (micro) (M1) vM1 11 11 98 99 36 [ 2 99 99 99 ] [ 1 0 -1 -1 -1 -1 -1 -1 ] ]
21278 [ (micro) (M2) vM2 13 13 98 99 80 [ 5 6 99 99 ] [ 1 0 1 0 -1 -1 -1 -1 ] ]
21279 [ (micro) (M3) vM3 15 15 98 99 132 [ 6 8 99 99 ] [ 1 0 1 0 -1 -1 -1 -1 ] ]
21280 [ (micro) (M4) vM4 17 17 98 99 192 [ 8 10 14 99 ] [ 1 0 1 0 1 0 -1 -1 ] ]
21281 [ (full) (1) v1to9 21 21 98 99 208 [ 7 10 13 17 ] [ 1 0 1 0 1 0 1 0 ] ]
21282 [ (full) (2) v1to9 25 25 18 99 359 [ 10 16 22 28 ] [ 1 0 1 0 1 0 1 0 ] ]
21283 [ (full) (3) v1to9 29 29 22 99 567 [ 15 26 36 44 ] [ 1 0 1 0 2 0 2 0 ] ]
21284 [ (full) (4) v1to9 33 33 26 99 807 [ 20 36 52 64 ] [ 1 0 2 0 2 0 4 0 ] ]
21285 [ (full) (5) v1to9 37 37 30 99 1079 [ 26 48 72 88 ] [ 1 0 2 0 2 2 2 2 ] ]
21286 [ (full) (6) v1to9 41 41 34 99 1383 [ 36 64 96 112 ] [ 2 0 4 0 4 0 4 0 ] ]
21287 [ (full) (7) v1to9 45 45 22 38 1568 [ 40 72 108 130 ] [ 2 0 4 0 2 4 4 1 ] ]
21288 [ (full) (8) v1to9 49 49 24 42 1936 [ 48 88 132 156 ] [ 2 0 2 2 4 2 4 2 ] ]
21289 [ (full) (9) v1to9 53 53 26 46 2336 [ 60 110 160 192 ] [ 2 0 3 2 4 4 4 4 ] ]
21290 [ (full) (10) v10to26 57 57 28 50 2768 [ 72 130 192 224 ] [ 2 2 4 1 6 2 6 2 ] ]
21291 [ (full) (11) v10to26 61 61 30 54 3232 [ 80 150 224 264 ] [ 4 0 1 4 4 4 3 8 ] ]
21292 [ (full) (12) v10to26 65 65 32 58 3728 [ 96 176 260 308 ] [ 2 2 6 2 4 6 7 4 ] ]
21293 [ (full) (13) v10to26 69 69 34 62 4256 [ 104 198 288 352 ] [ 4 0 8 1 8 4 12 4 ] ]
21294 [ (full) (14) v10to26 73 73 26 46 4651 [ 120 216 320 384 ] [ 3 1 4 5 11 5 11 5 ] ]
21295 [ (full) (15) v10to26 77 77 26 48 5243 [ 132 240 360 432 ] [ 5 1 5 5 5 7 11 7 ] ]
21296 [ (full) (16) v10to26 81 81 26 50 5867 [ 144 280 408 480 ] [ 5 1 7 3 15 2 3 13 ] ]
21297 [ (full) (17) v10to26 85 85 30 54 6523 [ 168 308 448 532 ] [ 1 5 10 1 1 15 2 17 ] ]
21298 [ (full) (18) v10to26 89 89 30 56 7211 [ 180 338 504 588 ] [ 5 1 9 4 17 1 2 19 ] ]
21299 [ (full) (19) v10to26 93 93 30 58 7931 [ 196 364 546 650 ] [ 3 4 3 11 17 4 9 16 ] ]
21300 [ (full) (20) v10to26 97 97 34 62 8683 [ 224 416 600 700 ] [ 3 5 3 13 15 5 15 10 ] ]
21301 [ (full) (21) v10to26 101 101 28 50 9252 [ 224 442 644 750 ] [ 4 4 17 0 17 6 19 6 ] ]
21302 [ (full) (22) v10to26 105 105 26 50 10068 [ 252 476 690 816 ] [ 2 7 17 0 7 16 34 0 ] ]
21303 [ (full) (23) v10to26 109 109 30 54 10916 [ 270 504 750 900 ] [ 4 5 4 14 11 14 16 14 ] ]
21304 [ (full) (24) v10to26 113 113 28 54 11796 [ 300 560 810 960 ] [ 6 4 6 14 11 16 30 2 ] ]
21305 [ (full) (25) v10to26 117 117 32 58 12708 [ 312 588 870 1050 ] [ 8 4 8 13 7 22 22 13 ] ]
21306 [ (full) (26) v10to26 121 121 30 58 13652 [ 336 644 952 1110 ] [ 10 2 19 4 28 6 33 4 ] ]
21307 [ (full) (27) v27to40 125 125 34 62 14628 [ 360 700 1020 1200 ] [ 8 4 22 3 8 26 12 28 ] ]
21308 [ (full) (28) v27to40 129 129 26 50 15371 [ 390 728 1050 1260 ] [ 3 10 3 23 4 31 11 31 ] ]
21309 [ (full) (29) v27to40 133 133 30 54 16411 [ 420 784 1140 1350 ] [ 7 7 21 7 1 37 19 26 ] ]
21310 [ (full) (30) v27to40 137 137 26 52 17483 [ 450 812 1200 1440 ] [ 5 10 19 10 15 25 23 25 ] ]
21311 [ (full) (31) v27to40 141 141 30 56 18587 [ 480 868 1290 1530 ] [ 13 3 2 29 42 1 23 28 ] ]
21312 [ (full) (32) v27to40 145 145 34 60 19723 [ 510 924 1350 1620 ] [ 17 0 10 23 10 35 19 35 ] ]
21313 [ (full) (33) v27to40 149 149 30 58 20891 [ 540 980 1440 1710 ] [ 17 1 14 21 29 19 11 46 ] ]
21314 [ (full) (34) v27to40 153 153 34 62 22091 [ 570 1036 1530 1800 ] [ 13 6 14 23 44 7 59 1 ] ]
21315 [ (full) (35) v27to40 157 157 30 54 23008 [ 570 1064 1590 1890 ] [ 12 7 12 26 39 14 22 41 ] ]
21316 [ (full) (36) v27to40 161 161 24 50 24272 [ 600 1120 1680 1980 ] [ 6 14 6 34 46 10 2 64 ] ]
21317 [ (full) (37) v27to40 165 165 28 54 25568 [ 630 1204 1770 2100 ] [ 17 4 29 14 49 10 24 46 ] ]
21318 [ (full) (38) v27to40 169 169 32 58 26896 [ 660 1260 1860 2220 ] [ 4 18 13 32 48 14 42 32 ] ]
21319 [ (full) (39) v27to40 173 173 26 54 28256 [ 720 1316 1950 2310 ] [ 20 4 40 7 43 22 10 67 ] ]
21320 [ (full) (40) v27to40 177 177 30 58 29648 [ 750 1372 2040 2430 ] [ 19 6 18 31 34 34 20 61 ] ]
21321 [ (rmqr) (R7x43) vR7x43 7 43 22 99 104 [ 99 7 99 10 ] [ -1 -1 1 0 -1 -1 1 0 ] ]
21322 [ (rmqr) (R7x59) vR7x59 7 59 20 40 171 [ 99 9 99 14 ] [ -1 -1 1 0 -1 -1 1 0 ] ]
21323 [ (rmqr) (R7x77) vR7x77 7 77 26 52 261 [ 99 12 99 22 ] [ -1 -1 1 0 -1 -1 1 0 ] ]
21324 [ (rmqr) (R7x99) vR7x99 7 99 24 50 358 [ 99 16 99 30 ] [ -1 -1 1 0 -1 -1 1 0 ] ]
21325 [ (rmqr) (R7x139) vR7x139 7 139 28 56 545 [ 99 24 99 44 ] [ -1 -1 1 0 -1 -1 2 0 ] ]
21326 [ (rmqr) (R9x43) vR9x43 9 43 22 99 170 [ 99 9 99 14 ] [ -1 -1 1 0 -1 -1 1 0 ] ]
21327 [ (rmqr) (R9x59) vR9x59 9 59 20 40 267 [ 99 12 99 22 ] [ -1 -1 1 0 -1 -1 1 0 ] ]
21328 [ (rmqr) (R9x77) vR9x77 9 77 26 52 393 [ 99 18 99 32 ] [ -1 -1 1 0 -1 -1 1 1 ] ]
21329 [ (rmqr) (R9x99) vR9x99 9 99 24 50 532 [ 99 24 99 44 ] [ -1 -1 1 0 -1 -1 2 0 ] ]
21330 [ (rmqr) (R9x139) vR9x139 9 139 28 56 797 [ 99 36 99 66 ] [ -1 -1 1 1 -1 -1 3 0 ] ]
21331 [ (rmqr) (R11x27) vR11x27 11 27 98 99 122 [ 99 8 99 10 ] [ -1 -1 1 0 -1 -1 1 0 ] ]
21332 [ (rmqr) (R11x43) vR11x43 11 43 22 99 249 [ 99 12 99 20 ] [ -1 -1 1 0 -1 -1 1 0 ] ]
21333 [ (rmqr) (R11x59) vR11x59 11 59 20 40 376 [ 99 16 99 32 ] [ -1 -1 1 0 -1 -1 1 1 ] ]
21334 [ (rmqr) (R11x77) vR11x77 11 77 26 52 538 [ 99 24 99 44 ] [ -1 -1 1 0 -1 -1 1 1 ] ]
21335 [ (rmqr) (R11x99) vR11x99 11 99 24 50 719 [ 99 32 99 60 ] [ -1 -1 1 1 -1 -1 1 1 ] ]
21336 [ (rmqr) (R11x139) vR11x139 11 139 28 56 1062 [ 99 48 99 90 ] [ -1 -1 2 0 -1 -1 3 0 ] ]
21337 [ (rmqr) (R13x27) vR13x27 13 27 98 99 172 [ 99 9 99 14 ] [ -1 -1 1 0 -1 -1 1 0 ] ]
21338 [ (rmqr) (R13x43) vR13x43 13 43 22 99 329 [ 99 14 99 28 ] [ -1 -1 1 0 -1 -1 1 0 ] ]
21339 [ (rmqr) (R13x59) vR13x59 13 59 20 40 486 [ 99 22 99 40 ] [ -1 -1 1 0 -1 -1 2 0 ] ]
21340 [ (rmqr) (R13x77) vR13x77 13 77 26 52 684 [ 99 32 99 56 ] [ -1 -1 1 1 -1 -1 1 1 ] ]
21341 [ (rmqr) (R13x99) vR13x99 13 99 24 50 907 [ 99 40 99 78 ] [ -1 -1 1 1 -1 -1 1 2 ] ]
21342 [ (rmqr) (R13x139) vR13x139 13 139 28 56 1328 [ 99 60 99 112 ] [ -1 -1 2 1 -1 -1 2 2 ] ]
21343 [ (rmqr) (R15x43) vR15x43 15 43 22 99 409 [ 99 18 99 36 ] [ -1 -1 1 0 -1 -1 1 1 ] ]
21344 [ (rmqr) (R15x59) vR15x59 15 59 20 40 596 [ 99 26 99 48 ] [ -1 -1 1 0 -1 -1 2 0 ] ]
21345 [ (rmqr) (R15x77) vR15x77 15 77 26 52 830 [ 99 36 99 72 ] [ -1 -1 1 1 -1 -1 2 1 ] ]
21346 [ (rmqr) (R15x99) vR15x99 15 99 24 50 1095 [ 99 48 99 88 ] [ -1 -1 2 0 -1 -1 4 0 ] ]
21347 [ (rmqr) (R15x139) vR15x139 15 139 28 56 1594 [ 99 72 99 130 ] [ -1 -1 2 1 -1 -1 1 4 ] ]
21348 [ (rmqr) (R17x43) vR17x43 17 43 22 99 489 [ 99 22 99 40 ] [ -1 -1 1 0 -1 -1 1 1 ] ]
21349 [ (rmqr) (R17x59) vR17x59 17 59 20 40 706 [ 99 32 99 60 ] [ -1 -1 2 0 -1 -1 2 0 ] ]
21350 [ (rmqr) (R17x77) vR17x77 17 77 26 52 976 [ 99 44 99 84 ] [ -1 -1 2 0 -1 -1 1 2 ] ]
21351 [ (rmqr) (R17x99) vR17x99 17 99 24 50 1283 [ 99 60 99 104 ] [ -1 -1 2 1 -1 -1 4 0 ] ]
21352 [ (rmqr) (R17x139) vR17x139 17 139 28 56 1860 [ 99 80 99 156 ] [ -1 -1 4 0 -1 -1 2 4 ] ]
21353 ] def
21354 } ctxdef
21355
21356 /eclval (LMQH) eclevel search pop length exch pop exch pop def
21357 0 1 metrics length 1 sub {
21358 /i exch def
21359 /m metrics i get def
21360 /frmt m 0 get def % Format of the symbol
21361 /vers m 1 get def % Version of symbol
21362 /vergrp m 2 get def % Version group
21363 /verind i 44 sub def % Version indicator for rMQR format info
21364 /rows m 3 get def % Length of side
21365 /cols m 4 get def % Length of side
21366 /asp2 m 5 get def % Position of second alignment symbol
21367 /asp3 m 6 get def % Position of third alignment symbol
21368 /nmod m 7 get def % Number of modules
21369 /ncws nmod 8 idiv def % Total number of codewords
21370 /rbit nmod 8 mod def % Number of remainder bits
21371 /lc4b false def % Last data codeword is 4 bits long
21372 vers (M1) eq vers (M3) eq or { % Adjustments for M1 and M3 symbols
21373 /ncws ncws 1 add def
21374 /rbit 0 def
21375 /lc4b true def
21376 } if
21377 /ecws m 8 get eclval get def % Number of error correction codewords
21378 /dcws ncws ecws sub def % Number of data codewords
21379 /dmod dcws 8 mul lc4b {4} {0} ifelse sub def % Number of data modules
21380 /ecb1 m 9 get eclval 2 mul get def % First error correction blocks
21381 /ecb2 m 9 get eclval 2 mul 1 add get def % Second error correction blocks
21382 /okay true def
21383 format frmt ne {/okay false def} if % The format must match that supplied
21384 frmt (micro) eq fnc1first and {/okay false def} if % FNC1 mode is only available in full and rmqr
21385 version (unset) ne version vers ne and {/okay false def} if % The version must match that supplied
21386 ecb1 -1 eq ecb2 -1 eq or {/okay false def} if % Error correction level must be valid
21387 /verbits msgbits vergrp get def
21388 verbits -1 eq { % Bitstream must be available
21389 /okay false def
21390 } {
21391 verbits length dmod gt {/okay false def} if % and fit into data modules
21392 } ifelse
21393 /term (000000000) 0 termlens vergrp get getinterval def
21394 okay {exit} if
21395 } for
21396
21397 okay not {
21398 /bwipp.qrcodeNoValidSymbol (Maximum length exceeded or invalid content) //raiseerror exec
21399 } if
21400
21401 /format frmt def
21402 /version vers def
21403 /msgbits verbits def
21404
21405 % Opportunistically raise the error level if a better fit to the matrix is possible
21406 fixedeclevel not {
21407 eclval 1 add 1 3 {
21408 /eclval_ exch def
21409 /ecws_ m 8 get eclval_ get def % Number of error correction codewords
21410 /dcws_ ncws ecws_ sub def % Number of data codewords
21411 /dmod_ dcws_ 8 mul lc4b {4} {0} ifelse sub def % Number of data modules
21412 /ecb1_ m 9 get eclval_ 2 mul get def % First error correction blocks
21413 /ecb2_ m 9 get eclval_ 2 mul 1 add get def % Second error correction blocks
21414 /okay true def
21415 ecb1_ -1 eq ecb2_ -1 eq or {/okay false def} if % Error correction level must be valid
21416 msgbits length dmod_ gt {/okay false def} if % and fit into data modules
21417 okay {
21418 /eclval eclval_ def
21419 /dcws dcws_ def
21420 /dmod dmod_ def
21421 /ecb1 ecb1_ def
21422 /ecb2 ecb2_ def
21423 } if
21424 } for
21425 } if
21426
21427 /dcpb dcws ecb1 ecb2 add idiv def % Base data codewords per block
21428 /ecpb ncws ecb1 ecb2 add idiv dcpb sub def % Error correction codewords per block
21429
21430 % Complete the message bits by adding the terminator, truncated if necessary
21431 /term term 0 dmod msgbits length sub term length 2 copy gt {exch} if pop getinterval def
21432 msgbits length term length add string
21433 dup 0 msgbits putinterval
21434 dup msgbits length term putinterval
21435 /msgbits exch def
21436
21437 % Expand the message bits by adding padding as necessary
21438 /pad dmod string def
21439 0 1 pad length 1 sub {pad exch 48 put} for
21440 pad 0 msgbits putinterval
21441 /padnum 0 def
21442 msgbits length 8 div ceiling 8 mul cvi 8 dmod lc4b {5} {1} ifelse sub {
21443 pad exch padstrs padnum get putinterval
21444 /padnum padnum 1 add 2 mod def
21445 } for
21446
21447 % Evaluate the padded message into codewords
21448 /cws dcws array def
21449 0 1 cws length 1 sub {
21450 /c exch def
21451 /bpcw 8 def
21452 lc4b c cws length 1 sub eq and {/bpcw 4 def} if
21453 /cwb pad c 8 mul bpcw getinterval def
21454 /cw 0 def
21455 0 1 bpcw 1 sub {
21456 /i exch def
21457 /cw cw 2 bpcw i sub 1 sub exp cvi cwb i get 48 sub mul add def
21458 } for
21459 cws c cw put
21460 } for
21461
21462 % Short final data byte in M1 and M3 symbols has high-order value
21463 lc4b {cws cws length 1 sub 2 copy get 4 bitshift put} if
21464
21465 options /debugcws known { /bwipp.debugcws cws //raiseerror exec } if
21466
21467 % Calculate the log and anti-log tables
21468 {
21469 /rsalog [ 1 255 { dup 2 mul dup 256 ge {285 xor} if } repeat ] def
21470 /rslog 256 array def
21471 1 1 255 {dup rsalog exch get exch rslog 3 1 roll put} for
21472 } ctxdef
21473
21474 % Function to calculate the product in the field
21475 /rsprod {
21476 2 copy 0 ne exch 0 ne and {
21477 rslog exch get exch rslog exch get add 255 mod rsalog exch get
21478 } {
21479 pop pop 0
21480 } ifelse
21481 } def
21482
21483 % Generate the coefficients for the Reed-Solomon algorithm
21484 /coeffs [ 1 ecpb {0} repeat ] def
21485 0 1 ecpb 1 sub {
21486 /i exch def
21487 coeffs i 1 add coeffs i get put
21488 i -1 1 {
21489 /j exch def
21490 coeffs j coeffs j 1 sub get coeffs j get rsalog i get rsprod xor put
21491 } for
21492 coeffs 0 coeffs 0 get rsalog i get rsprod put
21493 } for
21494 /coeffs coeffs 0 coeffs length 1 sub getinterval def
21495
21496 % Reed-Solomon algorithm to derive the error correction codewords
21497 /rscodes {
21498 /rscws exch def
21499 /rsnd rscws length def
21500 /rscws [ rscws aload pop ecpb {0} repeat ] def
21501 0 1 rsnd 1 sub {
21502 /m exch def
21503 /k rscws m get def
21504 0 1 ecpb 1 sub {
21505 /j exch def
21506 rscws m j add 1 add coeffs ecpb j sub 1 sub get k rsprod rscws m j add 1 add get xor put
21507 } for
21508 } for
21509 rscws rsnd ecpb getinterval
21510 } def
21511
21512 % Divide codewords into two groups of blocks and calculate the error correction codewords
21513 /dcwsb ecb1 ecb2 add array def
21514 /ecwsb ecb1 ecb2 add array def
21515 0 1 ecb1 1 sub { % First group of blocks has smaller number of data codewords
21516 /i exch def
21517 dcwsb i cws i dcpb mul dcpb getinterval put
21518 ecwsb i dcwsb i get rscodes put
21519 } for
21520 0 1 ecb2 1 sub { % Second group of blocks has larger number of data codewords
21521 /i exch def
21522 dcwsb ecb1 i add cws ecb1 dcpb mul i dcpb 1 add mul add dcpb 1 add getinterval put
21523 ecwsb ecb1 i add dcwsb ecb1 i add get rscodes put
21524 } for
21525
21526 % Reassemble the codewords
21527 /cws ncws array def
21528 /cw 0 def
21529 0 1 dcpb { % Interleave the data codeword blocks
21530 /i exch def
21531 0 1 ecb1 ecb2 add 1 sub {
21532 /j exch def
21533 i dcwsb j get length lt { % Ignore the end of short blocks
21534 cws cw dcwsb j get i get put
21535 /cw cw 1 add def
21536 } if
21537 } for
21538 } for
21539 0 1 ecpb 1 sub { % Interleave the error codeword blocks
21540 /i exch def
21541 0 1 ecb1 ecb2 add 1 sub {
21542 /j exch def
21543 cws cw ecwsb j get i get put
21544 /cw cw 1 add def
21545 } for
21546 } for
21547
21548 % Extend codewords by one if there are remainder bits
21549 rbit 0 gt {
21550 /pad cws length 1 add array def
21551 pad 0 cws putinterval
21552 pad pad length 1 sub 0 put
21553 /cws pad def
21554 } if
21555
21556 % Fixups for the short final data byte in M1 and M3 symbols
21557 lc4b {
21558 cws dcws 1 sub 2 copy get -4 bitshift put
21559 dcws 1 sub 1 ncws 2 sub {
21560 /i exch def
21561 cws i cws i get 15 and 4 bitshift put
21562 cws i cws i 1 add get -4 bitshift 15 and cws i get or put
21563 } for
21564 cws ncws 1 sub cws ncws 1 sub get 15 and 4 bitshift put
21565 } if
21566
21567 options /debugecc known { /bwipp.debugecc cws //raiseerror exec } if
21568
21569 % Create the bitmap
21570 /pixs [ rows cols mul {-1} repeat ] def
21571 /qmv {cols mul add} def
21572
21573 % Timing patterns
21574 format (full) eq {
21575 8 1 cols 9 sub {
21576 /i exch def
21577 pixs i 6 qmv i 1 add 2 mod put
21578 pixs 6 i qmv i 1 add 2 mod put
21579 } for
21580 } if
21581 format (micro) eq {
21582 8 1 cols 1 sub {
21583 /i exch def
21584 pixs i 0 qmv i 1 add 2 mod put
21585 pixs 0 i qmv i 1 add 2 mod put
21586 } for
21587 } if
21588 format (rmqr) eq {
21589 3 1 cols 4 sub { % Along top and bottom
21590 /i exch def
21591 pixs i 0 qmv i 1 add 2 mod put
21592 pixs i rows 1 sub qmv i 1 add 2 mod put
21593 } for
21594 3 1 rows 4 sub { % Along left and right
21595 /i exch def
21596 pixs 0 i qmv i 1 add 2 mod put
21597 pixs cols 1 sub i qmv i 1 add 2 mod put
21598 } for
21599 asp2 1 sub asp3 asp2 sub cols 13 sub { % Down interior
21600 /i exch def
21601 3 1 rows 4 sub {
21602 /j exch def
21603 pixs i j qmv j 1 add 2 mod put
21604 } for
21605 } for
21606 } if
21607
21608 % Finder patterns
21609 {
21610 /fpat [
21611 [ 1 1 1 1 1 1 1 0 ]
21612 [ 1 0 0 0 0 0 1 0 ]
21613 [ 1 0 1 1 1 0 1 0 ]
21614 [ 1 0 1 1 1 0 1 0 ]
21615 [ 1 0 1 1 1 0 1 0 ]
21616 [ 1 0 0 0 0 0 1 0 ]
21617 [ 1 1 1 1 1 1 1 0 ]
21618 [ 0 0 0 0 0 0 0 0 ]
21619 ] def
21620 /fsubpat [
21621 [ 1 1 1 1 1 9 9 9 ]
21622 [ 1 0 0 0 1 9 9 9 ]
21623 [ 1 0 1 0 1 9 9 9 ]
21624 [ 1 0 0 0 1 9 9 9 ]
21625 [ 1 1 1 1 1 9 9 9 ]
21626 [ 9 9 9 9 9 9 9 9 ]
21627 [ 9 9 9 9 9 9 9 9 ]
21628 [ 9 9 9 9 9 9 9 9 ]
21629 ] def
21630 /fcorpat [
21631 [ 1 1 1 9 9 9 9 9 ]
21632 [ 1 0 9 9 9 9 9 9 ]
21633 [ 1 9 9 9 9 9 9 9 ]
21634 [ 9 9 9 9 9 9 9 9 ]
21635 [ 9 9 9 9 9 9 9 9 ]
21636 [ 9 9 9 9 9 9 9 9 ]
21637 [ 9 9 9 9 9 9 9 9 ]
21638 [ 9 9 9 9 9 9 9 9 ]
21639 ] def
21640 /fnullpat [
21641 [ 9 9 9 9 9 9 9 9 ]
21642 [ 9 9 9 9 9 9 9 9 ]
21643 [ 9 9 9 9 9 9 9 9 ]
21644 [ 9 9 9 9 9 9 9 9 ]
21645 [ 9 9 9 9 9 9 9 9 ]
21646 [ 9 9 9 9 9 9 9 9 ]
21647 [ 9 9 9 9 9 9 9 9 ]
21648 [ 9 9 9 9 9 9 9 9 ]
21649 ] def
21650 /fpatmap <<
21651 % TL TR BL BR
21652 (full) [ fpat fpat fpat fnullpat ]
21653 (micro) [ fpat fnullpat fnullpat fnullpat ]
21654 (rmqr) [ fpat fcorpat fcorpat fsubpat ]
21655 >> def
21656 } ctxdef
21657 /fpats fpatmap format get def
21658 0 1 7 {
21659 /y exch def
21660 0 1 7 {
21661 /x exch def
21662 /fpb0 fpats 0 get y get x get def
21663 /fpb1 fpats 1 get y get x get def
21664 /fpb2 fpats 2 get y get x get def
21665 /fpb3 fpats 3 get y get x get def
21666 fpb0 9 ne y rows lt and {pixs x y qmv fpb0 put} if
21667 fpb1 9 ne {pixs cols x sub 1 sub y qmv fpb1 put} if
21668 fpb2 9 ne {pixs x rows y sub 1 sub qmv fpb2 put} if
21669 fpb3 9 ne {pixs cols x sub 1 sub rows y sub 1 sub qmv fpb3 put} if
21670 } for
21671 } for
21672
21673 % Alignment patterns
21674 {
21675 /algnpatfull [
21676 [ 1 1 1 1 1 ]
21677 [ 1 0 0 0 1 ]
21678 [ 1 0 1 0 1 ]
21679 [ 1 0 0 0 1 ]
21680 [ 1 1 1 1 1 ]
21681 ] def
21682 /algnpatrmqr [
21683 [ 1 1 1 9 9 ]
21684 [ 1 0 1 9 9 ]
21685 [ 1 1 1 9 9 ]
21686 [ 9 9 9 9 9 ]
21687 [ 9 9 9 9 9 ]
21688 ] def
21689 } ctxdef
21690
21691 /putalgnpat {
21692 /py exch def
21693 /px exch def
21694 0 1 4 {
21695 /pb exch def
21696 0 1 4 {
21697 /pa exch def
21698 /algnb algnpat pb get pa get def
21699 algnb 9 ne {
21700 pixs px pa add py pb add qmv algnb put
21701 } if
21702 } for
21703 } for
21704 } def
21705 format (full) eq {
21706 /algnpat algnpatfull def
21707 asp2 2 sub asp3 asp2 sub cols 13 sub {
21708 /i exch def
21709 i 4 putalgnpat
21710 4 i putalgnpat
21711 } for
21712 asp2 2 sub asp3 asp2 sub cols 9 sub {
21713 /x exch def
21714 asp2 2 sub asp3 asp2 sub rows 9 sub {
21715 /y exch def
21716 x y putalgnpat
21717 } for
21718 } for
21719 } if
21720 format (rmqr) eq {
21721 /algnpat algnpatrmqr def
21722 asp2 2 sub asp3 asp2 sub cols 13 sub {
21723 /i exch def
21724 i 0 putalgnpat
21725 i rows 3 sub putalgnpat
21726 } for
21727 } if
21728
21729 % Format information modules
21730 {
21731 /formatmapmicro [
21732 [ [ 1 8 ] ] [ [ 2 8 ] ] [ [ 3 8 ] ] [ [ 4 8 ] ] [ [ 5 8 ] ]
21733 [ [ 6 8 ] ] [ [ 7 8 ] ] [ [ 8 8 ] ] [ [ 8 7 ] ] [ [ 8 6 ] ]
21734 [ [ 8 5 ] ] [ [ 8 4 ] ] [ [ 8 3 ] ] [ [ 8 2 ] ] [ [ 8 1 ] ]
21735 ] def
21736 } ctxdef
21737 /formatmap <<
21738 (full) [
21739 [ [ 0 8 ] [ 8 cols 1 sub ] ] [ [ 1 8 ] [ 8 cols 2 sub ] ] [ [ 2 8 ] [ 8 cols 3 sub ] ]
21740 [ [ 3 8 ] [ 8 cols 4 sub ] ] [ [ 4 8 ] [ 8 cols 5 sub ] ] [ [ 5 8 ] [ 8 cols 6 sub ] ]
21741 [ [ 7 8 ] [ 8 cols 7 sub ] ] [ [ 8 8 ] [ cols 8 sub 8 ] ] [ [ 8 7 ] [ cols 7 sub 8 ] ]
21742 [ [ 8 5 ] [ cols 6 sub 8 ] ] [ [ 8 4 ] [ cols 5 sub 8 ] ] [ [ 8 3 ] [ cols 4 sub 8 ] ]
21743 [ [ 8 2 ] [ cols 3 sub 8 ] ] [ [ 8 1 ] [ cols 2 sub 8 ] ] [ [ 8 0 ] [ cols 1 sub 8 ] ]
21744 ]
21745 (micro) formatmapmicro
21746 (rmqr) [
21747 [ [ 11 3 ] [ cols 3 sub rows 6 sub ] ] [ [ 11 2 ] [ cols 4 sub rows 6 sub ] ] [ [ 11 1 ] [ cols 5 sub rows 6 sub ] ]
21748 [ [ 10 5 ] [ cols 6 sub rows 2 sub ] ] [ [ 10 4 ] [ cols 6 sub rows 3 sub ] ] [ [ 10 3 ] [ cols 6 sub rows 4 sub ] ]
21749 [ [ 10 2 ] [ cols 6 sub rows 5 sub ] ] [ [ 10 1 ] [ cols 6 sub rows 6 sub ] ] [ [ 9 5 ] [ cols 7 sub rows 2 sub ] ]
21750 [ [ 9 4 ] [ cols 7 sub rows 3 sub ] ] [ [ 9 3 ] [ cols 7 sub rows 4 sub ] ] [ [ 9 2 ] [ cols 7 sub rows 5 sub ] ]
21751 [ [ 9 1 ] [ cols 7 sub rows 6 sub ] ] [ [ 8 5 ] [ cols 8 sub rows 2 sub ] ] [ [ 8 4 ] [ cols 8 sub rows 3 sub ] ]
21752 [ [ 8 3 ] [ cols 8 sub rows 4 sub ] ] [ [ 8 2 ] [ cols 8 sub rows 5 sub ] ] [ [ 8 1 ] [ cols 8 sub rows 6 sub ] ]
21753 ]
21754 >> format get def
21755 formatmap {
21756 { aload pop qmv pixs exch 1 put } forall
21757 } forall
21758
21759 % Version information modules
21760 format (full) eq cols 45 ge and {
21761 /versionmap [
21762 [ [ cols 9 sub 5 ] [ 5 cols 9 sub ] ] [ [ cols 10 sub 5 ] [ 5 cols 10 sub ] ]
21763 [ [ cols 11 sub 5 ] [ 5 cols 11 sub ] ] [ [ cols 9 sub 4 ] [ 4 cols 9 sub ] ]
21764 [ [ cols 10 sub 4 ] [ 4 cols 10 sub ] ] [ [ cols 11 sub 4 ] [ 4 cols 11 sub ] ]
21765 [ [ cols 9 sub 3 ] [ 3 cols 9 sub ] ] [ [ cols 10 sub 3 ] [ 3 cols 10 sub ] ]
21766 [ [ cols 11 sub 3 ] [ 3 cols 11 sub ] ] [ [ cols 9 sub 2 ] [ 2 cols 9 sub ] ]
21767 [ [ cols 10 sub 2 ] [ 2 cols 10 sub ] ] [ [ cols 11 sub 2 ] [ 2 cols 11 sub ] ]
21768 [ [ cols 9 sub 1 ] [ 1 cols 9 sub ] ] [ [ cols 10 sub 1 ] [ 1 cols 10 sub ] ]
21769 [ [ cols 11 sub 1 ] [ 1 cols 11 sub ] ] [ [ cols 9 sub 0 ] [ 0 cols 9 sub ] ]
21770 [ [ cols 10 sub 0 ] [ 0 cols 10 sub ] ] [ [ cols 11 sub 0 ] [ 0 cols 11 sub ] ]
21771 ] def
21772 } {
21773 /versionmap [] def
21774 } ifelse
21775 versionmap {
21776 { aload pop qmv pixs exch 0 put } forall
21777 } forall
21778
21779 % Reserve the solitary dark module in full symbols
21780 format (full) eq {
21781 pixs 8 rows 8 sub qmv 0 put
21782 } if
21783
21784 % Calculate the mask patterns
21785 /maskfuncs <<
21786 (full) [
21787 {add 2 mod}
21788 {exch pop 2 mod}
21789 {pop 3 mod}
21790 {add 3 mod}
21791 {2 idiv exch 3 idiv add 2 mod}
21792 {mul dup 2 mod exch 3 mod add}
21793 {mul dup 2 mod exch 3 mod add 2 mod}
21794 {2 copy mul 3 mod 3 1 roll add 2 mod add 2 mod}
21795 ]
21796 (micro) [
21797 {exch pop 2 mod}
21798 {2 idiv exch 3 idiv add 2 mod}
21799 {mul dup 2 mod exch 3 mod add 2 mod}
21800 {2 copy mul 3 mod 3 1 roll add 2 mod add 2 mod}
21801 ]
21802 (rmqr) [
21803 {2 idiv exch 3 idiv add 2 mod}
21804 ]
21805 >> format get def
21806 mask -1 ne { % User specifies a mask
21807 /maskfuncs [maskfuncs mask 1 sub get] def
21808 /bestmaskval mask 1 sub def
21809 } if
21810 /masks maskfuncs length array def
21811 0 1 masks length 1 sub {
21812 /m exch def
21813 /mask rows cols mul array def
21814 0 1 rows 1 sub {
21815 /j exch def
21816 0 1 cols 1 sub {
21817 /i exch def
21818 i j maskfuncs m get exec 0 eq
21819 pixs i j qmv get -1 eq and {1} {0} ifelse
21820 mask i j qmv 3 -1 roll put
21821 } for
21822 } for
21823 masks m mask put
21824 } for
21825
21826 % Walk the symbol placing the bitstream
21827 /posx cols format (rmqr) ne {1} {2} ifelse sub def
21828 /posy rows 1 sub def
21829 /dir -1 def % -1 is upwards, 1 is downwards
21830 /col 1 def % 0 is left bit, 1 is right bit
21831 /num 0 def
21832 { % loop
21833 posx 0 lt {exit} if
21834 pixs posx posy qmv get -1 eq {
21835 cws num 8 idiv get 7 num 8 mod sub neg bitshift 1 and
21836 pixs posx posy qmv 3 -1 roll put
21837 /num num 1 add def
21838 } if
21839 col 1 eq {
21840 /col 0 def
21841 /posx posx 1 sub def
21842 } {
21843 /col 1 def
21844 /posx posx 1 add def
21845 /posy posy dir add def
21846 posy 0 lt posy rows ge or { % Turn around at top and bottom
21847 /dir dir -1 mul def
21848 /posy posy dir add def
21849 /posx posx 2 sub def
21850 % Hop over the timing pattern in full size symbols
21851 format (full) eq posx 6 eq and {/posx posx 1 sub def} if
21852 } if
21853 } ifelse
21854 } loop
21855
21856 % Evaluate runlength encoded rows or columns in full symbols
21857 /evalfulln1n3 {
21858 /scrle exch def
21859 % Detect runs of 5 or more like modules
21860 /scr1 0 scrle { dup 5 ge {add 2 sub dup} if pop } forall def
21861 % Detect 1:1:3:1:1 ratio next to 4 modules of whitespace
21862 /scr3 0 def
21863 3 2 scrle length 3 sub { % Scan odd (dark) runs within bounds
21864 /j exch def
21865 scrle j get 3 mod 0 eq { % Multiple of 3 black modules
21866 /fact scrle j get 3 idiv def
21867 scrle j 2 sub 5 getinterval {fact eq} forall and exch pop and and {
21868 j 3 eq j 4 add scrle length ge or { % At either extent of run
21869 /scr3 scr3 40 add def
21870 } { % Bounded by dark modules
21871 scrle j 3 sub get 4 ge scrle j 3 add get 4 ge or {
21872 /scr3 scr3 40 add def
21873 } if
21874 } ifelse
21875 } if
21876 } if
21877 } for
21878 scr1 scr3
21879 } def
21880
21881 % Evaluation algorithm for full symbols
21882 /evalfull {
21883 /sym exch def
21884
21885 /n1 0 def /n2 0 def /n3 0 def
21886 /rle cols 1 add array def
21887 /lastpairs cols array def
21888 /thispairs cols array def
21889 /colsadd1 cols 1 add def
21890 0 1 cols 1 sub {
21891 /i exch def
21892
21893 % Runlength encode (light, dark, light, ...) and evaluate each column
21894 mark 0 0
21895 i cols dup dup mul 1 sub {
21896 sym exch get exch 1 index eq {exch 1 add exch} {1 exch} ifelse
21897 } for
21898 pop
21899 rle 0 counttomark 2 sub getinterval astore
21900 evalfulln1n3 n3 add /n3 exch def n1 add /n1 exch def
21901 pop
21902
21903 % Runlength encode (light, dark, light, ...) and evaluate each row
21904 /symrow sym i cols mul cols getinterval def
21905 mark 0 0
21906 symrow {
21907 exch 1 index eq {exch 1 add exch} {1 exch} ifelse
21908 } forall
21909 pop
21910 rle 0 counttomark 2 sub getinterval astore
21911 evalfulln1n3 n3 add /n3 exch def n1 add /n1 exch def
21912 pop
21913
21914 % Count and score same coloured blocks
21915 /lastpairs thispairs /thispairs lastpairs def def
21916 symrow 0 get 1 eq {0} {1} ifelse
21917 symrow {exch 1 index add exch} forall
21918 pop
21919 thispairs astore pop
21920 i 0 gt {
21921 mark
21922 lastpairs aload pop thispairs aload pop
21923 n2 cols { exch colsadd1 index add 3 and 0 eq {3 add} if } repeat
21924 /n2 exch def
21925 cleartomark
21926 } if
21927
21928 } for
21929
21930 % Score dark/light imbalance
21931 /dark 0 sym {add} forall def
21932 /n4 dark 100 mul cols dup mul div 50 sub abs 5 div cvi 10 mul def
21933
21934 n1 n2 add n3 add n4 add
21935 } def
21936
21937 % Evaluation algorithm for micro symbols
21938 /evalmicro {
21939 /sym exch def
21940 /dkrhs 0 def /dkbot 0 def
21941 1 1 cols 1 sub {
21942 /i exch def
21943 /dkrhs dkrhs sym cols 1 sub i qmv get add def
21944 /dkbot dkbot sym i cols 1 sub qmv get add def
21945 } for
21946 dkrhs dkbot le {
21947 dkrhs 16 mul dkbot add neg
21948 } {
21949 dkbot 16 mul dkrhs add neg
21950 } ifelse
21951 } def
21952
21953 % Evaluate the masked symbols to find the most suitable
21954 /bestscore 999999999 def
21955 0 1 masks length 1 sub {
21956 /m exch def
21957 /masksym rows cols mul array def
21958 0 1 rows cols mul 1 sub {
21959 /i exch def
21960 masksym i pixs i get masks m get i get xor put
21961 } for
21962 masks length 1 ne { % Not rMQR nor user-specified mask
21963 format (full) eq {
21964 masksym evalfull /score exch def
21965 } {
21966 masksym evalmicro /score exch def
21967 } ifelse
21968 score bestscore lt {
21969 /bestsym masksym def
21970 /bestmaskval m def
21971 /bestscore score def
21972 } if
21973 } {
21974 /bestsym masksym def
21975 } ifelse
21976 } for
21977 /pixs bestsym def
21978
21979 % Set the solitary dark module in full symbols
21980 format (full) eq {
21981 pixs 8 cols 8 sub qmv 1 put
21982 } if
21983
21984 % Add the format information
21985 {
21986 /fmtvalsfull [
21987 16#5412 16#5125 16#5e7c 16#5b4b 16#45f9 16#40ce 16#4f97 16#4aa0
21988 16#77c4 16#72f3 16#7daa 16#789d 16#662f 16#6318 16#6c41 16#6976
21989 16#1689 16#13be 16#1ce7 16#19d0 16#0762 16#0255 16#0d0c 16#083b
21990 16#355f 16#3068 16#3f31 16#3a06 16#24b4 16#2183 16#2eda 16#2bed
21991 ] def
21992 /fmtvalsmicro [
21993 16#4445 16#4172 16#4e2b 16#4b1c 16#55ae 16#5099 16#5fc0 16#5af7
21994 16#6793 16#62a4 16#6dfd 16#68ca 16#7678 16#734f 16#7c16 16#7921
21995 16#06de 16#03e9 16#0cb0 16#0987 16#1735 16#1202 16#1d5b 16#186c
21996 16#2508 16#203f 16#2f66 16#2a51 16#34e3 16#31d4 16#3e8d 16#3bba
21997 ] def
21998 /fmtvalsrmqr1 [
21999 16#1fab2 16#1e597 16#1dbdd 16#1c4f8 16#1b86c 16#1a749 16#19903 16#18626
22000 16#17f0e 16#1602b 16#15e61 16#14144 16#13dd0 16#122f5 16#11cbf 16#1039a
22001 16#0f1ca 16#0eeef 16#0d0a5 16#0cf80 16#0b314 16#0ac31 16#0927b 16#08d5e
22002 16#07476 16#06b53 16#05519 16#04a3c 16#036a8 16#0298d 16#017c7 16#008e2
22003 16#3f367 16#3ec42 16#3d208 16#3cd2d 16#3b1b9 16#3ae9c 16#390d6 16#38ff3
22004 16#376db 16#369fe 16#357b4 16#34891 16#33405 16#32b20 16#3156a 16#30a4f
22005 16#2f81f 16#2e73a 16#2d970 16#2c655 16#2bac1 16#2a5e4 16#29bae 16#2848b
22006 16#27da3 16#26286 16#25ccc 16#243e9 16#23f7d 16#22058 16#21e12 16#20137
22007 ] def
22008 /fmtvalsrmqr2 [
22009 16#20a7b 16#2155e 16#22b14 16#23431 16#248a5 16#25780 16#269ca 16#276ef
22010 16#28fc7 16#290e2 16#2aea8 16#2b18d 16#2cd19 16#2d23c 16#2ec76 16#2f353
22011 16#30103 16#31e26 16#3206c 16#33f49 16#343dd 16#35cf8 16#362b2 16#37d97
22012 16#384bf 16#39b9a 16#3a5d0 16#3baf5 16#3c661 16#3d944 16#3e70e 16#3f82b
22013 16#003ae 16#01c8b 16#022c1 16#03de4 16#04170 16#05e55 16#0601f 16#07f3a
22014 16#08612 16#09937 16#0a77d 16#0b858 16#0c4cc 16#0dbe9 16#0e5a3 16#0fa86
22015 16#108d6 16#117f3 16#129b9 16#1369c 16#14a08 16#1552d 16#16b67 16#17442
22016 16#18d6a 16#1924f 16#1ac05 16#1b320 16#1cfb4 16#1d091 16#1eedb 16#1f1fe
22017 ] def
22018 } ctxdef
22019 format (full) eq {
22020 /ecid [ 1 0 3 2 ] eclval get def
22021 /fmtval fmtvalsfull ecid 3 bitshift bestmaskval add get def
22022 0 1 formatmap length 1 sub {
22023 /i exch def
22024 formatmap i get {
22025 pixs exch aload pop qmv fmtval 14 i sub neg bitshift 1 and put
22026 } forall
22027 } for
22028 } if
22029 format (micro) eq {
22030 /symid [ [0] [1 2] [3 4] [5 6 7] ] cols 11 sub 2 idiv get eclval get def
22031 /fmtval fmtvalsmicro symid 2 bitshift bestmaskval add get def
22032 0 1 formatmap length 1 sub {
22033 /i exch def
22034 pixs formatmap i get 0 get aload pop qmv fmtval 14 i sub neg bitshift 1 and put
22035 } for
22036 } if
22037 format (rmqr) eq {
22038 /fmtvalu [ -1 0 -1 1 ] eclval get 5 bitshift verind add def
22039 /fmtval1 fmtvalsrmqr1 fmtvalu get def
22040 /fmtval2 fmtvalsrmqr2 fmtvalu get def
22041 0 1 formatmap length 1 sub {
22042 /i exch def
22043 pixs formatmap i get 0 get aload pop qmv fmtval1 17 i sub neg bitshift 1 and put
22044 pixs formatmap i get 1 get aload pop qmv fmtval2 17 i sub neg bitshift 1 and put
22045 } for
22046 } if
22047
22048 % Add the version information
22049 {
22050 /vervals [
22051 16#07c94 16#085bc 16#09a99 16#0a4d3 16#0bbf6 16#0c762 16#0d847
22052 16#0e60d 16#0f928 16#10b78 16#1145d 16#12a17 16#13532 16#149a6
22053 16#15683 16#168c9 16#177ec 16#18ec4 16#191e1 16#1afab 16#1b08e
22054 16#1cc1a 16#1d33f 16#1ed75 16#1f250 16#209d5 16#216f0 16#228ba
22055 16#2379f 16#24b0b 16#2542e 16#26a64 16#27541 16#28c69
22056 ] def
22057 } ctxdef
22058 format (full) eq cols 45 ge and {
22059 /verval vervals cols 17 sub 4 idiv 7 sub get def
22060 0 1 versionmap length 1 sub {
22061 /i exch def
22062 versionmap i get {
22063 pixs exch {} forall qmv verval 17 i sub neg bitshift 1 and put
22064 } forall
22065 } for
22066 } if
22067
22068 % Return the arguments
22069 <<
22070 /ren /renmatrix
22071 /pixs pixs
22072 /pixx cols
22073 /pixy rows
22074 /height rows 2 mul 72 div
22075 /width cols 2 mul 72 div
22076 /borderleft format (full) eq {4.0} {2.0} ifelse
22077 /borderright format (full) eq {4.0} {2.0} ifelse
22078 /bordertop format (full) eq {4.0} {2.0} ifelse
22079 /borderbottom format (full) eq {4.0} {2.0} ifelse
22080 /opt options
22081 >>
22082
22083 dontdraw not //renmatrix if
22084
22085 //unloadctx exec
22086
22087 end
22088
22089 }
22090 [/barcode] {null def} forall
22091 bind def
22092 /qrcode dup load /uk.co.terryburton.bwipp defineresource pop
22093 end
22094 /setpacking where {pop setpacking} if
22095 %%EndData
22096 %%EndResource
22097 % --END ENCODER qrcode--
22098
22099 % --BEGIN ENCODER swissqrcode--
22100 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix qrcode--
22101 % --DESC: Swiss QR Code
22102 % --EXAM:
22103 % --EXOP:
22104 % --RNDR: renmatrix
22105 %%BeginResource: uk.co.terryburton.bwipp swissqrcode 0.0 2025111800 75536 75061
22106 %%BeginData: 117 ASCII Lines
22107 /setpacking where {pop currentpacking true setpacking} if
22108 10 dict
22109 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
22110 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
22111 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
22112 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
22113 dup /qrcode dup /uk.co.terryburton.bwipp findresource put
22114 begin
22115 /swissqrcode {
22116
22117 20 dict begin % Confine variables to local scope
22118
22119 /ctx null def
22120 /dontdraw false def
22121 /parse false def
22122
22123 //processoptions exec /options exch def
22124 /barcode exch def
22125
22126 % Parse ordinals of the form ^NNN to ASCII
22127 /fncvals <<
22128 /parse parse
22129 /parseonly true
22130 /parsefnc false
22131 >> def
22132 /barcode barcode fncvals //parseinput exec def
22133 /barlen barcode length def
22134 options (parse) undef
22135
22136 % Validate the input length
22137 barcode length 997 gt {
22138 /bwipp.swissqrcodeBadLength (Swiss QR Code input must not exceed 997 digits) //raiseerror exec
22139 } if
22140
22141 % Get the result of encoding with qrcode
22142 options (dontdraw) true put
22143 /args barcode options //qrcode exec def
22144
22145 args (opt) options put
22146 args
22147
22148 % The 7mm-wide Swiss Cross is defined by the specification as being an
22149 % overlaid image, i.e. not made out of "modules", so very likely a
22150 % different pitch. It cannot therefore be represented by our standard image
22151 % dictionary and would be a nightmare to gridfit. The application assumes a
22152 % sufficient high-resolution print process that such issues do not matter.
22153 %
22154 % So for now we simply do as we're told and paint over the top of the
22155 % barcode image that has been scaled to 46mm, user be damned!
22156 %
22157 dontdraw not {
22158
22159 gsave
22160 currentpoint translate
22161 72 25.4 div dup scale % pt to mm
22162
22163 % Clipping path with 7mm hole for the Swiss Cross
22164 gsave
22165 newpath
22166 0 0 moveto
22167 46 0 lineto
22168 46 46 lineto
22169 0 46 lineto
22170 closepath
22171 19.5 19.5 moveto
22172 19.5 26.5 lineto
22173 26.5 26.5 lineto
22174 26.5 19.5 lineto
22175 closepath
22176 clip
22177
22178 % Scale the QR Code to fit within 46mm
22179 gsave
22180 0 0 moveto
22181 46 args (pixx) get div 2 div dup scale
22182 //renmatrix exec
22183 grestore
22184
22185 grestore % Clipping
22186
22187 % Draw Swiss Cross
22188 19.5 dup translate
22189 7 83 div dup scale
22190
22191 newpath
22192 6 6 moveto
22193 6 77 lineto
22194 77 77 lineto
22195 77 6 lineto
22196 closepath
22197 49 18 moveto
22198 49 34 lineto
22199 65 34 lineto
22200 65 49 lineto
22201 49 49 lineto
22202 49 65 lineto
22203 34 65 lineto
22204 34 49 lineto
22205 18 49 lineto
22206 18 34 lineto
22207 34 34 lineto
22208 34 18 lineto
22209 closepath
22210 0 0 0 setrgbcolor fill
22211
22212 grestore
22213
22214 } if
22215
22216 end
22217
22218 }
22219 [/barcode] {null def} forall
22220 bind def
22221 /swissqrcode dup load /uk.co.terryburton.bwipp defineresource pop
22222 end
22223 /setpacking where {pop setpacking} if
22224 %%EndData
22225 %%EndResource
22226 % --END ENCODER swissqrcode--
22227
22228 % --BEGIN ENCODER microqrcode--
22229 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix qrcode--
22230 % --DESC: Micro QR Code
22231 % --EXAM: 1234
22232 % --EXOP:
22233 % --RNDR: renmatrix
22234 %%BeginResource: uk.co.terryburton.bwipp microqrcode 0.0 2025111800 66796 69801
22235 %%BeginData: 36 ASCII Lines
22236 /setpacking where {pop currentpacking true setpacking} if
22237 10 dict
22238 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
22239 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
22240 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
22241 dup /qrcode dup /uk.co.terryburton.bwipp findresource put
22242 begin
22243 /microqrcode {
22244
22245 20 dict begin % Confine variables to local scope
22246
22247 /ctx null def
22248 /dontdraw false def
22249
22250 //processoptions exec /options exch def
22251 /barcode exch def
22252
22253 % Get the result of encoding with qrcode with format=micro
22254 options (dontdraw) true put
22255 options (format) (micro) put
22256
22257 /args barcode options //qrcode exec def
22258
22259 args (opt) options put
22260 args
22261
22262 dontdraw not //renmatrix if
22263
22264 end
22265
22266 }
22267 [/barcode] {null def} forall
22268 bind def
22269 /microqrcode dup load /uk.co.terryburton.bwipp defineresource pop
22270 end
22271 /setpacking where {pop setpacking} if
22272 %%EndData
22273 %%EndResource
22274 % --END ENCODER microqrcode--
22275
22276 % --BEGIN ENCODER rectangularmicroqrcode--
22277 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix qrcode--
22278 % --DESC: Rectangular Micro QR Code
22279 % --EXAM: 1234
22280 % --EXOP: version=R17x139
22281 % --RNDR: renmatrix
22282 %%BeginResource: uk.co.terryburton.bwipp rectangularmicroqrcode 0.0 2025111800 66839 69833
22283 %%BeginData: 36 ASCII Lines
22284 /setpacking where {pop currentpacking true setpacking} if
22285 10 dict
22286 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
22287 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
22288 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
22289 dup /qrcode dup /uk.co.terryburton.bwipp findresource put
22290 begin
22291 /rectangularmicroqrcode {
22292
22293 20 dict begin % Confine variables to local scope
22294
22295 /ctx null def
22296 /dontdraw false def
22297
22298 //processoptions exec /options exch def
22299 /barcode exch def
22300
22301 % Get the result of encoding with qrcode with format=micro
22302 options (dontdraw) true put
22303 options (format) (rmqr) put
22304
22305 /args barcode options //qrcode exec def
22306
22307 args (opt) options put
22308 args
22309
22310 dontdraw not //renmatrix if
22311
22312 end
22313
22314 }
22315 [/barcode] {null def} forall
22316 bind def
22317 /rectangularmicroqrcode dup load /uk.co.terryburton.bwipp defineresource pop
22318 end
22319 /setpacking where {pop setpacking} if
22320 %%EndData
22321 %%EndResource
22322 % --END ENCODER rectangularmicroqrcode--
22323
22324 % --BEGIN ENCODER maxicode--
22325 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput renmaximatrix--
22326 % --DESC: MaxiCode
22327 % --EXAM: [)>^03001^02996152382802^029840^029001^0291Z00004951^029UPSN^02906X610^029159^0291234567^0291/1^029^029Y^029634 ALPHA DR^029PITTSBURGH^029PA^029^004
22328 % --EXOP: mode=2 parse
22329 % --RNDR: renmaximatrix
22330 %%BeginResource: uk.co.terryburton.bwipp maxicode 0.0 2025111800 191498 196297
22331 %%BeginData: 879 ASCII Lines
22332 /setpacking where {pop currentpacking true setpacking} if
22333 10 dict
22334 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
22335 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
22336 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
22337 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
22338 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
22339 dup /renmaximatrix dup /uk.co.terryburton.bwipp findresource put
22340 begin
22341 /maxicode {
22342
22343 20 dict begin
22344
22345 /ctx null def
22346 /dontdraw false def
22347 /mode -1 def
22348 /sam -1 def
22349 /parse false def
22350 /parsefnc false def
22351 /legacyencoder false def
22352
22353 //processoptions exec /options exch def
22354 /barcode exch def
22355
22356 barcode () eq {
22357 /bwipp.maxicodeEmptyData (The data must not be empty) //raiseerror exec
22358 } if
22359
22360 mode -1 ne mode 2 lt mode 6 gt or and {
22361 /bwipp.maxicodeBadMode (Mode must be 2 to 6) //raiseerror exec
22362 } if
22363
22364 sam -1 ne {
22365 true
22366 1 {
22367 sam dup 12 lt exch 88 gt or { pop false exit } if
22368 sam 10 mod dup 2 lt exch 8 gt or { pop false exit } if
22369 sam 10 idiv sam 10 mod gt { pop false exit } if
22370 } repeat
22371 not {
22372 /bwipp.maxicodeBadSAM (SAM must be formatted as "NM" for Nth of M symbols, from 2 to 8 symbols) //raiseerror exec
22373 } if
22374 } if
22375
22376 /encoding (new) def
22377 legacyencoder {/encoding (legacy) def} if
22378
22379 /maxicode //loadctx exec
22380
22381 % Parse the input
22382 /fncvals <<
22383 /parse parse
22384 /parsefnc parsefnc
22385 /eci true
22386 % ECIs only
22387 >> def
22388 /msg barcode fncvals //parseinput exec def
22389 /msglen msg length def
22390
22391 % Special message handling for modes 2 and 3
22392 mode 2 eq mode 3 eq or {
22393
22394 % Convert to a string (up to first ECI) for extracting the structured data
22395 /barcode msglen string def
22396 /barlen msglen def
22397 0 1 msglen 1 sub {
22398 /i exch def
22399 msg i get 0 lt {/barlen i def exit} if
22400 barcode i msg i get put
22401 } for
22402 /difflen msglen barlen sub def
22403
22404 % Normalise messages that begin with a field identifier [)>{RS}01{GS}yy
22405 /fid () def
22406 barlen 9 ge {
22407 barcode dup 0 7 getinterval <5b293e1e30311d> eq
22408 exch dup 7 get dup 48 ge exch 57 le and
22409 exch 8 get dup 48 ge exch 57 le and and and {
22410 /fid barcode 0 9 getinterval def
22411 /barcode barcode 9 barlen 9 sub getinterval def
22412 } if
22413 } if
22414
22415 % Read the postcode, country code and service code fields separated by GS
22416 barcode
22417 <1d> search {
22418 /pcode exch def pop
22419 mode 2 eq {
22420 true
22421 1 {
22422 pcode length dup 9 gt exch 0 eq or { pop false exit } if
22423 pcode { dup 48 lt exch 57 gt or { pop false exit } if } forall
22424 } repeat
22425 not {
22426 pop /bwipp.maxicodeBadMode2PostCode (A mode 2 postcode must not be empty or exceed 9 digits) //raiseerror exec
22427 } if
22428 } { % mode=3
22429 true
22430 1 {
22431 pcode length dup 6 gt exch 0 eq or { pop false exit } if
22432 pcode {
22433 dup 32 eq % SP
22434 exch dup dup 34 ge exch 58 le and % punct, 0-9, :
22435 exch dup 65 ge exch 90 le and % A-Z
22436 or or not { pop false exit } if
22437 } forall
22438 } repeat
22439 not {
22440 pop /bwipp.maxicodeBadMode3PostCode (A mode 3 postcode must not be empty or exceed 6 characters) //raiseerror exec
22441 } if
22442 } ifelse
22443 } {
22444 pop /bwipp.maxicodeExpectedPostCode (Expected postcode followed by group separator character) //raiseerror exec
22445 } ifelse
22446 <1d> search {
22447 /ccode exch def pop
22448 true
22449 1 {
22450 ccode length 3 ne { pop false exit } if
22451 ccode { dup 48 lt exch 57 gt or { pop false exit } if } forall
22452 } repeat
22453 not {
22454 pop /bwipp.maxicodeBadCountryCode (Country code must be three digits) //raiseerror exec
22455 } if
22456 } {
22457 pop /bwipp.maxicodeExpectedCountryCode (Expected country code followed by group separator character) //raiseerror exec
22458 } ifelse
22459 <1d> search {
22460 /scode exch def pop
22461 true
22462 1 {
22463 scode length 3 ne { pop false exit } if
22464 scode { dup 48 lt exch 57 gt or { pop false exit } if } forall
22465 } repeat
22466 not {
22467 pop /bwipp.maxicodeBadServiceClass (Service class must be three digits) //raiseerror exec
22468 } if
22469 } {
22470 pop /bwipp.maxicodeExpectedServiceClass (Expected service class followed by group separator character) //raiseerror exec
22471 } ifelse
22472 /barcode exch def
22473
22474 % Prepend the field identifier
22475 barcode length fid length add string dup
22476 0 fid putinterval dup
22477 fid length barcode putinterval
22478 /barcode exch def
22479 /barlen barcode length def
22480
22481 /msg [ barcode {} forall msg msglen difflen sub difflen getinterval aload pop ] def
22482 /msglen msg length def
22483
22484 } if
22485
22486 {
22487 % Special function characters
22488 /eci -1 def /pad -2 def /ns -3 def
22489 /la -4 def /lb -5 def
22490 /sa -6 def /sb -7 def /sc -8 def /sd -9 def /se -10 def
22491 /sa2 -11 def /sa3 -12 def
22492 /lkc -13 def /lkd -14 def /lke -15 def
22493 /pd2 -16 def /pd3 -17 def
22494
22495 % Character maps for each state
22496 /charmaps [
22497 % A B C D E
22498 [ 13 (`) 192 224 0 ] % 0
22499 [ (A) (a) 193 225 1 ] % 1
22500 [ (B) (b) 194 226 2 ] % 2
22501 [ (C) (c) 195 227 3 ] % 3
22502 [ (D) (d) 196 228 4 ] % 4
22503 [ (E) (e) 197 229 5 ] % 5
22504 [ (F) (f) 198 230 6 ] % 6
22505 [ (G) (g) 199 231 7 ] % 7
22506 [ (H) (h) 200 232 8 ] % 8
22507 [ (I) (i) 201 233 9 ] % 9
22508 [ (J) (j) 202 234 10 ] % 10
22509 [ (K) (k) 203 235 11 ] % 11
22510 [ (L) (l) 204 236 12 ] % 12
22511 [ (M) (m) 205 237 13 ] % 13
22512 [ (N) (n) 206 238 14 ] % 14
22513 [ (O) (o) 207 239 15 ] % 15
22514 [ (P) (p) 208 240 16 ] % 16
22515 [ (Q) (q) 209 241 17 ] % 17
22516 [ (R) (r) 210 242 18 ] % 18
22517 [ (S) (s) 211 243 19 ] % 19
22518 [ (T) (t) 212 244 20 ] % 20
22519 [ (U) (u) 213 245 21 ] % 21
22520 [ (V) (v) 214 246 22 ] % 22
22521 [ (W) (w) 215 247 23 ] % 23
22522 [ (X) (x) 216 248 24 ] % 24
22523 [ (Y) (y) 217 249 25 ] % 25
22524 [ (Z) (z) 218 250 26 ] % 26
22525 [ eci eci eci eci eci ] % 27
22526 [ 28 28 28 28 pad ] % 28
22527 [ 29 29 29 29 pd2 ] % 29
22528 [ 30 30 30 30 27 ] % 30
22529 [ ns ns ns ns ns ] % 31
22530 [ ( ) ({) 219 251 28 ] % 32
22531 [ pad pad 220 252 29 ] % 33
22532 [ (") (}) 221 253 30 ] % 34
22533 [ (#) (~) 222 254 31 ] % 35
22534 [ ($) 127 223 255 159 ] % 36
22535 [ (%) (;) 170 161 160 ] % 37
22536 [ (&) (<) 172 168 162 ] % 38
22537 [ (') (=) 177 171 163 ] % 39
22538 [ 40 (>) 178 175 164 ] % 40
22539 [ 41 (?) 179 176 165 ] % 41
22540 [ (*) ([) 181 180 166 ] % 42
22541 [ (+) 92 185 183 167 ] % 43
22542 [ (,) (]) 186 184 169 ] % 44
22543 [ (-) (^) 188 187 173 ] % 45
22544 [ (.) (_) 189 191 174 ] % 46
22545 [ (/) ( ) 190 138 182 ] % 47
22546 [ (0) (,) 128 139 149 ] % 48
22547 [ (1) (.) 129 140 150 ] % 49
22548 [ (2) (/) 130 141 151 ] % 50
22549 [ (3) (:) 131 142 152 ] % 51
22550 [ (4) (@) 132 143 153 ] % 52
22551 [ (5) (!) 133 144 154 ] % 53
22552 [ (6) (|) 134 145 155 ] % 54
22553 [ (7) pd2 135 146 156 ] % 55
22554 [ (8) sa2 136 147 157 ] % 56
22555 [ (9) sa3 137 148 158 ] % 57
22556 [ (:) pd3 la la la ] % 58
22557 [ sb sa ( ) ( ) ( ) ] % 59
22558 [ sc sc lkc sc sc ] % 60
22559 [ sd sd sd lkd sd ] % 61
22560 [ se se se se lke ] % 62
22561 [ lb la lb lb lb ] % 63
22562 ] def
22563
22564 % Invert charmaps to give character to value maps for each state
22565 /charvals [ 64 dict 64 dict 64 dict 64 dict 64 dict ] def
22566 0 1 charmaps length 1 sub {
22567 /i exch def
22568 /encs charmaps i get def
22569 0 1 4 {
22570 /j exch def
22571 encs j get dup type /stringtype eq {0 get} if % convert string to ASCII if required
22572 charvals j get exch i put
22573 } for
22574 } for
22575 /seta charvals 0 get def
22576 /setb charvals 1 get def
22577 /setc charvals 2 get def
22578 /setd charvals 3 get def
22579 /sete charvals 4 get def
22580 } ctxdef
22581
22582 /maxlen mode 5 eq {77} {mode 3 le {84} {93} ifelse} ifelse def
22583
22584 %
22585 % TODO: Support for this encoder will be dropped in the near future. If
22586 % you require it then let your reason be known.
22587 %
22588 encoding (legacy) eq {
22589
22590 % Compute numeric runlengths
22591 /nseq [ msglen 1 add {0} repeat ] def
22592 msglen 1 sub -1 0 {
22593 /i exch def
22594 msg i get dup 48 ge exch 57 le and {
22595 nseq i nseq i 1 add get 1 add put
22596 } {
22597 nseq i 0 put
22598 } ifelse
22599 } for
22600 /nseq nseq 0 msglen getinterval def
22601
22602 % Encode the message from ASCII to codewords
22603 /prefixinset {
22604 0 {
22605 2 copy exch length ge {exit} if
22606 2 copy get 3 index exch known {1 add} {exit} ifelse
22607 } loop
22608 exch pop exch pop
22609 } def
22610
22611 /enc {
22612 exch get out exch j exch put
22613 /j j 1 add def
22614 } def
22615
22616 /out 144 array def
22617 /i 0 def /j 0 def /cset (seta) def
22618 { % loop
22619 % Exit when no characters remain latching back to A if necessary
22620 i msglen eq {
22621 cset (seta) ne cset (setb) ne and out length maxlen lt and {
22622 la cset load enc
22623 /cset (seta) def
22624 } if
22625 exit
22626 } if
22627 { % not a loop but common exit point
22628 % Immediately encode an ECI
22629 msg i get -1000000 le {
22630 eci cset load enc
22631 msg i get neg 1000000 sub
22632 dup 000031 le { % ECI 000000 - 000031
22633 63 and
22634 1 array astore
22635 } { dup 001023 le { % ECI 000032 - 001023
22636 dup -6 bitshift 31 and 32 or exch
22637 63 and
22638 2 array astore
22639 } { dup 032767 le { % ECI 001024 - 032767
22640 dup -12 bitshift 47 and 48 or exch
22641 dup -6 bitshift 63 and exch
22642 63 and
22643 3 array astore
22644 } { % ECI 032768 - 999999
22645 dup -18 bitshift 55 and 56 or exch
22646 dup -12 bitshift 63 and exch
22647 dup -6 bitshift 63 and exch
22648 63 and
22649 4 array astore
22650 } ifelse } ifelse } ifelse
22651 dup out exch j exch putinterval
22652 length j add /j exch def
22653 /i i 1 add def
22654 exit
22655 } if
22656
22657 % If 9 numerals available then use NS
22658 nseq i get 9 ge {
22659 msg i 9 getinterval 0 exch {48 sub add 10 mul} forall 10 idiv
22660 4 { dup 63 and exch -6 bitshift } repeat cset load ns get
22661 0 2 10 {index} for 6 array astore 7 1 roll 6 {pop} repeat
22662 out exch j exch putinterval
22663 /i i 9 add def
22664 /j j 6 add def
22665 exit
22666 } if
22667
22668 % Read next three characters
22669 /char1 msg i get def
22670 /char2 i 1 add msglen lt {msg i 1 add get} {-99} ifelse def
22671 /char3 i 2 add msglen lt {msg i 2 add get} {-99} ifelse def
22672
22673 % If current mode is sufficient then directly encode
22674 cset load char1 known {
22675 char1 cset load enc
22676 /i i 1 add def
22677 exit
22678 } if
22679
22680 % For switching from A to B
22681 cset (seta) eq setb char1 known and {
22682 setb char2 known {
22683 lb seta enc
22684 /cset (setb) def
22685 } {
22686 sb seta enc
22687 char1 setb enc
22688 /i i 1 add def
22689 } ifelse
22690 exit
22691 } if
22692
22693 % For switching from B to A encode according to length of prefix
22694 cset (setb) eq seta char1 known and {
22695 /p seta msg i 4 msglen i sub 2 copy gt {exch} if pop getinterval prefixinset def
22696 p 1 eq {
22697 sa setb enc
22698 char1 seta enc
22699 /i i 1 add def
22700 } if
22701 p 2 eq {
22702 sa2 setb enc
22703 char1 seta enc
22704 char2 seta enc
22705 /i i 2 add def
22706 } if
22707 p 3 eq {
22708 sa3 setb enc
22709 char1 seta enc
22710 char2 seta enc
22711 char3 seta enc
22712 /i i 3 add def
22713 } if
22714 p 4 ge {
22715 la setb enc
22716 /cset (seta) def
22717 } if
22718 exit
22719 } if
22720
22721 % If character is in A or B then directly latch
22722 seta char1 known {
22723 la cset load enc
22724 /cset (seta) def
22725 exit
22726 } if
22727 setb char1 known {
22728 lb cset load enc
22729 /cset (setb) def
22730 exit
22731 } if
22732
22733 % Determine which one of sets C, D or E the character is in
22734 setc char1 known {/setx (setc) def /sx sc def /lkx lkc def} if
22735 setd char1 known {/setx (setd) def /sx sd def /lkx lkd def} if
22736 sete char1 known {/setx (sete) def /sx se def /lkx lke def} if
22737
22738 % Encode according to the length of the prefix
22739 /p setx load msg i 4 msglen i sub 2 copy gt {exch} if pop getinterval prefixinset def
22740 p 1 eq {
22741 sx cset load enc
22742 char1 setx load enc
22743 /i i 1 add def
22744 } if
22745 p 2 eq {
22746 sx cset load enc
22747 char1 setx load enc
22748 sx cset load enc
22749 char2 setx load enc
22750 /i i 2 add def
22751 } if
22752 p 3 eq {
22753 sx cset load enc
22754 char1 setx load enc
22755 sx cset load enc
22756 char2 setx load enc
22757 sx cset load enc
22758 char3 setx load enc
22759 /i i 3 add def
22760 } if
22761 p 4 ge {
22762 sx cset load enc
22763 lkx setx load enc
22764 /cset setx def
22765 } if
22766
22767 exit
22768 } loop % out
22769 } loop
22770 /encmsg out 0 j getinterval def
22771 /padval cset load pad get def
22772
22773 } if
22774
22775 encoding (new) eq {
22776
22777 % Check states needed (apart from A, which for typical data is always used)
22778 /haveb false def /havec false def /haved false def /havee false def
22779 /havei false def % ECI
22780 0 1 msglen 1 sub {
22781 msg exch get /c exch def
22782 c -1000000 le {
22783 /havei true def
22784 } { c 28 lt c 30 gt or c 32 ne and { % FS, GS, RS and space in all code sets
22785 setb c known { /haveb true def } if
22786 setc c known { /havec true def } if
22787 setd c known { /haved true def } if
22788 sete c known { /havee true def } if
22789 } if
22790 } ifelse
22791 } for
22792
22793 % Code sets with a pad code are first pick
22794 % A B E C D
22795 /priority [0 haveb {1} if havee {4} if havec {2} if haved {3} if] def
22796 /priority_rest priority 1 priority length 1 sub getinterval def % May be empty
22797
22798 % Prior code set Later code set
22799 % A B C D E
22800 /latch_sequence [[[ ][63 ][58 ][58 ][58 ]] % A
22801 [[63 ][ ][63 ][63 ][63 ]] % B
22802 [[60 60][60 60][ ][60 60][60 60]] % C
22803 [[61 61][61 61][61 61][ ][61 61]] % D
22804 [[62 62][62 62][62 62][62 62][ ]]] def % E
22805
22806 /latch_length [[ 0 1 1 1 1 ] % A
22807 [ 1 0 1 1 1 ] % B
22808 [ 2 2 0 2 2 ] % C
22809 [ 2 2 2 0 2 ] % D
22810 [ 2 2 2 2 0 ]] def % E
22811
22812 /max_int 16#7FFFFFFF def % max int should make sure a state doesn't get picked
22813
22814 % The encoder needs 10 history rows.
22815 % The circular history buffers are 16 long for convenience
22816 /best_length [16 {[0 0 0 0 0]} repeat] def
22817 /best_origin [16 {[0 0 0 0 0]} repeat] def
22818
22819 % Backtracking information
22820 /prior_code_set [msglen {[5 {0} repeat]} repeat] def
22821 /path_op [msglen {[5 {0} repeat]} repeat] def
22822
22823 % Length of Extended Channel Interpretation
22824 /out_eci {c neg 1000000 sub dup 1024 lt { 32 lt {2} {3} ifelse}
22825 {32768 lt {4} {5} ifelse} ifelse} def
22826
22827 % Operations that don't fit directly into the list below
22828 /enc_eci {c neg 1000000 sub dup 32 ge {dup 1024 lt {
22829 dup -6 bitshift 32 or exch 63 and} {dup 32768 lt {
22830 dup -12 bitshift 48 or exch
22831 dup -6 bitshift 63 and exch 63 and} {
22832 dup -18 bitshift 56 or exch
22833 dup -12 bitshift 63 and exch
22834 dup -6 bitshift 63 and exch 63 and} ifelse} ifelse} if} def
22835 /enc_ns {0 msg n 9 getinterval {48 sub exch 10 mul add} forall % Numeric
22836 dup -24 bitshift exch % Sequence
22837 dup -18 bitshift 63 and exch
22838 dup -12 bitshift 63 and exch
22839 dup -6 bitshift 63 and exch 63 and} def
22840 /enc_sha2 {seta c get seta msg n 1 add get get} def % Shift 2 A
22841 /enc_sha3 {seta c get seta msg n 1 add get get
22842 seta msg n 2 add get get} def % Shift 3 A
22843
22844 % Table of operations - operating table?
22845 /op_tab [ % predicate applicable sets encoding
22846 havei { << /can {c -1000000 le} /intake 1 /output {out_eci} /sets 2#11111 /enc {27 enc_eci } >> } if % ECI1 ABCDE
22847 << /can {digits 9 ge } /intake 9 /output {6 } /sets 2#11111 /enc {31 enc_ns } >> % NS ABCDE
22848 << /can {seta c known } /intake 1 /output {1 } /sets 2#00001 /enc { seta c get} >> % A A
22849 haveb { << /can {setb c known } /intake 1 /output {1 } /sets 2#00010 /enc { setb c get} >> } if % B B
22850 havec { << /can {setc c known } /intake 1 /output {1 } /sets 2#00100 /enc { setc c get} >> } if % C C
22851 haved { << /can {setd c known } /intake 1 /output {1 } /sets 2#01000 /enc { setd c get} >> } if % D D
22852 havee { << /can {sete c known } /intake 1 /output {1 } /sets 2#10000 /enc { sete c get} >> } if % E E
22853 << /can {num_a 1 ge } /intake 1 /output {2 } /sets 2#00010 /enc {59 seta c get} >> % SHA B
22854 << /can {num_a 2 ge } /intake 2 /output {3 } /sets 2#00010 /enc {56 enc_sha2 } >> % SHA2 B
22855 << /can {num_a 3 ge } /intake 3 /output {4 } /sets 2#00010 /enc {57 enc_sha3 } >> % SHA3 B
22856 haveb { << /can {setb c known } /intake 1 /output {2 } /sets 2#00001 /enc {59 setb c get} >> } if % SHB A
22857 havec { << /can {setc c known } /intake 1 /output {2 } /sets 2#11011 /enc {60 setc c get} >> } if % SHC ABCDE
22858 haved { << /can {setd c known } /intake 1 /output {2 } /sets 2#10111 /enc {61 setd c get} >> } if % SHD ABCDE
22859 havee { << /can {sete c known } /intake 1 /output {2 } /sets 2#01111 /enc {62 sete c get} >> } if % SHE ABCDE
22860 ] def
22861
22862 % Add idx to each entry
22863 0 op_tab {/idx 2 index put 1 add} forall pop
22864
22865 % Filter table of operations into lists of operations that apply in each code set
22866 /code_set_operations [[1 2 4 8 16] {/n exch def [op_tab {dup /sets get n and 0 eq {pop} if} forall]} forall] def
22867
22868 % Get the shortest encoded length for the code set (state) and plot the path
22869 /get_best_length {
22870 /latch_length_s latch_length state get def % Get latch length row targetting the code set
22871 max_int % Length returned if this is not a viable code set
22872 code_set_operations state get { % Loop over operations that apply to this code set
22873 /op exch def %
22874 op /can get exec { % Determine if the operation accepts the input
22875 /m n op /intake get sub 15 and def % Get index into circular history buffers
22876 /org best_origin m get state get def % Get the best prior code set
22877 best_length m get org get % Get the corresponding encoding length
22878 latch_length_s org get add % Add latch length
22879 op /output get exec add % Add output length to yield resulting length
22880 2 copy gt { % Compare lengths
22881 exch % Keep the shorter length
22882 path_op_0 state op /idx get put % Store operation in path
22883 prior_code_set_0 state org put % Store prior set in path
22884 } if pop % Pop off the longer (or equal) length
22885 } if
22886 } forall
22887 } def
22888
22889 % Loop to get the best prior code set using a row of
22890 % best encoded lengths and a row of latch sequence lengths.
22891 /get_best_origin {
22892 /latch_length_s latch_length state get def
22893 best_length_0 0 get latch_length_s 0 get add /orglen exch def 0
22894 priority_rest {
22895 /p exch def best_length_0 p get latch_length_s p get add dup orglen lt {/orglen exch def pop p} {pop} ifelse
22896 } forall
22897 } def
22898
22899 /digits 0 def % Number of contiguous digits seen
22900 /num_a 0 def % Number of contiguous characters seen that are encodable in code set A
22901
22902 % Make a table of best path options
22903 0 1 msglen 1 sub {
22904 /n exch def % Input index
22905 /c msg n get def % Input character
22906
22907 % Keep tabs on digits and characters in code set A
22908 /digits c 48 ge c 58 lt and {digits 1 add} {0} ifelse def
22909 /num_a seta c known {num_a 1 add} {0} ifelse def
22910
22911 % Get rows of interest
22912 /path_op_0 path_op n get def
22913 /prior_code_set_0 prior_code_set n get def
22914 /best_length_0 best_length n 15 and get def
22915 /best_origin_0 best_origin n 15 and get def
22916
22917 % Get best encoded lengths, then best prior code sets
22918 priority {/state exch def best_length_0 state get_best_length put} forall
22919 priority {/state exch def best_origin_0 state get_best_origin put} forall
22920 } for
22921
22922 /n msglen def
22923
22924 % Get the best code set to end with. Code sets with a pad code are first pick
22925 0 max_int priority {dup best_length_0 exch get dup 3 index lt {4 2 roll} if pop pop} forall
22926 /j exch def
22927 /state exch def
22928
22929 % End in a code set which has a pad code
22930 /pad_code [33 33 0 0 28] def
22931 /final_code_set pad_code state get 0 eq {0} {state} ifelse def
22932
22933 % Insert a latch to A if padding is necessary and the code set does not have a pad code.
22934 pad_code state get 0 eq j maxlen lt and {j 1 add array dup j 58 put} {j array} ifelse
22935 /padval pad_code final_code_set get def
22936 /len j def
22937
22938 % Follow the best path back to the start of the message
22939 {
22940 n 0 le {exit} if
22941 /pcs prior_code_set n 1 sub get state get def
22942 /op_idx path_op n 1 sub get state get def
22943 /op op_tab op_idx get def
22944 /n n op /intake get sub def
22945 /c msg n get def
22946 /enc op /enc get def
22947 /output [enc exec] def
22948 /latch latch_sequence state get pcs get def
22949 /len len latch length sub output length sub def
22950 dup len latch 3 copy putinterval length add output putinterval
22951 /state pcs def
22952 } loop
22953
22954 % Name the result
22955 /encmsg exch def
22956
22957 } if
22958
22959 % Prefix the encoded message with the structured append insert
22960 /sami sam -1 ne { [ seta pad get sam 10 idiv 1 sub 8 mul sam 10 mod 1 sub add ] } { [] } ifelse def
22961 /encmsg [ sami aload pop encmsg aload pop ] def
22962
22963 % Derive the primary and secondary codewords for modes 2 and 3
22964 mode 2 eq mode 3 eq or {
22965
22966 encmsg length 84 gt {
22967 /bwipp.maxicodeMode23TooLong (The secondary message is too long) //raiseerror exec
22968 } if
22969
22970 % Calculate the fixed-width binary values for the mode, postcode, country code and service
22971 /mdb (0000) 4 string copy dup mode cvi 2 4 string cvrs dup length 4 exch sub exch putinterval def
22972 /ccb (0000000000) 10 string copy dup ccode cvi 2 10 string cvrs dup length 10 exch sub exch putinterval def
22973 /scb (0000000000) 10 string copy dup scode cvi 2 10 string cvrs dup length 10 exch sub exch putinterval def
22974 /pcb (000000000000000000000000000000000000) 36 string copy def
22975 mode 2 eq {
22976 % For US postcodes lacking "+4", pad with zeroes (ISO/IEC 16023:2000 Annex B.1.4a)
22977 ccode (840) eq pcode length 5 eq and { /pcode ( 0000) 9 string copy dup 0 pcode putinterval def } if
22978 % For numeric postcode, first six bits represent length and remaining 30 bits the value
22979 pcb pcode length 2 6 string cvrs dup length 6 exch sub exch putinterval
22980 pcb pcode cvi 2 30 string cvrs dup length 36 exch sub exch putinterval
22981 } { % mode=3
22982 % For alphanumeric postcode, trim or pad with spaces to 6 chars and encode to binary
22983 /pccw [
22984 ( ) 6 string copy dup 0 pcode length 6 gt {pcode 0 6 getinterval} {pcode} ifelse putinterval
22985 {seta exch get} forall
22986 ] def
22987 0 1 5 {
22988 /i exch def
22989 pcb pccw i get 2 6 string cvrs dup length 6 i mul 6 add exch sub exch putinterval
22990 } for
22991 } ifelse
22992
22993 % Convolute the binary values into the structured carrier message
22994 /scm 60 string def
22995 scm 2 mdb putinterval
22996 scm 38 pcb 0 4 getinterval putinterval
22997 scm 30 pcb 4 6 getinterval putinterval
22998 scm 24 pcb 10 6 getinterval putinterval
22999 scm 18 pcb 16 6 getinterval putinterval
23000 scm 12 pcb 22 6 getinterval putinterval
23001 scm 6 pcb 28 6 getinterval putinterval
23002 scm 0 pcb 34 2 getinterval putinterval
23003 scm 52 ccb 0 2 getinterval putinterval
23004 scm 42 ccb 2 6 getinterval putinterval
23005 scm 36 ccb 8 2 getinterval putinterval
23006 scm 54 scb 0 6 getinterval putinterval
23007 scm 48 scb 6 4 getinterval putinterval
23008
23009 % Evaluate the structured carrier message as codewords
23010 /pri [ 0 0 0 0 0 0 0 0 0 0 ] def
23011 0 1 59 {
23012 /i exch def
23013 /ps i 6 idiv def
23014 /ep 2 5 i 6 mod sub exp cvi scm i get 48 sub mul def
23015 pri ps pri ps get ep add put
23016 } for
23017
23018 % Pad the encoded message into the secondary component
23019 /sec [ 84 {padval} repeat ] def
23020 sec 0 encmsg putinterval
23021
23022 } if
23023
23024 % Derive the primary and secondary codewords for modes 4, 5 and 6
23025 mode 4 eq mode 5 eq or mode 6 eq or mode -1 eq or {
23026
23027 % If mode isn't specified then use EEC if message fits, otherwise SEC
23028 mode -1 eq {
23029 /mode encmsg length 77 le {5} {4} ifelse def
23030 } if
23031
23032 /cws [ mode 5 eq {78} {94} ifelse {padval} repeat ] def
23033 encmsg length cws length 1 sub gt {
23034 /bwipp.maxicodeMode56TooLong (The message is too long) //raiseerror exec
23035 } if
23036 cws 0 mode put
23037 cws 1 encmsg putinterval
23038
23039 % Fit the message into the primary and secondary components
23040 /pri cws 0 10 getinterval def
23041 /sec cws 10 cws length 10 sub getinterval def
23042
23043 } if
23044
23045 % Calculate the log and anti-log tables
23046 {
23047 /rsalog [ 1 63 { dup 2 mul dup 64 ge {67 xor} if } repeat ] def
23048 /rslog 64 array def
23049 1 1 63 {dup rsalog exch get exch rslog 3 1 roll put} for
23050 } ctxdef
23051
23052 % Function to calculate the product in the field
23053 /rsprod {
23054 2 copy 0 ne exch 0 ne and {
23055 rslog exch get exch rslog exch get add 63 mod rsalog exch get
23056 } {
23057 pop pop 0
23058 } ifelse
23059 } def
23060
23061 % Generate error correction codewords
23062 /rscodes {
23063
23064 /rsnum exch def
23065 /cwb exch def
23066
23067 % Generate the coefficients
23068 /coeffs [ 1 rsnum {0} repeat ] def
23069 1 1 rsnum {
23070 /i exch def
23071 coeffs i coeffs i 1 sub get put
23072 i 1 sub -1 1 {
23073 /j exch def
23074 coeffs j coeffs j 1 sub get coeffs j get rsalog i get rsprod xor put
23075 } for
23076 coeffs 0 coeffs 0 get rsalog i get rsprod put
23077 } for
23078 /coeffs coeffs 0 coeffs length 1 sub getinterval def
23079
23080 % Calculate the error correction codewords
23081 /ecb [ rsnum {0} repeat ] def
23082 0 1 cwb length 1 sub {
23083 /t exch cwb exch get ecb 0 get xor def
23084 ecb length 1 sub -1 0 {
23085 /i exch def
23086 /p ecb length i sub 1 sub def
23087 ecb p t coeffs i get rsprod put
23088 i 0 gt { ecb p ecb p 1 add get ecb p get xor put } if
23089 } for
23090 } for
23091
23092 ecb
23093
23094 } def
23095
23096 % Split secondary codeword into odd and even elements
23097 /seco [ 0 2 sec length 1 sub { sec exch get } for ] def
23098 /sece [ 1 2 sec length 1 sub { sec exch get } for ] def
23099
23100 % Calculate the parity codewords for secondary codeword parts based on mode
23101 /scodes sec length 84 eq {20} {28} ifelse def % SEC/EEC mode
23102 /secochk seco scodes rscodes def
23103 /secechk sece scodes rscodes def
23104
23105 % Recompose the secondary parity codewords
23106 /secchk [ 0 1 scodes 1 sub { dup secochk exch get exch secechk exch get } for ] def
23107
23108 % Concatenate the data into final codewords
23109 /codewords [
23110 pri aload pop
23111 pri 10 rscodes aload pop
23112 sec aload pop
23113 secchk aload pop
23114 ] def
23115
23116 options /debugcws known { /bwipp.debugcws codewords //raiseerror exec } if
23117
23118 % Convert the codewords into module bits
23119 /mods [ 864 {0} repeat ] def
23120 0 1 143 {
23121 /i exch def
23122 /cw [ codewords i get 2 6 string cvrs {48 sub} forall ] def
23123 mods 6 i mul 6 cw length sub add cw putinterval
23124 } for
23125
23126 % Maps modules to pixels in the grid
23127 {
23128 /modmap [
23129 469 529 286 316 347 346 673 672 703 702 647 676 283 282 313 312 370 610 618 379
23130 378 409 408 439 705 704 559 589 588 619 458 518 640 701 675 674 285 284 315 314
23131 310 340 531 289 288 319 349 348 456 486 517 516 471 470 369 368 399 398 429 428
23132 549 548 579 578 609 608 649 648 679 678 709 708 639 638 669 668 699 698 279 278
23133 309 308 339 338 381 380 411 410 441 440 561 560 591 590 621 620 547 546 577 576
23134 607 606 367 366 397 396 427 426 291 290 321 320 351 350 651 650 681 680 711 710
23135 1 0 31 30 61 60 3 2 33 32 63 62 5 4 35 34 65 64 7 6
23136 37 36 67 66 9 8 39 38 69 68 11 10 41 40 71 70 13 12 43 42
23137 73 72 15 14 45 44 75 74 17 16 47 46 77 76 19 18 49 48 79 78
23138 21 20 51 50 81 80 23 22 53 52 83 82 25 24 55 54 85 84 27 26
23139 57 56 87 86 117 116 147 146 177 176 115 114 145 144 175 174 113 112 143 142
23140 173 172 111 110 141 140 171 170 109 108 139 138 169 168 107 106 137 136 167 166
23141 105 104 135 134 165 164 103 102 133 132 163 162 101 100 131 130 161 160 99 98
23142 129 128 159 158 97 96 127 126 157 156 95 94 125 124 155 154 93 92 123 122
23143 153 152 91 90 121 120 151 150 181 180 211 210 241 240 183 182 213 212 243 242
23144 185 184 215 214 245 244 187 186 217 216 247 246 189 188 219 218 249 248 191 190
23145 221 220 251 250 193 192 223 222 253 252 195 194 225 224 255 254 197 196 227 226
23146 257 256 199 198 229 228 259 258 201 200 231 230 261 260 203 202 233 232 263 262
23147 205 204 235 234 265 264 207 206 237 236 267 266 297 296 327 326 357 356 295 294
23148 325 324 355 354 293 292 323 322 353 352 277 276 307 306 337 336 275 274 305 304
23149 335 334 273 272 303 302 333 332 271 270 301 300 331 330 361 360 391 390 421 420
23150 363 362 393 392 423 422 365 364 395 394 425 424 383 382 413 412 443 442 385 384
23151 415 414 445 444 387 386 417 416 447 446 477 476 507 506 537 536 475 474 505 504
23152 535 534 473 472 503 502 533 532 455 454 485 484 515 514 453 452 483 482 513 512
23153 451 450 481 480 511 510 541 540 571 570 601 600 543 542 573 572 603 602 545 544
23154 575 574 605 604 563 562 593 592 623 622 565 564 595 594 625 624 567 566 597 596
23155 627 626 657 656 687 686 717 716 655 654 685 684 715 714 653 652 683 682 713 712
23156 637 636 667 666 697 696 635 634 665 664 695 694 633 632 663 662 693 692 631 630
23157 661 660 691 690 721 720 751 750 781 780 723 722 753 752 783 782 725 724 755 754
23158 785 784 727 726 757 756 787 786 729 728 759 758 789 788 731 730 761 760 791 790
23159 733 732 763 762 793 792 735 734 765 764 795 794 737 736 767 766 797 796 739 738
23160 769 768 799 798 741 740 771 770 801 800 743 742 773 772 803 802 745 744 775 774
23161 805 804 747 746 777 776 807 806 837 836 867 866 897 896 835 834 865 864 895 894
23162 833 832 863 862 893 892 831 830 861 860 891 890 829 828 859 858 889 888 827 826
23163 857 856 887 886 825 824 855 854 885 884 823 822 853 852 883 882 821 820 851 850
23164 881 880 819 818 849 848 879 878 817 816 847 846 877 876 815 814 845 844 875 874
23165 813 812 843 842 873 872 811 810 841 840 871 870 901 900 931 930 961 960 903 902
23166 933 932 963 962 905 904 935 934 965 964 907 906 937 936 967 966 909 908 939 938
23167 969 968 911 910 941 940 971 970 913 912 943 942 973 972 915 914 945 944 975 974
23168 917 916 947 946 977 976 919 918 949 948 979 978 921 920 951 950 981 980 923 922
23169 953 952 983 982 925 924 955 954 985 984 927 926 957 956 987 986 58 89 88 118
23170 149 148 178 209 208 238 269 268 298 329 328 358 389 388 418 449 448 478 509 508
23171 538 569 568 598 629 628 658 689 688 718 749 748 778 809 808 838 869 868 898 929
23172 928 958 989 988
23173 ] def
23174 } ctxdef
23175
23176 % Lookup pixels for enabled modules from modmap
23177 /pixs 864 array def
23178 /j 0 def
23179 0 1 mods length 1 sub {
23180 /i exch def
23181 mods i get 1 eq {
23182 pixs j modmap i get put
23183 /j j 1 add def
23184 } if
23185 } for
23186 /pixs [ pixs 0 j getinterval aload pop 28 29 280 281 311 457 488 500 530 670 700 677 707 ] def
23187
23188 % Return the arguments
23189 <<
23190 /ren /renmaximatrix
23191 /pixs pixs
23192 /borderleft 1.0
23193 /borderright 1.0
23194 /bordertop 1.0
23195 /borderbottom 1.0
23196 /opt options
23197 >>
23198
23199 dontdraw not //renmaximatrix if
23200
23201 //unloadctx exec
23202
23203 end
23204
23205 }
23206 [/barcode] {null def} forall
23207 bind def
23208 /maxicode dup load /uk.co.terryburton.bwipp defineresource pop
23209 end
23210 /setpacking where {pop setpacking} if
23211 %%EndData
23212 %%EndResource
23213 % --END ENCODER maxicode--
23214
23215 % --BEGIN ENCODER azteccode--
23216 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix--
23217 % --DESC: Aztec Code
23218 % --EXAM: This is Aztec Code
23219 % --EXOP: format=full
23220 % --RNDR: renmatrix
23221 %%BeginResource: uk.co.terryburton.bwipp azteccode 0.0 2025111800 202341 224487
23222 %%BeginData: 830 ASCII Lines
23223 /setpacking where {pop currentpacking true setpacking} if
23224 10 dict
23225 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
23226 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
23227 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
23228 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
23229 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
23230 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
23231 begin
23232 /azteccode {
23233
23234 20 dict begin
23235
23236 /ctx null def
23237 /dontdraw false def
23238 /format (full) def % full, compact or rune
23239 /readerinit false def
23240 /layers -1 def
23241 /eclevel 23 def
23242 /ecaddchars 3 def
23243 /raw false def
23244 /parse false def
23245 /parsefnc false def
23246
23247 //processoptions exec /options exch def
23248 /barcode exch def
23249
23250 /azteccode //loadctx exec
23251
23252 barcode () eq {
23253 /bwipp.aztecEmptyData (The data must not be empty) //raiseerror exec
23254 } if
23255
23256 eclevel 5 lt eclevel 95 gt or {
23257 /bwipp.aztecInvalidEClevel (The EC percentage must be from 5 to 95) //raiseerror exec
23258 } if
23259
23260 ecaddchars 3 lt {
23261 /bwipp.aztecInvalidECaddChars (The number of additional EC codewords must be 3 or more) //raiseerror exec
23262 } if
23263
23264 format (full) ne format (compact) ne format (rune) ne and and {
23265 /bwipp.aztecInvalidFormat (The format must be either full, compact or rune) //raiseerror exec
23266 } if
23267
23268 format (full) eq {
23269 readerinit layers 1 lt layers 22 gt or and {
23270 /bwipp.aztecFullInitInvalidLayers (Full-range symbols for reader programming must specify from 1 to 22 layers) //raiseerror exec
23271 } if
23272 layers -1 ne layers 1 lt layers 32 gt or and {
23273 /bwipp.aztecFullInvalidLayers (Layers for full-range symbols must be from 1 to 32) //raiseerror exec
23274 } if
23275 } if
23276
23277 format (compact) eq {
23278 readerinit {
23279 layers -1 ne layers 1 ne and {
23280 /bwipp.aztecCompactInitInvalidLayers (Compact symbols for reader programming must have 1 layer) //raiseerror exec
23281 } if
23282 /layers 1 def
23283 } if
23284 layers -1 ne layers 1 lt layers 4 gt or and {
23285 /bwipp.aztecCompactInvalidLayers (Layers for compact symbols must be from 1 to 4) //raiseerror exec
23286 } if
23287 } if
23288
23289 format (rune) eq {
23290 layers -1 ne {
23291 /bwipp.aztecRuneInvalidLayers (It is not valid to specify layers for runes) //raiseerror exec
23292 } if
23293 readerinit {
23294 /bwipp.aztecRuneReaderInit (Reader initialisation is not compactible with Aztec Runes) //raiseerror exec
23295 } if
23296 barcode length 0 eq {
23297 /bwipp.aztecRuneNotNumeric (Aztec runes must be numeric) //raiseerror exec
23298 } if
23299 barcode {
23300 dup 48 lt exch 57 gt or {
23301 /bwipp.aztecRuneNotNumeric (Aztec runes must be numeric) //raiseerror exec
23302 } if
23303 } forall
23304 barcode cvi dup 0 lt exch 255 gt or {
23305 /bwipp.aztecRuneInvalid (Aztec runes must be 0 to 255) //raiseerror exec
23306 } if
23307 } if
23308
23309 % Parse the input
23310 /fn1 -1 def
23311 /fncvals <<
23312 /parse parse
23313 /parsefnc parsefnc
23314 /eci true
23315 (FNC1) fn1
23316 >> def
23317 /msg barcode fncvals //parseinput exec def
23318 /msglen msg length def
23319
23320 {
23321 % State key: "U"pper, "L"ower, "M"ixed, "P"unctuation, "D"igit, "B"inary
23322 /U 0 def /L 1 def /M 2 def /P 3 def /D 4 def /B 5 def
23323
23324 % Special function characters
23325 /lu -2 def /ll -3 def /lm -4 def
23326 /lp -5 def /ld -6 def /su -7 def
23327 /sp -8 def /sb -9 def /fl -10 def
23328 /p2 -11 def /p3 -12 def /p4 -13 def /p5 -14 def
23329
23330 % Character maps for each state
23331 /charmaps [
23332 % U L M P D
23333 [ sp sp sp fl sp ] % 0
23334 [ 32 32 32 13 32 ] % 1
23335 [ (A) (a) 1 p2 (0) ] % 2 p2 = CR LF
23336 [ (B) (b) 2 p3 (1) ] % 3 p3 = ". "
23337 [ (C) (c) 3 p4 (2) ] % 4 p4 = ", "
23338 [ (D) (d) 4 p5 (3) ] % 5 p5 = ": "
23339 [ (E) (e) 5 (!) (4) ] % 6
23340 [ (F) (f) 6 (") (5) ] % 7
23341 [ (G) (g) 7 (#) (6) ] % 8
23342 [ (H) (h) 8 ($) (7) ] % 9
23343 [ (I) (i) 9 (%) (8) ] % 10
23344 [ (J) (j) 10 (&) (9) ] % 11
23345 [ (K) (k) 11 (') (,) ] % 12
23346 [ (L) (l) 12 40 (.) ] % 13
23347 [ (M) (m) 13 41 lu ] % 14
23348 [ (N) (n) 27 (*) su ] % 15
23349 [ (O) (o) 28 (+) -99 ] % 16
23350 [ (P) (p) 29 (,) -99 ] % 17
23351 [ (Q) (q) 30 (-) -99 ] % 18
23352 [ (R) (r) 31 (.) -99 ] % 19
23353 [ (S) (s) (@) (/) -99 ] % 20
23354 [ (T) (t) 92 (:) -99 ] % 21
23355 [ (U) (u) (^) (;) -99 ] % 22
23356 [ (V) (v) (_) (<) -99 ] % 23
23357 [ (W) (w) (`) (=) -99 ] % 24
23358 [ (X) (x) (|) (>) -99 ] % 25
23359 [ (Y) (y) (~) (?) -99 ] % 26
23360 [ (Z) (z) 127 ([) -99 ] % 27
23361 [ ll su ll (]) -99 ] % 28
23362 [ lm lm lu ({) -99 ] % 29
23363 [ ld ld lp (}) -99 ] % 30
23364 [ sb sb sb lu -99 ] % 31
23365 ] def
23366
23367 % Invert charmaps to give character to value maps for each state
23368 /charvals [ 32 dict 32 dict 32 dict 32 dict 16 dict ] def
23369 0 1 charmaps length 1 sub {
23370 /i exch def
23371 /encs charmaps i get def
23372 0 1 4 {
23373 /j exch def
23374 encs j get dup type /stringtype eq {0 get} if % convert string to ASCII if required
23375 charvals j get exch i put
23376 } for
23377 } for
23378
23379 % Punctuation compression
23380 /pcomp <<
23381 <0d0a> p2 % CR LF
23382 (. ) p3
23383 (, ) p4
23384 (: ) p5
23385 >> def
23386
23387 /e 1000000 def % "Empty"
23388
23389 /latlen [ % Bit length of latch between states
23390 % To: U L M P D B From
23391 [ 0 5 5 10 5 10 ] % U
23392 [ 9 0 5 10 5 10 ] % L
23393 [ 5 5 0 5 10 10 ] % M
23394 [ 5 10 10 0 10 15 ] % P
23395 [ 4 9 9 14 0 14 ] % D
23396 [ 0 0 0 0 0 0 ] % B
23397 ] def
23398
23399 /latseq [ % Latch sequences between states
23400 % To: U L M P D B From
23401 [ [] [ll] [lm] [lm lp] [ld] [sb] ] % U
23402 [ [ld lu] [] [lm] [lm lp] [ld] [sb] ] % L
23403 [ [lu] [ll] [] [lp] [lu ld] [sb] ] % M
23404 [ [lu] [lu ll] [lu lm] [] [lu ld] [lu sb] ] % P
23405 [ [lu] [lu ll] [lu lm] [lu lm lp] [] [lu sb] ] % D
23406 [ [lu] [ll] [lm] [] [] [] ] % B
23407 ] def
23408
23409 /shftlen [ % Bit length of shift to state
23410 % To: U L M P D From
23411 [ e e e 5 e ] % U
23412 [ 5 e e 5 e ] % L
23413 [ e e e 5 e ] % M
23414 [ e e e e e ] % P
23415 [ 4 e e 4 e ] % D
23416 ] def
23417
23418 } ctxdef
23419
23420 % Convert from input into message bitstream
23421 /msgbits () def
23422 format (rune) ne raw and {/msgbits barcode def} if
23423 format (rune) ne raw not and {
23424
23425 /charsize {
23426 dup 0 ge {
23427 % U L M P D B
23428 pop [ 5 5 5 5 4 8 ] exch get
23429 } { % FNC or ECI in P
23430 exch pop
23431 dup fn1 eq { % FNC1: PS{Flg(0)} + 3
23432 pop 8
23433 } { % ECI: PS{Flg(n)} + 3 + 4n
23434 neg 1000000 sub dup 0 eq {pop 1} if
23435 ln 10 ln div cvi 1 add 4 mul 8 add
23436 } ifelse
23437 } ifelse
23438 } def
23439
23440 % U L M P D B
23441 /curlen [ 0 e e e e e ] def
23442 /curseq [ [] [] [] [] [] [] ] def
23443
23444 /backto U def % U
23445 /lastchar () def
23446
23447 % Derive the optimal sequences ending in each state
23448 msg {
23449
23450 /char exch def
23451
23452 % Check for optimisations in the current sequences by latching from x to y
23453 { % loop
23454 /imp false def
23455 [ U L M P D B ] {
23456 /x exch def
23457 [ U L M P D B ] {
23458 /y exch def
23459 x B ne y backto eq or { % Only B -> backto
23460 /cost curlen x get latlen x get y get add def
23461 cost curlen y get lt {
23462 curlen y cost put
23463 curseq y [
23464 curseq x get aload pop
23465 latseq x get y get aload pop
23466 ] put
23467 y B eq { % Set backto to previous state
23468 /backto x P eq x D eq or {U} {x} ifelse def
23469 } if
23470 /imp true def
23471 } if
23472 } if
23473 } forall
23474 } forall
23475 imp not {exit} if % Repeat unless no improvement
23476 } loop
23477
23478 % Determine optimal next sequences for each valid encoding
23479 /nxtlen [ e e e e e e ] def
23480 /nxtseq 6 array def
23481
23482 [ U L M P D B ] {
23483 /x exch def
23484
23485 { % loop for common exit
23486
23487 % Skip states that cannot encode character
23488 char 0 ge {
23489 x B ne {charvals x get char known not {exit} if} if
23490 } {
23491 x P ne {exit} if % Only P can encode FNC1 and ECI
23492 } ifelse
23493
23494 % Extend directly
23495 /cost curlen x get x char charsize add def
23496 cost nxtlen x get lt {
23497 nxtlen x cost put
23498 nxtseq x [ curseq x get aload pop char ] put
23499 } if
23500
23501 % Optimise for direct shifts from y to x
23502 x B eq {exit} if % B is treated as a latch
23503 [ U L M P D ] {
23504 /y exch def
23505 x y ne {
23506 /cost curlen y get shftlen y get x get add x char charsize add def
23507 cost nxtlen y get lt {
23508 nxtlen y cost put
23509 nxtseq y [
23510 curseq y get aload pop
23511 x U eq {su} {sp} ifelse
23512 char
23513 ] put
23514 } if
23515 } if
23516 } forall
23517
23518 exit
23519 } loop
23520
23521 } forall
23522
23523 % Optimise using P compression
23524 lastchar () ne char 0 ge and {
23525 /pchars 2 string dup 0 lastchar put dup 1 char put def
23526 pcomp pchars known {
23527 [ U L M P D ] {
23528 /i exch def
23529 /inP true def % U and L can't encode CR, comma, dot or colon
23530 i M eq { % M can encode CR
23531 lastchar 13 eq { /inP false def } if
23532 } {
23533 i D eq { % D can encode comma and dot
23534 lastchar 44 eq lastchar 46 eq or { /inP false def } if
23535 } if
23536 } ifelse
23537 inP curlen i get nxtlen i get lt and {
23538 /curseqi curseq i get def
23539 /lastld false def
23540 /lastsp false def
23541 /lastidx -1 def
23542 curseqi length 1 sub -1 0 { % Search backwards for lastchar
23543 /idx exch def
23544 /ch curseqi idx get def
23545 lastidx -1 eq {
23546 ch lastchar eq {
23547 /lastidx idx def
23548 idx 0 gt {
23549 curseqi idx 1 sub get sp eq { /lastsp true def } if % Preceded by P/S
23550 } if
23551 } if
23552 } { % Found lastchar, check latch
23553 ch sb eq { % In B/S, do nothing
23554 /lastidx -1 def
23555 exit
23556 } if
23557 ch 0 lt ch ld ge and { % If have latch
23558 i P eq {
23559 ch ld eq { /lastld true def } if % Set flag if D/L for adjustment below
23560 } {
23561 ch lp ne { /inP lastsp def } if % If not P/L only in P if have P/S
23562 } ifelse
23563 exit
23564 } if
23565 } ifelse
23566 } for
23567 inP lastidx 0 ge and {
23568 nxtlen i curlen i get put
23569 lastidx curseqi length 1 sub lt { % If lastchar not at end of sequence
23570 i P eq {
23571 lastld { nxtlen i nxtlen i get 1 add put } if % Adjust count if D/L
23572 % Move lastchar to end and replace
23573 nxtseq i [ curseqi aload pop curseqi length lastidx sub -1 roll pop pcomp pchars get ] put
23574 } {
23575 % Replace lastchar in situ
23576 nxtseq i [ curseqi aload pop ] put
23577 nxtseq i get lastidx pcomp pchars get put
23578 } ifelse
23579 } {
23580 nxtseq i [ curseqi aload pop pop pcomp pchars get ] put
23581 } ifelse
23582 } if
23583 } if
23584 } forall
23585 } if
23586 } if
23587
23588 % Account for binary extension for 32 or more bytes
23589 nxtseq B get null ne {
23590 /numbytes 0 def
23591 nxtseq B get {
23592 sb eq {0} {numbytes 1 add} ifelse /numbytes exch def
23593 } forall
23594 numbytes 32 eq {nxtlen B nxtlen B get 11 add put} if
23595 } if
23596
23597 /curlen nxtlen def
23598 /curseq nxtseq def
23599 /lastchar char 0 ge {char} {()} ifelse def
23600
23601 } forall
23602
23603 % Select the optimal sequence
23604 /minseq e def
23605 [ U L M P D B ] {
23606 /i exch def
23607 curlen i get minseq lt {
23608 /minseq curlen i get def
23609 /seq curseq i get def
23610 } if
23611 } forall
23612
23613 % Encoding functions
23614 /tobin {
23615 string dup length 1 sub 0 exch 1 exch {1 index exch 48 put} for
23616 dup 3 -1 roll 2 2 index length string cvrs dup length 2 index length exch sub exch putinterval
23617 } def
23618
23619 /encu {charvals U get exch get 5 tobin} def
23620 /encl {charvals L get exch get 5 tobin} def
23621 /encm {charvals M get exch get 5 tobin} def
23622 /encd {charvals D get exch get 4 tobin} def
23623
23624 /encp {
23625 dup fn1 eq { % FNC1: Flg(0)
23626 pop (00000000)
23627 } {
23628 dup -1000000 le { % ECI: Flg(n) + n-Digits
23629 neg 1000000 sub dup dup 0 eq {pop 1} if
23630 ln 10 ln div cvi
23631 dup 1 add 4 mul 8 add string
23632 dup 0 (00000) putinterval % Flg(n)
23633 dup 2 index 1 add 3 tobin 5 exch putinterval % len
23634 3 1 roll -1 0 { % ECI digits in "Digit" encoding
23635 4 mul 8 add exch
23636 dup 10 idiv 3 index 4 2 roll
23637 10 mod 2 add 4 tobin putinterval
23638 } for
23639 pop
23640 } {
23641 charvals P get exch get 5 tobin
23642 } ifelse } ifelse
23643 } def
23644
23645 /encfuncs [ /encu /encl /encm /encp /encd ] def
23646
23647 /addtomsgbits {
23648 /v exch def
23649 msgbits j v putinterval
23650 /j j v length add def
23651 } def
23652
23653 % Encode the sequence
23654 /state U def
23655 /msgbits minseq string def
23656 /i 0 def /j 0 def {
23657 i seq length ge {exit} if
23658
23659 state B ne {
23660
23661 /char seq i get def
23662
23663 % Encode character
23664 char encfuncs state get load exec addtomsgbits
23665 /i i 1 add def
23666
23667 % Encode shifted next character
23668 char su eq char sp eq or {
23669 seq i get char su eq {encu} {encp} ifelse addtomsgbits
23670 /i i 1 add def
23671 } if
23672
23673 % Latches to new state
23674 char lu eq {/state U def} if
23675 char ll eq {/state L def} if
23676 char lm eq {/state M def} if
23677 char lp eq {/state P def} if
23678 char ld eq {/state D def} if
23679 char sb eq {/state B def} if
23680
23681 } { % Binary
23682
23683 % Find number of bytes before latch or end
23684 /numbytes 0 def {
23685 i numbytes add seq length ge {exit} if
23686 seq i numbytes add get 0 lt {exit} if
23687 /numbytes numbytes 1 add def
23688 } loop
23689
23690 % Encode length
23691 numbytes 31 le {
23692 numbytes 5 tobin addtomsgbits
23693 } {
23694 0 5 tobin addtomsgbits
23695 numbytes 31 sub 11 tobin addtomsgbits
23696 } ifelse
23697
23698 % Encode bytes
23699 numbytes {
23700 seq i get 8 tobin addtomsgbits
23701 /i i 1 add def
23702 } repeat
23703
23704 % Return to previous state as indicated
23705 i seq length lt {
23706 /char seq i get def
23707 /i i 1 add def
23708 char lu eq {/state U def} if
23709 char ll eq {/state L def} if
23710 char lm eq {/state M def} if
23711 } if
23712
23713 } ifelse
23714
23715 } loop
23716 /msgbits msgbits 0 j getinterval def
23717
23718 } if
23719
23720 % Lookup the most appropriate symbol specification
23721 {
23722 /metrics [
23723 [ (rune) 0 0 0 6 ] % Special metric for rune symbols
23724 [ (compact) 1 1 17 6 ] [ (full) 1 1 21 6 ] [ (compact) 2 0 40 6 ]
23725 [ (full) 2 1 48 6 ] [ (compact) 3 0 51 8 ] [ (full) 3 1 60 8 ]
23726 [ (compact) 4 0 76 8 ] [ (full) 4 1 88 8 ] [ (full) 5 1 120 8 ]
23727 [ (full) 6 1 156 8 ] [ (full) 7 1 196 8 ] [ (full) 8 1 240 8 ]
23728 [ (full) 9 1 230 10 ] [ (full) 10 1 272 10 ] [ (full) 11 1 316 10 ]
23729 [ (full) 12 1 364 10 ] [ (full) 13 1 416 10 ] [ (full) 14 1 470 10 ]
23730 [ (full) 15 1 528 10 ] [ (full) 16 1 588 10 ] [ (full) 17 1 652 10 ]
23731 [ (full) 18 1 720 10 ] [ (full) 19 1 790 10 ] [ (full) 20 1 864 10 ]
23732 [ (full) 21 1 940 10 ] [ (full) 22 1 1020 10 ] [ (full) 23 0 920 12 ]
23733 [ (full) 24 0 992 12 ] [ (full) 25 0 1066 12 ] [ (full) 26 0 1144 12 ]
23734 [ (full) 27 0 1224 12 ] [ (full) 28 0 1306 12 ] [ (full) 29 0 1392 12 ]
23735 [ (full) 30 0 1480 12 ] [ (full) 31 0 1570 12 ] [ (full) 32 0 1664 12 ]
23736 ] def
23737 } ctxdef
23738
23739 metrics {
23740 /m exch def
23741 /frmt m 0 get def % Format of the symbol
23742 /mlyr m 1 get def % Data layers
23743 /icap m 2 get def % Reader initialisation capable
23744 /ncws m 3 get def % Total of codewords
23745 /bpcw m 4 get def % Bits per codeword
23746 /numecw ncws eclevel mul 100 div ecaddchars add ceiling cvi def
23747 msgbits length 0 eq {/numecw 0 def} if % Error correction codewords
23748 /numdcw ncws numecw sub def % Data codewords
23749 /okay true def
23750 format frmt ne {/okay false def} if
23751 readerinit icap 1 ne and {/okay false def} if
23752 layers -1 ne layers mlyr ne and {/okay false def} if
23753 msgbits length bpcw div ceiling cvi numdcw gt {/okay false def} if
23754 okay {exit} if
23755 } forall
23756
23757 okay not {
23758 /bwipp.aztecNoValidSymbol (Maximum length exceeded) //raiseerror exec
23759 } if
23760
23761 /layers mlyr def
23762
23763 % Expand message bits into codewords avoiding codewords with all zeros or all ones
23764 /allzero {dup length (000000000000) 0 3 -1 roll getinterval eq} def
23765 /allones {dup length (111111111111) 0 3 -1 roll getinterval eq} def
23766 /cws ncws array def
23767 /m 0 def /c 0 def
23768 {
23769 msgbits length m le {exit} if
23770 msgbits length m sub bpcw ge {
23771 /cwb msgbits m bpcw 1 sub getinterval def % All but last bit
23772 /cwf msgbits m bpcw add 1 sub 1 getinterval def % Last bit
23773 cwb allzero {/cwf (1) def /m m 1 sub def} if % Flip last bit to avoid zeros
23774 cwb allones {/cwf (0) def /m m 1 sub def} if % Flip last bit to avoid ones
23775 % Concatenate the bits
23776 12 string dup 0 cwb putinterval
23777 dup bpcw 1 sub cwf putinterval
23778 0 bpcw getinterval
23779 /cwb exch def
23780 } { % Final codeword
23781 /cwb msgbits m msgbits length m sub getinterval def
23782 /cwb (111111111111) 12 string copy dup 0 cwb putinterval 0 bpcw getinterval def
23783 cwb allones {cwb cwb length 1 sub (0) putinterval} if % Prevent all ones
23784 } ifelse
23785 % Conversion of binary data into byte array
23786 /cw 0 def
23787 0 1 bpcw 1 sub {
23788 /i exch def
23789 /cw cw 2 bpcw i sub 1 sub exp cvi cwb i get 48 sub mul add def
23790 } for
23791 cws c cw put
23792 /m m bpcw add def
23793 /c c 1 add def
23794 } loop
23795 /cws cws 0 c getinterval def
23796
23797 options /debugcws known { /bwipp.debugcws cws //raiseerror exec } if
23798
23799 % Reed-Solomon algorithm
23800 /rscodes {
23801
23802 /rspm exch def
23803 /rsgf exch def
23804 /rsnc exch def
23805 /rscws exch def
23806
23807 % Calculate the log and anti-log tables
23808 /rsalog [ 1 rsgf 1 sub { dup 2 mul dup rsgf ge {rspm xor} if } repeat ] def
23809 /rslog rsgf array def
23810 1 1 rsgf 1 sub {dup rsalog exch get exch rslog 3 1 roll put} for
23811
23812 % Function to calculate the product in the field
23813 /rsprod {
23814 2 copy 0 ne exch 0 ne and {
23815 rslog exch get exch rslog exch get add rsgf 1 sub mod rsalog exch get
23816 } {
23817 pop pop 0
23818 } ifelse
23819 } def
23820
23821 % Generate the coefficients
23822 /coeffs [ 1 rsnc {0} repeat ] def
23823 1 1 rsnc {
23824 /i exch def
23825 coeffs i coeffs i 1 sub get put
23826 i 1 sub -1 1 {
23827 /j exch def
23828 coeffs j coeffs j 1 sub get coeffs j get rsalog i get rsprod xor put
23829 } for
23830 coeffs 0 coeffs 0 get rsalog i get rsprod put
23831 } for
23832
23833 % Extend the input with the error correction values
23834 /nd rscws length def
23835 /rscws [ rscws aload pop rsnc {0} repeat 0 ] def
23836 0 1 nd 1 sub {
23837 /k exch rscws exch get rscws nd get xor def
23838 0 1 rsnc 1 sub {
23839 /j exch def
23840 rscws nd j add rscws nd j add 1 add get k coeffs rsnc j sub 1 sub get rsprod xor put
23841 } for
23842 } for
23843
23844 % Return all but the last codeword
23845 rscws 0 rscws length 1 sub getinterval
23846
23847 } def
23848
23849 % Create the codewords and bit string for the mode
23850 format (full) eq {
23851 /mode layers 1 sub 11 bitshift cws length 1 sub add def
23852 readerinit {/mode mode 2#0000010000000000 or def} if
23853 /mode [
23854 mode 2#1111000000000000 and -12 bitshift
23855 mode 2#0000111100000000 and -8 bitshift
23856 mode 2#0000000011110000 and -4 bitshift
23857 mode 2#0000000000001111 and
23858 ] def
23859 /mode mode 6 16 19 rscodes def
23860 } if
23861 format (compact) eq {
23862 /mode layers 1 sub 6 bitshift cws length 1 sub add def
23863 readerinit {/mode mode 2#00100000 or def} if
23864 /mode [
23865 mode 2#11110000 and -4 bitshift
23866 mode 2#00001111 and
23867 ] def
23868 /mode mode 5 16 19 rscodes def
23869 } if
23870 format (rune) eq {
23871 /mode barcode cvi def
23872 /mode [
23873 mode 2#11110000 and -4 bitshift
23874 mode 2#00001111 and
23875 ] def
23876 /mode mode 5 16 19 rscodes def
23877 /mode [mode {2#1010 xor} forall] def % Invert alternate bits
23878 } if
23879 /modebits mode length 4 mul string def
23880 0 1 modebits length 1 sub {modebits exch (0) putinterval} for
23881 0 1 mode length 1 sub {
23882 /i exch def
23883 modebits mode i get 2 4 string cvrs dup length 4 exch sub 4 i mul add exch putinterval
23884 } for
23885
23886 % Extend the data codewords with error correction codewords to create the bit string for the data
23887 {
23888 /rsparams [
23889 [] [] [] [] [] []
23890 [ 64 67 ] % 6-bit codewords
23891 []
23892 [ 256 301 ] % 8-bit codewords
23893 []
23894 [ 1024 1033 ] % 10-bit codewords
23895 []
23896 [ 4096 4201 ] % 12-bit codewords
23897 ] def
23898 } ctxdef
23899 /cws cws ncws cws length sub rsparams bpcw get aload pop rscodes def
23900 format (full) eq {
23901 /databits layers layers mul 16 mul layers 112 mul add string def
23902 } {
23903 /databits layers layers mul 16 mul layers 88 mul add string def
23904 } ifelse
23905 0 1 databits length 1 sub {databits exch (0) putinterval} for
23906 0 1 ncws 1 sub {
23907 /i exch def
23908 databits cws i get 2 bpcw string cvrs
23909 dup length bpcw exch sub bpcw i mul add databits length ncws bpcw mul sub add
23910 exch putinterval
23911 } for
23912
23913 % Move to a point in the cartesian plane centered on the bullseye
23914 /cmv {size mul sub mid add} def
23915
23916 % Move to a bit position within a layer
23917 /lmv {
23918 /lbit exch def
23919 /llyr exch def
23920 /lwid fw llyr 4 mul add def
23921 /ldir lbit 2 idiv lwid idiv def
23922 ldir 0 eq { % Top
23923 lwid 1 sub 2 idiv neg 1 add lbit 2 idiv lwid mod add
23924 fw 1 sub 2 idiv llyr 2 mul add lbit 2 mod add
23925 cmv
23926 } if
23927 ldir 1 eq { % Right
23928 fw 2 idiv llyr 2 mul add lbit 2 mod add
23929 lwid 1 sub 2 idiv 1 sub lbit 2 idiv lwid mod sub
23930 cmv
23931 } if
23932 ldir 2 eq { % Bottom
23933 lwid 2 idiv neg 1 add lbit 2 idiv lwid mod add neg
23934 fw 2 idiv llyr 2 mul add lbit 2 mod add neg
23935 cmv
23936 } if
23937 ldir 3 eq { % Left
23938 fw 1 sub 2 idiv llyr 2 mul add lbit 2 mod add neg
23939 lwid 2 idiv 1 sub lbit 2 idiv lwid mod sub neg
23940 cmv
23941 } if
23942 } def
23943
23944 % Create the pixel map
23945 % For full symbols we disregard the reference grid at this stage
23946 format (full) eq {/fw 12 def} {/fw 9 def} ifelse
23947 /size fw layers 4 mul add 2 add def
23948 /pixs [size size mul {-1} repeat] def
23949 /mid size 1 sub 2 idiv size mul size 1 sub 2 idiv add def
23950
23951 % Data layers
23952 /i 0 def
23953 1 1 layers {
23954 /layer exch def
23955 0 1 fw layer 4 mul add 8 mul 1 sub {
23956 /pos exch def
23957 pixs layer pos lmv databits databits length i sub 1 sub get 48 sub put
23958 /i i 1 add def
23959 } for
23960 } for
23961
23962 % For full symbols expand the pixel map by inserting the reference grid
23963 format (full) eq {
23964 /fw 13 def
23965 /size fw layers 4 mul add 2 add layers 10.5 add 7.5 div 1 sub cvi 2 mul add def
23966 /mid size size mul 2 idiv def
23967 /npixs [size size mul {-2} repeat] def
23968 0 16 size 2 idiv {
23969 /i exch def
23970 0 1 size 1 sub {
23971 /j exch def
23972 npixs size 2 idiv neg j add i cmv [size 2 idiv j add i add 1 add 2 mod] putinterval
23973 npixs size 2 idiv neg j add i neg cmv [size 2 idiv j add i add 1 add 2 mod] putinterval
23974 npixs i size 2 idiv neg j add cmv [size 2 idiv j add i add 1 add 2 mod] putinterval
23975 npixs i neg size 2 idiv neg j add cmv [size 2 idiv j add i add 1 add 2 mod] putinterval
23976 } for
23977 } for
23978 /j 0 def
23979 0 1 npixs length 1 sub {
23980 /i exch def
23981 npixs i get -2 eq {
23982 npixs i pixs j get put
23983 /j j 1 add def
23984 } if
23985 } for
23986 /pixs npixs def
23987 } if
23988
23989 % Finder pattern
23990 /fw fw 2 idiv def
23991 fw neg 1 fw {
23992 /i exch def
23993 fw neg 1 fw {
23994 /j exch def
23995 pixs i j cmv
23996 i abs j abs gt {i abs} {j abs} ifelse 1 add 2 mod
23997 put
23998 } for
23999 } for
24000
24001 % Orientation bits
24002 [ [ fw 1 add neg fw 1 ] [ fw 1 add neg fw 1 add 1 ]
24003 [ fw neg fw 1 add 1 ] [ fw 1 add fw 1 add 1 ]
24004 [ fw 1 add fw 1 ] [ fw 1 add fw neg 1 ]
24005 [ fw fw 1 add 0 ] [ fw 1 add fw 1 add neg 0 ]
24006 [ fw fw 1 add neg 0 ] [ fw neg fw 1 add neg 0 ]
24007 [ fw 1 add neg fw 1 add neg 0 ] [ fw 1 add neg fw neg 0 ]
24008 ] {pixs exch aload pop 3 1 roll cmv exch put} forall
24009
24010 % Mode ring
24011 {
24012 /modemapfull [
24013 [-5 7] [-4 7] [-3 7] [-2 7] [-1 7] [ 1 7] [ 2 7] [ 3 7] [ 4 7] [ 5 7]
24014 [ 7 5] [ 7 4] [ 7 3] [ 7 2] [ 7 1] [ 7 -1] [ 7 -2] [ 7 -3] [ 7 -4] [ 7 -5]
24015 [ 5 -7] [ 4 -7] [ 3 -7] [ 2 -7] [ 1 -7] [-1 -7] [-2 -7] [-3 -7] [-4 -7] [-5 -7]
24016 [-7 -5] [-7 -4] [-7 -3] [-7 -2] [-7 -1] [-7 1] [-7 2] [-7 3] [-7 4] [-7 5]
24017 ] def
24018 /modemapcompact [
24019 [-3 5] [-2 5] [-1 5] [ 0 5] [ 1 5] [ 2 5] [ 3 5]
24020 [ 5 3] [ 5 2] [ 5 1] [ 5 0] [ 5 -1] [ 5 -2] [ 5 -3]
24021 [ 3 -5] [ 2 -5] [ 1 -5] [ 0 -5] [-1 -5] [-2 -5] [-3 -5]
24022 [-5 -3] [-5 -2] [-5 -1] [-5 0] [-5 1] [-5 2] [-5 3]
24023 ] def
24024 } ctxdef
24025 /modemap format (full) eq {modemapfull} {modemapcompact} ifelse def
24026 0 1 modemap length 1 sub {
24027 pixs modemap 2 index get aload pop cmv modebits 3 index get 48 sub put
24028 pop
24029 } for
24030
24031 <<
24032 /ren /renmatrix
24033 /pixs pixs
24034 /pixx size
24035 /pixy size
24036 /height size 2 mul 72 div
24037 /width size 2 mul 72 div
24038 /opt options
24039 >>
24040
24041 dontdraw not //renmatrix if
24042
24043 //unloadctx exec
24044
24045 end
24046
24047 }
24048 [/barcode] {null def} forall
24049 bind def
24050 /azteccode dup load /uk.co.terryburton.bwipp defineresource pop
24051 end
24052 /setpacking where {pop setpacking} if
24053 %%EndData
24054 %%EndResource
24055 % --END ENCODER azteccode--
24056
24057 % --BEGIN ENCODER azteccodecompact--
24058 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix azteccode--
24059 % --DESC: Compact Aztec Code
24060 % --EXAM: 1234
24061 % --EXOP:
24062 % --RNDR: renmatrix
24063 %%BeginResource: uk.co.terryburton.bwipp azteccodecompact 0.0 2025111800 66132 65962
24064 %%BeginData: 36 ASCII Lines
24065 /setpacking where {pop currentpacking true setpacking} if
24066 10 dict
24067 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
24068 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
24069 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
24070 dup /azteccode dup /uk.co.terryburton.bwipp findresource put
24071 begin
24072 /azteccodecompact {
24073
24074 20 dict begin % Confine variables to local scope
24075
24076 /ctx null def
24077 /dontdraw false def
24078
24079 //processoptions exec /options exch def
24080 /barcode exch def
24081
24082 % Get the result of encoding with azteccode with format=compact
24083 options (dontdraw) true put
24084 options (format) (compact) put
24085
24086 /args barcode options //azteccode exec def
24087
24088 args (opt) options put
24089 args
24090
24091 dontdraw not //renmatrix if
24092
24093 end
24094
24095 }
24096 [/barcode] {null def} forall
24097 bind def
24098 /azteccodecompact dup load /uk.co.terryburton.bwipp defineresource pop
24099 end
24100 /setpacking where {pop setpacking} if
24101 %%EndData
24102 %%EndResource
24103 % --END ENCODER azteccodecompact--
24104
24105 % --BEGIN ENCODER aztecrune--
24106 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix azteccode--
24107 % --DESC: Aztec Runes
24108 % --EXAM: 1
24109 % --EXOP:
24110 % --RNDR: renmatrix
24111 %%BeginResource: uk.co.terryburton.bwipp aztecrune 0.0 2025111800 66101 65938
24112 %%BeginData: 36 ASCII Lines
24113 /setpacking where {pop currentpacking true setpacking} if
24114 10 dict
24115 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
24116 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
24117 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
24118 dup /azteccode dup /uk.co.terryburton.bwipp findresource put
24119 begin
24120 /aztecrune {
24121
24122 20 dict begin % Confine variables to local scope
24123
24124 /ctx null def
24125 /dontdraw false def
24126
24127 //processoptions exec /options exch def
24128 /barcode exch def
24129
24130 % Get the result of encoding with azteccode with format=rune
24131 options (dontdraw) true put
24132 options (format) (rune) put
24133
24134 /args barcode options //azteccode exec def
24135
24136 args (opt) options put
24137 args
24138
24139 dontdraw not //renmatrix if
24140
24141 end
24142
24143 }
24144 [/barcode] {null def} forall
24145 bind def
24146 /aztecrune dup load /uk.co.terryburton.bwipp defineresource pop
24147 end
24148 /setpacking where {pop setpacking} if
24149 %%EndData
24150 %%EndResource
24151 % --END ENCODER aztecrune--
24152
24153 % --BEGIN ENCODER codeone--
24154 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix--
24155 % --DESC: Code One
24156 % --EXAM: Code One
24157 % --EXOP:
24158 % --RNDR: renmatrix
24159 %%BeginResource: uk.co.terryburton.bwipp codeone 0.0 2025111800 211492 237022
24160 %%BeginData: 921 ASCII Lines
24161 /setpacking where {pop currentpacking true setpacking} if
24162 10 dict
24163 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
24164 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
24165 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
24166 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
24167 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
24168 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
24169 begin
24170 /codeone {
24171
24172 20 dict begin
24173
24174 /ctx null def
24175 /dontdraw false def
24176 /version (unset) def
24177 /parse false def
24178 /parsefnc false def
24179
24180 //processoptions exec /options exch def
24181 /barcode exch def
24182
24183 false [ (unset) (T-16) (T-32) (T-48) (S-10) (S-20) (S-30) (A) (B) (C) (D) (E) (F) (G) (H) ]
24184 { version eq or } forall not {
24185 /bwipp.codeoneBadVersion (version must be A to H, T-16, T-32, T-48, S-10, S-20 or S-30) //raiseerror exec
24186 } if
24187
24188 /codeone //loadctx exec
24189
24190 /stype version 0 1 getinterval (S) eq def
24191 /ttype version 0 1 getinterval (T) eq def
24192
24193 {
24194 /stypevals [
24195 (1)
24196 (1010)
24197 (1100100)
24198 (1111101000)
24199 (10011100010000)
24200 (11000011010100000)
24201 (11110100001001000000)
24202 (100110001001011010000000)
24203 (101111101011110000100000000)
24204 (111011100110101100101000000000)
24205 (1001010100000010111110010000000000)
24206 (1011101001000011101101110100000000000)
24207 (1110100011010100101001010001000000000000)
24208 (10010001100001001110011100101010000000000000)
24209 (10110101111001100010000011110100100000000000000)
24210 (11100011010111111010100100110001101000000000000000)
24211 (100011100001101111001001101111110000010000000000000000)
24212 (101100011010001010111100001011101100010100000000000000000)
24213 ] def
24214
24215 % Basic metrics for the each symbol
24216 % ver row col dcol dcws rscw rsbl ro ri rl
24217 /stypemetrics [
24218 [ (S-10) 8 11 10 4 4 1 99 99 99 ]
24219 [ (S-20) 8 21 20 8 8 1 99 99 99 ]
24220 [ (S-30) 8 31 30 12 12 1 99 99 99 ]
24221 ] def
24222
24223 % Basic metrics for the each symbol
24224 % ver row col dcol dcws rscw rsbl ro ri rl
24225 /nonstypemetrics [
24226 [ (A) 16 18 16 10 10 1 4 99 6 ]
24227 [ (B) 22 22 20 19 16 1 4 99 8 ]
24228 [ (C) 28 32 28 44 26 1 4 22 11 ]
24229 [ (D) 40 42 36 91 44 1 4 16 16 ]
24230 [ (E) 52 54 48 182 70 1 4 22 22 ]
24231 [ (F) 70 76 68 370 140 2 4 22 31 ]
24232 [ (G) 104 98 88 732 280 4 6 21 47 ]
24233 [ (H) 148 134 120 1480 560 8 6 20 69 ]
24234 [ (T-16) 16 17 16 10 10 1 99 99 99 ]
24235 [ (T-32) 16 33 32 24 16 1 99 99 99 ]
24236 [ (T-48) 16 49 48 38 22 1 99 99 99 ]
24237 ] def
24238
24239 % Special characters
24240 /fnc1 -1 def /fnc3 -2 def
24241 /lC -5 def /lB -6 def /lX -7 def /lT -8 def /lD -9 def /unl -10 def
24242 /fnc2 -11 def /fnc4 -12 def /sft1 -13 def /sft2 -14 def /sft3 -15 def /eci -16 def /pad -17 def /fnc1lD -18 def
24243 /unlcw 255 def
24244
24245 /Avals <<
24246 0 1 128 {dup 1 add} for
24247 pad 129
24248 0 1 99 { % Double digits
24249 dup 10 2 string cvrs (00) 2 string copy dup 2 3 index length sub 4 -1 roll putinterval
24250 exch 130 add
24251 } for
24252 229 [ lC lB fnc1 fnc2 fnc3 fnc4 fnc1lD ] {exch 1 add dup} forall pop
24253 lX 238
24254 lT 239
24255 % 240-255 lD + 4 bits
24256 >> def
24257 /Avals <<
24258 Avals {[exch]} forall
24259 >> def
24260
24261 /CNvals <<
24262 sft1 0
24263 sft2 1
24264 sft3 2
24265 32 3
24266 48 1 57 {dup 44 sub} for % 0-9
24267 65 1 90 {dup 51 sub} for % A-Z
24268 >> def
24269 /C1vals << 0 1 31 {dup} for >> def
24270 /C2vals <<
24271 33 1 47 {dup 33 sub} for
24272 58 1 64 {dup 43 sub} for
24273 91 1 95 {dup 69 sub} for
24274 fnc1 27
24275 fnc2 28
24276 fnc3 29
24277 fnc4 30
24278 pad 31
24279 >> def
24280 /C3vals << 96 1 127 {dup 96 sub} for >> def
24281 /Cvals <<
24282 CNvals {[exch]} forall
24283 C1vals {[exch CNvals sft1 get exch]} forall
24284 C2vals {[exch CNvals sft2 get exch]} forall
24285 C3vals {[exch CNvals sft3 get exch]} forall
24286 >> def
24287
24288 /TNvals <<
24289 sft1 0
24290 sft2 1
24291 sft3 2
24292 32 3
24293 48 1 57 {dup 44 sub} for % 0-9
24294 97 1 122 {dup 83 sub} for % a-z
24295 >> def
24296 /T1vals << 0 1 31 {dup} for >> def
24297 /T2vals <<
24298 33 1 47 {dup 33 sub} for
24299 58 1 64 {dup 43 sub} for
24300 91 1 95 {dup 69 sub} for
24301 fnc1 27
24302 fnc2 28
24303 fnc3 29
24304 fnc4 30
24305 pad 31
24306 >> def
24307 /T3vals <<
24308 96 0
24309 65 1 90 {dup 64 sub} for
24310 123 1 127 {dup 96 sub} for
24311 >> def
24312 /Tvals <<
24313 TNvals {[exch]} forall
24314 T1vals {[exch TNvals sft1 get exch]} forall
24315 T2vals {[exch TNvals sft2 get exch]} forall
24316 T3vals {[exch TNvals sft3 get exch]} forall
24317 >> def
24318
24319 % Extended ASCII mappings
24320 128 1 255 {
24321 /i exch def
24322 Avals i [ Avals fnc4 get aload pop Avals i 128 sub get aload pop ] put
24323 Cvals i [ Cvals fnc4 get aload pop Cvals i 128 sub get aload pop ] put
24324 Tvals i [ Tvals fnc4 get aload pop Tvals i 128 sub get aload pop ] put
24325 } for
24326
24327 /Xvals <<
24328 13 0
24329 42 1
24330 62 2
24331 32 3
24332 48 1 57 {dup 44 sub} for
24333 65 1 90 {dup 51 sub} for
24334 >> def
24335 /Xvals <<
24336 Xvals {[exch]} forall
24337 >> def
24338
24339 /Bvals <<
24340 0 1 255 {dup} for
24341 >> def
24342 /Bvals <<
24343 Bvals {[exch]} forall
24344 >> def
24345
24346 /encvals [ Avals Cvals Tvals Xvals -1 Bvals ] def
24347
24348 /A 0 def /C 1 def /T 2 def /X 3 def /D 4 def /B 5 def
24349 } ctxdef
24350
24351 stype {
24352
24353 barcode {
24354 dup 48 lt exch 57 gt or {
24355 /bwipp.codeoneStypeNonDigit (S-Type symbols can only contain digits) //raiseerror exec
24356 } if
24357 } forall
24358
24359 /barlen barcode length def
24360 barlen 18 gt {
24361 /bwipp.codeoneStypeTooLong (Maximum length exceeded) //raiseerror exec
24362 } if
24363
24364 /normalize {
24365 /base exch def
24366 /num exch def
24367 num length 1 sub -1 1 {
24368 /i exch def
24369 num i 1 sub 2 copy get num i get base idiv add put
24370 num i num i get base mod put
24371 } for
24372 { %loop - extend input as necessary
24373 num 0 get base lt {exit} if
24374 /num [0 num aload pop] def
24375 num 0 num 0 get num 1 get base idiv add put
24376 num 1 num 1 get base mod put
24377 } loop
24378 % Trim leading zeros
24379 /num [/i true def num {dup 0 eq i and {pop} {/i false def} ifelse} forall] def
24380 num length 0 eq {/num [0] def} if
24381 num
24382 } def
24383
24384 /bigadd {
24385 2 copy length exch length
24386 2 copy sub abs /offset exch def
24387 lt {exch} if
24388 /a exch def /b exch def
24389 0 1 b length 1 sub {
24390 dup a exch offset add 2 copy get b 5 -1 roll get add put
24391 } for
24392 a
24393 } def
24394
24395 /barlen barcode length def
24396
24397 % Convert value plus one to binary
24398 /v [ 1 ] def
24399 0 1 barlen 1 sub {
24400 /i exch def
24401 [ stypevals i get {48 sub barcode barlen i sub 1 sub get 48 sub mul} forall ]
24402 v bigadd /v exch def
24403 } for
24404 /v v 2 normalize def
24405
24406 % Split into 5-bit codewords
24407 /v [ 5 v length 5 mod sub 5 mod {0} repeat v aload pop ] def
24408 /cws v length 5 idiv array def
24409 0 1 cws length 1 sub {
24410 /i exch def
24411 v i 5 mul 5 getinterval
24412 0 exch {add 2 mul} forall 2 idiv
24413 cws exch i exch put
24414 } for
24415
24416 /metrics stypemetrics def
24417
24418 } { % Standard and type-T
24419
24420 % Convert input into bytes accounting for FNC characters
24421 /fncvals <<
24422 /parse parse
24423 /parsefnc parsefnc
24424 /eci true
24425 (FNC1) fnc1
24426 (FNC3) fnc3
24427 >> def
24428 /msg barcode fncvals //parseinput exec def
24429 /msglen msg length def
24430
24431 % Code One stores ECIs in data
24432 /eciesc 16#5c def % We choose \ as a typical default
24433 /numecis 0 msg { -1000000 le {1 add} if } forall def
24434 numecis 0 gt {
24435 /msgtmp msg length 2 mul numecis 6 mul add 2 add array def
24436 msgtmp 0 pad put
24437 msgtmp 1 eciesc put
24438 /j 2 def
24439 0 1 msg length 1 sub {
24440 msg exch get
24441 dup -1000000 le {
24442 neg 10 7 string cvrs 1 6 getinterval {} forall 6 array astore
24443 msgtmp exch j 1 add exch putinterval
24444 msgtmp j eciesc put
24445 /j j 7 add def
24446 } {
24447 dup eciesc ne {
24448 msgtmp exch j exch put
24449 /j j 1 add def
24450 } {
24451 pop
24452 msgtmp j eciesc put
24453 msgtmp j 1 add eciesc put
24454 /j j 2 add def
24455 } ifelse
24456 } ifelse
24457 } for
24458 /msg msgtmp 0 j getinterval def
24459 /msglen msg length def
24460 } if
24461
24462 /metrics nonstypemetrics def
24463
24464 % Select metrics of an appropriate symbol
24465 /fullcws [] def
24466 metrics {
24467 /m exch def
24468 /vers m 0 get def % Version of symbol
24469 /dcws m 4 get def % Data codewords in symbol
24470 /okay true def
24471 version (unset) eq {
24472 vers length 1 ne {/okay false def} if
24473 } {
24474 version vers ne {/okay false def} if
24475 } ifelse
24476 okay {/fullcws [ fullcws aload pop dcws ] def} if
24477 } forall
24478 /numremcws [ 1480 {10000} repeat ] def
24479 fullcws {numremcws exch 1 sub 1 put} forall
24480 1478 -1 0 {
24481 /i exch def
24482 numremcws i get 1 ne {
24483 numremcws i numremcws i 1 add get 1 add put
24484 } if
24485 } for
24486
24487 /numD [ msglen {0} repeat 0 ] def
24488 /nextXterm [ msglen {0} repeat 9999 ] def
24489 /nextNonX [ msglen {0} repeat 9999 ] def
24490 msglen 1 sub -1 0 {
24491 /i exch def
24492 /barchar msg i get def
24493 barchar 48 ge barchar 57 le and {
24494 numD i numD i 1 add get 1 add put
24495 } if
24496 barchar 13 eq barchar 42 eq or barchar 62 eq or {
24497 nextXterm i 0 put
24498 } {
24499 nextXterm i nextXterm i 1 add get 1 add put
24500 } ifelse
24501 Xvals barchar known not {
24502 nextNonX i 0 put
24503 } {
24504 nextNonX i nextNonX i 1 add get 1 add put
24505 } ifelse
24506 } for
24507 /nextXterm [nextXterm {dup 10000 gt {pop 10000} if} forall] def
24508 /nextNonX [nextNonX {dup 10000 gt {pop 10000} if} forall] def
24509
24510 /isD {char 48 ge char 57 le and} def
24511 /isC {CNvals char known} def
24512 /isT {TNvals char known} def
24513 /isX {Xvals char known} def
24514 /isEA {char 127 gt} def
24515 /isFN {char 0 lt} def
24516 /XtermFirst {dup nextXterm exch get exch nextNonX exch get lt} def
24517
24518 /lookup {
24519 /ac 1 def /cc 2 def /tc 2 def /xc 2 def /bc 3 def
24520 mode A eq {/ac 0 def /cc 1 def /tc 1 def /xc 1 def /bc 2 def} if
24521 mode C eq {/cc 0 def} if
24522 mode T eq {/tc 0 def} if
24523 mode X eq {/xc 0 def} if % Assume mistake in spec
24524 mode B eq {/bc 0 def} if
24525 1 { % common exit
24526 /k 0 def { % loop
24527 i k add msglen eq {
24528 true [ac cc tc xc ] {bc exch ceiling le and} forall {B exit} if
24529 true [ cc tc xc bc] {ac exch ceiling le and} forall {A exit} if
24530 true [ tc xc ] {cc ceiling exch ceiling le and} forall {C exit} if
24531 true [ xc ] {tc ceiling exch ceiling le and} forall {T exit} if
24532 X exit
24533 } if
24534 /char msg i k add get def
24535 /ac ac isD {1 2 div add} {isEA {ceiling 2 add} {ceiling 1 add} ifelse} ifelse def
24536 /cc cc isC {2 3 div add} {isEA { 8 3 div add } { 4 3 div add } ifelse} ifelse def
24537 /tc tc isT {2 3 div add} {isEA { 8 3 div add } { 4 3 div add } ifelse} ifelse def
24538 /xc xc isX {2 3 div add} {isEA {13 3 div add } {10 3 div add } ifelse} ifelse def
24539 /bc bc isFN {3 add} {1 add} ifelse def
24540 k 3 ge { % Checking after at least 4 characters (cf. Data Matrix), not 3 as in spec Step Q
24541 true [ac cc tc xc ] {bc 1 add exch ceiling le and} forall {B exit} if
24542 true [ cc tc xc bc] {ac 1 add exch ceiling le and} forall {A exit} if
24543 true [ac cc xc bc] {tc ceiling 1 add exch ceiling le and} forall {T exit} if
24544 true [ac tc ] {cc ceiling 1 add exch ceiling le and} forall {
24545 cc ceiling xc ceiling lt {C exit} if
24546 cc xc eq {i k add 1 add XtermFirst {X exit} {C exit} ifelse} if
24547 } if
24548 true [ac cc tc bc] {xc ceiling 1 add exch ceiling le and} forall {X exit} if
24549 } if
24550 /k k 1 add def
24551 } loop
24552 } repeat
24553 } def
24554
24555 /addtocws {
24556 dup length j add 1480 gt {
24557 pop /bwipp.codeoneTooLong (Maximum length exceeded) //raiseerror exec
24558 } if
24559 dup cws exch j exch putinterval
24560 /j exch length j add def
24561 } def
24562
24563 /tobin {
24564 string dup length 1 sub 0 exch 1 exch {1 index exch 48 put} for
24565 dup 3 -1 roll 2 2 index length string cvrs dup length 2 index length exch sub exch putinterval
24566 [ exch {48 sub} forall ]
24567 } def
24568
24569 /encA {
24570 1 { % Common exit
24571 numD i get 21 ge {
24572 /Dbits [ 1 1 1 1 ] def
24573 /mode D def
24574 exit
24575 } if
24576 numD i get dup 13 ge exch i add msglen eq and {
24577 /Dbits [ 1 1 1 1 ] def
24578 /mode D def
24579 exit
24580 } if
24581 numD i get 2 ge {
24582 2 string dup 0 msg i get put dup 1 msg i 1 add get put Avals exch get addtocws
24583 /i i 2 add def
24584 exit
24585 } if
24586 msg i get fnc1 eq {
24587 numD i 1 add get 15 ge {
24588 Avals fnc1lD get addtocws
24589 /i i 1 add def
24590 /Dbits [] def
24591 /mode D def
24592 exit
24593 } if
24594 numD i 1 add get dup 7 ge exch i add 1 add msglen eq and {
24595 Avals fnc1lD get addtocws
24596 /i i 1 add def
24597 /Dbits [] def
24598 /mode D def
24599 exit
24600 } if
24601 } if
24602 /newmode lookup def
24603 newmode mode ne {
24604 Avals [-1 lC lT lX lD lB] newmode get get addtocws
24605 /mode newmode def
24606 exit
24607 } if
24608 Avals msg i get get addtocws
24609 /i i 1 add def
24610 exit
24611 } repeat
24612 } def
24613
24614 /CTXvalstocws {
24615 /in exch def
24616 mark
24617 0 3 in length 1 sub {
24618 in exch 3 getinterval 0 exch {add 40 mul} forall 40 idiv 1 add
24619 dup 256 idiv exch 256 mod
24620 } for
24621 counttomark array astore exch pop
24622 } def
24623
24624 /encCTX {
24625 /p 0 def
24626 /ctxvals 2220 array def
24627
24628 % Lookup the values for each character
24629 {
24630 i msglen eq {exit} if
24631 p 3 mod 0 eq {
24632 numD i get 12 ge {
24633 ctxvals 0 p getinterval CTXvalstocws addtocws
24634 [unlcw] addtocws
24635 /mode A def
24636 exit
24637 } if
24638 numD i get dup 8 ge exch i add msglen eq and {
24639 ctxvals 0 p getinterval CTXvalstocws addtocws
24640 [unlcw] addtocws
24641 /mode A def
24642 exit
24643 } if
24644 mode X eq { % Steps E1c, E2
24645 Xvals msg i get known not {
24646 ctxvals 0 p getinterval CTXvalstocws addtocws
24647 % Unlatch to ASCII unless one codeword left and single ASCII to encode
24648 numremcws j get 1 ne msg i get 127 gt or {
24649 [unlcw] addtocws
24650 } if
24651 /mode A def
24652 exit
24653 } if
24654 i 1 add msglen lt {
24655 Xvals msg i 1 add get known not {exit} if
24656 i 2 add msglen lt {
24657 Xvals msg i 2 add get known not {exit} if
24658 } if
24659 } if
24660 } {
24661 lookup mode ne {
24662 ctxvals 0 p getinterval CTXvalstocws addtocws
24663 [unlcw] addtocws
24664 /mode A def
24665 exit
24666 } if
24667 } ifelse
24668 msglen i sub 3 le { % Check end of data conditions
24669 /remcws numremcws j p 3 idiv 2 mul add get def
24670 /remvals [
24671 msg i msglen i sub getinterval {
24672 dup encvals mode get exch known {
24673 encvals mode get exch get aload pop
24674 } { % Unencodable X12 characters
24675 pop -1 -1 -1 -1
24676 } ifelse
24677 } forall
24678 ] def
24679 remcws 2 eq remvals length 3 eq and {
24680 % Encode and omit unlatch
24681 [
24682 ctxvals 0 p getinterval aload pop
24683 remvals aload pop
24684 ] CTXvalstocws addtocws
24685 /mode A def
24686 /i msglen def
24687 exit
24688 } if
24689 remcws 2 eq remvals length 2 eq and mode X ne and {
24690 % Encode with sft1 as third value, omit unlatch
24691 [
24692 ctxvals 0 p getinterval aload pop
24693 remvals aload pop
24694 encvals mode get sft1 get aload pop
24695 ] CTXvalstocws addtocws
24696 /mode A def
24697 /i msglen def
24698 exit
24699 } if
24700 remcws 2 eq remvals length 1 eq and {
24701 % Unlatch to ASCII
24702 ctxvals 0 p getinterval CTXvalstocws addtocws
24703 [unlcw] addtocws
24704 Avals msg i get get addtocws
24705 /mode A def
24706 /i msglen def
24707 exit
24708 } if
24709 remcws 1 eq remvals length 1 eq and {
24710 % Implied unlatch to ASCII
24711 ctxvals 0 p getinterval CTXvalstocws addtocws
24712 Avals msg i get get addtocws
24713 /mode A def
24714 /i msglen def
24715 exit
24716 } if
24717 } if
24718 } if
24719 encvals mode get msg i get get
24720 dup ctxvals exch p exch putinterval
24721 /p exch length p add def
24722 /i i 1 add def
24723 } loop
24724
24725 % Backtrack to a boundary and return to ASCII
24726 mode A ne {
24727 {
24728 p 3 mod 0 eq {exit} if
24729 /i i 1 sub def
24730 /p p encvals mode get msg i get get length sub def
24731 } loop
24732 [
24733 ctxvals 0 p getinterval aload pop
24734 ] CTXvalstocws addtocws
24735 [unlcw] addtocws
24736 /mode A def
24737 % Encode something to avoid latching immediately back
24738 i msglen ne {
24739 numD i get 2 ge {
24740 2 string dup 0 msg i get put dup 1 msg i 1 add get put Avals exch get addtocws
24741 /i i 2 add def
24742 } {
24743 Avals msg i get get addtocws
24744 /i i 1 add def
24745 } ifelse
24746 } if
24747 } if
24748
24749 } def
24750
24751 /encD {
24752
24753 { % loop
24754
24755 numD i get 3 lt {
24756
24757 /Drem 8 Dbits length 8 mod sub 8 mod def
24758 /remcws numremcws j Dbits length 8 idiv add get def
24759
24760 % Final codeword with no data
24761 numremcws j Dbits length 8 idiv add 1 sub get 1 sub 0 eq Drem 0 eq and % No remaining codewords and no bits
24762 remcws 1 eq Drem 0 ne and or % Or 1 remaining codeword and some bits
24763 i msglen eq and {
24764 Drem 4 eq Drem 6 eq or { /Dbits [ Dbits aload pop 1 1 1 1 ] def } if
24765 Drem 2 eq Drem 6 eq or { /Dbits [ Dbits aload pop 0 1 ] def } if
24766 exit
24767 } if
24768
24769 % Final digit or double-digit into final codeword as ASCII
24770 i msglen 1 sub eq numD i get 1 eq and
24771 i msglen 2 sub eq numD i get 2 eq and or
24772 remcws 1 eq and Drem 0 eq and {exit} if
24773
24774 % Latch to ASCII unless 4 or 6 bits remain in final codeword
24775 i msglen 1 sub eq numD i get 1 eq and
24776 remcws 1 eq and Drem 4 eq Drem 6 eq or and not {
24777 /Dbits [ Dbits aload pop 1 1 1 1 1 1 ] def
24778 /Drem 8 Dbits length 8 mod sub 8 mod def
24779 } if
24780
24781 % Try to encode a digit in remaining bits
24782 Drem 4 eq Drem 6 eq or {
24783 numD i get 1 ge {
24784 /Dbits [ Dbits aload pop msg i get 48 sub 1 add 4 tobin aload pop ] def
24785 /i i 1 add def
24786 } {
24787 /Dbits [ Dbits aload pop 1 1 1 1 ] def
24788 } ifelse
24789 /Drem Drem 4 sub def
24790 } if
24791 Drem 2 eq {
24792 /Dbits [ Dbits aload pop 0 1 ] def
24793 /Drem 0 def
24794 } if
24795
24796 exit
24797
24798 } if
24799
24800 % Three digit value plus one to ten bits
24801 /Dbits [
24802 Dbits aload pop
24803 0 msg i 3 getinterval {48 sub add 10 mul} forall 10 idiv
24804 1 add 10 tobin aload pop
24805 ] def
24806 /i i 3 add def
24807
24808 } loop
24809
24810 mark
24811 0 8 Dbits length 1 sub {
24812 Dbits exch 8 getinterval 0 exch {add 2 mul} forall 2 idiv
24813 } for
24814 counttomark array astore exch pop addtocws
24815 /mode A def
24816
24817 } def
24818
24819 /encB {
24820 /p 0 def /bvals 1480 array def {
24821 i msglen eq {exit} if
24822 msg i get 0 lt {exit} if % Function character
24823 lookup mode ne {exit} if
24824 bvals p msg i get put
24825 /p p 1 add def
24826 /i i 1 add def
24827 } loop
24828 /remcws numremcws j p add get 1 sub def
24829 /bvals [
24830 remcws 0 eq i msglen eq and { % Terminates symbol
24831 0
24832 } {
24833 p 250 lt {p} {p 250 idiv 249 add p 250 mod} ifelse
24834 } ifelse
24835 bvals 0 p getinterval aload pop
24836 ] def
24837 bvals addtocws
24838 /mode A def
24839 } def
24840
24841 % Derive the codewords
24842 /cws 1480 array def
24843 /mode A def /i 0 def /j 0 def {
24844 i msglen ge {exit} if
24845 [ /encA /encCTX /encCTX /encCTX /encD /encB ] mode get load exec
24846 } loop
24847 /cws cws 0 j getinterval def
24848
24849 } ifelse
24850
24851 % Select metrics of an appropriate symbol
24852 metrics {
24853 /m exch def
24854 /vers m 0 get def % Version of symbol
24855 /rows m 1 get def % Rows in symbol
24856 /cols m 2 get def % Columns in symbol
24857 /dcol m 3 get def % Data columns in symbol
24858 /dcws m 4 get def % Data codewords in symbol
24859 /rscw m 5 get def % Error correction codewords
24860 /rsbl m 6 get def % Error correction blocks
24861 /riso m 7 get def % Riser offset
24862 /risi m 8 get def % Riser interval
24863 /risl m 9 get def % Riser length
24864 /dcpb dcws rsbl idiv def % Data codewords per block
24865 /ecpb rscw rsbl idiv def % Error codewords per block
24866 /okay true def
24867 version (unset) ne version vers ne and {/okay false def} if % The version must match that supplied
24868 cws length dcws gt {/okay false def} if
24869 okay {exit} if
24870 } forall
24871
24872 okay not {
24873 /bwipp.codeoneNoValidSymbol (Maximum length exceeded) //raiseerror exec
24874 } if
24875
24876 % Extend cws to ncws codewords by addition of pad characters
24877 stype not {
24878 /cws [ cws aload pop dcws cws length sub {129} repeat ] def
24879 } {
24880 /cws [ dcws cws length sub {0} repeat cws aload pop ] def
24881 } ifelse
24882
24883 options /debugcws known { /bwipp.debugcws cws //raiseerror exec } if
24884
24885 % De-interleave the codewords into blocks
24886 /cwbs rsbl array def % Array of data codeword blocks
24887 /ecbs rsbl array def % Array of error correction blocks
24888 0 1 rsbl 1 sub {
24889 /i exch def
24890 /cwb dcpb array def
24891 0 1 dcpb 1 sub {
24892 /j exch def
24893 cwb j cws j rsbl mul i add get put
24894 } for
24895 cwbs i cwb put
24896 } for
24897
24898 % Log and anti-log tables and function to calculate product in the field
24899 /gf stype {32} {256} ifelse def
24900 /gf-1 gf 1 sub def
24901 /pm stype {37} {301} ifelse def
24902 /rsalog [ 1 gf-1 { dup 2 mul dup gf ge {pm xor} if } repeat ] def
24903 /rslog gf array def
24904 1 1 gf-1 {dup rsalog exch get exch rslog 3 1 roll put} for
24905 /rsprod {
24906 2 copy 0 ne exch 0 ne and {
24907 rslog exch get exch rslog exch get add gf-1 mod rsalog exch get
24908 } {
24909 pop pop 0
24910 } ifelse
24911 } def
24912
24913 % Generate the coefficients for the Reed-Solomon algorithm
24914 /coeffs [ 1 ecpb {0} repeat ] def
24915 0 1 ecpb 1 sub {
24916 /i exch def
24917 coeffs i 1 add coeffs i get put
24918 i -1 1 {
24919 /j exch def
24920 coeffs j coeffs j 1 sub get coeffs j get rsalog i get rsprod xor put
24921 } for
24922 coeffs 0 coeffs 0 get rsalog i get rsprod put
24923 } for
24924 /coeffs coeffs 0 coeffs length 1 sub getinterval def
24925
24926 % Reed-Solomon algorithm to derive the error correction codewords
24927 0 1 cwbs length 1 sub {
24928 /i exch def
24929 /rscws [ cwbs i get aload pop ecpb {0} repeat ] def
24930 0 1 dcpb 1 sub {
24931 /m exch def
24932 /k rscws m get def
24933 0 1 ecpb 1 sub {
24934 /j exch def
24935 rscws m j add 1 add coeffs ecpb j sub 1 sub get k rsprod rscws m j add 1 add get xor put
24936 } for
24937 } for
24938 ecbs i rscws dcpb ecpb getinterval put
24939 } for
24940
24941 % Extend codewords with the interleaved error correction codes
24942 /cws [ cws aload pop rscw {0} repeat ] def
24943 0 1 rscw 1 sub {
24944 /i exch def
24945 cws dcws i add ecbs i rsbl mod get i rsbl idiv get put
24946 } for
24947
24948 % Module matrix for layout of the codewords
24949 /mmat dcws rscw add stype {5} {8} ifelse mul array def
24950 /r 0 def /c 0 def
24951 0 stype {2} {1} ifelse cws length 1 sub {
24952 /i exch def
24953 stype not {
24954 (00000000) 8 string copy dup cws i get 2 8 string cvrs
24955 dup length 8 exch sub exch putinterval [ exch {48 sub} forall ]
24956 dup 0 4 getinterval /top exch def
24957 4 4 getinterval /bot exch def
24958 } {
24959 (00000) 5 string copy dup cws i get 2 5 string cvrs
24960 dup length 5 exch sub exch putinterval [ exch {48 sub} forall ]
24961 /c1 exch def
24962 (00000) 5 string copy dup cws i 1 add get 2 5 string cvrs
24963 dup length 5 exch sub exch putinterval [ exch {48 sub} forall ]
24964 /c2 exch def
24965 /top [ c1 0 3 getinterval aload pop c2 0 2 getinterval aload pop ] def
24966 /bot [ c1 3 2 getinterval aload pop c2 2 3 getinterval aload pop ] def
24967 } ifelse
24968 mmat r dcol mul c add top putinterval
24969 mmat r 1 add dcol mul c add bot putinterval
24970 /c c top length add def
24971 c dcol eq {/c 0 def /r r 2 add def} if
24972 } for
24973
24974 % Create bitmap and add finder patterns
24975 /mmv {cols mul add} def
24976 /pixs [ rows cols mul {-1} repeat ] def
24977
24978 % Centre pattern
24979 /artifact [
24980 {cols {0} repeat}
24981 {cols {1} repeat}
24982 {0 cols 2 sub {1} repeat 0}
24983 {0 1 cols 4 sub {0} repeat 1 0}
24984 {cols 1 sub 2 idiv {-1} repeat 1 cols 1 sub 2 idiv {-1} repeat}
24985 {cols 1 sub 2 idiv {-1} repeat 0 cols 1 sub 2 idiv {-1} repeat}
24986 {1 cols 2 sub {0} repeat 1}
24987 {1 0 cols 4 sub {1} repeat 0 1}
24988 ] def
24989 {
24990 /cpatmap <<
24991 /A (121343)
24992 /B (12134343)
24993 /C (12121343)
24994 /D (1213434343)
24995 /E (1212134343)
24996 /F (1212121343)
24997 /G (121213434343)
24998 /H (121212134343)
24999 /S (56661278)
25000 /T (5666666666127878)
25001 >> def
25002 } ctxdef
25003 /cpat cpatmap vers 0 1 getinterval get def
25004 pixs 0 rows cpat length sub 2 idiv mmv
25005 [ cpat {artifact exch 49 sub get exec} forall ] putinterval
25006
25007 % Risers
25008 0 1 risl 1 sub {
25009 /i exch def
25010 riso risi cols 1 sub {
25011 /j exch def
25012 [ 1 i 12 mod 0 eq {1} {0} ifelse ] dup
25013 pixs j i mmv
25014 3 -1 roll putinterval
25015 i risl 1 sub ne {
25016 pixs cols j sub 2 sub rows i sub 1 sub mmv
25017 3 -1 roll putinterval
25018 } {pop} ifelse
25019 } for
25020 } for
25021
25022 % Black dots
25023 {
25024 /blackdotmap <<
25025 /A [ [12 5] ]
25026 /B [ [16 7] ]
25027 /C [ [26 12] ]
25028 /D []
25029 /E [ [26 23] ]
25030 /F [ [26 32] [70 32] [26 34] [70 34] ]
25031 /G [ [27 48] [69 48] ]
25032 /H [ [26 70] [66 70] [106 70] [26 72] [66 72] [106 72] ]
25033 /S-10 []
25034 /S-20 [ [10 4] ]
25035 /S-30 [ [15 4] [15 6] ]
25036 /T-16 [ [8 10] ]
25037 /T-32 [ [16 10] [16 12] ]
25038 /T-48 [ [24 10] [24 12] [24 14] ]
25039 >> def
25040 } ctxdef
25041 blackdotmap vers get {pixs exch aload pop mmv 1 put} forall
25042
25043 % Place the modules onto a pixel map between alignment patterns
25044 /j 0 def
25045 0 1 pixs length 1 sub {
25046 /i exch def
25047 pixs i get -1 eq {
25048 pixs i mmat j get put
25049 /j j 1 add def
25050 } if
25051 } for
25052
25053 % Return the arguments
25054 <<
25055 /ren /renmatrix
25056 /pixs pixs
25057 /pixx cols
25058 /pixy rows
25059 /height rows 72 div 2 mul
25060 /width cols 72 div 2 mul
25061 stype ttype or {
25062 /borderleft 1.0
25063 /borderright 1.0
25064 /bordertop 0.0
25065 /borderbottom 1.0
25066 } if
25067 /opt options
25068 >>
25069
25070 dontdraw not //renmatrix if
25071
25072 //unloadctx exec
25073
25074 end
25075
25076 }
25077 [/barcode] {null def} forall
25078 bind def
25079 /codeone dup load /uk.co.terryburton.bwipp defineresource pop
25080 end
25081 /setpacking where {pop setpacking} if
25082 %%EndData
25083 %%EndResource
25084 % --END ENCODER codeone--
25085
25086 % --BEGIN ENCODER hanxin--
25087 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix--
25088 % --DESC: Han Xin Code
25089 % --EXAM: This is Han Xin
25090 % --EXOP:
25091 % --RNDR: renmatrix
25092 %%BeginResource: uk.co.terryburton.bwipp hanxin 0.0 2025111800 329976 362728
25093 %%BeginData: 884 ASCII Lines
25094 /setpacking where {pop currentpacking true setpacking} if
25095 10 dict
25096 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
25097 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
25098 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
25099 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
25100 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
25101 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
25102 begin
25103 /hanxin {
25104
25105 20 dict begin
25106
25107 /ctx null def
25108 /dontdraw false def
25109 /version (unset) def % 1-84
25110 /eclevel (L2) def % L1, L2, L3 or L4
25111 /parse false def
25112 /parsefnc false def
25113 /mask -1 def
25114
25115 //processoptions exec /options exch def
25116 /barcode exch def
25117
25118 barcode () eq {
25119 /bwipp.hanxinEmptyData (The data must not be empty) //raiseerror exec
25120 } if
25121
25122 version (unset) ne {
25123 version length dup 1 ge exch 2 le and dup {
25124 pop
25125 true version {dup 48 lt exch 57 gt or { pop false } if } forall dup {
25126 pop version cvi dup 1 ge exch 84 le and
25127 } if
25128 } if
25129 not {
25130 /bwipp.hanxinInvalidVersion (Valid versions are 1 to 84) //raiseerror exec
25131 } if
25132 } if
25133
25134 eclevel length 2 eq dup {
25135 pop eclevel 0 1 getinterval (L) eq dup {
25136 pop eclevel 1 get 48 sub dup 1 ge exch 4 le and
25137 } if
25138 } if
25139 not {
25140 /bwipp.hanxinInvalidErrorCorrectionLevel (Valid error correction levels are L1 to L4) //raiseerror exec
25141 } if
25142
25143 mask -1 ne {
25144 mask 1 lt mask 4 gt or {
25145 /bwipp.hanxinInvalidErrorCorrectionLevel (The valid masks are 1 to 4) //raiseerror exec
25146 } if
25147 } if
25148
25149 /hanxin //loadctx exec
25150
25151 % Parse the input
25152 /fncvals <<
25153 /parse parse
25154 /parsefnc parsefnc
25155 % No FNC characters defined
25156 >> def
25157 /msg barcode fncvals //parseinput exec def
25158 /msglen msg length def
25159
25160 /tobin {
25161 string dup length 1 sub 0 exch 1 exch {1 index exch 48 put} for
25162 dup 3 -1 roll 2 2 index length string cvrs
25163 dup length 2 index length exch sub exch putinterval
25164 } def
25165
25166 % Encode the data using byte mode encoding
25167 /bits 4 13 add msglen 8 mul add string def
25168 bits 0 (0011) putinterval
25169 bits 4 msglen 13 tobin putinterval
25170 0 1 msglen 1 sub {
25171 /i exch def
25172 bits 17 i 8 mul add msg i get 8 tobin putinterval
25173 } for
25174
25175 % Lookup the most appropriate symbol specification
25176 {
25177 /metrics [
25178 % vers size align modules error correction blocks
25179 [ (1) 23 -1 0 205 [ 1 21 4 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25180 [ 1 17 8 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25181 [ 1 13 12 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25182 [ 1 9 16 ] [ 0 -1 -1 ] [ 0 -1 -1 ] ]
25183 [ (2) 25 -1 0 301 [ 1 31 6 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25184 [ 1 25 12 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25185 [ 1 19 18 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25186 [ 1 15 22 ] [ 0 -1 -1 ] [ 0 -1 -1 ] ]
25187 [ (3) 27 -1 0 405 [ 1 42 8 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25188 [ 1 34 16 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25189 [ 1 26 24 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25190 [ 1 20 30 ] [ 0 -1 -1 ] [ 0 -1 -1 ] ]
25191 [ (4) 29 14 1 439 [ 1 46 8 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25192 [ 1 38 16 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25193 [ 1 30 24 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25194 [ 1 22 32 ] [ 0 -1 -1 ] [ 0 -1 -1 ] ]
25195 [ (5) 31 16 1 555 [ 1 57 12 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25196 [ 1 49 20 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25197 [ 1 37 32 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25198 [ 1 14 20 ] [ 1 13 22 ] [ 0 -1 -1 ] ]
25199 [ (6) 33 16 1 675 [ 1 70 14 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25200 [ 1 58 26 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25201 [ 1 24 20 ] [ 1 22 18 ] [ 0 -1 -1 ]
25202 [ 1 16 24 ] [ 1 18 26 ] [ 0 -1 -1 ] ]
25203 [ (7) 35 17 1 805 [ 1 84 16 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25204 [ 1 70 30 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25205 [ 1 26 22 ] [ 1 28 24 ] [ 0 -1 -1 ]
25206 [ 2 14 20 ] [ 1 12 20 ] [ 0 -1 -1 ] ]
25207 [ (8) 37 18 1 943 [ 1 99 18 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25208 [ 1 40 18 ] [ 1 41 18 ] [ 0 -1 -1 ]
25209 [ 1 31 26 ] [ 1 32 28 ] [ 0 -1 -1 ]
25210 [ 2 16 24 ] [ 1 15 22 ] [ 0 -1 -1 ] ]
25211 [ (9) 39 19 1 1089 [ 1 114 22 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25212 [ 2 48 20 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25213 [ 2 24 20 ] [ 1 26 22 ] [ 0 -1 -1 ]
25214 [ 2 18 28 ] [ 1 18 26 ] [ 0 -1 -1 ] ]
25215 [ (10) 41 20 1 1243 [ 1 131 24 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25216 [ 1 52 22 ] [ 1 57 24 ] [ 0 -1 -1 ]
25217 [ 2 27 24 ] [ 1 29 24 ] [ 0 -1 -1 ]
25218 [ 2 21 32 ] [ 1 19 30 ] [ 0 -1 -1 ] ]
25219 [ (11) 43 14 2 1289 [ 1 135 26 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25220 [ 1 56 24 ] [ 1 57 24 ] [ 0 -1 -1 ]
25221 [ 2 28 24 ] [ 1 31 26 ] [ 0 -1 -1 ]
25222 [ 2 22 32 ] [ 1 21 32 ] [ 0 -1 -1 ] ]
25223 [ (12) 45 15 2 1455 [ 1 153 28 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25224 [ 1 62 26 ] [ 1 65 28 ] [ 0 -1 -1 ]
25225 [ 2 32 28 ] [ 1 33 28 ] [ 0 -1 -1 ]
25226 [ 3 17 26 ] [ 1 22 30 ] [ 0 -1 -1 ] ]
25227 [ (13) 47 16 2 1629 [ 1 86 16 ] [ 1 85 16 ] [ 0 -1 -1 ]
25228 [ 1 71 30 ] [ 1 72 30 ] [ 0 -1 -1 ]
25229 [ 2 37 32 ] [ 1 35 30 ] [ 0 -1 -1 ]
25230 [ 3 20 30 ] [ 1 21 32 ] [ 0 -1 -1 ] ]
25231 [ (14) 49 16 2 1805 [ 1 94 18 ] [ 1 95 18 ] [ 0 -1 -1 ]
25232 [ 2 51 22 ] [ 1 55 24 ] [ 0 -1 -1 ]
25233 [ 3 30 26 ] [ 1 31 26 ] [ 0 -1 -1 ]
25234 [ 4 18 28 ] [ 1 17 24 ] [ 0 -1 -1 ] ]
25235 [ (15) 51 17 2 1995 [ 1 104 20 ] [ 1 105 20 ] [ 0 -1 -1 ]
25236 [ 2 57 24 ] [ 1 61 26 ] [ 0 -1 -1 ]
25237 [ 3 33 28 ] [ 1 36 30 ] [ 0 -1 -1 ]
25238 [ 4 20 30 ] [ 1 19 30 ] [ 0 -1 -1 ] ]
25239 [ (16) 53 17 2 2187 [ 1 115 22 ] [ 1 114 22 ] [ 0 -1 -1 ]
25240 [ 2 65 28 ] [ 1 61 26 ] [ 0 -1 -1 ]
25241 [ 3 38 32 ] [ 1 33 30 ] [ 0 -1 -1 ]
25242 [ 5 19 28 ] [ 1 14 24 ] [ 0 -1 -1 ] ]
25243 [ (17) 55 18 2 2393 [ 1 126 24 ] [ 1 125 24 ] [ 0 -1 -1 ]
25244 [ 2 70 30 ] [ 1 69 30 ] [ 0 -1 -1 ]
25245 [ 4 33 28 ] [ 1 29 26 ] [ 0 -1 -1 ]
25246 [ 5 20 30 ] [ 1 19 30 ] [ 0 -1 -1 ] ]
25247 [ (18) 57 19 2 2607 [ 1 136 26 ] [ 1 137 26 ] [ 0 -1 -1 ]
25248 [ 3 56 24 ] [ 1 59 26 ] [ 0 -1 -1 ]
25249 [ 5 35 30 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25250 [ 6 18 28 ] [ 1 21 28 ] [ 0 -1 -1 ] ]
25251 [ (19) 59 20 2 2829 [ 1 148 28 ] [ 1 149 28 ] [ 0 -1 -1 ]
25252 [ 3 61 26 ] [ 1 64 28 ] [ 0 -1 -1 ]
25253 [ 7 24 20 ] [ 1 23 22 ] [ 0 -1 -1 ]
25254 [ 6 20 30 ] [ 1 21 32 ] [ 0 -1 -1 ] ]
25255 [ (20) 61 20 2 3053 [ 3 107 20 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25256 [ 3 65 28 ] [ 1 72 30 ] [ 0 -1 -1 ]
25257 [ 7 26 22 ] [ 1 23 22 ] [ 0 -1 -1 ]
25258 [ 7 19 28 ] [ 1 20 32 ] [ 0 -1 -1 ] ]
25259 [ (21) 63 21 2 3291 [ 3 115 22 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25260 [ 4 56 24 ] [ 1 63 28 ] [ 0 -1 -1 ]
25261 [ 7 28 24 ] [ 1 25 22 ] [ 0 -1 -1 ]
25262 [ 8 18 28 ] [ 1 21 22 ] [ 0 -1 -1 ] ]
25263 [ (22) 65 16 3 3383 [ 2 116 22 ] [ 1 122 24 ] [ 0 -1 -1 ]
25264 [ 4 56 24 ] [ 1 72 30 ] [ 0 -1 -1 ]
25265 [ 7 28 24 ] [ 1 32 26 ] [ 0 -1 -1 ]
25266 [ 8 18 28 ] [ 1 24 30 ] [ 0 -1 -1 ] ]
25267 [ (23) 67 17 3 3631 [ 3 127 24 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25268 [ 5 51 22 ] [ 1 62 26 ] [ 0 -1 -1 ]
25269 [ 7 30 26 ] [ 1 35 26 ] [ 0 -1 -1 ]
25270 [ 8 20 30 ] [ 1 21 32 ] [ 0 -1 -1 ] ]
25271 [ (24) 69 17 3 3887 [ 2 135 26 ] [ 1 137 26 ] [ 0 -1 -1 ]
25272 [ 5 56 24 ] [ 1 59 26 ] [ 0 -1 -1 ]
25273 [ 7 33 28 ] [ 1 30 28 ] [ 0 -1 -1 ]
25274 [ 11 16 24 ] [ 1 19 26 ] [ 0 -1 -1 ] ]
25275 [ (25) 71 18 3 4151 [ 3 105 20 ] [ 1 121 22 ] [ 0 -1 -1 ]
25276 [ 5 61 26 ] [ 1 57 26 ] [ 0 -1 -1 ]
25277 [ 9 28 24 ] [ 1 28 22 ] [ 0 -1 -1 ]
25278 [ 10 19 28 ] [ 1 18 30 ] [ 0 -1 -1 ] ]
25279 [ (26) 73 18 3 4423 [ 2 157 30 ] [ 1 150 28 ] [ 0 -1 -1 ]
25280 [ 5 65 28 ] [ 1 61 26 ] [ 0 -1 -1 ]
25281 [ 8 33 28 ] [ 1 34 30 ] [ 0 -1 -1 ]
25282 [ 10 19 28 ] [ 2 15 26 ] [ 0 -1 -1 ] ]
25283 [ (27) 75 19 3 4703 [ 3 126 24 ] [ 1 115 22 ] [ 0 -1 -1 ]
25284 [ 7 51 22 ] [ 1 54 22 ] [ 0 -1 -1 ]
25285 [ 8 35 30 ] [ 1 37 30 ] [ 0 -1 -1 ]
25286 [ 15 15 22 ] [ 1 10 22 ] [ 0 -1 -1 ] ]
25287 [ (28) 77 19 3 4991 [ 4 105 20 ] [ 1 103 20 ] [ 0 -1 -1 ]
25288 [ 7 56 24 ] [ 1 45 18 ] [ 0 -1 -1 ]
25289 [ 10 31 26 ] [ 1 27 26 ] [ 0 -1 -1 ]
25290 [ 10 17 26 ] [ 3 20 28 ] [ 1 21 28 ] ]
25291 [ (29) 79 20 3 5287 [ 3 139 26 ] [ 1 137 28 ] [ 0 -1 -1 ]
25292 [ 6 66 28 ] [ 1 66 30 ] [ 0 -1 -1 ]
25293 [ 9 36 30 ] [ 1 34 32 ] [ 0 -1 -1 ]
25294 [ 13 19 28 ] [ 1 17 32 ] [ 0 -1 -1 ] ]
25295 [ (30) 81 20 3 5591 [ 6 84 16 ] [ 1 82 16 ] [ 0 -1 -1 ]
25296 [ 6 70 30 ] [ 1 68 30 ] [ 0 -1 -1 ]
25297 [ 7 35 30 ] [ 3 33 28 ] [ 1 32 28 ]
25298 [ 13 20 30 ] [ 1 20 28 ] [ 0 -1 -1 ] ]
25299 [ (31) 83 21 3 5903 [ 5 105 20 ] [ 1 94 18 ] [ 0 -1 -1 ]
25300 [ 6 74 32 ] [ 1 71 30 ] [ 0 -1 -1 ]
25301 [ 11 33 28 ] [ 1 34 32 ] [ 0 -1 -1 ]
25302 [ 13 19 28 ] [ 3 16 26 ] [ 0 -1 -1 ] ]
25303 [ (32) 85 17 4 6033 [ 4 127 24 ] [ 1 126 24 ] [ 0 -1 -1 ]
25304 [ 7 66 28 ] [ 1 66 30 ] [ 0 -1 -1 ]
25305 [ 12 30 24 ] [ 1 24 28 ] [ 1 24 30 ]
25306 [ 15 19 28 ] [ 1 17 32 ] [ 0 -1 -1 ] ]
25307 [ (33) 87 17 4 6353 [ 7 84 16 ] [ 1 78 16 ] [ 0 -1 -1 ]
25308 [ 7 70 30 ] [ 1 66 28 ] [ 0 -1 -1 ]
25309 [ 12 33 28 ] [ 1 32 30 ] [ 0 -1 -1 ]
25310 [ 14 21 32 ] [ 1 24 28 ] [ 0 -1 -1 ] ]
25311 [ (34) 89 18 4 6689 [ 5 117 22 ] [ 1 117 24 ] [ 0 -1 -1 ]
25312 [ 8 66 28 ] [ 1 58 26 ] [ 0 -1 -1 ]
25313 [ 11 38 32 ] [ 1 34 32 ] [ 0 -1 -1 ]
25314 [ 15 20 30 ] [ 2 17 26 ] [ 0 -1 -1 ] ]
25315 [ (35) 91 18 4 7025 [ 4 148 28 ] [ 1 146 28 ] [ 0 -1 -1 ]
25316 [ 8 68 30 ] [ 1 70 24 ] [ 0 -1 -1 ]
25317 [ 10 36 32 ] [ 3 38 28 ] [ 0 -1 -1 ]
25318 [ 16 19 28 ] [ 3 16 26 ] [ 0 -1 -1 ] ]
25319 [ (36) 93 19 4 7377 [ 4 126 24 ] [ 2 135 26 ] [ 0 -1 -1 ]
25320 [ 8 70 28 ] [ 2 43 26 ] [ 0 -1 -1 ]
25321 [ 13 32 28 ] [ 2 41 30 ] [ 0 -1 -1 ]
25322 [ 17 19 28 ] [ 3 15 26 ] [ 0 -1 -1 ] ]
25323 [ (37) 95 19 4 7729 [ 5 136 26 ] [ 1 132 24 ] [ 0 -1 -1 ]
25324 [ 5 67 30 ] [ 4 68 28 ] [ 1 69 28 ]
25325 [ 14 35 30 ] [ 1 32 24 ] [ 0 -1 -1 ]
25326 [ 18 18 26 ] [ 3 16 28 ] [ 1 14 28 ] ]
25327 [ (38) 97 19 4 8089 [ 3 142 26 ] [ 3 141 28 ] [ 0 -1 -1 ]
25328 [ 8 70 30 ] [ 1 73 32 ] [ 1 74 32 ]
25329 [ 12 34 30 ] [ 3 34 26 ] [ 1 35 28 ]
25330 [ 18 21 32 ] [ 1 27 30 ] [ 0 -1 -1 ] ]
25331 [ (39) 99 20 4 8465 [ 5 116 22 ] [ 2 103 20 ] [ 1 102 20 ]
25332 [ 9 74 32 ] [ 1 74 30 ] [ 0 -1 -1 ]
25333 [ 14 34 28 ] [ 2 32 32 ] [ 1 32 30 ]
25334 [ 19 21 32 ] [ 1 25 26 ] [ 0 -1 -1 ] ]
25335 [ (40) 101 20 4 8841 [ 7 116 22 ] [ 1 117 22 ] [ 0 -1 -1 ]
25336 [ 11 65 28 ] [ 1 58 24 ] [ 0 -1 -1 ]
25337 [ 15 38 32 ] [ 1 27 28 ] [ 0 -1 -1 ]
25338 [ 20 20 30 ] [ 1 20 32 ] [ 1 21 32 ] ]
25339 [ (41) 103 17 5 9009 [ 6 136 26 ] [ 1 130 24 ] [ 0 -1 -1 ]
25340 [ 11 66 28 ] [ 1 62 30 ] [ 0 -1 -1 ]
25341 [ 14 34 28 ] [ 3 34 32 ] [ 1 30 30 ]
25342 [ 18 20 30 ] [ 3 20 28 ] [ 2 15 26 ] ]
25343 [ (42) 105 17 5 9401 [ 5 105 20 ] [ 2 115 22 ] [ 2 116 22 ]
25344 [ 10 75 32 ] [ 1 73 32 ] [ 0 -1 -1 ]
25345 [ 16 38 32 ] [ 1 27 28 ] [ 0 -1 -1 ]
25346 [ 22 19 28 ] [ 2 16 30 ] [ 1 19 30 ] ]
25347 [ (43) 107 18 5 9799 [ 6 147 28 ] [ 1 146 28 ] [ 0 -1 -1 ]
25348 [ 11 66 28 ] [ 2 65 30 ] [ 0 -1 -1 ]
25349 [ 18 33 28 ] [ 2 33 30 ] [ 0 -1 -1 ]
25350 [ 22 21 32 ] [ 1 28 30 ] [ 0 -1 -1 ] ]
25351 [ (44) 109 18 5 10207 [ 6 116 22 ] [ 3 125 24 ] [ 0 -1 -1 ]
25352 [ 11 75 32 ] [ 1 68 30 ] [ 0 -1 -1 ]
25353 [ 13 35 28 ] [ 6 34 32 ] [ 1 30 30 ]
25354 [ 23 21 32 ] [ 1 26 30 ] [ 0 -1 -1 ] ]
25355 [ (45) 111 18 5 10623 [ 7 105 20 ] [ 4 95 18 ] [ 0 -1 -1 ]
25356 [ 12 67 28 ] [ 1 63 30 ] [ 1 62 32 ]
25357 [ 21 31 26 ] [ 2 33 32 ] [ 0 -1 -1 ]
25358 [ 23 21 32 ] [ 2 24 30 ] [ 0 -1 -1 ] ]
25359 [ (46) 113 19 5 11045 [ 10 116 22 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25360 [ 12 74 32 ] [ 1 78 30 ] [ 0 -1 -1 ]
25361 [ 18 37 32 ] [ 1 39 30 ] [ 1 41 28 ]
25362 [ 25 21 32 ] [ 1 27 28 ] [ 0 -1 -1 ] ]
25363 [ (47) 115 19 5 11477 [ 5 126 24 ] [ 4 115 22 ] [ 1 114 22 ]
25364 [ 12 67 28 ] [ 2 66 32 ] [ 1 68 30 ]
25365 [ 21 35 30 ] [ 1 39 30 ] [ 0 -1 -1 ]
25366 [ 26 21 32 ] [ 1 28 28 ] [ 0 -1 -1 ] ]
25367 [ (48) 117 19 5 11917 [ 9 126 24 ] [ 1 117 22 ] [ 0 -1 -1 ]
25368 [ 13 75 32 ] [ 1 68 30 ] [ 0 -1 -1 ]
25369 [ 20 35 30 ] [ 3 35 28 ] [ 0 -1 -1 ]
25370 [ 27 21 32 ] [ 1 28 30 ] [ 0 -1 -1 ] ]
25371 [ (49) 119 17 6 12111 [ 9 126 24 ] [ 1 137 26 ] [ 0 -1 -1 ]
25372 [ 13 71 30 ] [ 2 68 32 ] [ 0 -1 -1 ]
25373 [ 20 37 32 ] [ 1 39 28 ] [ 1 38 28 ]
25374 [ 24 20 32 ] [ 5 25 28 ] [ 0 -1 -1 ] ]
25375 [ (50) 121 17 6 12559 [ 8 147 28 ] [ 1 141 28 ] [ 0 -1 -1 ]
25376 [ 10 73 32 ] [ 4 74 30 ] [ 1 73 30 ]
25377 [ 16 36 32 ] [ 6 39 30 ] [ 1 37 30 ]
25378 [ 27 21 32 ] [ 3 20 26 ] [ 0 -1 -1 ] ]
25379 [ (51) 123 18 6 13025 [ 9 137 26 ] [ 1 135 26 ] [ 0 -1 -1 ]
25380 [ 12 70 30 ] [ 4 75 32 ] [ 0 -1 -1 ]
25381 [ 24 35 30 ] [ 1 40 28 ] [ 0 -1 -1 ]
25382 [ 23 20 32 ] [ 8 24 30 ] [ 0 -1 -1 ] ]
25383 [ (52) 125 18 6 13489 [ 14 95 18 ] [ 1 86 18 ] [ 0 -1 -1 ]
25384 [ 13 73 32 ] [ 3 77 30 ] [ 0 -1 -1 ]
25385 [ 24 35 30 ] [ 2 35 28 ] [ 0 -1 -1 ]
25386 [ 26 21 32 ] [ 5 21 30 ] [ 1 23 30 ] ]
25387 [ (53) 127 18 6 13961 [ 9 147 28 ] [ 1 142 28 ] [ 0 -1 -1 ]
25388 [ 10 73 30 ] [ 6 70 32 ] [ 1 71 32 ]
25389 [ 25 35 30 ] [ 2 34 26 ] [ 0 -1 -1 ]
25390 [ 29 21 32 ] [ 4 22 30 ] [ 0 -1 -1 ] ]
25391 [ (54) 129 18 6 14441 [ 11 126 24 ] [ 1 131 24 ] [ 0 -1 -1 ]
25392 [ 16 74 32 ] [ 1 79 30 ] [ 0 -1 -1 ]
25393 [ 25 38 32 ] [ 1 25 30 ] [ 0 -1 -1 ]
25394 [ 33 21 32 ] [ 1 28 28 ] [ 0 -1 -1 ] ]
25395 [ (55) 131 19 6 14939 [ 14 105 20 ] [ 1 99 18 ] [ 0 -1 -1 ]
25396 [ 19 65 28 ] [ 1 72 28 ] [ 0 -1 -1 ]
25397 [ 24 37 32 ] [ 2 40 30 ] [ 1 41 30 ]
25398 [ 31 21 32 ] [ 4 24 32 ] [ 0 -1 -1 ] ]
25399 [ (56) 133 19 6 15435 [ 10 147 28 ] [ 1 151 28 ] [ 0 -1 -1 ]
25400 [ 15 71 30 ] [ 3 71 32 ] [ 1 73 32 ]
25401 [ 24 37 32 ] [ 3 38 30 ] [ 1 39 30 ]
25402 [ 36 19 30 ] [ 3 29 26 ] [ 0 -1 -1 ] ]
25403 [ (57) 135 19 6 15939 [ 15 105 20 ] [ 1 99 18 ] [ 0 -1 -1 ]
25404 [ 19 70 30 ] [ 1 64 28 ] [ 0 -1 -1 ]
25405 [ 27 38 32 ] [ 2 25 26 ] [ 0 -1 -1 ]
25406 [ 38 20 30 ] [ 2 18 28 ] [ 0 -1 -1 ] ]
25407 [ (58) 137 17 7 16171 [ 14 105 20 ] [ 1 113 22 ] [ 1 114 22 ]
25408 [ 17 67 30 ] [ 3 92 32 ] [ 0 -1 -1 ]
25409 [ 30 35 30 ] [ 1 41 30 ] [ 0 -1 -1 ]
25410 [ 36 21 32 ] [ 1 26 30 ] [ 1 27 30 ] ]
25411 [ (59) 139 17 7 16691 [ 11 146 28 ] [ 1 146 26 ] [ 0 -1 -1 ]
25412 [ 20 70 30 ] [ 1 60 26 ] [ 0 -1 -1 ]
25413 [ 29 38 32 ] [ 1 24 32 ] [ 0 -1 -1 ]
25414 [ 40 20 30 ] [ 2 17 26 ] [ 0 -1 -1 ] ]
25415 [ (60) 141 18 7 17215 [ 3 137 26 ] [ 1 136 26 ] [ 10 126 24 ]
25416 [ 22 65 28 ] [ 1 75 30 ] [ 0 -1 -1 ]
25417 [ 30 37 32 ] [ 1 51 30 ] [ 0 -1 -1 ]
25418 [ 42 20 30 ] [ 1 21 30 ] [ 0 -1 -1 ] ]
25419 [ (61) 143 18 7 17751 [ 12 126 24 ] [ 2 118 22 ] [ 1 116 22 ]
25420 [ 19 74 32 ] [ 1 74 30 ] [ 1 72 28 ]
25421 [ 30 38 32 ] [ 2 29 30 ] [ 0 -1 -1 ]
25422 [ 39 20 32 ] [ 2 37 26 ] [ 1 38 26 ] ]
25423 [ (62) 145 18 7 18295 [ 12 126 24 ] [ 3 136 26 ] [ 0 -1 -1 ]
25424 [ 21 70 30 ] [ 2 65 28 ] [ 0 -1 -1 ]
25425 [ 34 35 30 ] [ 1 44 32 ] [ 0 -1 -1 ]
25426 [ 42 20 30 ] [ 2 19 28 ] [ 2 18 28 ] ]
25427 [ (63) 147 18 7 18847 [ 12 126 24 ] [ 3 117 22 ] [ 1 116 22 ]
25428 [ 25 61 26 ] [ 2 62 28 ] [ 0 -1 -1 ]
25429 [ 34 35 30 ] [ 1 40 32 ] [ 1 41 32 ]
25430 [ 45 20 30 ] [ 1 20 32 ] [ 1 21 32 ] ]
25431 [ (64) 149 19 7 19403 [ 15 105 20 ] [ 2 115 22 ] [ 2 116 22 ]
25432 [ 25 65 28 ] [ 1 72 28 ] [ 0 -1 -1 ]
25433 [ 18 35 30 ] [ 17 37 32 ] [ 1 50 32 ]
25434 [ 42 20 30 ] [ 6 19 28 ] [ 1 15 28 ] ]
25435 [ (65) 151 19 7 19971 [ 19 105 20 ] [ 1 101 20 ] [ 0 -1 -1 ]
25436 [ 33 51 22 ] [ 1 65 22 ] [ 0 -1 -1 ]
25437 [ 40 33 28 ] [ 1 28 28 ] [ 0 -1 -1 ]
25438 [ 49 20 30 ] [ 1 18 28 ] [ 0 -1 -1 ] ]
25439 [ (66) 153 17 8 20229 [ 18 105 20 ] [ 2 117 22 ] [ 0 -1 -1 ]
25440 [ 26 65 28 ] [ 1 80 30 ] [ 0 -1 -1 ]
25441 [ 35 35 30 ] [ 3 35 28 ] [ 1 36 28 ]
25442 [ 52 18 28 ] [ 2 38 30 ] [ 0 -1 -1 ] ]
25443 [ (67) 155 17 8 20805 [ 26 84 16 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25444 [ 26 70 30 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25445 [ 45 31 26 ] [ 1 9 26 ] [ 0 -1 -1 ]
25446 [ 52 20 30 ] [ 0 -1 -1 ] [ 0 -1 -1 ] ]
25447 [ (68) 157 17 8 21389 [ 16 126 24 ] [ 1 114 22 ] [ 1 115 22 ]
25448 [ 23 70 30 ] [ 3 65 28 ] [ 1 66 28 ]
25449 [ 40 35 30 ] [ 1 43 30 ] [ 0 -1 -1 ]
25450 [ 46 20 30 ] [ 7 19 28 ] [ 1 16 28 ] ]
25451 [ (69) 159 18 8 21993 [ 19 116 22 ] [ 1 105 22 ] [ 0 -1 -1 ]
25452 [ 20 70 30 ] [ 7 66 28 ] [ 1 63 28 ]
25453 [ 40 35 30 ] [ 1 42 32 ] [ 1 43 32 ]
25454 [ 54 20 30 ] [ 1 19 30 ] [ 0 -1 -1 ] ]
25455 [ (70) 161 18 8 22593 [ 17 126 24 ] [ 2 115 22 ] [ 0 -1 -1 ]
25456 [ 24 70 30 ] [ 4 74 32 ] [ 0 -1 -1 ]
25457 [ 48 31 26 ] [ 2 18 26 ] [ 0 -1 -1 ]
25458 [ 54 19 28 ] [ 6 15 26 ] [ 1 14 26 ] ]
25459 [ (71) 163 18 8 23201 [ 29 84 16 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25460 [ 29 70 30 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25461 [ 6 34 30 ] [ 3 36 30 ] [ 38 33 28 ]
25462 [ 58 20 30 ] [ 0 -1 -1 ] [ 0 -1 -1 ] ]
25463 [ (72) 165 18 8 23817 [ 16 147 28 ] [ 1 149 28 ] [ 0 -1 -1 ]
25464 [ 31 66 28 ] [ 1 37 26 ] [ 0 -1 -1 ]
25465 [ 48 33 28 ] [ 1 23 26 ] [ 0 -1 -1 ]
25466 [ 53 20 30 ] [ 6 19 28 ] [ 1 17 28 ] ]
25467 [ (73) 167 19 8 24453 [ 20 115 22 ] [ 2 134 24 ] [ 0 -1 -1 ]
25468 [ 29 66 28 ] [ 2 56 26 ] [ 2 57 26 ]
25469 [ 45 36 30 ] [ 2 15 28 ] [ 0 -1 -1 ]
25470 [ 59 20 30 ] [ 2 21 32 ] [ 0 -1 -1 ] ]
25471 [ (74) 169 19 8 25085 [ 17 147 28 ] [ 1 134 26 ] [ 0 -1 -1 ]
25472 [ 26 70 30 ] [ 5 75 32 ] [ 0 -1 -1 ]
25473 [ 47 35 30 ] [ 1 48 32 ] [ 0 -1 -1 ]
25474 [ 64 18 28 ] [ 2 33 30 ] [ 1 35 30 ] ]
25475 [ (75) 171 17 9 25373 [ 22 115 22 ] [ 1 133 24 ] [ 0 -1 -1 ]
25476 [ 33 65 28 ] [ 1 74 28 ] [ 0 -1 -1 ]
25477 [ 43 36 30 ] [ 5 27 28 ] [ 1 30 28 ]
25478 [ 57 20 30 ] [ 5 21 32 ] [ 1 24 32 ] ]
25479 [ (76) 173 17 9 26021 [ 18 136 26 ] [ 2 142 26 ] [ 0 -1 -1 ]
25480 [ 33 66 28 ] [ 2 49 26 ] [ 0 -1 -1 ]
25481 [ 48 35 30 ] [ 2 38 28 ] [ 0 -1 -1 ]
25482 [ 64 20 30 ] [ 1 20 32 ] [ 0 -1 -1 ] ]
25483 [ (77) 175 17 9 26677 [ 19 126 24 ] [ 2 135 26 ] [ 1 136 26 ]
25484 [ 32 66 28 ] [ 2 55 26 ] [ 2 56 26 ]
25485 [ 49 36 30 ] [ 2 18 32 ] [ 0 -1 -1 ]
25486 [ 65 18 28 ] [ 5 27 30 ] [ 1 29 30 ] ]
25487 [ (78) 177 18 9 27335 [ 20 137 26 ] [ 1 130 26 ] [ 0 -1 -1 ]
25488 [ 30 75 32 ] [ 2 71 32 ] [ 0 -1 -1 ]
25489 [ 46 35 30 ] [ 6 39 32 ] [ 0 -1 -1 ]
25490 [ 3 12 30 ] [ 70 19 28 ] [ 0 -1 -1 ] ]
25491 [ (79) 179 18 9 28007 [ 20 147 28 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25492 [ 35 70 30 ] [ 0 -1 -1 ] [ 0 -1 -1 ]
25493 [ 49 35 30 ] [ 5 35 28 ] [ 0 -1 -1 ]
25494 [ 70 20 30 ] [ 0 -1 -1 ] [ 0 -1 -1 ] ]
25495 [ (80) 181 18 9 28687 [ 21 136 26 ] [ 1 155 28 ] [ 0 -1 -1 ]
25496 [ 34 70 30 ] [ 1 64 28 ] [ 1 65 28 ]
25497 [ 54 35 30 ] [ 1 45 30 ] [ 0 -1 -1 ]
25498 [ 68 20 30 ] [ 3 18 28 ] [ 1 19 28 ] ]
25499 [ (81) 183 18 9 29375 [ 19 126 24 ] [ 5 115 22 ] [ 1 114 22 ]
25500 [ 33 70 30 ] [ 3 65 28 ] [ 1 64 28 ]
25501 [ 52 35 30 ] [ 3 41 32 ] [ 1 40 32 ]
25502 [ 67 20 30 ] [ 5 21 32 ] [ 1 24 32 ] ]
25503 [ (82) 185 18 9 30071 [ 2 150 28 ] [ 21 136 26 ] [ 0 -1 -1 ]
25504 [ 32 70 30 ] [ 6 65 28 ] [ 0 -1 -1 ]
25505 [ 52 38 32 ] [ 2 27 32 ] [ 0 -1 -1 ]
25506 [ 73 20 30 ] [ 2 22 32 ] [ 0 -1 -1 ] ]
25507 [ (83) 187 17 10 30387 [ 21 126 24 ] [ 4 136 26 ] [ 0 -1 -1 ]
25508 [ 30 74 32 ] [ 6 73 30 ] [ 0 -1 -1 ]
25509 [ 54 35 30 ] [ 4 40 32 ] [ 0 -1 -1 ]
25510 [ 75 20 30 ] [ 1 20 28 ] [ 0 -1 -1 ] ]
25511 [ (84) 189 17 10 31091 [ 30 105 20 ] [ 1 114 22 ] [ 0 -1 -1 ]
25512 [ 3 45 22 ] [ 55 47 20 ] [ 0 -1 -1 ]
25513 [ 2 26 26 ] [ 62 33 28 ] [ 0 -1 -1 ]
25514 [ 79 18 28 ] [ 4 33 30 ] [ 0 -1 -1 ] ]
25515 ] def
25516 } ctxdef
25517
25518 /eclval eclevel 1 get 49 sub def
25519 metrics {
25520 /m exch def
25521 /vers m 0 get def % Version of symbol
25522 /size m 1 get def % Length of side
25523 /alnk m 2 get def % Regular alignment pattern length
25524 /alnn m 3 get def % Number of alignment patterns
25525 /alnr size alnk alnn mul sub def % Remainder alignment pattern length
25526 /nmod m 4 get def % Number of modules
25527 /ncws nmod 8 idiv def % Total number of codewords
25528 /rbit nmod 8 mod def % Number of remainder bits
25529 /ecbs m 5 eclval 3 mul add 3 getinterval def % Error correction blocks
25530 /ecws 0 ecbs {dup 0 get exch 2 get mul add} forall def % Number of error correction codewords
25531 /dcws ncws ecws sub def % Number of data codewords
25532 /dmod dcws 8 mul def % Number of data modules
25533 /okay true def
25534 version (unset) ne version vers ne and {/okay false def} if % The version must match that supplied
25535 bits length dmod gt {/okay false def} if % Bitstream must fit into data modules
25536 okay {exit} if
25537 } forall
25538
25539 okay not {
25540 /bwipp.hanxinNoValidSymbol (Maximum length exceeded or invalid content) //raiseerror exec
25541 } if
25542
25543 /version vers def
25544 /msgbits bits def
25545 /e1nb ecbs 0 get 0 get def /e2nb ecbs 1 get 0 get def /e3nb ecbs 2 get 0 get def
25546 /e1dcws ecbs 0 get 1 get def /e2dcws ecbs 1 get 1 get def /e3dcws ecbs 2 get 1 get def
25547 /e1ecws ecbs 0 get 2 get def /e2ecws ecbs 1 get 2 get def /e3ecws ecbs 2 get 2 get def
25548
25549 % Expand the message bits by adding padding as necessary
25550 /pad dmod string def
25551 0 1 pad length 1 sub {pad exch 48 put} for
25552 pad 0 msgbits putinterval
25553
25554 % Evaluate the padded message into codewords
25555 /cws dcws array def
25556 0 1 cws length 1 sub {
25557 /c exch def
25558 /cwb pad c 8 mul 8 getinterval def
25559 /cw 0 def
25560 0 1 7 {
25561 /i exch def
25562 /cw cw 2 8 i sub 1 sub exp cvi cwb i get 48 sub mul add def
25563 } for
25564 cws c cw put
25565 } for
25566
25567 /rscodes {
25568
25569 /rspm exch def
25570 /rsgf exch def
25571 /rsnc exch def
25572 /rscws exch def
25573
25574 % Calculate the log and anti-log tables
25575 /rsalog [ 1 rsgf 1 sub { dup 2 mul dup rsgf ge {rspm xor} if } repeat ] def
25576 /rslog rsgf array def
25577 1 1 rsgf 1 sub {dup rsalog exch get exch rslog 3 1 roll put} for
25578
25579 % Function to calculate the product in the field
25580 /rsprod {
25581 2 copy 0 ne exch 0 ne and {
25582 rslog exch get exch rslog exch get add rsgf 1 sub mod rsalog exch get
25583 } {
25584 pop pop 0
25585 } ifelse
25586 } def
25587
25588 % Generate the coefficients
25589 /coeffs [ 1 rsnc {0} repeat ] def
25590 1 1 rsnc {
25591 /i exch def
25592 coeffs i coeffs i 1 sub get put
25593 i 1 sub -1 1 {
25594 /j exch def
25595 coeffs j coeffs j 1 sub get coeffs j get rsalog i get rsprod xor put
25596 } for
25597 coeffs 0 coeffs 0 get rsalog i get rsprod put
25598 } for
25599
25600 % Extend the input with the error correction values
25601 /nd rscws length def
25602 /rscws [ rscws aload pop rsnc {0} repeat 0 ] def
25603 0 1 nd 1 sub {
25604 /k exch rscws exch get rscws nd get xor def
25605 0 1 rsnc 1 sub {
25606 /j exch def
25607 rscws nd j add rscws nd j add 1 add get k coeffs rsnc j sub 1 sub get rsprod xor put
25608 } for
25609 } for
25610
25611 % Return all but the last codeword
25612 rscws 0 rscws length 1 sub getinterval
25613
25614 } def
25615
25616 % Divide codewords into two groups of blocks and calculate the error correction codewords
25617 /dcwsb e1nb e2nb add e3nb add array def
25618 /ecwsb dcwsb length array def
25619 /in 0 def /out 0 def
25620 e1nb {
25621 cws in e1dcws getinterval e1ecws 256 355 rscodes
25622 dup 0 e1dcws getinterval dcwsb exch out exch put
25623 e1dcws e1ecws getinterval ecwsb exch out exch put
25624 /in in e1dcws add def /out out 1 add def
25625 } repeat
25626 e2nb {
25627 cws in e2dcws getinterval e2ecws 256 355 rscodes
25628 dup 0 e2dcws getinterval dcwsb exch out exch put
25629 e2dcws e2ecws getinterval ecwsb exch out exch put
25630 /in in e2dcws add def /out out 1 add def
25631 } repeat
25632 e3nb {
25633 cws in e3dcws getinterval e3ecws 256 355 rscodes
25634 dup 0 e3dcws getinterval dcwsb exch out exch put
25635 e3dcws e3ecws getinterval ecwsb exch out exch put
25636 /in in e3dcws add def /out out 1 add def
25637 } repeat
25638
25639 % Reassemble the codewords
25640 /cws ncws array def
25641 /cw 0 def
25642 0 1 dcwsb length 1 sub {
25643 /i exch def
25644 dcwsb i get dup cws exch cw exch putinterval length cw add /cw exch def
25645 ecwsb i get dup cws exch cw exch putinterval length cw add /cw exch def
25646 } for
25647
25648 % Split codewords into groups of 13 and concatenate
25649 /cws [
25650 0 1 ncws 1 sub 12 2 copy gt {exch} if pop {
25651 13 ncws 1 sub { dup ncws lt {cws exch get} {pop} ifelse } for
25652 } for
25653 ] def
25654
25655 % Extend codewords by one if there are remainder bits
25656 rbit 0 gt {
25657 /pad cws length 1 add array def
25658 pad 0 cws putinterval
25659 pad pad length 1 sub 0 put
25660 /cws pad def
25661 } if
25662
25663 options /debugcws known { /bwipp.debugcws cws //raiseerror exec } if
25664
25665 % Create the bitmap
25666 /pixs [ size size mul {-1} repeat ] def
25667 /qmv {size mul add} def
25668
25669 % Alignment patterns
25670 alnn 0 ne {
25671 /trmv {size mul size add 1 sub exch sub} def
25672 /aplot {
25673 3 1 roll 3 copy exch trmv pixs exch 3 -1 roll put
25674 trmv pixs exch 3 -1 roll put
25675 } def
25676 /i 0 def /stag 0 def {
25677 i size ge {exit} if
25678 0 1 size 1 sub {
25679 /j exch def
25680 j alnr add size lt {
25681 j alnk idiv stag add 2 mod 0 eq % Staggered groups of k modules
25682 i 0 eq j alnk lt and not and % Keep clear at top right
25683 j alnk mod 0 eq or % Complete regular-spaced grid
25684 } {
25685 alnn stag add 2 mod 0 eq % Bottom right remainder
25686 } ifelse
25687 {
25688 j i 1 aplot
25689 j 1 add i 1 add 2 copy size lt exch size lt and {0 aplot} {pop pop} ifelse
25690 } if
25691 } for
25692 i alnr add size eq {
25693 /i i alnr add 1 sub def
25694 } {
25695 /i i alnk add def
25696 } ifelse
25697 /stag 1 stag sub def
25698 } loop
25699 alnk alnk size 2 sub {
25700 /i exch def
25701 i alnk idiv 2 mod 0 ne {
25702 pixs 0 i 1 sub trmv 0 put
25703 pixs 0 i 1 add trmv 0 put
25704 pixs 1 i 1 sub trmv 0 put
25705 pixs 1 i trmv 0 put
25706 pixs 1 i 1 add trmv 0 put
25707 pixs i 1 sub 0 trmv 0 put
25708 pixs i 1 add 0 trmv 0 put
25709 pixs i 1 sub 1 trmv 0 put
25710 pixs i 1 trmv 0 put
25711 pixs i 1 add 1 trmv 0 put
25712 } if
25713 pixs size 1 sub i 1 sub trmv get 1 ne {
25714 pixs size 1 sub i 1 sub trmv 0 put
25715 pixs size 2 sub i 1 sub trmv 0 put
25716 pixs size 2 sub i trmv 0 put
25717 pixs size 2 sub i 1 add trmv 0 put
25718 pixs size 1 sub i 1 add trmv 0 put
25719 pixs i 1 sub size 1 sub trmv 0 put
25720 pixs i 1 sub size 2 sub trmv 0 put
25721 pixs i size 2 sub trmv 0 put
25722 pixs i 1 add size 2 sub trmv 0 put
25723 pixs i 1 add size 1 sub trmv 0 put
25724 } if
25725 } for
25726 } if
25727
25728 % Finder patterns
25729 {
25730 /fpat [
25731 [ 1 1 1 1 1 1 1 0 ]
25732 [ 1 0 0 0 0 0 0 0 ]
25733 [ 1 0 1 1 1 1 1 0 ]
25734 [ 1 0 1 0 0 0 0 0 ]
25735 [ 1 0 1 0 1 1 1 0 ]
25736 [ 1 0 1 0 1 1 1 0 ]
25737 [ 1 0 1 0 1 1 1 0 ]
25738 [ 0 0 0 0 0 0 0 0 ]
25739 ] def
25740 /fpat2 [
25741 [ 1 1 1 0 1 0 1 0 ]
25742 [ 1 1 1 0 1 0 1 0 ]
25743 [ 1 1 1 0 1 0 1 0 ]
25744 [ 0 0 0 0 1 0 1 0 ]
25745 [ 1 1 1 1 1 0 1 0 ]
25746 [ 0 0 0 0 0 0 1 0 ]
25747 [ 1 1 1 1 1 1 1 0 ]
25748 [ 0 0 0 0 0 0 0 0 ]
25749 ] def
25750 } ctxdef
25751 0 1 fpat length 1 sub {
25752 /y exch def
25753 0 1 fpat 0 get length 1 sub {
25754 /x exch def
25755 /fpb fpat y get x get def
25756 /fpb2 fpat2 y get x get def
25757 pixs x y qmv fpb put
25758 pixs size x sub 1 sub y qmv fpb put
25759 pixs size x sub 1 sub size y sub 1 sub qmv fpb put
25760 pixs x size y sub 1 sub qmv fpb2 put
25761 } for
25762 } for
25763
25764 % Format information modules
25765 /functionmap [
25766 [ [ 0 8 ] [ size 1 sub size 9 sub ] ] [ [ 1 8 ] [ size 2 sub size 9 sub ] ]
25767 [ [ 2 8 ] [ size 3 sub size 9 sub ] ] [ [ 3 8 ] [ size 4 sub size 9 sub ] ]
25768 [ [ 4 8 ] [ size 5 sub size 9 sub ] ] [ [ 5 8 ] [ size 6 sub size 9 sub ] ]
25769 [ [ 6 8 ] [ size 7 sub size 9 sub ] ] [ [ 7 8 ] [ size 8 sub size 9 sub ] ]
25770 [ [ 8 8 ] [ size 9 sub size 9 sub ] ]
25771 [ [ 8 7 ] [ size 9 sub size 8 sub ] ] [ [ 8 6 ] [ size 9 sub size 7 sub ] ]
25772 [ [ 8 5 ] [ size 9 sub size 6 sub ] ] [ [ 8 4 ] [ size 9 sub size 5 sub ] ]
25773 [ [ 8 3 ] [ size 9 sub size 4 sub ] ] [ [ 8 2 ] [ size 9 sub size 3 sub ] ]
25774 [ [ 8 1 ] [ size 9 sub size 2 sub ] ] [ [ 8 0 ] [ size 9 sub size 1 sub ] ]
25775 [ [ size 9 sub 0 ] [ 8 size 1 sub ] ] [ [ size 9 sub 1 ] [ 8 size 2 sub ] ]
25776 [ [ size 9 sub 2 ] [ 8 size 3 sub ] ] [ [ size 9 sub 3 ] [ 8 size 4 sub ] ]
25777 [ [ size 9 sub 4 ] [ 8 size 5 sub ] ] [ [ size 9 sub 5 ] [ 8 size 6 sub ] ]
25778 [ [ size 9 sub 6 ] [ 8 size 7 sub ] ] [ [ size 9 sub 7 ] [ 8 size 8 sub ] ]
25779 [ [ size 9 sub 8 ] [ 8 size 9 sub ] ]
25780 [ [ size 8 sub 8 ] [ 7 size 9 sub ] ] [ [ size 7 sub 8 ] [ 6 size 9 sub ] ]
25781 [ [ size 6 sub 8 ] [ 5 size 9 sub ] ] [ [ size 5 sub 8 ] [ 4 size 9 sub ] ]
25782 [ [ size 4 sub 8 ] [ 3 size 9 sub ] ] [ [ size 3 sub 8 ] [ 2 size 9 sub ] ]
25783 [ [ size 2 sub 8 ] [ 1 size 9 sub ] ] [ [ size 1 sub 8 ] [ 0 size 9 sub ] ]
25784 ] def
25785 functionmap {
25786 { aload pop qmv pixs exch 0 put } forall
25787 } forall
25788
25789 /maskfuncs [
25790 {pop pop 1}
25791 {add 2 mod}
25792 {1 index add 3 mod exch 3 mod add 2 mod}
25793 {2 copy mod 3 1 roll 2 copy exch mod 3 1 roll 3 mod exch 3 mod
25794 add add add 2 mod}
25795 ] def
25796 mask -1 ne { % User specifies a mask
25797 /maskfuncs [maskfuncs mask 1 sub get] def
25798 /bestmaskval mask 1 sub def
25799 } if
25800 /masks maskfuncs length array def
25801 0 1 masks length 1 sub {
25802 /m exch def
25803 /mask size size mul array def
25804 0 1 size 1 sub {
25805 /j exch def
25806 0 1 size 1 sub {
25807 /i exch def
25808 i 1 add j 1 add maskfuncs m get exec 0 eq
25809 pixs i j qmv get -1 eq and {1} {0} ifelse
25810 mask i j qmv 3 -1 roll put
25811 } for
25812 } for
25813 masks m mask put
25814 } for
25815
25816 % Walk the symbol placing the bitstream
25817 /posx 0 def
25818 /posy 0 def
25819 /num 0 def
25820 { % loop
25821 posy size eq {exit} if
25822 pixs posx posy qmv get -1 eq {
25823 cws num 8 idiv get 7 num 8 mod sub neg bitshift 1 and
25824 pixs posx posy qmv 3 -1 roll put
25825 /num num 1 add def
25826 } if
25827 /posx posx 1 add def
25828 posx size eq {/posx 0 def /posy posy 1 add def} if
25829 } loop
25830
25831 % Evaluate runlength encoded rows or columns in full symbols
25832 /evalfulln1n3 {
25833 /scrle exch def
25834 % Detect runs of 3 or more like modules
25835 /scr1 0 scrle { dup 3 ge {4 mul add dup} if pop } forall def
25836 /scr3 0 def
25837 % Detect 1:1:1:1:3 ratio next to 3 modules of whitespace
25838 5 2 scrle length 1 sub { % Scan odd (dark) runs within bounds
25839 /j exch def
25840 scrle j get 3 mod 0 eq { % Multiple of 3 black modules
25841 /fact scrle j get 3 idiv def
25842 scrle j 4 sub 4 getinterval {fact eq} forall and and and {
25843 j 5 eq j 2 add scrle length ge or { % At either extent of run
25844 /scr3 scr3 50 add def
25845 } { % Bounded by dark modules
25846 scrle j 5 sub get 3 ge scrle j 1 add get 3 ge or {
25847 /scr3 scr3 50 add def
25848 } if
25849 } ifelse
25850 } if
25851 } if
25852 } for
25853 % Detect 3:1:1:1:1 ratio next to 3 modules of whitespace
25854 1 2 scrle length 5 sub { % Scan odd (dark) runs within bounds
25855 /j exch def
25856 scrle j get 3 mod 0 eq { % Multiple of 3 black modules
25857 /fact scrle j get 3 idiv def
25858 scrle j 1 add 4 getinterval {fact eq} forall and and and {
25859 j 1 eq j 6 add scrle length ge or { % At either extent of run
25860 /scr3 scr3 50 add def
25861 } { % Bounded by dark modules
25862 scrle j 1 sub get 3 ge scrle j 5 add get 3 ge or {
25863 /scr3 scr3 50 add def
25864 } if
25865 } ifelse
25866 } if
25867 } if
25868 } for
25869 scr1 scr3
25870 } def
25871
25872 % Evaluation algorithm
25873 /evalfull {
25874 /sym exch def
25875
25876 /n1 0 def /n3 0 def
25877 /rle size 1 add array def
25878 /lastpairs size array def
25879 /thispairs size array def
25880 /sizeadd1 size 1 add def
25881 0 1 size 1 sub {
25882 /i exch def
25883
25884 % Runlength encode (light, dark, light, ...) and evaluate each column
25885 mark 0 0
25886 i size dup dup mul 1 sub {
25887 sym exch get exch 1 index eq {exch 1 add exch} {1 exch} ifelse
25888 } for
25889 pop
25890 rle 0 counttomark 2 sub getinterval astore
25891 evalfulln1n3 n3 add /n3 exch def n1 add /n1 exch def
25892 pop
25893
25894 % Runlength encode (light, dark, light, ...) and evaluate each row
25895 /symrow sym i size mul size getinterval def
25896 mark 0 0
25897 symrow {
25898 exch 1 index eq {exch 1 add exch} {1 exch} ifelse
25899 } forall
25900 pop
25901 rle 0 counttomark 2 sub getinterval astore
25902 evalfulln1n3 n3 add /n3 exch def n1 add /n1 exch def
25903 pop
25904
25905 } for
25906
25907 n1 n3 add
25908 } def
25909
25910 % Evaluate the masked symbols to find the most suitable
25911 /bestscore 999999999 def
25912 0 1 masks length 1 sub {
25913 /m exch def
25914 /masksym size size mul array def
25915 0 1 size size mul 1 sub {
25916 /i exch def
25917 masksym i pixs i get masks m get i get xor put
25918 } for
25919 masks length 1 ne {
25920 masksym evalfull /score exch def
25921 score bestscore lt {
25922 /bestsym masksym def
25923 /bestmaskval m def
25924 /bestscore score def
25925 } if
25926 } {
25927 /bestsym masksym def
25928 } ifelse
25929 } for
25930 /pixs bestsym def
25931
25932 % Add the function information
25933 /funval size 21 sub 2 idiv 20 add 4 mul eclval add 4 mul bestmaskval add def
25934 [ funval 16#0F00 and -8 bitshift
25935 funval 16#00F0 and -4 bitshift
25936 funval 16#000F and ]
25937 4 16 19 rscodes /funvals exch def
25938 /funbits [
25939 funvals {
25940 4 tobin {48 sub} forall
25941 } forall
25942 0 1 0 1 0 1
25943 ] def
25944 0 1 functionmap length 1 sub {
25945 /i exch def
25946 functionmap i get {
25947 pixs exch aload pop qmv funbits i get put
25948 } forall
25949 } for
25950
25951 % Return the arguments
25952 <<
25953 /ren /renmatrix
25954 /pixs pixs
25955 /pixx size
25956 /pixy size
25957 /height size 2 mul 72 div
25958 /width size 2 mul 72 div
25959 /borderleft 3.0
25960 /borderright 3.0
25961 /bordertop 3.0
25962 /borderbottom 3.0
25963 /opt options
25964 >>
25965
25966 dontdraw not //renmatrix if
25967
25968 //unloadctx exec
25969
25970 end
25971
25972 }
25973 [/barcode] {null def} forall
25974 bind def
25975 /hanxin dup load /uk.co.terryburton.bwipp defineresource pop
25976 end
25977 /setpacking where {pop setpacking} if
25978 %%EndData
25979 %%EndResource
25980 % --END ENCODER hanxin--
25981
25982 % --BEGIN ENCODER dotcode--
25983 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix--
25984 % --DESC: DotCode
25985 % --EXAM: This is DotCode
25986 % --EXOP: inkspread=0.16
25987 % --RNDR: renmatrix
25988 %%BeginResource: uk.co.terryburton.bwipp dotcode 0.0 2025111800 249158 285040
25989 %%BeginData: 1090 ASCII Lines
25990 /setpacking where {pop currentpacking true setpacking} if
25991 10 dict
25992 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
25993 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
25994 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
25995 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
25996 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
25997 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
25998 begin
25999 /dotcode {
26000
26001 20 dict begin
26002
26003 /ctx null def
26004 /dontdraw false def
26005 /rows -1 def
26006 /columns -1 def
26007 /ratio -1.0 def
26008 /parse false def
26009 /parsefnc false def
26010 /raw false def
26011 /fast false def
26012 /mask -1 def
26013
26014 //processoptions exec /options exch def
26015 /barcode exch def
26016
26017 rows -1 ne {
26018 rows 5 lt {
26019 /bwipp.dotcodeBadRows (There must be at least 5 rows) //raiseerror exec
26020 } if
26021 } if
26022
26023 columns -1 ne {
26024 columns 5 lt {
26025 /bwipp.dotcodeBadColumns (There must be at least 5 columns) //raiseerror exec
26026 } if
26027 } if
26028
26029 rows -1 ne columns -1 ne and rows columns add 2 mod 1 ne and {
26030 /bwipp.dotcodeRowsColumnsBadParity (Sum of rows and columns must be odd) //raiseerror exec
26031 } if
26032
26033 % Set the ratio to 3:2 if no size is specified
26034 ratio -1 eq rows -1 eq and columns -1 eq and {
26035 /ratio 3 2 div def
26036 } if
26037 ratio -1 ne {
26038 ratio 0 le {
26039 /bwipp.dotcodeRatio (The ratio must be greater than 0) //raiseerror exec
26040 } if
26041 } if
26042
26043 mask -1 ne {
26044 mask 0 lt mask 3 gt or {
26045 /bwipp.dotcodeBadMask (Valid mask values are 0 to 3) //raiseerror exec
26046 } if
26047 } if
26048
26049 /dotcode //loadctx exec
26050
26051 % Convert input into bytes accounting for FNC characters
26052 {
26053 /laa -1 def /lab -2 def /lac -3 def /bin -4 def
26054 /sfa -5 def /sfb -6 def /sb2 -7 def /sb3 -8 def
26055 /sb4 -9 def /sb5 -10 def /sb6 -11 def /sfc -12 def
26056 /sc2 -13 def /sc3 -14 def /sc4 -15 def /sc5 -16 def
26057 /sc6 -17 def /sc7 -18 def /bsa -19 def /bsb -20 def
26058 /tma -21 def /tmb -22 def /tmc -23 def /tms -24 def
26059 /fn1 -25 def /fn2 -26 def /fn3 -27 def /crl -28 def
26060 /aim -29 def /m05 -30 def /m06 -31 def /m12 -32 def
26061 /mac -33 def
26062 } ctxdef
26063
26064 % Parse the input
26065 /fncvals <<
26066 /parse parse
26067 /parsefnc parsefnc
26068 /eci true
26069 (FNC1) fn1
26070 % (FNC2) fn2 % Use ^ECInnnnnn for ECI; Structured append not supported
26071 (FNC3) fn3
26072 >> def
26073 /msg barcode fncvals //parseinput exec def
26074 /msglen msg length def
26075
26076 % Special FNC2 semantics: Expand ECI characters into ^FNC2nnnnnn
26077 /numecis 0 msg { -1000000 le {1 add} if } forall def
26078 /msgtmp msg length numecis 6 mul add array def
26079 /j 0 def
26080 0 1 msg length 1 sub {
26081 msg exch get dup -1000000 le {
26082 neg 10 7 string cvrs 1 6 getinterval {} forall 6 array astore
26083 msgtmp exch j 1 add exch putinterval
26084 msgtmp j fn2 put
26085 /j j 7 add def
26086 } {
26087 msgtmp exch j exch put
26088 /j j 1 add def
26089 } ifelse
26090 } for
26091 /msg msgtmp def
26092 /msglen msg length def
26093
26094 % Character maps for each state
26095 {
26096 /charmaps [
26097 % A B C A B C A B C
26098 [ 32 32 (00) ] [ (!) (!) (01) ] [ (") (") (02) ] % 0-2
26099 [ (#) (#) (03) ] [ ($) ($) (04) ] [ (%) (%) (05) ] % 3-5
26100 [ (&) (&) (06) ] [ (') (') (07) ] [ 40 40 (08) ] % 6-8
26101 [ 41 41 (09) ] [ (*) (*) (10) ] [ (+) (+) (11) ] % 9-11
26102 [ (,) (,) (12) ] [ (-) (-) (13) ] [ (.) (.) (14) ] % 12-14
26103 [ (/) (/) (15) ] [ (0) (0) (16) ] [ (1) (1) (17) ] % 15-17
26104 [ (2) (2) (18) ] [ (3) (3) (19) ] [ (4) (4) (20) ] % 18-20
26105 [ (5) (5) (21) ] [ (6) (6) (22) ] [ (7) (7) (23) ] % 21-23
26106 [ (8) (8) (24) ] [ (9) (9) (25) ] [ (:) (:) (26) ] % 24-26
26107 [ (;) (;) (27) ] [ (<) (<) (28) ] [ (=) (=) (29) ] % 27-29
26108 [ (>) (>) (30) ] [ (?) (?) (31) ] [ (@) (@) (32) ] % 30-32
26109 [ (A) (A) (33) ] [ (B) (B) (34) ] [ (C) (C) (35) ] % 33-35
26110 [ (D) (D) (36) ] [ (E) (E) (37) ] [ (F) (F) (38) ] % 36-38
26111 [ (G) (G) (39) ] [ (H) (H) (40) ] [ (I) (I) (41) ] % 39-41
26112 [ (J) (J) (42) ] [ (K) (K) (43) ] [ (L) (L) (44) ] % 42-44
26113 [ (M) (M) (45) ] [ (N) (N) (46) ] [ (O) (O) (47) ] % 45-47
26114 [ (P) (P) (48) ] [ (Q) (Q) (49) ] [ (R) (R) (50) ] % 48-50
26115 [ (S) (S) (51) ] [ (T) (T) (52) ] [ (U) (U) (53) ] % 51-53
26116 [ (V) (V) (54) ] [ (W) (W) (55) ] [ (X) (X) (56) ] % 54-56
26117 [ (Y) (Y) (57) ] [ (Z) (Z) (58) ] [ ([) ([) (59) ] % 57-59
26118 [ 92 92 (60) ] [ (]) (]) (61) ] [ (^) (^) (62) ] % 60-62
26119 [ (_) (_) (63) ] [ 0 (`) (64) ] [ 1 (a) (65) ] % 63-65
26120 [ 2 (b) (66) ] [ 3 (c) (67) ] [ 4 (d) (68) ] % 66-68
26121 [ 5 (e) (69) ] [ 6 (f) (70) ] [ 7 (g) (71) ] % 69-71
26122 [ 8 (h) (72) ] [ 9 (i) (73) ] [ 10 (j) (74) ] % 72-74
26123 [ 11 (k) (75) ] [ 12 (l) (76) ] [ 13 (m) (77) ] % 75-77
26124 [ 14 (n) (78) ] [ 15 (o) (79) ] [ 16 (p) (80) ] % 78-80
26125 [ 17 (q) (81) ] [ 18 (r) (82) ] [ 19 (s) (83) ] % 81-83
26126 [ 20 (t) (84) ] [ 21 (u) (85) ] [ 22 (v) (86) ] % 84-86
26127 [ 23 (w) (87) ] [ 24 (x) (88) ] [ 25 (y) (89) ] % 87-89
26128 [ 26 (z) (90) ] [ 27 ({) (91) ] [ 28 (|) (92) ] % 90-92
26129 [ 29 (}) (93) ] [ 30 (~) (94) ] [ 31 127 (95) ] % 93-95
26130 [ sfb crl (96) ] [ sb2 9 (97) ] [ sb3 28 (98) ] % 96-98
26131 [ sb4 29 (99) ] [ sb5 30 aim ] [ sb6 sfa laa ] % 99-101
26132 [ lab laa sfb ] [ sc2 sc2 sb2 ] [ sc3 sc3 sb3 ] % 102-104
26133 [ sc4 sc4 sb4 ] [ lac lac lab ] [ fn1 fn1 fn1 ] % 105-107
26134 [ fn2 fn2 fn2 ] [ fn3 fn3 fn3 ] [ bsa bsa bsa ] % 108-110
26135 [ bsb bsb bsb ] [ bin bin bin ] % 111-112
26136 ] def
26137
26138 % Invert charmaps to give character to value maps for each state
26139 /charvals [ 113 dict 117 dict 113 dict ] def
26140 0 1 charmaps length 1 sub {
26141 /i exch def
26142 /encs charmaps i get def
26143 0 1 2 {
26144 /j exch def
26145 encs j get dup type /stringtype eq {0 get} if % convert string to ASCII if required
26146 charvals j get exch i put
26147 } for
26148 } for
26149 /Avals charvals 0 get def
26150 /Bvals charvals 1 get def
26151 Bvals m05 97 put
26152 Bvals m06 98 put
26153 Bvals m12 99 put
26154 Bvals mac 100 put
26155 /Cvals charvals 2 get def
26156 /BINvals <<
26157 102 [ sc2 sc3 sc4 sc5 sc6 sc7 tma tmb tmc tms ] {exch 1 add dup} forall pop
26158 >> def
26159
26160 /A 0 def /B 1 def /C 2 def /BIN 3 def
26161 } ctxdef
26162
26163 % Pre-compute properties of the input at each point
26164 /nDigits [ msglen 1 add {0} repeat ] def
26165 /SeventeenTen [ msglen 1 add {false} repeat ] def
26166 /ECI [ msglen 1 add {false} repeat ] def
26167 /DatumA [ msglen 1 add {false} repeat ] def
26168 /DatumB [ msglen 1 add {false} repeat ] def
26169 /DatumC [ msglen 1 add {false} repeat ] def
26170 /Binary [ msglen 8 add {false} repeat ] def
26171 /AheadC [ msglen 1 add {0} repeat ] def
26172 /TryC [ msglen 1 add {0} repeat ] def
26173 /AheadA [ msglen 1 add {0} repeat ] def
26174 /AheadB [ msglen 1 add {0} repeat ] def
26175 /UntilEndSeg [ msglen 1 add {0} repeat ] def
26176 msglen 1 sub -1 0 {
26177 /i exch def
26178 /barchar msg i get def
26179 barchar 48 ge barchar 57 le and {
26180 nDigits i nDigits i 1 add get 1 add put
26181 } if
26182 Avals barchar known {DatumA i true put} if
26183 Bvals barchar known {DatumB i true put} if
26184 /CRLF false def
26185 barchar 13 eq i msglen 1 sub lt and {
26186 msg i 1 add get 10 eq {/CRLF true def} if
26187 } if
26188 CRLF {DatumB i true put} if
26189 nDigits i get 2 ge {DatumC i true put} if
26190 barchar 0 lt {DatumC i true put} if % FNCx
26191 barchar 128 ge {Binary i true put} if
26192 nDigits i get 10 ge { % 17xxxxxx10
26193 mark
26194 msg i 10 getinterval aload pop
26195 1 { % common exit
26196 48 ne {false exit} if
26197 49 ne {false exit} if
26198 pop pop pop pop pop pop
26199 55 ne {false exit} if
26200 49 ne {false exit} if
26201 true
26202 } repeat
26203 SeventeenTen i 3 -1 roll put
26204 cleartomark
26205 } if
26206 nDigits i 1 add get 6 ge msg i get fn2 eq and { % ^FNC2xxxxxx
26207 ECI i true put
26208 } if
26209 barchar 0 lt barchar fn3 ne and { % FNCx, except FNC3
26210 AheadC i AheadC i 1 add get 1 add put
26211 } {
26212 nDigits i get 1 le {
26213 AheadC i 0 put
26214 } {
26215 AheadC i AheadC i 2 add get 1 add put
26216 } ifelse
26217 } ifelse
26218 nDigits i get 0 gt AheadC i get AheadC i 1 add get gt and {
26219 TryC i AheadC i get put
26220 } if
26221 DatumA i get TryC i get 2 lt and barchar fn3 ne and {
26222 AheadA i AheadA i 1 add get 1 add put
26223 } if
26224 DatumB i get TryC i get 2 lt and barchar fn3 ne and {
26225 AheadB i AheadB i 1 add CRLF {1 add} if get 1 add put
26226 } if
26227 barchar fn3 ne {
26228 UntilEndSeg i UntilEndSeg i 1 add get 1 add put
26229 } if
26230 } for
26231
26232 /addtocws {
26233 dup cws exch j exch putinterval
26234 /j exch length j add def
26235 } def
26236
26237 % Base 259 to one more in base 103
26238 /base259to103 {
26239 /in exch def
26240 /inlen in length def
26241 /in [ 5 inlen sub {0} repeat in aload pop ] def
26242 /out 6 array def
26243 /msbs [ in 0 2 getinterval aload pop ] def
26244 /mscs [
26245 msbs aload pop exch 259 mul add
26246 2 {dup 103 mod exch 103 idiv} repeat
26247 ] def
26248 /lsbs [ in 2 3 getinterval aload pop ] def
26249 /lscs [
26250 lsbs aload pop exch 259 mul add exch 67081 mul add
26251 3 {dup 103 mod exch 103 idiv} repeat
26252 ] def
26253 lscs 0 get mscs 0 get 42 mul add
26254 out 5 2 index 103 mod put
26255 103 idiv lscs 1 get add mscs 0 get 68 mul add mscs 1 get 42 mul add
26256 out 4 2 index 103 mod put
26257 103 idiv lscs 2 get add mscs 0 get 92 mul add mscs 1 get 68 mul add mscs 2 get 42 mul add
26258 out 3 2 index 103 mod put
26259 103 idiv lscs 3 get add mscs 0 get 15 mul add mscs 1 get 92 mul add mscs 2 get 68 mul add
26260 out 2 2 index 103 mod put
26261 103 idiv mscs 1 get 15 mul add mscs 2 get 92 mul add
26262 out 1 2 index 103 mod put
26263 103 idiv mscs 2 get 15 mul add
26264 out 0 3 -1 roll 103 mod put
26265 out 6 inlen sub 1 sub inlen 1 add getinterval
26266 } def
26267
26268 /finaliseBIN {
26269 bpos 0 ne {
26270 bvals 0 bpos getinterval base259to103 aload pop
26271 /bpos 0 def
26272 } if
26273 } def
26274
26275 /addtobin {
26276 bvals exch bpos exch put
26277 /bpos bpos 1 add def
26278 bpos 5 eq { finaliseBIN } if
26279 } def
26280
26281 /ECIabc { % ECI encoding for modes A, B and C
26282 msg i 1 add 6 getinterval 0 exch {48 sub add 10 mul} forall 10 idiv
26283 dup 40 ge {
26284 40 sub
26285 dup 12769 idiv 40 add exch 12769 mod
26286 dup 113 idiv exch 113 mod
26287 } if
26288 } def
26289
26290 /ECIbin { % ECI encoding for binary mode
26291 [
26292 msg i 1 add 6 getinterval 0 exch {48 sub add 10 mul} forall 10 idiv
26293 dup 65536 ge {
26294 258 exch dup 65536 idiv exch 65536 mod dup 256 idiv exch 256 mod
26295 } {
26296 dup 256 ge {
26297 257 exch dup 256 idiv exch 256 mod
26298 } {
26299 256 exch
26300 } ifelse
26301 } ifelse
26302 ] {
26303 addtobin
26304 } forall
26305 } def
26306
26307 /encC {
26308 1 { % Common exit
26309 i segstart eq { % Structured data macros
26310 1 { % common exit
26311 i segend 7 sub gt {0 exit} if
26312 msg segstart get 91 ne {0 exit} if % [
26313 msg segstart 1 add get 41 ne {0 exit} if % )
26314 msg segstart 2 add get 62 ne {0 exit} if % >
26315 msg segstart 3 add get 30 ne {0 exit} if % {RS}
26316 msg segstart 4 add get dup 48 lt exch 57 gt or {0 exit} if % digit
26317 msg segstart 5 add get dup 48 lt exch 57 gt or {0 exit} if % digit
26318 msg segend 1 sub get 4 ne {0 exit} if % End: {EOT}
26319 msg segstart 4 add get 48 sub 10 mul msg segstart 5 add get 48 sub add
26320 dup dup 05 ne exch dup 06 ne exch 12 ne and and {pop mac exit} if
26321 msg segstart 6 add get 29 ne {pop 0 exit} if % {GS}
26322 msg segend 2 sub get 30 ne {pop 0 exit} if % End: {RS}
26323 dup 05 eq {pop m05 exit} if
26324 06 eq { m06 exit} if
26325 m12 exit
26326 } repeat
26327 /inmac exch def
26328 inmac 0 ne {
26329 [ Cvals lab get ] addtocws
26330 /mode B def
26331 [ Bvals inmac get ] addtocws
26332 inmac mac eq {
26333 [ Bvals msg segstart 4 add get get ] addtocws
26334 [ Bvals msg segstart 5 add get get ] addtocws
26335 /i i 6 add def
26336 } {
26337 /i i 7 add def
26338 } ifelse
26339 exit
26340 } if
26341 } if
26342 % Special treatment of FNC1 in First for Dotcode
26343 i segstart eq {
26344 % Encode an FNC1 if two digits start a segment
26345 nDigits i get 2 ge {
26346 [ Cvals fn1 get ] addtocws
26347 } if
26348 % Skip an FNC1 if followed by two digits at start of segment
26349 msg i get fn1 eq nDigits i 1 add get 2 ge and {
26350 /i i 1 add def
26351 } if
26352 } if
26353 SeventeenTen i get {
26354 [ % 17xxxxxx10 macro
26355 Cvals aim get
26356 msg i 2 add get 48 sub 10 mul msg i 3 add get 48 sub add
26357 msg i 4 add get 48 sub 10 mul msg i 5 add get 48 sub add
26358 msg i 6 add get 48 sub 10 mul msg i 7 add get 48 sub add
26359 ] addtocws
26360 /i i 10 add def
26361 exit
26362 } if
26363 DatumC i get {
26364 msg i get dup fn1 eq exch dup fn2 eq exch fn3 eq or or { % FNCx
26365 [ Cvals msg i get get ] addtocws
26366 ECI i get { % FNC2 then 6 digits
26367 [ ECIabc ] addtocws
26368 /i i 7 add def
26369 exit
26370 } if
26371 msg i get fn3 eq segstart i ne and { % FNC3
26372 /i i 1 add def
26373 /inmac 0 def
26374 /segstart i def
26375 /segend i UntilEndSeg i get add def
26376 exit
26377 } if
26378 /i i 1 add def
26379 exit
26380 } if
26381 [ msg i get 48 sub 10 mul msg i 1 add get 48 sub add ] addtocws
26382 /i i 2 add def
26383 exit
26384 } if
26385 Binary i get { % Binary
26386 nDigits i 1 add get 0 gt {
26387 msg i get 160 lt {
26388 [ Cvals bsa get Avals msg i get 128 sub get ] addtocws
26389 } {
26390 [ Cvals bsb get Bvals msg i get 128 sub get ] addtocws
26391 } ifelse
26392 /i i 1 add def
26393 exit
26394 } if
26395 [ Cvals bin get ] addtocws
26396 /mode BIN def
26397 exit
26398 } if
26399 /m AheadA i get def /n AheadB i get def
26400 m n gt {
26401 [ Cvals laa get ] addtocws
26402 /mode A def
26403 exit
26404 } if
26405 i segstart eq {
26406 msg i get dup 9 eq exch dup 28 eq exch dup 29 eq exch 30 eq or or or {
26407 [ Cvals laa get ] addtocws
26408 /mode A def
26409 exit
26410 } if
26411 } if
26412 n 4 gt {
26413 [ Cvals lab get ] addtocws
26414 /mode B def
26415 exit
26416 } if
26417 [ Cvals [ sfb sb2 sb3 sb4 ] n 1 sub get get ] addtocws
26418 n {
26419 msg i get 13 eq {
26420 [ Bvals crl get ] addtocws
26421 /i i 2 add def
26422 } {
26423 [ Bvals msg i get get ] addtocws
26424 /i i 1 add def
26425 } ifelse
26426 } repeat
26427 exit
26428 } repeat
26429 } def % encC
26430
26431 /encB {
26432 1 { % Common exit
26433 /n TryC i get def
26434 n 2 ge {
26435 n 4 gt {
26436 [ Bvals lac get ] addtocws
26437 /mode C def
26438 exit
26439 } if
26440 [ Bvals [ sfc sc2 sc3 sc4 ] n 1 sub get get ] addtocws
26441 n {
26442 msg i get 0 lt {
26443 [ Cvals msg i get get ] addtocws
26444 /i i 1 add def
26445 } {
26446 [ msg i get 48 sub 10 mul msg i 1 add get 48 sub add ] addtocws
26447 /i i 2 add def
26448 } ifelse
26449 } repeat
26450 exit
26451 } if
26452 DatumB i get {
26453 msg i get dup fn1 eq exch dup fn2 eq exch fn3 eq or or { % FNCx
26454 [ Bvals msg i get get ] addtocws
26455 ECI i get { % FNC2 then 6 digits
26456 [ ECIabc ] addtocws
26457 /i i 7 add def
26458 exit
26459 } if
26460 msg i get fn3 eq i segstart ne and { % FNC3
26461 /i i 1 add def
26462 /mode C def
26463 /inmac 0 def
26464 /segstart i def
26465 /segend i UntilEndSeg i get add def
26466 exit
26467 } if
26468 /i i 1 add def
26469 exit
26470 } if
26471 msg i get 13 eq i msglen 1 sub lt and {
26472 msg i 1 add get 10 eq { % CRLF
26473 [ Bvals crl get ] addtocws
26474 /i i 2 add def
26475 exit
26476 } if
26477 } if
26478 [ Bvals msg i get get ] addtocws
26479 /i i 1 add def
26480 exit
26481 } if
26482 Binary i get { % Binary
26483 DatumB i 1 add get {
26484 msg i get 160 lt {
26485 [ Bvals bsa get Avals msg i get 128 sub get ] addtocws
26486 } {
26487 [ Bvals bsb get Bvals msg i get 128 sub get ] addtocws
26488 } ifelse
26489 /i i 1 add def
26490 exit
26491 } if
26492 [ Bvals bin get ] addtocws
26493 /mode BIN def
26494 exit
26495 } if
26496 AheadA i get 1 eq {
26497 [ Bvals sfa get Avals msg i get get ] addtocws
26498 /i i 1 add def
26499 exit
26500 } if
26501 [ Bvals laa get ] addtocws
26502 /mode A def
26503 exit
26504 } repeat
26505 } def
26506
26507 /encA {
26508 1 { % Common exit
26509 /n TryC i get def
26510 n 2 ge {
26511 n 4 gt {
26512 [ Avals lac get ] addtocws
26513 /mode C def
26514 exit
26515 } if
26516 [ Avals [ sfc sc2 sc3 sc4 ] n 1 sub get get ] addtocws
26517 n {
26518 msg i get 0 lt {
26519 [ Cvals msg i get get ] addtocws
26520 /i i 1 add def
26521 } {
26522 [ msg i get 48 sub 10 mul msg i 1 add get 48 sub add ] addtocws
26523 /i i 2 add def
26524 } ifelse
26525 } repeat
26526 exit
26527 } if
26528 DatumA i get {
26529 msg i get dup fn1 eq exch dup fn2 eq exch fn3 eq or or { % FNCx
26530 [ Avals msg i get get ] addtocws
26531 ECI i get { % FNC2 then 6 digits
26532 [ ECIabc ] addtocws
26533 /i i 7 add def
26534 exit
26535 } if
26536 msg i get fn3 eq i segstart ne and { % FNC3
26537 /i i 1 add def
26538 /mode C def
26539 /inmac 0 def
26540 /segstart i def
26541 /segend i UntilEndSeg i get add def
26542 exit
26543 } if
26544 /i i 1 add def
26545 exit
26546 } if
26547 [ Avals msg i get get ] addtocws
26548 /i i 1 add def
26549 exit
26550 } if
26551 Binary i get { % Binary
26552 DatumA i 1 add get {
26553 msg i get 160 lt {
26554 [ Avals bsa get Avals msg i get 128 sub get ] addtocws
26555 } {
26556 [ Avals bsb get Bvals msg i get 128 sub get ] addtocws
26557 } ifelse
26558 /i i 1 add def
26559 exit
26560 } if
26561 [ Avals bin get ] addtocws
26562 /mode BIN def
26563 exit
26564 } if
26565 /n AheadB i get def
26566 n 6 gt {
26567 [ Avals lab get ] addtocws
26568 /mode B def
26569 exit
26570 } if
26571 [ Avals [ sfb sb2 sb3 sb4 sb5 sb6 ] n 1 sub get get ] addtocws
26572 n {
26573 msg i get 13 eq {
26574 [ Bvals crl get ] addtocws
26575 /i i 2 add def
26576 } {
26577 [ Bvals msg i get get ] addtocws
26578 /i i 1 add def
26579 } ifelse
26580 } repeat
26581 exit
26582 } repeat
26583 } def
26584
26585 /encBIN {
26586 1 { % Common exit
26587 /n TryC i get def
26588 n 2 ge {
26589 [ finaliseBIN ] addtocws
26590 n 7 gt { % Terminate to C
26591 [ BINvals tmc get ] addtocws
26592 /mode C def
26593 exit
26594 } if
26595 [ BINvals [ sc2 sc3 sc4 sc5 sc6 sc7 ] n 2 sub get get ] addtocws
26596 n {
26597 msg i get 0 lt {
26598 [ Cvals msg i get get ] addtocws
26599 /i i 1 add def
26600 } {
26601 [ msg i get 48 sub 10 mul msg i 1 add get 48 sub add ] addtocws
26602 /i i 2 add def
26603 } ifelse
26604 } repeat
26605 exit
26606 } if
26607 ECI i get Binary i 7 add get and { % ECI then binary
26608 [ ECIbin ] addtocws
26609 /i i 7 add def
26610 i msglen eq { [ finaliseBIN ] addtocws } if
26611 exit
26612 } if
26613 msg i get 0 ge { % Not FNCx
26614 Binary i get Binary i 1 add get or
26615 Binary i 2 add get or Binary i 3 add get or
26616 ECI i 1 add get Binary i 8 add get and or {
26617 [ msg i get addtobin ] addtocws
26618 /i i 1 add def
26619 i msglen eq { [ finaliseBIN ] addtocws } if
26620 exit
26621 } if
26622 } if
26623 [ finaliseBIN ] addtocws
26624 i msglen 1 sub ne { % Not last character
26625 msg i get fn3 eq i segstart ne and { % FNC3
26626 [ BINvals tms get ] addtocws
26627 /i i 1 add def
26628 /mode C def
26629 /inmac 0 def
26630 /segstart i def
26631 /segend i UntilEndSeg i get add def
26632 exit
26633 } if
26634 AheadA i get AheadB i get gt {
26635 [ BINvals tma get ] addtocws
26636 /mode A def
26637 } {
26638 [ BINvals tmb get ] addtocws
26639 /mode B def
26640 } ifelse
26641 exit
26642 } if
26643 exit
26644 } repeat
26645 } def
26646
26647 /cws msglen 2 mul 1 add array def
26648 /mode C def
26649 /bvals 5 array def /bpos 0 def
26650 /inmac 0 def /segstart 0 def /segend UntilEndSeg 0 get def
26651 /i 0 def /j 0 def {
26652 i msglen ge {exit} if
26653 inmac 0 ne { % Jump over macro trailers
26654 inmac mac ne i segend 2 sub eq and { % {RS}{EOT}
26655 /i i 2 add def
26656 i msglen ge {exit} if
26657 } if
26658 inmac mac eq i segend 1 sub eq and { % {EOT}
26659 /i i 1 add def
26660 i msglen ge {exit} if
26661 } if
26662 } if
26663 [ /encA /encB /encC /encBIN ] mode get load exec
26664 } loop
26665 /cws cws 0 j getinterval def
26666
26667 % Determine the symbol size
26668 /nd cws length def
26669 /minarea nd 3 add nd 2 idiv add 9 mul 2 add 2 mul def
26670 ratio -1 ne { % Fixed ratio
26671 /hgt minarea ratio div sqrt def
26672 /wid minarea ratio mul sqrt def
26673 /h hgt cvi def /w wid cvi def
26674 h w add 2 mod 1 eq {
26675 h w mul minarea lt {/h h 1 add def /w w 1 add def} if
26676 } {
26677 hgt w mul wid h mul lt {
26678 /w w 1 add def
26679 h w mul minarea lt {
26680 /w w 1 sub def /h h 1 add def
26681 h w mul minarea lt {/w w 2 add def} if
26682 } if
26683 } {
26684 /h h 1 add def
26685 h w mul minarea lt {
26686 /h h 1 sub def /w w 1 add def
26687 h w mul minarea lt {/h h 2 add def} if
26688 } if
26689 } ifelse
26690 } ifelse
26691 /rows h def /columns w def
26692 } {
26693 columns -1 eq { % Fixed height
26694 /columns minarea rows add 1 sub rows idiv dup rows add 2 mod 0 eq {1 add} if def
26695 } if
26696 rows -1 eq { % Fixed width
26697 /rows minarea columns add 1 sub columns idiv dup columns add 2 mod 0 eq {1 add} if def
26698 } if
26699 } ifelse
26700
26701 % Extend the codewords with padding
26702 /ndots rows columns mul 2 idiv def
26703 {
26704 nd 1 add dup 2 idiv 3 add add 9 mul 2 add ndots gt {exit} if
26705 /nd nd 1 add def
26706 } loop
26707 /nc nd 2 idiv 3 add def
26708 /nw nd nc add def
26709 /rembits ndots nw 9 mul 2 add sub def
26710 nd cws length gt {
26711 /cws [
26712 cws aload pop
26713 mode BIN eq {109} {106} ifelse
26714 nd cws length sub 1 sub {106} repeat
26715 ] def
26716 } if
26717
26718 options /debugcws known { /bwipp.debugcws cws //raiseerror exec } if
26719
26720 % Check that the codewords will fit in the symbol
26721 nw 9 mul ndots 2 sub gt {
26722 /bwipp.dotcodeTooLong (Maximum length exceeded) //raiseerror exec
26723 } if
26724
26725 % Create an array containing the character mappings
26726 {
26727 /encs [
26728 (101010101) (010101011) (010101101) (010110101) (011010101)
26729 (101010110) (101011010) (101101010) (110101010) (010101110)
26730 (010110110) (010111010) (011010110) (011011010) (011101010)
26731 (100101011) (100101101) (100110101) (101001011) (101001101)
26732 (101010011) (101011001) (101100101) (101101001) (110010101)
26733 (110100101) (110101001) (001010111) (001011011) (001011101)
26734 (001101011) (001101101) (001110101) (010010111) (010011011)
26735 (010011101) (010100111) (010110011) (010111001) (011001011)
26736 (011001101) (011010011) (011011001) (011100101) (011101001)
26737 (100101110) (100110110) (100111010) (101001110) (101011100)
26738 (101100110) (101101100) (101110010) (101110100) (110010110)
26739 (110011010) (110100110) (110101100) (110110010) (110110100)
26740 (111001010) (111010010) (111010100) (001011110) (001101110)
26741 (001110110) (001111010) (010011110) (010111100) (011001110)
26742 (011011100) (011100110) (011101100) (011110010) (011110100)
26743 (100010111) (100011011) (100011101) (100100111) (100110011)
26744 (100111001) (101000111) (101100011) (101110001) (110001011)
26745 (110001101) (110010011) (110011001) (110100011) (110110001)
26746 (111000101) (111001001) (111010001) (000101111) (000110111)
26747 (000111011) (000111101) (001001111) (001100111) (001110011)
26748 (001111001) (010001111) (011000111) (011100011) (011110001)
26749 (100011110) (100111100) (101111000) (110001110) (110011100)
26750 (110111000) (111000110) (111001100)
26751 ] def
26752 } ctxdef
26753
26754 % Final six dots arranged at edges
26755 rows 2 mod 0 eq {
26756 /sixedges [
26757 [ columns 1 sub rows 2 sub ]
26758 [ 0 rows 2 sub ]
26759 [ columns 2 sub rows 1 sub ]
26760 [ 1 rows 1 sub ]
26761 [ columns 1 sub 0 ]
26762 [ 0 0 ]
26763 ] def
26764 } {
26765 /sixedges [
26766 [ columns 2 sub 0 ]
26767 [ columns 2 sub rows 1 sub ]
26768 [ columns 1 sub 1 ]
26769 [ columns 1 sub rows 2 sub ]
26770 [ 0 0 ]
26771 [ 0 rows 1 sub ]
26772 ] def
26773 } ifelse
26774
26775 /dmv {columns mul add} def
26776
26777 % Construct the template
26778 /outline rows columns mul array def
26779 0 1 rows 1 sub {
26780 /y exch def
26781 0 1 columns 1 sub {
26782 /x exch def
26783 outline x y dmv x y add 2 mod 1 sub put
26784 } for
26785 } for
26786 sixedges {
26787 outline exch aload pop dmv 1 put
26788 } forall
26789
26790 /clearcol {
26791 /x exch def
26792 true
26793 x 1 and 2 rows 1 sub {
26794 x exch dmv sym exch get 1 eq {pop false exit} if
26795 } for
26796 } def
26797
26798 /clearrow {
26799 /y exch def
26800 true
26801 y 1 and 2 columns 1 sub {
26802 y dmv sym exch get 1 eq {pop false exit} if
26803 } for
26804 } def
26805
26806 % Evaluate the symbol
26807 /evalsymbol {
26808 /sym exch def
26809
26810 % Identify the worst side
26811 /worst 9999999 def
26812 [ [ /x 0 ] [ /x 1 ] [ /y 0 ] [ /y 1 ] ] { % Top Bottom Left Right
26813 aload pop /fl exch def /dir exch def
26814 /sum 0 def /first -1 def /last -1 def
26815 0 1 dir /x eq {columns} {rows} ifelse 1 sub {
26816 dir exch def
26817 sym
26818 dir load
26819 dir /x eq {rows} {columns} ifelse 1 sub fl mul
26820 dir /y eq {exch} if
26821 dmv get 1 eq {
26822 first -1 eq {/first dir load def} if
26823 /last dir load def
26824 /sum sum 1 add def
26825 } if
26826 } for
26827 sum last add first sub
26828 dir /x eq {rows} {columns} ifelse mul
26829 dup worst lt {/worst exch def} {pop} ifelse
26830 } forall
26831
26832 /pen 0 def
26833
26834 % Check for groups of blank columns unless data is encoded vertically
26835 % in a symbol of sufficient height to overcome up to six consecutive 0s
26836 % in two neighbouring 5 of 9 dot patterns
26837 rows 2 mod 1 eq rows 12 le or {
26838 /sum 0 def /p 0 def
26839 1 1 columns 2 sub {
26840 clearcol {
26841 /sum sum 1 add def
26842 /p sum 1 eq {rows} {p rows mul} ifelse def
26843 } {
26844 /sum 0 def
26845 /pen pen p add def
26846 /p 0 def
26847 } ifelse
26848 } for
26849 /pen pen p add def
26850 } if
26851
26852 % Check for groups of blank rows unless data is encoded horizontally
26853 % in a symbol of sufficient width to overcome up to six consecutive 0s
26854 % in two neighbouring 5 of 9 dot patterns
26855 rows 2 mod 0 eq columns 12 le or {
26856 /sum 0 def /p 0 def
26857 1 1 rows 2 sub {
26858 clearrow {
26859 /sum sum 1 add def
26860 /p sum 1 eq {columns} {p columns mul} ifelse def
26861 } {
26862 /sum 0 def
26863 /pen pen p add def
26864 /p 0 def
26865 } ifelse
26866 } for
26867 /pen pen p add def
26868 } if
26869
26870 % Pad twice on all sides
26871 /symp [
26872 columns 4 add 2 mul {0} repeat
26873 0 columns sym length 1 sub {
26874 0 exch 0 exch
26875 sym exch columns getinterval aload pop
26876 0 0
26877 } for
26878 columns 4 add 2 mul {0} repeat
26879 ] def
26880
26881 % Count voids and isolated dots
26882 /columns columns 4 add def
26883 /rows rows 4 add def
26884 /sum 0 def
26885 2 1 rows 3 sub {
26886 /y exch def
26887 y 1 and 2 add 2 columns 3 sub {
26888 /x exch def
26889 1 { % Common exit
26890 symp x 1 sub y 1 sub dmv get 1 eq {exit} if
26891 symp x 1 add y 1 sub dmv get 1 eq {exit} if
26892 symp x 1 sub y 1 add dmv get 1 eq {exit} if
26893 symp x 1 add y 1 add dmv get 1 eq {exit} if
26894 symp x y dmv get 0 eq {/sum sum 1 add def exit} if
26895 symp x 2 sub y dmv get 1 eq {exit} if
26896 symp x y 2 sub dmv get 1 eq {exit} if
26897 symp x 2 add y dmv get 1 eq {exit} if
26898 symp x y 2 add dmv get 1 eq {exit} if
26899 /sum sum 1 add def
26900 } repeat
26901 } for
26902 } for
26903 /columns columns 4 sub def
26904 /rows rows 4 sub def
26905
26906 worst 0 eq { % Fixed penalty to disqualify a symbol with an unlit edge
26907 -99999
26908 } {
26909 worst sum sum mul sub pen sub
26910 } ifelse
26911
26912 } def
26913
26914 % Reed Solomon antilog table
26915 {
26916 /rsalog [ 1 112 { dup 3 mul 113 mod } repeat ] def
26917 } ctxdef
26918 /step nw 112 idiv 1 add def
26919 /offset {step mul start add} def
26920
26921 % Evaluate the symbols in the following order:
26922 % fast mode: m3 -> m3' -> m2 -> m2' -> m1 -> m1' -> m0 -> m0'
26923 % dflt mode: (m0 m1 m2 m3) -> (m0' m1' m2' m3')
26924 % -> : Test if we have met the HxW/2 threshold
26925 % m' : Symbols with six edge dots forcibly lit
26926 % () : Best of
26927 /bestscore -99999999 def
26928 /masks mask -1 ne {
26929 [ mask ]
26930 } {
26931 fast { [ 2#11 2#10 2#01 2#00 ] } { [ 2#00 2#01 2#10 2#11 ] } ifelse
26932 } ifelse def
26933 /litmasks 4 array def
26934 masks { % For each mask pattern
26935
26936 /mask exch def
26937
26938 % Calculate the error correction codewords for each block
26939 /rscws [
26940 mask
26941 [ 0 3 7 17 ] mask get 0 cws {1 index add 113 mod exch 2 index add exch 3 1 roll} forall pop pop
26942 nc {0} repeat
26943 ] def
26944 0 1 step 1 sub {
26945 /start exch def
26946 /ND nd 1 add start sub step add 1 sub step idiv def
26947 /NW nw 1 add start sub step add 1 sub step idiv def
26948 /NC NW ND sub def
26949 /coeffs [ 1 NC {0} repeat ] def
26950 1 1 NC {
26951 /i exch def
26952 NC -1 1 {
26953 /j exch def
26954 coeffs j coeffs j get 113 add rsalog i get coeffs j 1 sub get mul 113 mod sub 113 mod put
26955 } for
26956 } for
26957 0 1 ND 1 sub {
26958 /t exch rscws exch offset get rscws ND offset get add 113 mod def
26959 0 1 NC 2 sub {
26960 /j exch def
26961 rscws ND j add offset rscws ND j add 1 add offset get 113 add t coeffs j 1 add get mul 113 mod sub 113 mod put
26962 } for
26963 rscws ND NC add 1 sub offset 113 t coeffs NC get mul 113 mod sub 113 mod put
26964 } for
26965 ND 1 NW 1 sub { dup rscws exch offset 113 rscws 5 -1 roll offset get sub 113 mod put } for
26966 } for
26967
26968 % Create the bitstream
26969 /bits ndots string def
26970 bits 0 [ (00) (01) (10) (11) ] mask get putinterval
26971 1 1 nw {
26972 /i exch def
26973 bits i 1 sub 9 mul 2 add encs rscws i get get putinterval
26974 } for
26975 rembits 0 gt {
26976 bits nw 9 mul 2 add (11111111111111111) 0 rembits getinterval putinterval
26977 } if
26978
26979 % Walk the symbol placing the bitstream
26980 /pixs outline dup length array copy def
26981 /posx 0 def
26982 /posy rows 2 mod 0 eq {0} {rows 1 sub} ifelse def
26983 bits 0 bits length 6 sub getinterval {
26984 { % Move to next vacant position
26985 pixs posx posy dmv get -1 eq {exit} if
26986 rows 2 mod 0 eq {
26987 /posy posy 1 add def
26988 posy rows eq {
26989 /posy 0 def
26990 /posx posx 1 add def
26991 } if
26992 } {
26993 /posx posx 1 add def
26994 posx columns eq {
26995 /posx 0 def
26996 /posy posy 1 sub def
26997 } if
26998 } ifelse
26999 } loop
27000 pixs posx posy dmv 3 -1 roll 48 sub put
27001 } forall
27002 0 1 5 { % Last six edge dots
27003 /i exch def
27004 pixs sixedges i get aload pop dmv
27005 bits bits length 6 sub i add get 48 sub put
27006 } for
27007
27008 % Evaluate the symbol to find the most suitable mask
27009 /score pixs evalsymbol def
27010 score bestscore gt {
27011 /bestsym pixs def
27012 /bestscore score def
27013 fast bestscore rows columns mul 2 idiv gt and {exit} if
27014 } if
27015
27016 % Make a copy with lit edges for possible later evaluation
27017 /litmask pixs dup length array copy def
27018 0 1 5 { % Light last six edge dots
27019 /i exch def
27020 litmask sixedges i get aload pop dmv
27021 1 put
27022 } for
27023 litmasks mask litmask put
27024
27025 % In fast mode immediately score the lit symbol
27026 fast {
27027 /score litmask evalsymbol def
27028 score bestscore gt {
27029 /bestsym litmask def
27030 /bestscore score def
27031 bestscore rows columns mul 2 idiv gt {exit} if
27032 } if
27033 } if
27034
27035 } forall
27036 /pixs bestsym def
27037
27038 % For default mode, if best mask fails threshold then recalculate with lit corners and pick best
27039 fast not bestscore rows columns mul 2 idiv le and {
27040 /bestscore -99999999 def
27041 masks {
27042 litmasks exch get /litmask exch def
27043 /score litmask evalsymbol def
27044 score bestscore gt {
27045 /bestsym litmask def
27046 /bestscore score def
27047 } if
27048 } forall
27049 /pixs bestsym def
27050 } if
27051
27052 % Return the arguments
27053 <<
27054 /ren /renmatrix
27055 /dotty true
27056 /pixs pixs
27057 /pixx columns
27058 /pixy rows
27059 /height rows 2 mul 72 div
27060 /width columns 2 mul 72 div
27061 /borderleft 3.0
27062 /borderright 3.0
27063 /bordertop 3.0
27064 /borderbottom 3.0
27065 /opt options
27066 >>
27067
27068 dontdraw not //renmatrix if
27069
27070 //unloadctx exec
27071
27072 end
27073
27074 }
27075 [/barcode] {null def} forall
27076 bind def
27077 /dotcode dup load /uk.co.terryburton.bwipp defineresource pop
27078 end
27079 /setpacking where {pop setpacking} if
27080 %%EndData
27081 %%EndResource
27082 % --END ENCODER dotcode--
27083
27084 % --BEGIN ENCODER ultracode--
27085 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix--
27086 % --DESC: Ultracode
27087 % --EXAM: Awesome colours!
27088 % --EXOP: eclevel=EC2
27089 % --RNDR: renmatrix
27090 %%BeginResource: uk.co.terryburton.bwipp ultracode 0.0 2025111800 104247 103363
27091 %%BeginData: 357 ASCII Lines
27092 /setpacking where {pop currentpacking true setpacking} if
27093 10 dict
27094 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
27095 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
27096 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
27097 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
27098 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
27099 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
27100 begin
27101 /ultracode {
27102
27103 20 dict begin
27104
27105 /ctx null def
27106 /dontdraw false def
27107 /eclevel (EC2) def % EC1-EC5, and EC0 for rev 1
27108 /parse false def
27109 /parsefnc false def
27110 /start 257 def % 8-bit ISO-8859-1, until we write high-level encoders
27111 /link1 0 def
27112 /raw false def
27113 /rev 2 def % Ultracode specification revision
27114
27115 //processoptions exec /options exch def
27116 /barcode exch def
27117
27118 rev dup 1 ne exch 2 ne and {
27119 /bwipp.ultracodeInvalidRevision (Valid revisions are 1 and 2) //raiseerror exec
27120 } if
27121
27122 eclevel length 3 eq dup {
27123 pop eclevel 0 2 getinterval (EC) eq dup {
27124 pop eclevel 2 get 48 sub dup rev 2 eq {1} {0} ifelse ge exch 5 le and
27125 } if
27126 } if
27127 not {
27128 /bwipp.ultracodeInvalidErrorCorrectionLevel (Valid error correction levels are EC1 to EC5, and EC0 for legacy revision 1) //raiseerror exec
27129 } if
27130
27131 /ultracode //loadctx exec
27132
27133 raw {
27134
27135 /dcws barcode length array def
27136 /i 0 def /j 0 def
27137 { % loop
27138 i barcode length eq {exit} if
27139 /cw barcode i 1 add 3 getinterval cvi def
27140 dcws j cw put
27141 /i i 4 add def
27142 /j j 1 add def
27143 } loop
27144 /dcws dcws 0 j getinterval def
27145
27146 } {
27147
27148 % Parse the input
27149 /fn1 -1 def /fn3 -2 def
27150 /fncvals <<
27151 /parse parse
27152 /parsefnc parsefnc
27153 (FNC1) fn1
27154 (FNC3) fn3
27155 >> def
27156 /msg barcode fncvals //parseinput exec def
27157 /msglen msg length def
27158
27159 /scr [] def % Empty symbol control region
27160 /scp [] def % Empty start sequence parameters
27161 /dcws [
27162 scr aload pop
27163 scp aload pop
27164 msg {
27165 dup fn1 eq {pop 268} if
27166 dup fn3 eq {pop 269} if
27167 } forall
27168 ] def
27169
27170 } ifelse
27171
27172 options /debugcws known { /bwipp.debugcws dcws //raiseerror exec } if
27173
27174 /mcc dcws length 3 add def % Message codewords: start mcc acc [dcws ...]
27175
27176 /eclval eclevel 2 get 48 sub def
27177 eclval 0 ne {
27178 /qcc [0 1 2 4 6 8] eclval get mcc 25 idiv mcc 25 mod 0 ne {1 add} if mul 5 add def
27179 } {
27180 /qcc 3 def
27181 } ifelse
27182 /acc qcc 3 sub 78 link1 mul add def
27183 /tcc mcc qcc add def
27184
27185 % Lookup the most appropriate symbol specification
27186 {
27187 /metrics [
27188 % rows minc maxc mcol
27189 [ 2 7 37 5 ]
27190 [ 3 36 84 13 ]
27191 [ 4 85 161 22 ]
27192 [ 5 142 282 29 ]
27193 ] def
27194 } ctxdef
27195
27196 metrics {
27197 /m exch def
27198 /rows m 0 get def
27199 /minc m 1 get def % Minimum permissible codewords
27200 /maxc m 2 get def % Maximum permissible codewords
27201 /mcol m 3 get def % Minimum tile columns
27202 /okay true def
27203 tcc minc lt tcc maxc gt or {/okay false def} if
27204 okay {exit} if
27205 } forall
27206
27207 okay not {
27208 /bwipp.ultracodeNoValidSymbol (Maximum length exceeded or invalid content) //raiseerror exec
27209 } if
27210
27211 % Determine required number of columns and pads
27212 mcol 1 61 {
27213 /columns exch def
27214 columns
27215 columns 15 ge {1 sub} if
27216 columns 31 ge {1 sub} if
27217 columns 47 ge {1 sub} if
27218 rows mul 3 sub tcc sub dup 0 ge {
27219 /pads exch def
27220 exit
27221 } if
27222 pop
27223 } for
27224 /dcc columns mcol sub def
27225
27226 % Reed-Solomon error correction
27227 /rsseq [
27228 start
27229 mcc
27230 acc
27231 dcws aload pop
27232 qcc {0} repeat
27233 0 % Working space
27234 ] def
27235
27236 % Calculate the log and anti-log tables
27237 {
27238 /rsalog [ 1 282 {dup 3 mul 283 mod} repeat ] def
27239 /rslog 283 array def
27240 1 1 282 {dup rsalog exch get exch rslog 3 1 roll put} for
27241 } ctxdef
27242
27243 % Function to calculate the product in the field
27244 /rsprod {
27245 2 copy 0 ne exch 0 ne and {
27246 rslog exch get exch rslog exch get add 282 mod rsalog exch get
27247 } {
27248 pop pop 0
27249 } ifelse
27250 } def
27251
27252 % Generate the coefficients
27253 /n mcc def /k qcc def
27254 /coeffs [ 1 k {0} repeat ] def
27255 1 1 k {
27256 /i exch def
27257 coeffs i coeffs i 1 sub get put
27258 i 1 sub -1 1 {
27259 /j exch def
27260 coeffs j coeffs j 1 sub get coeffs j get rsalog i get rsprod add 283 mod put
27261 } for
27262 coeffs 0 coeffs 0 get rsalog i get rsprod put
27263 } for
27264 /coeffs coeffs 0 coeffs length 1 sub getinterval def
27265 coeffs length 1 sub -2 0 {coeffs exch 2 copy get 283 exch sub put} for
27266
27267 % Derive the error codewords
27268 0 1 n 1 sub {
27269 /t exch rsseq exch get rsseq n get add 283 mod def
27270 0 1 k 1 sub {
27271 /j exch def
27272 rsseq n j add rsseq n j add 1 add get 283 t coeffs k j sub 1 sub get mul 283 mod sub add 283 mod put
27273 } for
27274 } for
27275 n 1 n k add { dup rsseq exch 283 rsseq 5 -1 roll get sub 283 mod put } for
27276 /ecws rsseq n k getinterval def
27277
27278 options /debugecc known { /bwipp.debugecc ecws //raiseerror exec } if
27279
27280 {
27281 /tiles [
27282 13135 13136 13153 13156 13163 13165 13513 13515 13516 13531 % 0-9
27283 13535 13536 13561 13563 13565 13613 13615 13616 13631 13635 % 10-19
27284 13636 13651 13653 13656 15135 15136 15153 15163 15165 15313 % 20-29
27285 15315 15316 15351 15353 15356 15361 15363 15365 15613 15615 % 30-39
27286 15616 15631 15635 15636 15651 15653 15656 16135 16136 16153 % 40-49
27287 16156 16165 16313 16315 16316 16351 16353 16356 16361 16363 % 50-59
27288 16365 16513 16515 16516 16531 16535 16536 16561 16563 16565 % 60-69
27289 31315 31316 31351 31356 31361 31365 31513 31515 31516 31531 % 70-79
27290 31535 31536 31561 31563 31565 31613 31615 31631 31635 31636 % 80-89
27291 31651 31653 31656 35131 35135 35136 35151 35153 35156 35161 % 90-99
27292 35163 35165 35315 35316 35351 35356 35361 35365 35613 35615 % 100-109
27293 35616 35631 35635 35636 35651 35653 35656 36131 36135 36136 % 110-119
27294 36151 36153 36156 36163 36165 36315 36316 36351 36356 36361 % 120-129
27295 36365 36513 36515 36516 36531 36535 36536 36561 36563 36565 % 130-139
27296 51313 51315 51316 51351 51353 51356 51361 51363 51365 51513 % 140-149
27297 51516 51531 51536 51561 51563 51613 51615 51616 51631 51635 % 150-159
27298 51636 51651 51653 51656 53131 53135 53136 53151 53153 53156 % 160-169
27299 53161 53163 53165 53513 53516 53531 53536 53561 53563 53613 % 170-179
27300 53615 53616 53631 53635 53636 53651 53653 53656 56131 56135 % 180-189
27301 56136 56151 56153 56156 56161 56163 56165 56313 56315 56316 % 190-199
27302 56351 56353 56356 56361 56363 56365 56513 56516 56531 56536 % 200-209
27303 56561 56563 61313 61315 61316 61351 61353 61356 61361 61363 % 210-219
27304 61365 61513 61515 61516 61531 61535 61536 61561 61563 61565 % 220-229
27305 61615 61631 61635 61651 61653 63131 63135 63136 63151 63153 % 230-239
27306 63156 63161 63163 63165 63513 63515 63516 63531 63535 63536 % 240-249
27307 63561 63563 63565 63613 63615 63631 63635 63651 63653 65131 % 250-259
27308 65135 65136 65151 65153 65156 65161 65163 65165 65313 65315 % 260-269
27309 65316 65351 65353 65356 65361 65363 65365 65613 65615 65631 % 270-279
27310 65635 65651 65653 56565 51515 % 280-284
27311 ] def
27312
27313 /dccurev1 [
27314 51363 51563 51653 53153 53163 53513 53563 53613 % 0-7
27315 53653 56153 56163 56313 56353 56363 56513 56563 % 8-15
27316 51316 51356 51536 51616 53156 53516 53536 53616 % 16-23
27317 53636 53656 56136 56156 56316 56356 56516 56536 % 24-31
27318 ] def
27319 /dcclrev1 [
27320 61351 61361 61531 61561 61631 61651 63131 63151 % 0-7
27321 63161 63531 63561 63631 65131 65161 65351 65631 % 8-15
27322 31351 31361 31531 31561 31631 31651 35131 35151 % 16-23
27323 35161 35361 35631 35651 36131 36151 36351 36531 % 24-31
27324 ] def
27325 /dccurev2 [
27326 15316 16316 13516 16516 13616 15616 13136 15136 % 0-7
27327 16136 13536 16536 13636 13156 16156 15356 13656 % 8-15
27328 15313 16313 13513 16513 13613 15613 13153 15153 % 16-23
27329 16153 16353 13653 15653 13163 15163 15363 13563 % 24-31
27330 ] def
27331 /dcclrev2 [
27332 36315 36515 35615 35135 36135 31535 36535 31635 % 0-7
27333 35635 35165 36165 31365 35365 36365 31565 36565 % 8-15
27334 61315 65315 63515 61615 65135 61535 63535 61635 % 16-23
27335 63635 65635 63165 65165 61365 65365 61565 63565 % 24-31
27336 ] def
27337 } ctxdef
27338
27339 /dccu rev 1 eq {dccurev1} {dccurev2} ifelse def
27340 /dccl rev 1 eq {dcclrev1} {dcclrev2} ifelse def
27341
27342 % Create the bitmap
27343 /rows rows 6 mul 1 add def
27344 /columns columns 6 add def
27345 /pixs [ rows columns mul {-1} repeat ] def
27346 /qmv {columns mul add} def
27347 0 1 columns 1 sub {
27348 /i exch def
27349 0 6 rows 1 sub {
27350 /j exch def
27351 i 5 ge {pixs i j qmv i 2 mod 9 mul put} if
27352 } for
27353 pixs i 0 qmv 9 put
27354 pixs i rows 1 sub qmv 9 put
27355 } for
27356 1 1 rows 2 sub {
27357 /i exch def
27358 3 16 columns 1 sub {
27359 /j exch def
27360 pixs j i qmv 1 i 2 mod sub 9 mul put
27361 } for
27362 pixs 0 i qmv 9 put
27363 pixs 1 i qmv 1 i 2 mod sub 9 mul put
27364 pixs 2 i qmv 0 put
27365 pixs 3 i qmv 9 put
27366 pixs 4 i qmv 0 put
27367 pixs columns 1 sub i qmv 9 put
27368 } for
27369
27370 % DCCU and DCCL tiles
27371 /i rows 2 idiv 5 sub def
27372 [
27373 dccu dcc get 10 5 string cvrs {48 sub} forall
27374 0
27375 dccl dcc get 10 5 string cvrs {48 sub} forall
27376 ] {
27377 pixs 2 i qmv 3 -1 roll put
27378 /i i 1 add def
27379 } forall
27380
27381 % Data tiles
27382 /tileseq [
27383 start
27384 mcc
27385 ecws aload pop
27386 tcc
27387 283 % SEP
27388 acc
27389 dcws aload pop
27390 pads {284} repeat
27391 qcc
27392 ] def
27393
27394 /x 5 def /y 1 def
27395 tileseq {
27396 tiles exch get 10 5 string cvrs {
27397 pixs x y qmv 3 -1 roll 48 sub put
27398 /y y 1 add def
27399 } forall
27400 y rows 1 sub ne {
27401 /y y 1 add def % Jump horizontal timing pattern
27402 } {
27403 /x x 1 add def /y 1 def
27404 pixs x y qmv get -1 ne {
27405 /x x 1 add def % Jump vertical timing pattern
27406 } if
27407 } ifelse
27408 } forall
27409
27410 {
27411 /colormap <<
27412 0 (FFFFFF) % W
27413 9 (000000) % K
27414 1 (00FFFF) % C
27415 3 (FF00FF) % M
27416 5 (FFFF00) % Y
27417 6 (00FF00) % G
27418 >> def
27419 } ctxdef
27420
27421 % Return the arguments
27422 <<
27423 /ren /renmatrix
27424 /pixs pixs
27425 /pixx columns
27426 /pixy rows
27427 /height rows 72 div 2 mul
27428 /width columns 72 div 2 mul
27429 /colormap colormap
27430 /borderleft 1.0
27431 /borderright 1.0
27432 /bordertop 1.0
27433 /borderbottom 1.0
27434 /opt options
27435 >>
27436
27437 dontdraw not //renmatrix if
27438
27439 //unloadctx exec
27440
27441 end
27442
27443 }
27444 [/barcode] {null def} forall
27445 bind def
27446 /ultracode dup load /uk.co.terryburton.bwipp defineresource pop
27447 end
27448 /setpacking where {pop setpacking} if
27449 %%EndData
27450 %%EndResource
27451 % --END ENCODER ultracode--
27452
27453 % --BEGIN ENCODER jabcode--
27454 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix--
27455 % --DESC: JAB Code (Beta)
27456 % --EXAM: This is JAB Code
27457 % --EXOP: eclevel=6
27458 % --RNDR: renmatrix
27459 %%BeginResource: uk.co.terryburton.bwipp jabcode 0.0 2025111800 257891 292987
27460 %%BeginData: 1121 ASCII Lines
27461 /setpacking where {pop currentpacking true setpacking} if
27462 10 dict
27463 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
27464 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
27465 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
27466 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
27467 begin
27468 /jabcode {
27469
27470 20 dict begin
27471
27472 /ctx null def
27473 /dontdraw false def
27474 /rows -1 def
27475 /columns -1 def
27476 /slave false def
27477 /colors 16 def
27478 /eclevel 6 def % 0-10
27479 /raw false def
27480 /parse false def
27481 /parsefnc false def
27482 /mask -1 def % 0-7
27483
27484 //processoptions exec /options exch def
27485 /barcode exch def
27486
27487 /databpm colors ln 2 ln div round cvi def
27488 /metabpm colors dup 8 gt {pop 8} if ln 2 ln div round cvi def
27489
27490 % Parse the input
27491 /fn1 -1 def
27492 /fncvals <<
27493 /parse parse
27494 /parsefnc parsefnc
27495 (FNC1) fn1
27496 >> def
27497 /msg barcode fncvals //parseinput exec def
27498 /msglen msg length def
27499
27500 % Wide array support, as needed
27501 {65536 array} stopped {
27502 pop
27503 /arrayw {
27504 dup 65535 idiv 1 add dup array exch 0 exch 1 sub {2 copy 65535 array put 1 add} repeat
27505 1 index 4 1 roll 3 -1 roll 65535 mod array put
27506 } def
27507 /getw {exch 1 index 65535 idiv get exch 65535 mod get} def
27508 /putw {3 1 roll exch 1 index 65535 idiv get exch 65535 mod 3 -1 roll put} def
27509 /copyw {exch 0 exch {dup length array copy 3 copy put pop 1 add} forall pop} def
27510 } {
27511 pop
27512 /arrayw {array} def
27513 /getw {get} def
27514 /putw {put} def
27515 /copyw {copy} def
27516 } ifelse
27517
27518 /addtobits {
27519 dup bits j 3 -1 roll putinterval
27520 length j add /j exch def
27521 } def
27522
27523 /tofixedbits { % Zero padded base 2 string
27524 (0000000000000) 13 string copy dup 4 -1 roll 2 13 string cvrs
27525 dup length 4 index exch sub exch putinterval
27526 0 3 -1 roll getinterval
27527 } def
27528
27529 % Encode the data using byte mode encoding and terminate with EOM
27530 /bits 7 msglen 15 le {4} {17} ifelse add msglen 8 mul add 12 add string def
27531 /j 0 def
27532 31 5 tofixedbits addtobits % MS
27533 (00) addtobits % S/B
27534 msglen 15 le {
27535 msglen 4 tofixedbits addtobits
27536 } {
27537 (0000) addtobits
27538 msglen 16 sub 13 tofixedbits addtobits
27539 } ifelse
27540 0 1 msglen 1 sub {
27541 msg exch get 8 tofixedbits addtobits
27542 } for
27543 28 5 tofixedbits addtobits % L/L
27544 31 5 tofixedbits addtobits % MS
27545 (11) addtobits % EOM
27546
27547 % TODO Cascade
27548 /diffside 21 def
27549 /sameshape false def
27550 /sameecc false def
27551 /hasslaves false def
27552
27553 % Determine the metrics for a symbol of a given size
27554 /metrics {
27555 /mc exch def /mr exch def
27556 mc mr mul % All modules
27557 mc 25 sub 16 idiv 2 add mr 25 sub 16 idiv 2 add
27558 mul 4 sub 7 mul % Alignment modules
27559 64 colors 2 copy gt {exch} if pop 2 mul % Palette modules
27560 slave {7} {17} ifelse 4 mul % Finder modules
27561
27562 % Metadata bits and modules
27563 slave not { % Master
27564 /metass mr mc eq {0} {1} ifelse def
27565 mr mc 2 copy lt {exch} if pop
27566 21 sub 16 idiv [ 0 1 2 2 3 3 3 3 ] exch get /metavf exch def
27567 /metavlen metass 0 eq {[2 2 3 4]} {[4 6 8 10]} ifelse metavf get def
27568 /metaelen metavf 2 mul 10 add def
27569 7 % II: SS VF MSK SF
27570 metavlen add metaelen add % III: V E
27571 hasslaves {4 add} if % III: S
27572 2 mul % LDPC
27573 metabpm div ceiling cvi
27574 dup metabpm mul 6 add /nummetabits exch def
27575 6 add % I: Nc into 6 modules
27576 } { % Slave
27577 3 % I: SS SE SF
27578 sameshape not {5 add} if % II: V
27579 hasslaves {3 add} if % II: S
27580 sameecc not {
27581 mr mc 2 copy lt {exch} if pop
27582 21 sub 16 idiv [ 10 12 14 14 16 16 16 16 ] exch get
27583 add % III: E
27584 } if
27585 2 mul % LDPC
27586 metabpm div ceiling cvi
27587 dup metabpm mul /nummetabits exch def
27588 } ifelse
27589
27590 dup /nummetamodules exch def
27591 add add add sub /numdatamodules exch def
27592 /numdatabits numdatamodules databpm mul def
27593 } def
27594
27595 % Select a symbol size sufficient to carry the message
27596 /coderate [ 0.67 0.63 0.57 0.55 0.50 0.43 0.34 0.25 0.20 0.17 0.14 ] eclevel get def
27597 /grosslen bits length coderate div ceiling cvi def
27598 /snapsize {ceiling cvi 18 sub dup 0 lt {pop 0} if 4 idiv 4 mul 21 add} def
27599
27600 rows -1 eq columns -1 eq and { % Square if neither rows or columns fixed
27601 /size grosslen sqrt snapsize def
27602 {
27603 size size metrics
27604 grosslen numdatabits le {exit} if
27605 /size size 4 add def
27606 } loop
27607 /rows size def
27608 /columns size def
27609 } {
27610 columns -1 eq rows -1 ne and { % Fixed height
27611 /columns grosslen rows div snapsize def
27612 {
27613 rows columns metrics
27614 grosslen numdatabits le {exit} if
27615 /columns columns 4 add def
27616 } loop
27617 } if
27618 rows -1 eq columns -1 ne and { % Fixed width
27619 /rows grosslen columns div snapsize def
27620 {
27621 rows columns metrics
27622 grosslen numdatabits le {exit} if
27623 /rows rows 4 add def
27624 } loop
27625 } if
27626 rows -1 ne columns -1 ne and { % Fixed height and width
27627 rows columns metrics
27628 } if
27629 } ifelse
27630 /C numdatabits def
27631 /cols columns def
27632
27633 % TODO Reject all invalid sizes
27634 rows 145 gt cols 145 gt or {
27635 /bwipp.jabcodeNoValidSymbol (Maximum length exceeded or invalid content) //raiseerror exec
27636 } if
27637
27638 % Pick ECC params to maximally fill symbol
27639 /min C def
27640 3 1 8 {
27641 /i exch def
27642 i 1 add 1 9 {
27643 /j exch def
27644 /dist C j idiv j mul C j idiv i mul sub bits length sub def
27645 dist min lt dist 0 ge and {
27646 /datawc i def
27647 /datawr j def
27648 /min dist def
27649 } if
27650 } for
27651 } for
27652
27653 % Extend the encoded data to fill the required data length
27654 /tmpbits C datawr idiv datawr mul C datawr idiv datawc mul sub string def
27655 tmpbits 0 bits putinterval
27656 bits length 1 tmpbits length 1 sub {
27657 dup 1 sub tmpbits exch get dup 2 mod 0 eq {1 add} {1 sub} ifelse
27658 tmpbits 3 1 roll put
27659 } for
27660 /bits tmpbits def
27661
27662 % Avoid 15-bit overflow when multiplying the digits by stealing from the second digit
27663 % m = 6364136223846793005 = 0x 5851 f42d 4c95 7f2d
27664 /m0 16#5851 16#1 add def /m1 16#f42d 16#10000 sub def /m2 16#4c95 def /m3 16#7f2d def
27665
27666 /lcg64_temper {
27667
27668 % Multiply seed by 6364136223846793005 then add 1
27669
27670 /p00 m0 s0 mul def /p01 m0 s1 mul def /p02 m0 s2 mul def /p03 m0 s3 mul def
27671 /p10 m1 s0 mul def /p11 m1 s1 mul def /p12 m1 s2 mul def /p13 m1 s3 mul def
27672 /p20 m2 s0 mul def /p21 m2 s1 mul def /p22 m2 s2 mul def /p23 m2 s3 mul def
27673 /p30 m3 s0 mul def /p31 m3 s1 mul def /p32 m3 s2 mul def /p33 m3 s3 mul def
27674
27675 /s3 p33 16#10000 mod 1 add def % 1 added here
27676 /s2 p32 16#10000 mod p33 16#10000 idiv add
27677 p23 16#10000 mod add def
27678 /s1 p31 16#10000 mod p32 16#10000 idiv add
27679 p22 16#10000 mod p23 16#10000 idiv add add
27680 p13 16#10000 mod add def
27681 /s0 p30 16#10000 mod p31 16#10000 idiv add
27682 p21 16#10000 mod p22 16#10000 idiv add add
27683 p12 16#10000 mod p13 16#10000 idiv add add
27684 p03 16#10000 mod add def
27685
27686 % Simplify carry by making each digit positive by borrowing from more significant digit
27687 /s3 s3 16#10000 add def
27688 /s2 s2 16#ffff add def
27689 /s1 s1 16#ffff add def
27690 /s0 s0 16#ffff add def
27691
27692 % Carry
27693 /s2 s3 16#10000 idiv s2 add def /s3 s3 16#10000 mod def
27694 /s1 s2 16#10000 idiv s1 add def /s2 s2 16#10000 mod def
27695 /s0 s1 16#10000 idiv s0 add def /s1 s1 16#10000 mod def
27696 /s0 s0 16#10000 mod def
27697
27698 % Temper most significant 32 bits
27699 s0 16#8000 sub 16#10000 mul s1 add 16#80000000 xor
27700 16#ffffffff and
27701 dup -11 bitshift xor
27702 dup 7 bitshift 16#62d3a980 neg and xor % 0x9D2C5680 - 0x100000000
27703 dup 15 bitshift 16#103a0000 neg and xor % 0xEFC60000 - 0x100000000
27704 16#ffffffff and
27705 dup -18 bitshift xor
27706
27707 } def
27708
27709 /createMatrixA {
27710
27711 /nb_pcb wr 4 lt {Pg_sub_block 2 idiv} {Pg_sub_block wr idiv wc mul} ifelse def
27712 /offset Pg_sub_block 32 div ceiling cvi def
27713 /effwidth offset 32 mul def
27714 /matrixA offset nb_pcb mul arrayw def
27715 0 1 offset nb_pcb mul 1 sub {matrixA exch 0 putw} for
27716 /permutation Pg_sub_block array def
27717 0 1 Pg_sub_block 1 sub {permutation exch dup put} for
27718
27719 0 1 Pg_sub_block wr idiv 1 sub {
27720 /i exch def
27721 0 1 wr 1 sub {
27722 /j exch def
27723 matrixA i effwidth wr add mul j add 32 idiv
27724 2 copy getw 1 31 i effwidth wr add mul j add 32 mod sub bitshift or putw
27725 } for
27726 } for
27727
27728 % Pseudorandom permutation
27729 /s0 16#0000 def /s1 16#0000 def /s2 16#000B def /s3 16#FC39 def % s=785465
27730 1 1 wc 1 sub {
27731 /i exch def
27732 /off_index Pg_sub_block wr idiv i mul def
27733 0 1 Pg_sub_block 1 sub {
27734 /j exch def
27735 lcg64_temper
27736 dup 0 lt {16#80000000 xor 2147483648.0 add} if
27737 4294967296.0 div Pg_sub_block j sub mul cvi % (float)UINT32_MAX = 65536.0 * 65536
27738 /pos exch def
27739 0 1 Pg_sub_block wr idiv 1 sub {
27740 /k exch def
27741 matrixA off_index k add offset mul j 32 idiv add
27742 2 copy getw
27743 matrixA permutation pos get 32 idiv k offset mul add getw
27744 31 permutation pos get 32 mod sub neg bitshift 1 and
27745 31 j 32 mod sub bitshift
27746 or putw
27747 } for
27748 permutation pos permutation Pg_sub_block 1 sub j sub 2 copy get permutation pos get
27749 exch 4 1 roll % p b p a p[a] p[b] -> p b p[a] p a p[b]
27750 put put
27751 } for
27752 } for
27753
27754 } def
27755
27756 /createMetadataMatrixA {
27757
27758 /nb_pcb Pg_sub_block 2 idiv def
27759 /offset Pg_sub_block 32 div ceiling cvi def
27760 /matrixA offset nb_pcb mul arrayw def
27761 0 1 offset nb_pcb mul 1 sub {matrixA exch 0 putw} for
27762 /permutation Pg_sub_block array def
27763 0 1 Pg_sub_block 1 sub {permutation exch dup put} for
27764
27765 % Pseudorandom permutation
27766 /s0 16#0000 def /s1 16#0000 def /s2 16#0000 def /s3 16#9691 def % s=38545
27767 /nb_once nb_pcb wc div Pg_sub_block mul 3 add cvi nb_pcb idiv def
27768 0 1 nb_pcb 1 sub {
27769 /i exch def
27770 0 1 nb_once 1 sub {
27771 /j exch def
27772 lcg64_temper
27773 dup 0 lt {16#80000000 xor 2147483648.0 add} if
27774 4294967296.0 div Pg_sub_block j sub mul cvi % (float)UINT32_MAX = 65536.0 * 65536
27775 /pos exch def
27776 matrixA i offset mul permutation pos get 32 idiv add
27777 2 copy getw 1 31 permutation pos get 32 mod sub bitshift or putw
27778 permutation pos permutation Pg_sub_block 1 sub j sub 2 copy get permutation pos get
27779 exch 4 1 roll % p b p a p[a] p[b] -> p b p[a] p a p[b]
27780 put put
27781 } for
27782 } for
27783
27784 } def
27785
27786 /GaussJordan {
27787
27788 /nb_pcb wr 4 lt {Pg_sub_block 2 idiv} {Pg_sub_block wr idiv wc mul} ifelse def
27789 /offset Pg_sub_block 32 div ceiling cvi def
27790 /matrixH matrixA dup length array copyw def
27791 /column_arrangement [ Pg_sub_block {0} repeat ] def
27792 /processed_column [ Pg_sub_block {false} repeat ] def
27793 /zero_lines_nb [ nb_pcb {0} repeat ] def
27794 /swap_col [ Pg_sub_block 2 mul {0} repeat ] def
27795 /zero_lines 0 def
27796
27797 /loop0 0 def
27798 0 1 nb_pcb 1 sub {
27799 /i exch def
27800 /pivot_column Pg_sub_block 1 add def
27801 0 1 Pg_sub_block 1 sub {
27802 /j exch def
27803 matrixH offset 32 mul i mul j add 32 idiv getw
27804 31 offset 32 mul i mul j add 32 mod sub neg bitshift 1 and 1 eq {
27805 /pivot_column j def
27806 exit
27807 } if
27808 } for
27809 pivot_column Pg_sub_block lt {
27810 processed_column pivot_column true put
27811 column_arrangement pivot_column i put
27812 pivot_column nb_pcb ge {
27813 swap_col loop0 2 mul pivot_column put
27814 /loop0 loop0 1 add def
27815 } if
27816 /off_index pivot_column 32 idiv def
27817 /off_index1 pivot_column 32 mod def
27818 0 1 nb_pcb 1 sub {
27819 /j exch def
27820 i j ne {
27821 matrixH off_index j offset mul add getw
27822 31 off_index1 sub neg bitshift 1 and 1 eq {
27823 0 1 offset 1 sub {
27824 /k exch def
27825 matrixH offset j mul k add
27826 2 copy getw matrixH offset i mul k add getw xor putw
27827 } for
27828 } if
27829 } if
27830 } for
27831 } {
27832 zero_lines_nb zero_lines i put
27833 /zero_lines zero_lines 1 add def
27834 } ifelse
27835 } for
27836
27837 /matrix_rank nb_pcb zero_lines sub def
27838 /loop2 0 def
27839 matrix_rank 1 nb_pcb 1 sub {
27840 /i exch def
27841 column_arrangement i get 0 gt {
27842 0 1 nb_pcb 1 sub {
27843 /j exch def
27844 processed_column j get not {
27845 column_arrangement j column_arrangement i get put
27846 column_arrangement i 0 put
27847 processed_column j true put
27848 processed_column i false put
27849 swap_col loop0 2 mul i put
27850 swap_col loop0 2 mul 1 add j put
27851 column_arrangement i j put
27852 /loop0 loop0 1 add def
27853 /loop2 loop2 1 add def
27854 exit
27855 } if
27856 } for
27857 } if
27858 } for
27859
27860 /loop1 0 def
27861 0 1 nb_pcb 1 sub {
27862 /kl exch def
27863 processed_column kl get not loop1 loop0 loop2 sub lt and {
27864 column_arrangement kl column_arrangement swap_col loop1 2 mul get get put
27865 processed_column kl true put
27866 swap_col loop1 2 mul 1 add kl put
27867 /loop1 loop1 1 add def
27868 } if
27869 } for
27870
27871 /loop1 0 def
27872 0 1 nb_pcb 1 sub {
27873 /kl exch def
27874 processed_column kl get not {
27875 column_arrangement kl zero_lines_nb loop1 get put
27876 /loop1 loop1 1 add def
27877 } if
27878 } for
27879
27880 0 1 nb_pcb 1 sub {
27881 /i exch def
27882 0 1 offset 1 sub {
27883 /j exch def
27884 matrixH column_arrangement i get offset mul j add getw
27885 matrixA exch i offset mul j add exch putw
27886 } for
27887 } for
27888
27889 /tmp 0 def
27890 0 1 loop0 1 sub {
27891 /i exch def
27892 0 1 nb_pcb 1 sub {
27893 /j exch def
27894 matrixA swap_col i 2 mul get 32 idiv j offset mul add getw
27895 31 swap_col i 2 mul get 32 mod sub neg bitshift 1 and neg tmp xor 1 and
27896 tmp xor /tmp exch def
27897 matrixA swap_col i 2 mul get 32 idiv j offset mul add
27898 2 copy getw
27899 matrixA swap_col i 2 mul 1 add get 32 idiv j offset mul add getw
27900 31 swap_col i 2 mul 1 add get 32 mod sub neg bitshift 1 and neg
27901 matrixA swap_col i 2 mul get 32 idiv j offset mul add getw xor
27902 1 31 swap_col i 2 mul get 32 mod sub bitshift and
27903 xor putw
27904 matrixA swap_col i 2 mul 1 add get 32 idiv j offset mul add
27905 2 copy getw
27906 tmp 1 and neg
27907 matrixA swap_col i 2 mul 1 add get 32 idiv j offset mul add getw xor
27908 1 31 swap_col i 2 mul 1 add get 32 mod sub bitshift and
27909 xor putw
27910 } for
27911 } for
27912
27913 } def
27914
27915 /createGeneratorMatrix {
27916
27917 /pn Pg_sub_block matrix_rank sub def
27918 /offset pn 32 div ceiling cvi def
27919 /effwidth offset 32 mul def
27920 /offset_cap Pg_sub_block 32 div ceiling cvi def
27921 /G offset Pg_sub_block mul arrayw def
27922 0 1 offset Pg_sub_block mul 1 sub {
27923 G exch 0 putw
27924 } for
27925 0 1 pn 1 sub {
27926 /i exch def
27927 G Pg_sub_block pn sub i add offset mul i 32 idiv add
27928 2 copy getw 1 31 i 32 mod sub bitshift or putw
27929 } for
27930 /matrix_index Pg_sub_block pn sub def
27931 /loop0 0 def
27932 0 1 Pg_sub_block pn sub effwidth mul 1 sub {
27933 /i exch def
27934 matrix_index Pg_sub_block ge {
27935 /loop0 loop0 1 add def
27936 /matrix_index Pg_sub_block pn sub def
27937 } if
27938 i effwidth mod pn lt {
27939 G i 32 idiv
27940 2 copy getw
27941 matrixA matrix_index 32 idiv offset_cap loop0 mul add getw
27942 31 matrix_index 32 mod sub neg bitshift 1 and neg
27943 G i 32 idiv getw xor
27944 1 31 i 32 mod sub bitshift and
27945 xor putw
27946 /matrix_index matrix_index 1 add def
27947 } if
27948 } for
27949
27950 } def
27951
27952 /ldpc {
27953
27954 /wr exch def
27955 /wc exch def
27956 [ exch {48 sub} forall ] /data exch def
27957
27958 /Pn data length def
27959 wr -1 ne { % Message data
27960 /Pg Pn wr mul wr wc sub div ceiling wr div ceiling wr mul cvi def
27961 /nb_sub_blocks Pg 2700 idiv 1 add def
27962 /Pg_sub_block Pg nb_sub_blocks idiv wr idiv wr mul def
27963 /Pn_sub_block Pg_sub_block wr wc sub mul wr idiv def
27964 /nb_sub_blocks Pg Pg_sub_block idiv def
27965 /encoding_iterations Pg Pg_sub_block idiv Pn_sub_block nb_sub_blocks mul Pn lt {1 sub} if def
27966 createMatrixA
27967 } { % Metadata
27968 /Pg Pn 2 mul def
27969 /nb_sub_blocks 1 def
27970 /Pg_sub_block Pg def
27971 /Pn_sub_block Pn def
27972 /encoding_iterations 1 def
27973 createMetadataMatrixA
27974 } ifelse
27975 GaussJordan
27976 createGeneratorMatrix
27977
27978 /ecc_encoded_data Pg array def
27979
27980 /offset Pg_sub_block matrix_rank sub 32 div ceiling cvi def
27981 0 1 encoding_iterations 1 sub {
27982 /iter exch def
27983 0 1 Pg_sub_block 1 sub {
27984 /i exch def
27985 /temp 0 def
27986 /loop0 0 def
27987 /offset_index offset i mul def
27988 iter Pn_sub_block mul 1 iter 1 add Pn_sub_block mul 1 sub {
27989 data exch get
27990 G offset_index loop0 32 idiv add getw 31 loop0 32 mod sub neg bitshift 1 and and
27991 /temp exch temp xor def
27992 /loop0 loop0 1 add def
27993 } for
27994 ecc_encoded_data i iter Pg_sub_block mul add temp put
27995 } for
27996 } for
27997
27998 encoding_iterations nb_sub_blocks ne {
27999 /start encoding_iterations Pn_sub_block mul def
28000 /last_index encoding_iterations Pg_sub_block mul def
28001 /Pg_sub_block Pg encoding_iterations Pg_sub_block mul sub def
28002 /Pn_sub_block Pg_sub_block wr wc sub mul wr idiv def
28003 createMatrixA
28004 GaussJordan
28005 createGeneratorMatrix
28006 /offset Pg_sub_block matrix_rank sub 32 div ceiling cvi def
28007 0 1 Pg_sub_block 1 sub {
28008 /i exch def
28009 /temp 0 def
28010 /loop0 0 def
28011 /offset_index offset i mul def
28012 start 1 Pn 1 sub {
28013 data exch get
28014 G offset_index loop0 32 idiv add getw 31 loop0 32 mod sub neg bitshift 1 and and
28015 /temp exch temp xor def
28016 /loop0 loop0 1 add def
28017 } for
28018 ecc_encoded_data i last_index add temp put
28019 } for
28020 } if
28021
28022 /out Pg string def
28023 0 1 Pg 1 sub {
28024 dup ecc_encoded_data exch get
28025 out 3 1 roll 48 add put
28026 } for
28027 out
28028
28029 } def
28030
28031 % Replace data bitstream with LDPC error correction stream
28032 /bits bits datawc datawr ldpc def
28033
28034 % Interleave via pseudorandom permutation
28035 /s0 16#0000 def /s1 16#0000 def /s2 16#0003 def /s3 16#75C7 def % s=226759
28036 bits length 1 sub -1 1 {
28037 /l exch def
28038 lcg64_temper
28039 dup 0 lt {16#80000000 xor 2147483648.0 add} if
28040 4294967296.0 div l 1 add mul cvi % (float)UINT32_MAX = 65536.0 * 65536
28041 /r exch def
28042 bits l get bits r get
28043 bits exch l exch put
28044 bits exch r exch put
28045 } for
28046
28047 % Append padding bits to the interleaved, ECC encoded data up to capacity
28048 /tmpbits C string def
28049 tmpbits 0 bits putinterval
28050 /j bits length def
28051 C j sub 1 add 2 idiv {
28052 tmpbits j 48 put
28053 j 1 add C lt {tmpbits j 1 add 49 put} if
28054 /j j 2 add def
28055 } repeat
28056 /bits tmpbits def
28057
28058 % Define the color palette
28059 colors 4 eq {
28060 /bi 0 def /gi 1 def /mi 2 def /yi 3 def
28061 /ki 4 def /wi 5 def % Extended
28062 /palette <<
28063 bi (0000FF) gi (00FF00) mi (FF00FF) yi (FFFF00)
28064 ki (000000) wi (FFFFFF)
28065 >> def
28066 /metacolorindex [bi gi mi yi] def
28067 /palettelayout [bi gi mi yi] def
28068 } {
28069 /rgbres <<
28070 % r g b Graduations
28071 8 [ 2 2 2 ]
28072 16 [ 4 2 2 ]
28073 32 [ 4 4 2 ]
28074 64 [ 4 4 4 ]
28075 128 [ 8 4 4 ]
28076 256 [ 8 8 4 ]
28077 >> colors get def
28078
28079 /rvals rgbres 0 get [ exch 1 sub dup 0 exch 1 exch {255 2 index div mul round cvi exch} for pop ] def
28080 /gvals rgbres 1 get [ exch 1 sub dup 0 exch 1 exch {255 2 index div mul round cvi exch} for pop ] def
28081 /bvals rgbres 2 get [ exch 1 sub dup 0 exch 1 exch {255 2 index div mul round cvi exch} for pop ] def
28082
28083 /palette colors dict def
28084 /palettelayout 64 colors 2 copy gt {exch} if pop array def
28085 /i 0 def /j 8 def
28086 rvals {
28087 /r exch def
28088 gvals {
28089 /g exch def
28090 bvals {
28091 /b exch def
28092 r 16 bitshift g 8 bitshift or b or
28093 (000000) 6 string copy dup 3 -1 roll 16 6 string cvrs dup length 6 exch sub exch putinterval
28094 false
28095 1 index (000000) eq {/ki i def pop true} if
28096 1 index (0000FF) eq {/bi i def pop true} if
28097 1 index (00FF00) eq {/gi i def pop true} if
28098 1 index (00FFFF) eq {/ci i def pop true} if
28099 1 index (FF0000) eq {/ri i def pop true} if
28100 1 index (FF00FF) eq {/mi i def pop true} if
28101 1 index (FFFF00) eq {/yi i def pop true} if
28102 1 index (FFFFFF) eq {/wi i def pop true} if
28103 not {
28104 colors 64 le
28105 colors 128 eq
28106 r 0 eq r 73 eq or r 182 eq or r 255 eq or and
28107 colors 256 eq
28108 r 0 eq r 73 eq or r 182 eq or r 255 eq or and
28109 g 0 eq g 73 eq or g 182 eq or g 255 eq or and
28110 or or { % RGB space is sampled into 64 slots
28111 palettelayout j i put
28112 /j j 1 add def
28113 } if
28114 } if
28115 palette exch i exch put
28116 /i i 1 add def
28117 } forall
28118 } forall
28119 } forall
28120 palettelayout 0 [ki bi gi ci ri mi yi wi] putinterval
28121 /metacolorindex [ki bi gi ci ri mi yi wi] def
28122 } ifelse
28123
28124 % Create the pixel map
28125 /pixs [rows cols mul {-1} repeat] def
28126 /jmv {cols mul add} def
28127
28128 % Finder patterns
28129 slave not { % Master alignment pattern
28130 /fpat [
28131 [ 1 1 1 0 0 ]
28132 [ 1 2 2 0 0 ]
28133 [ 1 2 1 2 1 ]
28134 [ 0 0 2 2 1 ]
28135 [ 0 0 1 1 1 ]
28136 ] def
28137 /fmap [
28138 [ -1 bi yi ] % UL
28139 [ -1 yi bi ] % LL
28140 [ -1 gi mi ] % UR
28141 [ -1 mi gi ] % LR
28142 ] def
28143 } { % Slave alignment pattern
28144 /fpat [
28145 [ 0 0 0 0 0 ]
28146 [ 0 2 2 0 0 ]
28147 [ 0 2 1 2 0 ]
28148 [ 0 0 2 2 0 ]
28149 [ 0 0 0 0 0 ]
28150 ] def
28151 /fmap [
28152 [ -1 ki wi ] % UL
28153 [ -1 ki wi ] % LL
28154 [ -1 ki wi ] % UR
28155 [ -1 ki wi ] % LR
28156 ] def
28157 } ifelse
28158 0 1 4 {
28159 /y exch def
28160 0 1 4 {
28161 /x exch def
28162 /fpb fpat y get x get def
28163 pixs x 1 add y 1 add jmv fmap 0 get fpb get put
28164 pixs x 1 add rows y sub 2 sub jmv fmap 1 get fpb get put
28165 pixs x cols add 6 sub y 1 add jmv fmap 2 get fpb get put
28166 pixs x cols add 6 sub rows y sub 2 sub jmv fmap 3 get fpb get put
28167 } for
28168 } for
28169
28170 % Alignment patterns
28171 /algnpat0 [
28172 [ ki ki -1 ]
28173 [ ki wi ki ]
28174 [ -1 ki ki ]
28175 ] def
28176 /algnpat1 [
28177 [ -1 ki ki ]
28178 [ ki wi ki ]
28179 [ ki ki -1 ]
28180 ] def
28181 /num cols 16 div round cvi 1 sub def
28182 /algnrpos [ 3 17 ] def
28183 num 0 gt {
28184 /algnrpos [ 0 1 num {cols 7 sub num div mul cvi 3 add} for ] def
28185 } if
28186 /num rows 16 div round cvi 1 sub def
28187 /algncpos [ 3 17 ] def
28188 num 0 gt {
28189 /algncpos [ 0 1 num {rows 7 sub num div mul cvi 3 add} for ] def
28190 } if
28191 /putalgnpat {
28192 /pp exch def
28193 /py exch def
28194 /px exch def
28195 0 1 2 {
28196 /pb exch def
28197 0 1 2 {
28198 /pa exch def
28199 pixs px pa add py pb add jmv pp pb get pa get put
28200 } for
28201 } for
28202 } def
28203 0 1 algncpos length 1 sub {
28204 /j exch def
28205 /y algncpos j get def
28206 0 1 algnrpos length 1 sub {
28207 /i exch def
28208 /x algnrpos i get def
28209 pixs x y jmv get -1 eq {
28210 x 1 sub y 1 sub i j add 2 mod 0 eq {algnpat0} {algnpat1} ifelse putalgnpat
28211 } if
28212 } for
28213 } for
28214
28215 slave not {
28216
28217 [ % Expanded to [ x y ] [ x -y ] [ -x -y ] [ x -y ]
28218 % Metadata and palette
28219 [ 6 1 ] [ 6 2 ] [ 6 3 ] [ 6 4 ] [ 6 5 ] [ 6 6 ] [ 5 6 ] [ 4 6 ] [ 3 6 ] [ 2 6 ] % 0-39
28220 [ 1 6 ] [ 7 1 ] [ 7 2 ] [ 7 3 ] [ 7 4 ] [ 7 5 ] [ 7 6 ] [ 7 7 ] [ 6 7 ] [ 5 7 ] % 40-79
28221 % Palette only
28222 [ 4 7 ] [ 3 7 ] [ 2 7 ] [ 1 7 ] [ 8 1 ] [ 8 2 ] [ 8 3 ] [ 8 4 ] % 16-31
28223 [ 8 5 ] [ 8 6 ] [ 8 7 ] [ 8 8 ] [ 7 8 ] [ 6 8 ] [ 5 8 ] [ 4 8 ] % 32-47
28224 [ 3 8 ] [ 2 8 ] [ 1 8 ] [ 9 1 ] [ 9 2 ] [ 9 3 ] [ 9 4 ] [ 9 5 ] % 48-63
28225 ] {
28226 aload pop /y exch def /x exch def
28227 [ x y ] [ x neg y ] [ x neg y neg ] [ x y neg ]
28228 } forall
28229 176 array astore /metadatamap exch def
28230
28231 /palettemap1 [
28232 [ 4 1 ] [ 4 2 ] [ 5 1 ] [ 5 2 ] [ 2 4 ] [ 2 5 ] [ 1 4 ] [ 1 5 ] % 0-7
28233 [ -2 1 ] [ -2 2 ] [ -1 1 ] [ -1 2 ] [ -4 4 ] [ -4 5 ] [ -5 4 ] [ -5 5 ] % 8-15
28234 ] def
28235
28236 /palettemap2 [
28237 [ -4 -5 ] [ -4 -4 ] [ -5 -5 ] [ -5 -4 ] [ -2 -2 ] [ -2 -1 ] [ -1 -2 ] [ -1 -1 ] % 0-7
28238 [ 2 -5 ] [ 2 -4 ] [ 1 -5 ] [ 1 -4 ] [ 4 -2 ] [ 4 -1 ] [ 5 -2 ] [ 5 -1 ] % 8-15
28239 ] def
28240
28241 } { % Slave
28242
28243 % TODO Cascade
28244
28245 /metadatamap [
28246 1 1 19 {
28247 /i exch def
28248 [ 0 i ] [ 1 i ]
28249 } for
28250 5 1 12 {
28251 /i exch def
28252 [ 2 i ] [ 3 i ]
28253 } for
28254 ] def
28255
28256 /palettemap1 [
28257 5 1 12 { [ exch 4 exch ] } for
28258 12 -1 5 { [ exch 5 exch ] } for
28259 5 1 12 { [ exch 6 exch ] } for
28260 12 -1 5 { [ exch 7 exch ] } for
28261 ] def
28262
28263 /palettemap2 [
28264 palettemap1 {[ exch aload pop neg exch neg exch]} forall
28265 ] def
28266
28267 } ifelse
28268
28269 % Normalise wrapping
28270 metadatamap {
28271 dup 0 get dup 0 lt {cols add 1 sub 1 index 0 3 -1 roll put} {pop} ifelse
28272 dup 1 get dup 0 lt {rows add 1 sub 1 index 1 3 -1 roll put} {pop} ifelse
28273 pop
28274 } forall
28275 palettemap1 {
28276 dup 0 get dup 0 lt {cols add 1 sub 1 index 0 3 -1 roll put} {pop} ifelse
28277 dup 1 get dup 0 lt {rows add 1 sub 1 index 1 3 -1 roll put} {pop} ifelse
28278 pop
28279 } forall
28280 palettemap2 {
28281 dup 0 get dup 0 lt {cols add 1 sub 1 index 0 3 -1 roll put} {pop} ifelse
28282 dup 1 get dup 0 lt {rows add 1 sub 1 index 1 3 -1 roll put} {pop} ifelse
28283 pop
28284 } forall
28285
28286 % Reserve the metadata modules to be placed once mask is determined
28287 0 1 nummetamodules 1 sub {
28288 pixs exch metadatamap exch get aload pop jmv 0 put
28289 } for
28290
28291 % Place the color palette
28292 slave not {
28293 % Up to first 16 colors into finder slots
28294 0 1 16 colors 2 copy gt {exch} if pop 1 sub {
28295 /i exch def
28296 palettelayout i get dup
28297 pixs exch palettemap1 i get aload pop jmv exch put
28298 pixs exch palettemap2 i get aload pop jmv exch put
28299 } for
28300 /i 16 def
28301 } {
28302 /i 0 def
28303 } ifelse
28304
28305 % Continue palette placement after end of metadata modules
28306 /j nummetamodules def
28307 i 2 palettelayout length 1 sub {
28308 /i exch def
28309 palettelayout i get dup
28310 pixs exch metadatamap j get aload pop jmv exch put
28311 pixs exch metadatamap j 2 add get aload pop jmv exch put
28312 palettelayout i 1 add get dup
28313 pixs exch metadatamap j 1 add get aload pop jmv exch put
28314 pixs exch metadatamap j 3 add get aload pop jmv exch put
28315 /j j 4 add def
28316 } for
28317
28318 % Calculate the mask patterns applied to data modules
28319 /maskfuncs [
28320 {add colors mod}
28321 {pop colors mod}
28322 {exch pop colors mod}
28323 {3 idiv exch 2 idiv add colors mod}
28324 {2 idiv exch 3 idiv add colors mod}
28325 {add dup 2 idiv exch 3 idiv add colors mod}
28326 {2 copy exch dup mul mul 7 mod 3 1 roll exch dup mul add 2 mul 19 mod add colors mod}
28327 {2 copy dup mul mul 5 mod 3 1 roll dup mul exch 2 mul add 13 mod add colors mod}
28328 ] def
28329 mask -1 ne { % User specifies a mask
28330 /maskfuncs [maskfuncs mask get] def
28331 /bestmaskval mask def
28332 } if
28333 /masks maskfuncs length array def
28334 0 1 masks length 1 sub {
28335 /m exch def
28336 /mask rows cols mul array def
28337 0 1 rows 1 sub {
28338 /j exch def
28339 0 1 cols 1 sub {
28340 /i exch def
28341 pixs i j jmv get -1 eq {i j maskfuncs m get exec} {0} ifelse
28342 mask i j jmv 3 -1 roll put
28343 } for
28344 } for
28345 masks m mask put
28346 } for
28347
28348 % Walk the symbol placing the data bitstream
28349 /posx 0 def /posy 0 def
28350 /i 0 def
28351 { % loop
28352 posx cols eq {exit} if
28353 pixs posx posy jmv get -1 eq {
28354 bits i databpm getinterval 0 exch {48 sub add 2 mul} forall 2 idiv
28355 pixs posx posy jmv 3 -1 roll put
28356 /i i databpm add def
28357 } if
28358 /posy posy 1 add def
28359 posy rows eq {/posy 0 def /posx posx 1 add def} if
28360 } loop
28361
28362 % Evaluate runlength encoded rows or columns in full symbols
28363 /evalrle {
28364 /scrle exch def
28365 /scr1 0 def /scr3 0 def
28366 0 2 scrle length 2 sub {
28367 /j exch def
28368 scrle j 1 add get -1 ne { % Skip over voids
28369 % Detect runs of 5 or more like modules, except in voids
28370 scrle j get dup 5 ge {2 sub /scr1 exch scr1 add def} {pop} ifelse
28371 % Detect finder pattern
28372 j 4 ge j scrle length 5 sub le and {
28373 scrle j 4 sub 10 getinterval % n1 c1 ... n5 c5
28374 dup {1 eq} forall pop 4 {exch pop and} repeat { % n{1-5}=1
28375 mark exch aload pop
28376 8 index dup 6 index eq exch 2 index eq and % c1=c3=c5
28377 7 index 4 index eq and { % c2=c4
28378 2 index /c4 exch def /c5 exch def
28379 c4 bi eq c5 yi eq and c4 yi eq c5 bi eq and
28380 c4 gi eq c5 mi eq and c4 mi eq c5 gi eq and
28381 or or or {/scr3 scr3 100 add def} if
28382 } if
28383 cleartomark
28384 } {pop} ifelse
28385 } if
28386 } if
28387 } for
28388 scr1 scr3
28389 } def
28390
28391 /evalmask {
28392 /sym exch def
28393
28394 /n1 0 def /n2 0 def /n3 0 def
28395 /rle rows cols 2 copy lt {exch} if pop 2 mul 2 add array def
28396 /lastpairs cols array def
28397 /thispairs cols array def
28398
28399 % Runlength encode and evaluate each column
28400 0 1 cols 1 sub {
28401 /i exch def
28402 mark 0 -1
28403 i cols rows cols mul 1 sub {
28404 sym exch get 2 copy eq {pop exch 1 add exch} {1 exch} ifelse
28405 } for
28406 rle 0 counttomark 2 sub getinterval astore
28407 evalrle n3 add /n3 exch def n1 add /n1 exch def
28408 pop
28409 } for
28410
28411 0 1 rows 1 sub {
28412 /i exch def
28413
28414 % Runlength encode and evaluate each row
28415 /symrow sym i cols mul cols getinterval def
28416 mark 0 -1
28417 symrow {
28418 2 copy eq {pop exch 1 add exch} {1 exch} ifelse
28419 } forall
28420 rle 0 counttomark 2 sub getinterval astore
28421 evalrle n3 add /n3 exch def n1 add /n1 exch def
28422 pop
28423
28424 % Count and score same coloured blocks
28425 /lastpairs thispairs /thispairs lastpairs def def
28426 -1 symrow {exch 2 copy ne {pop -1 exch} if} forall
28427 pop
28428 thispairs astore pop
28429 i 0 gt {
28430 mark
28431 lastpairs aload pop thispairs aload pop
28432 n2 cols { exch dup -1 ne { cols 1 add index eq {3 add} if } {pop} ifelse } repeat
28433 /n2 exch def
28434 cleartomark
28435 } if
28436 } for
28437
28438 n1 n2 add n3 add
28439 } def
28440
28441 % Evaluate the masked symbols to find the most suitable
28442 /bestscore 999999999 def
28443 0 1 masks length 1 sub {
28444 /m exch def
28445 /masksym rows cols mul array def
28446 0 1 rows cols mul 1 sub {
28447 /i exch def
28448 masksym i pixs i get masks m get i get xor put
28449 } for
28450 masks length 1 ne {
28451 masksym evalmask /score exch def
28452 score bestscore lt {
28453 /bestsym masksym def
28454 /bestmaskval m def
28455 /bestscore score def
28456 } if
28457 } {
28458 /bestsym masksym def
28459 } ifelse
28460 } for
28461 /pixs bestsym def
28462 /metamask bestmaskval def
28463
28464 % Derive the metadata bitstream
28465 /addtometapart {
28466 dup metapart p 3 -1 roll putinterval
28467 length p add /p exch def
28468 } def
28469
28470 /addtometabits {
28471 dup metabits q 3 -1 roll putinterval
28472 length q add /q exch def
28473 } def
28474
28475 /metapart 40 string def
28476 /metabits nummetabits string def
28477 /p 0 def /q 0 def
28478 slave not {
28479
28480 % Part I
28481 colors ln 2 ln div round cvi 1 sub
28482 3 tofixedbits addtometapart % Nc
28483 metapart 0 p getinterval 2 -1 ldpc addtometabits /p 0 def
28484
28485 % Part II
28486 metass 1 tofixedbits addtometapart % SS
28487 metavf 2 tofixedbits addtometapart % VF
28488 metamask 3 tofixedbits addtometapart % MSK
28489 hasslaves {(1)} {(0)} ifelse addtometapart % SF
28490 metapart 0 p getinterval 2 -1 ldpc addtometabits /p 0 def
28491
28492 % Part III
28493 metass 0 eq { % Square
28494 cols 17 sub 4 idiv [ 0 4 8 16 ] metavf get sub 1 sub
28495 metavlen tofixedbits addtometapart % V
28496 } { % Rectangular
28497 cols 17 sub 4 idiv 1 sub
28498 metavlen 2 idiv tofixedbits addtometapart % V1
28499 rows 17 sub 4 idiv 1 sub
28500 metavlen 2 idiv tofixedbits addtometapart % V2
28501 } ifelse
28502 datawc 3 sub metaelen 2 idiv tofixedbits addtometapart % E1
28503 datawr 4 sub metaelen 2 idiv tofixedbits addtometapart % E2
28504 hasslaves { % TODO Cascading
28505 0 4 tofixedbits addtometapart % S
28506 } if
28507 metapart 0 p getinterval 2 -1 ldpc addtometabits /p 0 def
28508
28509 } { % slave
28510
28511 % Part I
28512 sameshape {0} {1} ifelse 1 tofixedbits addtometapart % SS
28513 sameecc {0} {1} ifelse 1 tofixedbits addtometapart % SE
28514 hasslaves {1} {0} ifelse 1 tofixedbits addtometapart % SF
28515 metapart 0 p getinterval 2 -1 ldpc addtometabits /p 0 def
28516
28517 % Part II
28518 sameshape not {
28519 diffside 17 sub 4 idiv 1 sub
28520 5 tofixedbits addtometapart % V
28521 } if
28522 hasslaves { % TODO Cascading
28523 0 3 tofixedbits addtometapart % S
28524 } if
28525 metapart 0 p getinterval 2 -1 ldpc addtometabits /p 0 def
28526
28527 % Part III
28528 sameecc not {
28529 datawc 3 sub metaelen 2 idiv tofixedbits addtometapart % E1
28530 datawr 4 sub metaelen 2 idiv tofixedbits addtometapart % E2
28531 } if
28532 metapart 0 p getinterval 2 -1 ldpc addtometabits /p 0 def
28533
28534 } ifelse
28535 q 1 nummetabits 1 sub { % Pad with 0s
28536 metabits exch 48 put
28537 } for
28538
28539 % Place the metadata
28540 /i 0 def /j 0 def
28541 slave not { % Two-color encoding of Part I (Nc) in master symbols
28542 metabits i 6 getinterval {
28543 colors 4 eq {[bi yi]} {[ki wi]} ifelse exch 48 sub get
28544 pixs metadatamap j get aload pop jmv 3 -1 roll put
28545 /j j 1 add def
28546 } forall
28547 /i i 6 add def
28548 } if
28549 nummetabits i sub metabpm idiv {
28550 metabits i metabpm getinterval 0 exch {48 sub add 2 mul} forall 2 idiv
28551 metacolorindex exch get
28552 pixs metadatamap j get aload pop jmv 3 -1 roll put
28553 /i i metabpm add def
28554 /j j 1 add def
28555 } repeat
28556
28557 <<
28558 /ren /renmatrix
28559 /pixs pixs
28560 /pixx cols
28561 /pixy rows
28562 /colormap palette
28563 /height rows 2 mul 72 div
28564 /width cols 2 mul 72 div
28565 /borderleft 0.0
28566 /borderright 0.0
28567 /bordertop 0.0
28568 /borderbottom 0.0
28569 /opt options
28570 >>
28571
28572 dontdraw not //renmatrix if
28573
28574 end
28575
28576 }
28577 [/barcode] {null def} forall
28578 bind def
28579 /jabcode dup load /uk.co.terryburton.bwipp defineresource pop
28580 end
28581 /setpacking where {pop setpacking} if
28582 %%EndData
28583 %%EndResource
28584 % --END ENCODER jabcode--
28585
28586 % --BEGIN ENCODER gs1-cc--
28587 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process rendertext renmatrix micropdf417 pdf417--
28588 % --DESC: GS1 Composite 2D Component
28589 % --EXAM: (01)09521234543213(3103)000123
28590 % --EXOP: ccversion=b cccolumns=4
28591 % --RNDR: renmatrix
28592 %%BeginResource: uk.co.terryburton.bwipp gs1-cc 0.0 2025111800 219585 211632
28593 %%BeginData: 654 ASCII Lines
28594 /setpacking where {pop currentpacking true setpacking} if
28595 10 dict
28596 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
28597 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
28598 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
28599 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
28600 dup /gs1process dup /uk.co.terryburton.bwipp findresource put
28601 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
28602 dup /pdf417 dup /uk.co.terryburton.bwipp findresource put
28603 dup /micropdf417 dup /uk.co.terryburton.bwipp findresource put
28604 begin
28605 /gs1-cc {
28606
28607 20 dict begin % Confine variables to local scope
28608
28609 /ctx null def
28610 /parse false def
28611 /dontlint false def
28612 /lintreqs false def
28613 /dontdraw false def
28614 /ccversion (a) def
28615 /cccolumns -1 def
28616 /lintype () def
28617 /linwidth -1 def
28618
28619 //processoptions exec /options exch def
28620 /barcode exch def
28621
28622 /gs1-cc //loadctx exec
28623
28624 ccversion (a) ne ccversion (b) ne and ccversion (c) ne and {
28625 /bwipp.gs1ccBadCCversion (ccversion must be a, b or c) //raiseerror exec
28626 } if
28627
28628 cccolumns 30 gt {
28629 /bwipp.gs1ccColumnsTooBig (The maximum number of composite component columns is 30) //raiseerror exec
28630 } if
28631
28632 {
28633 /lintypecccolumns <<
28634 /ean13 4
28635 /upca 4
28636 /ean8 3
28637 /upce 2
28638 /gs1-128 4
28639 /databaromni 4
28640 /databarstacked 2
28641 /databarstackedomni 2
28642 /databartruncated 4
28643 /databarlimited 3
28644 /databarexpanded 4
28645 /databarexpandedstacked 4
28646 >> def
28647 } ctxdef
28648
28649 lintype () ne {
28650 lintypecccolumns lintype known not {
28651 /bwipp.gs1ccBadLinType (The lintype is not recognised) //raiseerror exec
28652 } if
28653 } if
28654
28655 % Select columns based on linear type
28656 cccolumns -1 eq {
28657 lintype (gs1-128) eq ccversion (c) eq and {
28658 linwidth 0 lt {
28659 /bwipp.gs1ccMissingLinWidth (linwidth must be set for a GS1-128 with a CC-C composite component) //raiseerror exec
28660 } if
28661 linwidth 68 lt {
28662 /bwipp.gs1ccMinimumLinWidth (Minimum linwidth for a GS1-128 with a CC-C composite component is 68) //raiseerror exec
28663 } if
28664 linwidth 68 eq { 1 } { linwidth 52 sub 17 idiv } ifelse % Ensure cccolumns != 0 if minimum linwidth
28665 } {
28666 lintype () ne { lintypecccolumns lintype get } {2} ifelse
28667 } ifelse
28668 /cccolumns exch def
28669 } if
28670
28671 barcode /ai //gs1process exec
28672 /fncs exch def
28673 /vals exch def
28674 /ais exch def
28675
28676 % Method selection
28677 /isupper {dup 65 ge exch 90 le and} def % A-Z
28678 /isnum0 {dup 48 ge exch 57 le and} def % 0-9
28679 /isnum1 {dup 49 ge exch 57 le and} def % 1-9
28680 { % common exit
28681
28682 % (10/11/17)...
28683 ais length 1 ge {
28684 ais 0 get (10) eq ais 0 get (11) eq or ais 0 get (17) eq or {
28685 -1 (10) exit
28686 } if
28687 } if
28688
28689 % (90){0-3 digits not starting 0}{upper alpha}...
28690 ais length 1 ge {
28691 ais 0 get (90) eq {
28692 /v vals 0 get def
28693 v length 1 ge {
28694 v 0 get isupper {
28695 0 (11) exit
28696 } if
28697 } if
28698 v length 2 ge {
28699 v 0 get isnum1
28700 v 1 get isupper and {
28701 1 (11) exit
28702 } if
28703 } if
28704 v length 3 ge {
28705 v 0 get isnum1
28706 v 1 get isnum0 and
28707 v 2 get isupper and {
28708 2 (11) exit
28709 } if
28710 } if
28711 v length 4 ge {
28712 v 0 get isnum1
28713 v 1 get isnum0 and
28714 v 2 get isnum0 and
28715 v 3 get isupper and {
28716 3 (11) exit
28717 } if
28718 } if
28719 } if
28720 } if
28721
28722 % Freeform
28723 -1 (0) exit
28724
28725 } loop
28726 /method exch def
28727 /npre exch def
28728
28729 /tobin {
28730 string dup length 1 sub 0 exch 1 exch {1 index exch 48 put} for
28731 dup 3 -1 roll 2 2 index length string cvrs dup length 2 index length exch sub exch putinterval
28732 } def
28733
28734 {
28735
28736 /fnc1 -1 def /lnumeric -2 def /lalphanumeric -3 def /liso646 -4 def
28737
28738 /alpha <<
28739 65 1 90 {dup 65 sub 5 tobin} for
28740 48 1 57 {dup 4 add 6 tobin} for
28741 fnc1 (11111)
28742 >> def
28743
28744 /numeric <<
28745 0 1 119 {
28746 dup (00) 2 string copy dup 3 -1 roll 11 2 string cvrs
28747 dup length 2 exch sub exch putinterval
28748 dup 0 get 65 eq {dup 0 94 put} if
28749 dup 1 get 65 eq {dup 1 94 put} if
28750 exch 8 add
28751 (0000000) 7 string copy dup 3 -1 roll 2 7 string cvrs
28752 dup length 7 exch sub exch putinterval
28753 } for
28754 lalphanumeric (0000)
28755 >> def
28756
28757 /alphanumeric <<
28758 48 1 57 {dup 43 sub 5 tobin} for
28759 fnc1 (01111)
28760 65 1 90 {dup 33 sub 6 tobin} for
28761 42 (111010)
28762 44 1 47 {dup 15 add 6 tobin} for
28763 lnumeric (000)
28764 liso646 (00100)
28765 >> def
28766
28767 /iso646 <<
28768 48 1 57 {dup 43 sub 5 tobin} for
28769 fnc1 (01111)
28770 65 1 90 {dup 1 sub 7 tobin} for
28771 97 1 122 {dup 7 sub 7 tobin} for
28772 33 (11101000)
28773 34 (11101001)
28774 37 1 47 {dup 197 add 8 tobin} for
28775 58 1 63 {dup 187 add 8 tobin} for
28776 95 (11111011)
28777 32 (11111100)
28778 lnumeric (000)
28779 lalphanumeric (00100)
28780 >> def
28781
28782 } ctxdef
28783
28784 method (10) eq { % TODO: fixme
28785 ais 0 get (11) eq ais 0 get (17) eq or {
28786 vals 0 get
28787 dup 0 2 getinterval cvi 384 mul exch
28788 dup 2 2 getinterval cvi 1 sub 32 mul exch
28789 4 2 getinterval cvi add add
28790 (0000000000000000) 16 string copy dup 3 -1 roll 2 16 string cvrs
28791 dup length 16 exch sub exch putinterval
28792 [ 1 0
28793 4 -1 roll {48 sub} forall
28794 ais 0 get (11) eq {0} {1} ifelse
28795 ] /cdf exch def
28796 /ais ais 1 ais length 1 sub getinterval def
28797 /vals vals 1 vals length 1 sub getinterval def
28798 /fncs fncs 1 fncs length 1 sub getinterval def
28799 } {
28800 /cdf [ 1 0 1 1 ] def
28801 } ifelse
28802 ais length 0 ne {
28803 ais 0 get (10) eq {
28804 /gpf [ vals 0 get {} forall ] def
28805 ais length 1 gt {/gpf [ gpf aload pop fnc1 ] def} if % TODO: check
28806 /ais ais 1 ais length 1 sub getinterval def
28807 /vals vals 1 vals length 1 sub getinterval def
28808 /fncs fncs 1 fncs length 1 sub getinterval def
28809 } {
28810 /gpf [fnc1] def % TODO: check
28811 } ifelse
28812 } {
28813 /cdf [ cdf aload pop 0 0 0 0 0 1 1 1 1 ] def
28814 /gpf [] def
28815 } ifelse
28816 /mode (numeric) def
28817 } if
28818
28819 method (11) eq {
28820 /cdf [ 1 1 ] def
28821 /ai90 vals 0 get def
28822 npre 1 add ai90 length ne {
28823 ai90 npre 1 add ai90 length npre sub 1 sub getinterval
28824 } {
28825 ()
28826 } ifelse
28827 /ai90rem exch def
28828 /nalpha 0 ai90rem {dup 65 ge exch 90 le and {1 add} if} forall def
28829 /nnums 0 ai90rem {dup 48 ge exch 57 le and {1 add} if} forall def
28830 /mode nalpha nnums gt {(alpha)} { nalpha 0 eq {(numeric)} {(alphanumeric)} ifelse } ifelse def
28831 nalpha nnums add ai90rem length ne {/mode (alphanumeric) def} if
28832 /cdf [
28833 cdf aload pop
28834 mode (alphanumeric) eq {0} if
28835 mode (numeric) eq {1 0} if
28836 mode (alpha) eq {1 1} if
28837 ] def
28838 /ais1 ais length 1 gt {ais 1 get} {-1} ifelse def
28839 /vals1 vals length 1 gt {vals 1 get} {-1} ifelse def
28840 ais1 (21) eq ais1 (8004) eq or {
28841 /cdf [ cdf aload pop ais1 (21) eq {1 0} {1 1} ifelse ] def
28842 } {
28843 /cdf [ cdf aload pop 0 ] def
28844 } ifelse
28845 /nval npre 0 ne {ai90 0 npre getinterval cvi} {0} ifelse def
28846 (BDHIJKLNPQRSTVXZ) ai90 npre 1 getinterval search {
28847 length exch pop exch pop
28848 /aval exch def
28849 } {
28850 pop /aval -1 def
28851 } ifelse
28852 nval 31 lt aval -1 ne and {
28853 (00000) 5 string copy dup nval 2 5 string cvrs
28854 dup length 5 exch sub exch putinterval
28855 [ exch {48 sub} forall ] /nbits exch def
28856 (0000) 4 string copy dup aval 2 4 string cvrs
28857 dup length 4 exch sub exch putinterval
28858 [ exch {48 sub} forall ] /abits exch def
28859 /cdf [
28860 cdf aload pop
28861 nbits aload pop
28862 abits aload pop
28863 ] def
28864 } {
28865 (0000000000) 10 string copy dup nval 2 10 string cvrs
28866 dup length 10 exch sub exch putinterval
28867 [ exch {48 sub} forall ] /nbits exch def
28868 (00000) 5 string copy dup ai90 npre get 65 sub 2 5 string cvrs
28869 dup length 5 exch sub exch putinterval
28870 [ exch {48 sub} forall ] /abits exch def
28871 /cdf [
28872 cdf aload pop
28873 1 1 1 1 1
28874 nbits aload pop
28875 abits aload pop
28876 ] def
28877 } ifelse
28878 mode (alpha) ne {
28879 /gpf [ ai90rem {} forall ais length 1 gt {fnc1} if ] def
28880 } {
28881 /in [ ai90rem {} forall ais length 1 gt {fnc1} if ] def
28882 /out in length 6 mul array def
28883 /j 0 def
28884 0 1 in length 1 sub {
28885 in exch get alpha exch get
28886 dup [ exch {48 sub} forall ] out exch j exch putinterval
28887 length j add /j exch def
28888 } for
28889 /cdf [
28890 cdf aload pop
28891 out 0 j getinterval aload pop
28892 ] def
28893 /gpf [] def
28894 ais length 1 gt {/mode (numeric) def} if
28895 } ifelse
28896 /ais ais 1 ais length 1 sub getinterval def
28897 /vals vals 1 vals length 1 sub getinterval def
28898 /fncs fncs 1 fncs length 1 sub getinterval def
28899 ais length 0 ne {
28900 ais1 (21) eq ais1 (8004) eq or {
28901 /gpf [
28902 gpf aload pop
28903 vals1 {} forall
28904 ] def
28905 /ais ais 1 ais length 1 sub getinterval def
28906 /vals vals 1 vals length 1 sub getinterval def
28907 /fncs fncs 1 fncs length 1 sub getinterval def
28908 ais length 0 ne {/gpf [gpf aload pop fnc1] def} if
28909 } if
28910 } if
28911 } if
28912
28913 method (0) eq {
28914 /cdf [ 0 ] def
28915 /gpf [] def
28916 /mode (numeric) def
28917 } if
28918
28919 % Append the remaining AI data
28920 0 1 ais length 1 sub {
28921 /i exch def
28922 /ai ais i get def
28923 /val vals i get def
28924 gpf length ai length add val length add array
28925 dup 0 gpf putinterval
28926 dup gpf length ai [ exch {} forall ] putinterval
28927 dup gpf length ai length add val [ exch {} forall ] putinterval
28928 /gpf exch def
28929 i ais length 1 sub ne fncs i get and { % Append FNC1
28930 gpf length 1 add array
28931 dup 0 gpf putinterval
28932 dup gpf length fnc1 put
28933 /gpf exch def
28934 } if
28935 } for
28936
28937 % Calculate the number of bits remaining to the next valid symbol size
28938 {
28939 /bitcapsmaps <<
28940 /a [
28941 [167 138 118 108 88 78 59]
28942 [167 138 118 98 78]
28943 [197 167 138 108 78]
28944 ]
28945 /b [
28946 [ 336 296 256 208 160 104 56]
28947 [ 768 648 536 416 304 208 152 112 72 32]
28948 [1184 1016 840 672 496 352 264 208 152 96 56]
28949 ]
28950 >> def
28951 } ctxdef
28952
28953 /rembits {
28954 /used exch def
28955 ccversion (c) ne { % cc-a or cc-b
28956 /bitcaps bitcapsmaps ccversion get cccolumns 2 sub get def
28957 -1 bitcaps {dup used ge {exch} if pop} forall
28958 dup -1 ne {used sub} if
28959 } {
28960 << /c -1 >> ccversion get pop % Assert cc-c
28961 /m used 8 div ceiling cvi dup 6 idiv 5 mul exch 6 mod add def
28962 m 40 le {8 } if
28963 m 41 ge m 160 le and {16} if
28964 m 161 ge m 320 le and {32} if
28965 m 321 ge m 833 le and {64} if % 833 = 900 - 3 - 64, where 900 = 30 rows x 30 cols limit
28966 m 834 ge {32} if % Reduce to meet advertised "up to 2361 digits" (allows max 2372) within 900 limit
28967 /eccws exch def
28968 /m m eccws add 3 add def
28969 cccolumns 30 gt { /cccolumns 30 def } if
28970 { % Loop until rows <= 30 or columns >= 30 (GS1 General Specifications 5.11.2.3)
28971 m cccolumns div ceiling cvi 30 le cccolumns 30 ge or {exit} if
28972 /cccolumns cccolumns 1 add def
28973 } loop
28974 /r m cccolumns div ceiling cvi def
28975 r 3 lt { /r 3 def } if % GS1 General Specifications 5.11.2.3 "3 to 30 rows"
28976 /tgt cccolumns r mul eccws sub 3 sub dup 5 idiv 6 mul exch 5 mod add 8 mul def
28977 used 8304 le {tgt used sub} {-1} ifelse
28978 } ifelse
28979 dup -1 eq { % Upgrade CC-A to CC-B or CC-B to CC-C to fit
28980 pop
28981 ccversion (a) eq {
28982 /ccversion (b) def
28983 } {
28984 ccversion (b) eq lintype (gs1-128) eq and {
28985 /ccversion (c) def
28986 /cccolumns linwidth 52 sub 17 idiv def
28987 } {
28988 /ccversion -1 def
28989 } ifelse
28990 } ifelse
28991 used rembits
28992 } if
28993 } def
28994
28995 /encode {
28996 dup /raw ne {exch get} {pop} ifelse
28997 [ exch {48 sub} forall ]
28998 dup length exch
28999 gpfenc exch j exch putinterval
29000 /j exch j add def
29001 } def
29002
29003 % Pre-compute alphanumeric and numeric runlengths and position of next ISO646-only characters
29004 /numericruns [ gpf length {0} repeat 0 -1 ] def
29005 /alphanumericruns [ gpf length {0} repeat 0 ] def
29006 /nextiso646only [ gpf length {0} repeat 9999 ] def
29007 gpf length 1 sub -1 0 {
29008 /i exch def
29009 gpf i get
29010 (00) 2 string copy
29011 dup 0 gpf i get dup fnc1 eq {pop 94} if put
29012 i gpf length 1 sub lt {dup 1 gpf i 1 add get dup fnc1 eq {pop 94} if put} if
29013 numeric exch known {
29014 numericruns i numericruns i 2 add get 2 add put
29015 } {
29016 numericruns i 0 put
29017 } ifelse
29018 dup alphanumeric exch known {
29019 alphanumericruns i alphanumericruns i 1 add get 1 add put
29020 } {
29021 alphanumericruns i 0 put
29022 } ifelse
29023 dup iso646 exch known exch alphanumeric exch known not and {
29024 nextiso646only i 0 put
29025 } {
29026 nextiso646only i nextiso646only i 1 add get 1 add put
29027 } ifelse
29028 } for
29029
29030 % Encode the general purpose field
29031 /gpfenc 8304 array def % 8304 = (865 / 5) * 6 * 8, where 865 = 900 - 3 - 32
29032 /i 0 def /j 0 def
29033 { % loop
29034 i gpf length eq {exit} if
29035 { % not a loop but common exit point
29036
29037 mode (numeric) eq {
29038 i gpf length 2 sub le {
29039 2 string
29040 dup 0 gpf i get dup fnc1 eq {pop 94} if put
29041 dup 1 gpf i 1 add get dup fnc1 eq {pop 94} if put
29042 dup numeric exch known {
29043 numeric encode
29044 /i i 2 add def
29045 exit
29046 } if
29047 pop
29048 lalphanumeric numeric encode
29049 /mode (alphanumeric) def
29050 exit
29051 } {
29052 gpf i get dup 48 lt exch 57 gt or {
29053 lalphanumeric numeric encode
29054 /mode (alphanumeric) def
29055 exit
29056 } if
29057 /rem cdf length j add rembits def
29058 rem 4 ge rem 6 le and { % C1 + 1 into 4 to 6 bits
29059 (000000) 6 string copy 0 rem getinterval
29060 dup gpf i get 47 sub 2 4 string cvrs
29061 dup length 4 exch sub exch putinterval /raw encode
29062 /i i 1 add def
29063 exit
29064 } { % C1.FNC1
29065 2 string dup 0 gpf i get put dup 1 94 put numeric encode
29066 /i i 1 add def
29067 exit
29068 } ifelse
29069 } ifelse
29070 } if
29071
29072 mode (alphanumeric) eq {
29073 gpf i get fnc1 eq {
29074 fnc1 alphanumeric encode
29075 /mode (numeric) def
29076 /i i 1 add def
29077 exit
29078 } if
29079 gpf i get dup iso646 exch known exch alphanumeric exch known not and {
29080 liso646 alphanumeric encode
29081 /mode (iso646) def
29082 exit
29083 } if
29084 numericruns i get 6 ge {
29085 lnumeric alphanumeric encode
29086 /mode (numeric) def
29087 exit
29088 } if
29089 numericruns i get dup 4 ge exch i add gpf length eq and {
29090 lnumeric alphanumeric encode
29091 /mode (numeric) def
29092 exit
29093 } if
29094 gpf i get alphanumeric encode
29095 /i i 1 add def
29096 exit
29097 } if
29098
29099 mode (iso646) eq {
29100 gpf i get fnc1 eq {
29101 fnc1 iso646 encode
29102 /mode (numeric) def
29103 /i i 1 add def
29104 exit
29105 } if
29106 numericruns i get 4 ge nextiso646only i get 10 ge and {
29107 lnumeric iso646 encode
29108 /mode (numeric) def
29109 exit
29110 } if
29111 alphanumericruns i get 5 ge nextiso646only i get 10 ge and {
29112 lalphanumeric iso646 encode
29113 /mode (alphanumeric) def
29114 exit
29115 } if
29116 gpf i get iso646 encode
29117 /i i 1 add def
29118 exit
29119 } if
29120
29121 } loop
29122 } loop
29123 /gpf gpfenc 0 j getinterval def
29124
29125 % Create pad
29126 /pad cdf length gpf length add rembits array def
29127 pad length 0 gt {
29128 0 5 pad length 1 sub { % Fill with 00100
29129 /i exch def
29130 pad i [ 0 0 1 0 0 ] 0 pad length i sub 5 2 copy gt {exch} if pop getinterval putinterval
29131 } for
29132 mode (numeric) eq { % Prefix shift from numeric to ASCII
29133 /pad [ 0 0 0 0 pad aload pop ] 0 pad length getinterval def
29134 } if
29135 mode (alpha) eq { % Prefix FNC1 + shift from numeric to ASCII
29136 /pad [ 1 1 1 1 1 0 0 0 0 pad aload pop ] 0 pad length getinterval def
29137 } if
29138 } if
29139
29140 % Concatenate fields
29141 /bits [
29142 cdf aload pop
29143 gpf aload pop
29144 pad aload pop
29145 ] def
29146
29147 {
29148 /pwr928 [
29149 [ 0 0 0 0 0 0 1 ]
29150 68 {7 array} repeat
29151 ] def
29152 1 1 68 {
29153 /j exch def
29154 /v 0 def
29155 6 -1 1 {
29156 /i exch def
29157 /v pwr928 j 1 sub get i get 2 mul v 928 idiv add def
29158 pwr928 j get i v 928 mod put
29159 } for
29160 pwr928 j get 0 pwr928 j 1 sub get 0 get 2 mul v 928 idiv add put
29161 } for
29162 } ctxdef
29163
29164 ccversion (a) eq {
29165 /cws [ 28 {0} repeat ] def
29166 /b 0 def /c 0 def
29167 { % loop
29168 b bits length eq {exit} if
29169 /bs bits b 69 bits length b sub 2 copy gt {exch} if pop getinterval def
29170 /bsl bs length def
29171 /cs cws c bsl 10 idiv 1 add getinterval def
29172 /csl cs length def
29173 0 1 bsl 1 sub {
29174 /i exch def
29175 0 1 csl 1 sub {
29176 /j exch def
29177 cs j 2 copy get
29178 pwr928 i get j 7 add csl sub get
29179 bs bsl i sub 1 sub get
29180 mul add put
29181 } for
29182 } for
29183 csl 1 sub -1 1 {
29184 /i exch def
29185 cs i 1 sub 2 copy get cs i get 928 idiv add put
29186 cs i 2 copy get 928 mod put
29187 } for
29188 /b b bsl add def
29189 /c c csl add def
29190 } loop
29191 /cws cws 0 c getinterval def
29192 /barcode cws length 4 mul string def
29193 0 1 cws length 1 sub {
29194 /i exch def
29195 (^000) 4 string copy dup cws i get 10 4 string cvrs
29196 dup length 4 exch sub exch putinterval
29197 barcode i 4 mul 3 -1 roll putinterval
29198 } for
29199 options (parse) undef
29200 options (dontdraw) true put
29201 options (cca) true put
29202 options (columns) cccolumns put
29203 /args barcode options //micropdf417 exec def
29204 } if
29205
29206 ccversion (b) eq {
29207 /barcode bits length 8 idiv string def
29208 0 1 barcode length 1 sub {
29209 /i exch def
29210 bits i 8 mul 8 getinterval 0 exch {add 2 mul} forall 2 idiv
29211 barcode exch i exch put
29212 } for
29213 options (parse) undef
29214 options (dontdraw) true put
29215 options (ccb) true put
29216 options (columns) cccolumns put
29217 /args barcode options //micropdf417 exec def
29218 } if
29219
29220 ccversion (c) eq {
29221 /barcode bits length 8 idiv string def
29222 0 1 barcode length 1 sub {
29223 /i exch def
29224 bits i 8 mul 8 getinterval 0 exch {add 2 mul} forall 2 idiv
29225 barcode exch i exch put
29226 } for
29227 options (parse) undef
29228 options (dontdraw) true put
29229 options (ccc) true put
29230 options (columns) cccolumns put
29231 options (eclevel) eccws ln 2 ln div cvi 1 sub put
29232 /args barcode options //pdf417 exec def
29233 } if
29234
29235 args
29236 dontdraw not //renmatrix if
29237
29238 //unloadctx exec
29239
29240 end
29241
29242 }
29243 [/barcode] {null def} forall
29244 bind def
29245 /gs1-cc dup load /uk.co.terryburton.bwipp defineresource pop
29246 end
29247 /setpacking where {pop setpacking} if
29248 %%EndData
29249 %%EndResource
29250 % --END ENCODER gs1-cc--
29251
29252 % --BEGIN ENCODER ean13composite--
29253 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process rendertext renlinear renmatrix ean5 ean2 ean13 micropdf417 pdf417 gs1-cc--
29254 % --DESC: EAN-13 Composite
29255 % --EXAM: 9520123456788|(99)1234-abcd
29256 % --EXOP: includetext
29257 % --RNDR: renlinear renmatrix
29258 %%BeginResource: uk.co.terryburton.bwipp ean13composite 0.0 2025111800 116192 109023
29259 %%BeginData: 151 ASCII Lines
29260 /setpacking where {pop currentpacking true setpacking} if
29261 10 dict
29262 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
29263 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
29264 dup /ean13 dup /uk.co.terryburton.bwipp findresource put
29265 dup /gs1-cc dup /uk.co.terryburton.bwipp findresource put
29266 dup /gs1process dup /uk.co.terryburton.bwipp findresource put
29267 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
29268 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
29269 begin
29270 /ean13composite {
29271
29272 20 dict begin % Confine variables to local scope
29273
29274 /ctx null def
29275 /dontdraw false def
29276 /usematrix false def
29277 /parse false def
29278 /dontlint false def
29279 /lintreqs true def
29280
29281 //processoptions exec /options exch def
29282 /barcode exch def
29283
29284 dontdraw { /usematrix true def } if
29285
29286 % Split the linear and composite parts
29287 barcode (|) search {
29288 /linear exch def
29289 pop
29290 /comp exch def
29291 } {
29292 pop /bwipp.missingCompositeComponent (A Composite Component must be provided following a pipe character) //raiseerror exec
29293 } ifelse
29294
29295 options (lintype) (ean13) put
29296 options (inkspreadv) 0.0 put
29297 options (dontdraw) true put
29298 options (dontlint) true put
29299
29300 % Lint with a fake AI (01)
29301 comp length 18 add string
29302 dup 0 ((01)00000000000000) putinterval
29303 dup 18 comp putinterval
29304 /ai //gs1process exec pop pop pop
29305
29306 % Plot the linear part
29307 linear options //ean13 exec
29308 usematrix not {
29309 gsave
29310
29311 //renlinear exec
29312
29313 currentpoint
29314
29315 % Plot the 2D part
29316 -3 78 rmoveto comp options //gs1-cc exec //renmatrix exec
29317
29318 % Plot the separator
29319 72 add exch 1 sub exch moveto <<
29320 /ren /renmatrix
29321 /pixs [
29322 0 1 93 {0} repeat 1 0
29323 1 0 93 {0} repeat 0 1
29324 0 1 93 {0} repeat 1 0
29325 ]
29326 /pixx 97
29327 /pixy 3
29328 /height 6 72 div
29329 /width 97 72 div
29330 /opt options
29331 >> //renmatrix exec
29332
29333 grestore
29334 } {
29335 /linsym exch def
29336 /sbs linsym /sbs get def
29337 /bhs linsym /bhs get def
29338 /bbs linsym /bbs get def
29339 /linwidth 0 sbs {cvi add} forall def
29340
29341 /compsym comp options //gs1-cc exec def
29342 /ccpixs compsym /pixs get def
29343 /ccpixx compsym /pixx get def
29344
29345 /linpad [ ccpixx 97 sub {0} repeat ] def
29346
29347 /diff linwidth linpad length add 1 add ccpixx sub def % An add-on can make linear wider than composite
29348 diff 0 gt { % Left align composite
29349 /ccrpad [ diff {0} repeat ] def
29350 /pixx ccpixx diff add def
29351 } {
29352 /ccrpad 0 array def
29353 /pixx ccpixx def
29354 } ifelse
29355
29356 /pixs [
29357 0 ccpixx ccpixs length 1 sub {
29358 /i exch def
29359 ccpixs i ccpixx getinterval aload pop ccrpad aload pop
29360 } for
29361 2 { linpad aload pop 0 1 93 {0} repeat 1 0 ccrpad aload pop } repeat
29362 2 { linpad aload pop 1 0 93 {0} repeat 0 1 ccrpad aload pop } repeat
29363 2 { linpad aload pop 0 1 93 {0} repeat 1 0 ccrpad aload pop } repeat
29364 71 -1 0 {
29365 /y exch def
29366 linpad aload pop
29367 0
29368 0 1 sbs length 1 sub {
29369 /i exch def
29370 i 2 mod 0 eq {
29371 % Don't print when bbs > y || (bbs + bhs) < y (i.e. add-on or includetext offsets)
29372 bbs i 2 idiv get 72 mul dup y gt exch bhs i 2 idiv get 72 mul add y lt or {
29373 sbs i get cvi {0} repeat
29374 } {
29375 sbs i get cvi {1} repeat
29376 } ifelse
29377 } {
29378 sbs i get cvi {0} repeat
29379 } ifelse
29380 } for
29381 diff 0 lt {0} if % Allow for middle separator overhang on RHS if no add-on
29382 } for
29383 ] def
29384
29385 /pixy pixs length pixx idiv def
29386 <<
29387 /ren /renmatrix
29388 /pixs pixs
29389 /pixx pixx
29390 /pixy pixy
29391 /height pixy 72 div
29392 /width pixx 72 div
29393 /opt options
29394 >>
29395
29396 dontdraw not {
29397 gsave
29398 //renmatrix exec
29399 grestore
29400 } if
29401 } ifelse
29402
29403 end
29404
29405 }
29406 [/barcode] {null def} forall
29407 bind def
29408 /ean13composite dup load /uk.co.terryburton.bwipp defineresource pop
29409 end
29410 /setpacking where {pop setpacking} if
29411 %%EndData
29412 %%EndResource
29413 % --END ENCODER ean13composite--
29414
29415 % --BEGIN ENCODER ean8composite--
29416 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process rendertext renlinear renmatrix ean5 ean2 ean8 micropdf417 pdf417 gs1-cc--
29417 % --DESC: EAN-8 Composite
29418 % --EXAM: 95200002|(21)A12345678
29419 % --EXOP: includetext
29420 % --RNDR: renlinear renmatrix
29421 %%BeginResource: uk.co.terryburton.bwipp ean8composite 0.0 2025111800 113101 112925
29422 %%BeginData: 154 ASCII Lines
29423 /setpacking where {pop currentpacking true setpacking} if
29424 10 dict
29425 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
29426 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
29427 dup /ean8 dup /uk.co.terryburton.bwipp findresource put
29428 dup /gs1-cc dup /uk.co.terryburton.bwipp findresource put
29429 dup /gs1process dup /uk.co.terryburton.bwipp findresource put
29430 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
29431 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
29432 begin
29433 /ean8composite {
29434
29435 20 dict begin % Confine variables to local scope
29436
29437 /ctx null def
29438 /dontdraw false def
29439 /usematrix false def
29440 /parse false def
29441 /dontlint false def
29442 /lintreqs true def
29443
29444 //processoptions exec /options exch def
29445 /barcode exch def
29446
29447 dontdraw { /usematrix true def } if
29448
29449 % Split the linear and composite parts
29450 barcode (|) search {
29451 /linear exch def
29452 pop
29453 /comp exch def
29454 } {
29455 pop /bwipp.missingCompositeComponent (A Composite Component must be provided following a pipe character) //raiseerror exec
29456 } ifelse
29457
29458 % Get the result of encoding with ean8 and gs1-cc
29459 options (lintype) (ean8) put
29460 options (inkspreadv) 0.0 put
29461 options (dontdraw) true put
29462 options (dontlint) true put
29463
29464 % Lint with a fake AI (01)
29465 comp length 18 add string
29466 dup 0 ((01)00000000000000) putinterval
29467 dup 18 comp putinterval
29468 /ai //gs1process exec pop pop pop
29469
29470 % Plot the linear part
29471 linear options //ean8 exec
29472 usematrix not {
29473 gsave
29474
29475 //renlinear exec
29476
29477 currentpoint
29478
29479 % Plot the 2D part
29480 comp options //gs1-cc exec
29481 dup (pixx) get 70 exch sub 78 rmoveto
29482 //renmatrix exec
29483
29484 % Plot the separator
29485 72 add exch 1 sub exch moveto <<
29486 /ren /renmatrix
29487 /pixs [
29488 0 1 65 {0} repeat 1 0
29489 1 0 65 {0} repeat 0 1
29490 0 1 65 {0} repeat 1 0
29491 ]
29492 /pixx 69
29493 /pixy 3
29494 /height 6 72 div
29495 /width 69 72 div
29496 /opt options
29497 >> //renmatrix exec
29498
29499 grestore
29500 } {
29501 /linsym exch def
29502 /sbs linsym /sbs get def
29503 /bhs linsym /bhs get def
29504 /bbs linsym /bbs get def
29505 /linwidth 0 sbs {cvi add} forall def
29506
29507 /compsym comp options //gs1-cc exec def
29508 /ccpixs compsym /pixs get def
29509 /ccpixx compsym /pixx get def
29510
29511 /linpad [ ccpixx 69 sub {0} repeat ] def
29512
29513 /diff linwidth linpad length add 1 add ccpixx sub def % An add-on can make linear wider than composite
29514 diff 0 gt { % Left align composite
29515 /ccrpad [ diff {0} repeat ] def
29516 /pixx ccpixx diff add def
29517 } {
29518 /ccrpad 0 array def
29519 /pixx ccpixx def
29520 } ifelse
29521
29522 /pixs [
29523 0 ccpixx ccpixs length 1 sub {
29524 /i exch def
29525 ccpixs i ccpixx getinterval aload pop ccrpad aload pop
29526 } for
29527 2 { linpad aload pop 0 1 65 {0} repeat 1 0 ccrpad aload pop } repeat
29528 2 { linpad aload pop 1 0 65 {0} repeat 0 1 ccrpad aload pop } repeat
29529 2 { linpad aload pop 0 1 65 {0} repeat 1 0 ccrpad aload pop } repeat
29530 71 -1 0 {
29531 /y exch def
29532 linpad aload pop
29533 0
29534 0 1 sbs length 1 sub {
29535 /i exch def
29536 i 2 mod 0 eq {
29537 % Don't print when bbs > y || (bbs + bhs) < y (i.e. add-on or includetext offsets)
29538 bbs i 2 idiv get 72 mul dup y gt exch bhs i 2 idiv get 72 mul add y lt or {
29539 sbs i get cvi {0} repeat
29540 } {
29541 sbs i get cvi {1} repeat
29542 } ifelse
29543 } {
29544 sbs i get cvi {0} repeat
29545 } ifelse
29546 } for
29547 diff 0 lt {0} if % Allow for middle separator overhang on RHS if no add-on
29548 } for
29549 ] def
29550
29551 /pixy pixs length pixx idiv def
29552 <<
29553 /ren /renmatrix
29554 /pixs pixs
29555 /pixx pixx
29556 /pixy pixy
29557 /height pixy 72 div
29558 /width pixx 72 div
29559 /opt options
29560 >>
29561
29562 dontdraw not {
29563 gsave
29564 //renmatrix exec
29565 grestore
29566 } if
29567 } ifelse
29568
29569 end
29570
29571 }
29572 [/barcode] {null def} forall
29573 bind def
29574 /ean8composite dup load /uk.co.terryburton.bwipp defineresource pop
29575 end
29576 /setpacking where {pop setpacking} if
29577 %%EndData
29578 %%EndResource
29579 % --END ENCODER ean8composite--
29580
29581 % --BEGIN ENCODER upcacomposite--
29582 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process rendertext renlinear renmatrix ean5 ean2 upca micropdf417 pdf417 gs1-cc--
29583 % --DESC: UPC-A Composite
29584 % --EXAM: 012345000058|(99)1234-abcd
29585 % --EXOP: includetext
29586 % --RNDR: renlinear renmatrix
29587 %%BeginResource: uk.co.terryburton.bwipp upcacomposite 0.0 2025111800 116314 109018
29588 %%BeginData: 151 ASCII Lines
29589 /setpacking where {pop currentpacking true setpacking} if
29590 10 dict
29591 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
29592 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
29593 dup /upca dup /uk.co.terryburton.bwipp findresource put
29594 dup /gs1-cc dup /uk.co.terryburton.bwipp findresource put
29595 dup /gs1process dup /uk.co.terryburton.bwipp findresource put
29596 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
29597 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
29598 begin
29599 /upcacomposite {
29600
29601 20 dict begin % Confine variables to local scope
29602
29603 /ctx null def
29604 /dontdraw false def
29605 /usematrix false def
29606 /parse false def
29607 /dontlint false def
29608 /lintreqs true def
29609
29610 //processoptions exec /options exch def
29611 /barcode exch def
29612
29613 dontdraw { /usematrix true def } if
29614
29615 % Split the linear and composite parts
29616 barcode (|) search {
29617 /linear exch def
29618 pop
29619 /comp exch def
29620 } {
29621 pop /bwipp.missingCompositeComponent (A Composite Component must be provided following a pipe character) //raiseerror exec
29622 } ifelse
29623
29624 options (lintype) (ean13) put
29625 options (inkspreadv) 0.0 put
29626 options (dontdraw) true put
29627 options (dontlint) true put
29628
29629 % Lint with a fake AI (01)
29630 comp length 18 add string
29631 dup 0 ((01)00000000000000) putinterval
29632 dup 18 comp putinterval
29633 /ai //gs1process exec pop pop pop
29634
29635 % Plot the linear part
29636 linear options //upca exec
29637 usematrix not {
29638 gsave
29639
29640 //renlinear exec
29641
29642 currentpoint
29643
29644 % Plot the 2D part
29645 -3 78 rmoveto comp options //gs1-cc exec //renmatrix exec
29646
29647 % Plot the separator
29648 72 add exch 1 sub exch moveto <<
29649 /ren /renmatrix
29650 /pixs [
29651 0 1 93 {0} repeat 1 0
29652 1 0 93 {0} repeat 0 1
29653 0 1 93 {0} repeat 1 0
29654 ]
29655 /pixx 97
29656 /pixy 3
29657 /height 6 72 div
29658 /width 97 72 div
29659 /opt options
29660 >> //renmatrix exec
29661
29662 grestore
29663 } {
29664 /linsym exch def
29665 /sbs linsym /sbs get def
29666 /bhs linsym /bhs get def
29667 /bbs linsym /bbs get def
29668 /linwidth 0 sbs {cvi add} forall def
29669
29670 /compsym comp options //gs1-cc exec def
29671 /ccpixs compsym /pixs get def
29672 /ccpixx compsym /pixx get def
29673
29674 /linpad [ ccpixx 97 sub {0} repeat ] def
29675
29676 /diff linwidth linpad length add 1 add ccpixx sub def % An add-on can make linear wider than composite
29677 diff 0 gt { % Left align composite
29678 /ccrpad [ diff {0} repeat ] def
29679 /pixx ccpixx diff add def
29680 } {
29681 /ccrpad 0 array def
29682 /pixx ccpixx def
29683 } ifelse
29684
29685 /pixs [
29686 0 ccpixx ccpixs length 1 sub {
29687 /i exch def
29688 ccpixs i ccpixx getinterval aload pop ccrpad aload pop
29689 } for
29690 2 { linpad aload pop 0 1 93 {0} repeat 1 0 ccrpad aload pop } repeat
29691 2 { linpad aload pop 1 0 93 {0} repeat 0 1 ccrpad aload pop } repeat
29692 2 { linpad aload pop 0 1 93 {0} repeat 1 0 ccrpad aload pop } repeat
29693 71 -1 0 {
29694 /y exch def
29695 linpad aload pop
29696 0
29697 0 1 sbs length 1 sub {
29698 /i exch def
29699 i 2 mod 0 eq {
29700 % Don't print when bbs > y || (bbs + bhs) < y (i.e. add-on or includetext offsets)
29701 bbs i 2 idiv get 72 mul dup y gt exch bhs i 2 idiv get 72 mul add y lt or {
29702 sbs i get cvi {0} repeat
29703 } {
29704 sbs i get cvi {1} repeat
29705 } ifelse
29706 } {
29707 sbs i get cvi {0} repeat
29708 } ifelse
29709 } for
29710 diff 0 lt {0} if % Allow for middle separator overhang on RHS if no add-on
29711 } for
29712 ] def
29713
29714 /pixy pixs length pixx idiv def
29715 <<
29716 /ren /renmatrix
29717 /pixs pixs
29718 /pixx pixx
29719 /pixy pixy
29720 /height pixy 72 div
29721 /width pixx 72 div
29722 /opt options
29723 >>
29724
29725 dontdraw not {
29726 gsave
29727 //renmatrix exec
29728 grestore
29729 } if
29730 } ifelse
29731
29732 end
29733
29734 }
29735 [/barcode] {null def} forall
29736 bind def
29737 /upcacomposite dup load /uk.co.terryburton.bwipp defineresource pop
29738 end
29739 /setpacking where {pop setpacking} if
29740 %%EndData
29741 %%EndResource
29742 % --END ENCODER upcacomposite--
29743
29744 % --BEGIN ENCODER upcecomposite--
29745 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process rendertext renlinear renmatrix ean5 ean2 upce micropdf417 pdf417 gs1-cc--
29746 % --DESC: UPC-E Composite
29747 % --EXAM: 01234558|(15)021231
29748 % --EXOP: includetext
29749 % --RNDR: renlinear renmatrix
29750 %%BeginResource: uk.co.terryburton.bwipp upcecomposite 0.0 2025111800 112753 112553
29751 %%BeginData: 151 ASCII Lines
29752 /setpacking where {pop currentpacking true setpacking} if
29753 10 dict
29754 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
29755 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
29756 dup /upce dup /uk.co.terryburton.bwipp findresource put
29757 dup /gs1-cc dup /uk.co.terryburton.bwipp findresource put
29758 dup /gs1process dup /uk.co.terryburton.bwipp findresource put
29759 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
29760 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
29761 begin
29762 /upcecomposite {
29763
29764 20 dict begin % Confine variables to local scope
29765
29766 /ctx null def
29767 /dontdraw false def
29768 /usematrix false def
29769 /parse false def
29770 /dontlint false def
29771 /lintreqs true def
29772
29773 //processoptions exec /options exch def
29774 /barcode exch def
29775
29776 dontdraw { /usematrix true def } if
29777
29778 % Split the linear and composite parts
29779 barcode (|) search {
29780 /linear exch def
29781 pop
29782 /comp exch def
29783 } {
29784 pop /bwipp.missingCompositeComponent (A Composite Component must be provided following a pipe character) //raiseerror exec
29785 } ifelse
29786
29787 options (lintype) (upce) put
29788 options (inkspreadv) 0.0 put
29789 options (dontdraw) true put
29790 options (dontlint) true put
29791
29792 % Lint with a fake AI (01)
29793 comp length 18 add string
29794 dup 0 ((01)00000000000000) putinterval
29795 dup 18 comp putinterval
29796 /ai //gs1process exec pop pop pop
29797
29798 % Plot the linear part
29799 linear options //upce exec
29800 usematrix not {
29801 gsave
29802
29803 //renlinear exec
29804
29805 currentpoint
29806
29807 % Plot the 2D part
29808 -3 78 rmoveto comp options //gs1-cc exec //renmatrix exec
29809
29810 % Plot the separator
29811 72 add exch 1 sub exch moveto <<
29812 /ren /renmatrix
29813 /pixs [
29814 0 1 49 {0} repeat 1 0
29815 1 0 49 {0} repeat 0 1
29816 0 1 49 {0} repeat 1 0
29817 ]
29818 /pixx 53
29819 /pixy 3
29820 /height 6 72 div
29821 /width 53 72 div
29822 /opt options
29823 >> //renmatrix exec
29824
29825 grestore
29826 } {
29827 /linsym exch def
29828 /sbs linsym /sbs get def
29829 /bhs linsym /bhs get def
29830 /bbs linsym /bbs get def
29831 /linwidth 0 sbs {cvi add} forall def
29832
29833 /compsym comp options //gs1-cc exec def
29834 /ccpixs compsym /pixs get def
29835 /ccpixx compsym /pixx get def
29836
29837 /linpad [ ccpixx 53 sub {0} repeat ] def
29838
29839 /diff linwidth linpad length add 1 add ccpixx sub def % An add-on can make linear wider than composite
29840 diff 0 gt { % Left align composite
29841 /ccrpad [ diff {0} repeat ] def
29842 /pixx ccpixx diff add def
29843 } {
29844 /ccrpad 0 array def
29845 /pixx ccpixx def
29846 } ifelse
29847
29848 /pixs [
29849 0 ccpixx ccpixs length 1 sub {
29850 /i exch def
29851 ccpixs i ccpixx getinterval aload pop ccrpad aload pop
29852 } for
29853 2 { linpad aload pop 0 1 49 {0} repeat 1 0 ccrpad aload pop } repeat
29854 2 { linpad aload pop 1 0 49 {0} repeat 0 1 ccrpad aload pop } repeat
29855 2 { linpad aload pop 0 1 49 {0} repeat 1 0 ccrpad aload pop } repeat
29856 71 -1 0 {
29857 /y exch def
29858 linpad aload pop
29859 0
29860 0 1 sbs length 1 sub {
29861 /i exch def
29862 i 2 mod 0 eq {
29863 % Don't print when bbs > y || (bbs + bhs) < y (i.e. add-on or includetext offsets)
29864 bbs i 2 idiv get 72 mul dup y gt exch bhs i 2 idiv get 72 mul add y lt or {
29865 sbs i get cvi {0} repeat
29866 } {
29867 sbs i get cvi {1} repeat
29868 } ifelse
29869 } {
29870 sbs i get cvi {0} repeat
29871 } ifelse
29872 } for
29873 diff 0 lt {0} if % Allow for middle separator overhang on RHS if no add-on
29874 } for
29875 ] def
29876
29877 /pixy pixs length pixx idiv def
29878 <<
29879 /ren /renmatrix
29880 /pixs pixs
29881 /pixx pixx
29882 /pixy pixy
29883 /height pixy 72 div
29884 /width pixx 72 div
29885 /opt options
29886 >>
29887
29888 dontdraw not {
29889 gsave
29890 //renmatrix exec
29891 grestore
29892 } if
29893 } ifelse
29894
29895 end
29896
29897 }
29898 [/barcode] {null def} forall
29899 bind def
29900 /upcecomposite dup load /uk.co.terryburton.bwipp defineresource pop
29901 end
29902 /setpacking where {pop setpacking} if
29903 %%EndData
29904 %%EndResource
29905 % --END ENCODER upcecomposite--
29906
29907 % --BEGIN ENCODER databaromnicomposite--
29908 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process rendertext renlinear renmatrix databaromni micropdf417 pdf417 gs1-cc--
29909 % --DESC: GS1 DataBar Omnidirectional Composite
29910 % --EXAM: (01)09521234543213|(11)990102
29911 % --EXOP:
29912 % --RNDR: renlinear renmatrix
29913 %%BeginResource: uk.co.terryburton.bwipp databaromnicomposite 0.0 2025111800 108510 104340
29914 %%BeginData: 150 ASCII Lines
29915 /setpacking where {pop currentpacking true setpacking} if
29916 10 dict
29917 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
29918 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
29919 dup /databaromni dup /uk.co.terryburton.bwipp findresource put
29920 dup /gs1-cc dup /uk.co.terryburton.bwipp findresource put
29921 dup /gs1process dup /uk.co.terryburton.bwipp findresource put
29922 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
29923 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
29924 begin
29925 /databaromnicomposite {
29926
29927 20 dict begin % Confine variables to local scope
29928
29929 /ctx null def
29930 /dontdraw false def
29931 /usematrix false def
29932 /parse false def
29933 /dontlint false def
29934 /lintreqs true def
29935
29936 //processoptions exec /options exch def
29937 /barcode exch def
29938
29939 dontdraw { /usematrix true def } if
29940
29941 % Split the linear and composite parts
29942 barcode (|) search {
29943 /linear exch def
29944 pop
29945 /comp exch def
29946 } {
29947 pop /bwipp.missingCompositeComponent (A Composite Component must be provided following a pipe character) //raiseerror exec
29948 } ifelse
29949
29950 usematrix not { gsave } if
29951
29952 options (lintype) (databaromni) put
29953 options (linkage) true put
29954 options (inkspreadv) 0.0 put
29955 options (dontdraw) true put
29956 options (dontlint) true put
29957
29958 % Lint the combined AI element strings
29959 linear length comp length add string
29960 dup 0 linear putinterval
29961 dup linear length comp putinterval
29962 /ai //gs1process exec pop pop pop
29963
29964 % Plot the linear part
29965 linear options //databaromni exec
29966 dup (sbs) get /linsbs exch def
29967 dup (bhs) get 0 get 72 mul /linheight exch def
29968 usematrix not { //renlinear exec } { pop } ifelse
29969
29970 % Plot the separator
29971 /sepfinder {
29972 /fp exch def
29973 fp 1 fp 12 add {
29974 /i exch def
29975 bot i get 0 eq {
29976 bot i 1 sub get 1 eq {
29977 1
29978 } {
29979 sep i 1 sub get 0 eq {1} {0} ifelse
29980 } ifelse
29981 } {
29982 0
29983 } ifelse
29984 sep exch i exch put
29985 } for
29986 /f3 [1 1 1 1 1 1 1 1 1 0 1 1 1] def
29987 true 0 1 12 {dup bot exch fp add get exch f3 exch get eq and} for {
29988 % Right shifted module for value 3 finder
29989 sep fp [ 0 0 0 0 0 0 0 0 0 0 1 0 0 ] putinterval
29990 } if
29991 } def
29992 mark
29993 0 linsbs {1 index 1 eq {{0}} {{1}} ifelse repeat} forall
29994 counttomark 1 sub array astore /bot exch def pop pop
29995 /sep [ bot {1 exch sub} forall ] def
29996 sep 0 [0 0 0] putinterval
29997 sep sep length 4 sub [0 0 0 0] putinterval
29998 18 sepfinder 64 sepfinder
29999
30000 usematrix not {
30001
30002 currentpoint
30003
30004 % Plot the 2D part
30005 -5 linheight 1 add rmoveto comp options //gs1-cc exec //renmatrix exec
30006
30007 linheight add moveto <<
30008 /ren /renmatrix
30009 /pixs sep
30010 /pixx sep length
30011 /pixy 1
30012 /height 1 72 div
30013 /width sep length 72 div
30014 /opt options
30015 >> //renmatrix exec
30016
30017 grestore
30018 } {
30019 /compsym comp options //gs1-cc exec def
30020 /ccpixs compsym /pixs get def
30021 /ccpixx compsym /pixx get def
30022
30023 /linpixs [ 0 % Begin with left guard space
30024 linsbs { cvi 1 index 0 eq {{1}} {{0}} ifelse repeat } forall % Alternates i 1/0's
30025 ] def
30026 /sep [ 0 sep aload pop ] def % Offset by 1
30027
30028 /linheight linheight cvi def
30029 % ccpixx is 99 for both 4-col CC-A and 4-col CC-B; linpixs length is 96
30030 /pixs [
30031 0 ccpixx ccpixs length 1 sub { % Right pad composite with 1 space
30032 /i exch def
30033 ccpixs i ccpixx getinterval aload pop 0
30034 } for
30035 0 0 0 0 sep aload pop linheight { 0 0 0 0 linpixs aload pop } repeat % Left pad with 4 spaces
30036 ] def
30037 /pixx ccpixx 1 add def % 100
30038
30039 /pixy pixs length pixx idiv def
30040 <<
30041 /ren /renmatrix
30042 /pixs pixs
30043 /pixx pixx
30044 /pixy pixy
30045 /height pixy 72 div
30046 /width pixx 72 div
30047 /opt options
30048 >>
30049
30050 dontdraw not {
30051 gsave
30052 //renmatrix exec
30053 grestore
30054 } if
30055 } ifelse
30056
30057 end
30058
30059 }
30060 [/barcode] {null def} forall
30061 bind def
30062 /databaromnicomposite dup load /uk.co.terryburton.bwipp defineresource pop
30063 end
30064 /setpacking where {pop setpacking} if
30065 %%EndData
30066 %%EndResource
30067 % --END ENCODER databaromnicomposite--
30068
30069 % --BEGIN ENCODER databarstackedcomposite--
30070 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process rendertext renlinear renmatrix databaromni databarstacked micropdf417 pdf417 gs1-cc--
30071 % --DESC: GS1 DataBar Stacked Composite
30072 % --EXAM: (01)09521234543213|(17)010200
30073 % --EXOP:
30074 % --RNDR: renlinear renmatrix
30075 %%BeginResource: uk.co.terryburton.bwipp databarstackedcomposite 0.0 2025111800 105610 108723
30076 %%BeginData: 145 ASCII Lines
30077 /setpacking where {pop currentpacking true setpacking} if
30078 10 dict
30079 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
30080 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
30081 dup /databarstacked dup /uk.co.terryburton.bwipp findresource put
30082 dup /gs1-cc dup /uk.co.terryburton.bwipp findresource put
30083 dup /gs1process dup /uk.co.terryburton.bwipp findresource put
30084 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
30085 begin
30086 /databarstackedcomposite {
30087
30088 20 dict begin % Confine variables to local scope
30089
30090 /ctx null def
30091 /dontdraw false def
30092 /usematrix false def
30093 /parse false def
30094 /dontlint false def
30095 /lintreqs true def
30096
30097 //processoptions exec /options exch def
30098 /barcode exch def
30099
30100 dontdraw { /usematrix true def } if
30101
30102 % Split the linear and composite parts
30103 barcode (|) search {
30104 /linear exch def
30105 pop
30106 /comp exch def
30107 } {
30108 pop /bwipp.missingCompositeComponent (A Composite Component must be provided following a pipe character) //raiseerror exec
30109 } ifelse
30110
30111 usematrix not { gsave } if
30112
30113 options (lintype) (databarstacked) put
30114 options (linkage) true put
30115 options (inkspreadv) 0.0 put
30116 options (dontdraw) true put
30117 options (dontlint) true put
30118
30119 % Lint the combined AI element strings
30120 linear length comp length add string
30121 dup 0 linear putinterval
30122 dup linear length comp putinterval
30123 /ai //gs1process exec pop pop pop
30124
30125 % Plot the linear part
30126 linear options //databarstacked exec
30127 dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def
30128 dup (pixy) get /linheight exch def
30129 usematrix not { //renmatrix exec } { /pixs get /linpixs exch def } ifelse
30130
30131 % Plot the separator
30132 /sepfinder {
30133 /fp exch def
30134 fp 1 fp 12 add {
30135 /i exch def
30136 bot i get 0 eq {
30137 bot i 1 sub get 1 eq {
30138 1
30139 } {
30140 sep i 1 sub get 0 eq {1} {0} ifelse
30141 } ifelse
30142 } {
30143 0
30144 } ifelse
30145 sep exch i exch put
30146 } for
30147 /f3 [1 1 1 1 1 1 1 1 1 0 1 1 1] def
30148 true 0 1 12 {dup bot exch fp add get exch f3 exch get eq and} for {
30149 % Right shifted module for value 3 finder
30150 sep fp [ 0 0 0 0 0 0 0 0 0 0 1 0 0 ] putinterval
30151 } if
30152 } def
30153 /sep [ bot {1 exch sub} forall ] def
30154 sep 0 [ 0 0 0 0 ] putinterval
30155 sep sep length 4 sub [ 0 0 0 0 ] putinterval
30156 18 sepfinder
30157
30158 usematrix not {
30159
30160 currentpoint
30161
30162 % Plot the 2D part
30163 1 linheight 1 add rmoveto comp options //gs1-cc exec //renmatrix exec
30164
30165 linheight add moveto <<
30166 /ren /renmatrix
30167 /pixs sep
30168 /pixx sep length
30169 /pixy 1
30170 /height 1 72 div
30171 /width sep length 72 div
30172 /opt options
30173 >> //renmatrix exec
30174
30175 grestore
30176 } {
30177 /compsym comp options //gs1-cc exec def
30178 /ccpixs compsym /pixs get def
30179 /ccpixx compsym /pixx get def
30180
30181 /linwidth sep length def % 50
30182 % ccpixx is 55 for both 2-col CC-A and 2-col CC-B
30183 /pixs [
30184 0 ccpixx ccpixs length 1 sub { % Left pad composite with 1 space
30185 /i exch def
30186 0 ccpixs i ccpixx getinterval aload pop
30187 } for
30188 sep aload pop 0 0 0 0 0 0
30189 0 linwidth linpixs length 1 sub { % Right pad linear with 6 spaces
30190 /i exch def
30191 linpixs i linwidth getinterval aload pop 0 0 0 0 0 0
30192 } for
30193 ] def
30194 /pixx ccpixx 1 add def % 56
30195
30196 /pixy pixs length pixx idiv def
30197 <<
30198 /ren /renmatrix
30199 /pixs pixs
30200 /pixx pixx
30201 /pixy pixy
30202 /height pixy 72 div
30203 /width pixx 72 div
30204 /opt options
30205 >>
30206
30207 dontdraw not {
30208 gsave
30209 //renmatrix exec
30210 grestore
30211 } if
30212 } ifelse
30213
30214 end
30215
30216 }
30217 [/barcode] {null def} forall
30218 bind def
30219 /databarstackedcomposite dup load /uk.co.terryburton.bwipp defineresource pop
30220 end
30221 /setpacking where {pop setpacking} if
30222 %%EndData
30223 %%EndResource
30224 % --END ENCODER databarstackedcomposite--
30225
30226 % --BEGIN ENCODER databarstackedomnicomposite--
30227 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process rendertext renlinear renmatrix databaromni databarstackedomni micropdf417 pdf417 gs1-cc--
30228 % --DESC: GS1 DataBar Stacked Omnidirectional Composite
30229 % --EXAM: (01)03612345678904|(11)990102
30230 % --EXOP:
30231 % --RNDR: renlinear renmatrix
30232 %%BeginResource: uk.co.terryburton.bwipp databarstackedomnicomposite 0.0 2025111800 105638 108747
30233 %%BeginData: 145 ASCII Lines
30234 /setpacking where {pop currentpacking true setpacking} if
30235 10 dict
30236 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
30237 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
30238 dup /databarstackedomni dup /uk.co.terryburton.bwipp findresource put
30239 dup /gs1-cc dup /uk.co.terryburton.bwipp findresource put
30240 dup /gs1process dup /uk.co.terryburton.bwipp findresource put
30241 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
30242 begin
30243 /databarstackedomnicomposite {
30244
30245 20 dict begin % Confine variables to local scope
30246
30247 /ctx null def
30248 /dontdraw false def
30249 /usematrix false def
30250 /parse false def
30251 /dontlint false def
30252 /lintreqs true def
30253
30254 //processoptions exec /options exch def
30255 /barcode exch def
30256
30257 dontdraw { /usematrix true def } if
30258
30259 % Split the linear and composite parts
30260 barcode (|) search {
30261 /linear exch def
30262 pop
30263 /comp exch def
30264 } {
30265 pop /bwipp.missingCompositeComponent (A Composite Component must be provided following a pipe character) //raiseerror exec
30266 } ifelse
30267
30268 usematrix not { gsave } if
30269
30270 options (lintype) (databarstackedomni) put
30271 options (linkage) true put
30272 options (inkspreadv) 0.0 put
30273 options (dontdraw) true put
30274 options (dontlint) true put
30275
30276 % Lint the combined AI element strings
30277 linear length comp length add string
30278 dup 0 linear putinterval
30279 dup linear length comp putinterval
30280 /ai //gs1process exec pop pop pop
30281
30282 % Plot the linear part
30283 linear options //databarstackedomni exec
30284 dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def
30285 dup (pixy) get /linheight exch def
30286 usematrix not { //renmatrix exec } { /pixs get /linpixs exch def } ifelse
30287
30288 % Plot the separator
30289 /sepfinder {
30290 /fp exch def
30291 fp 1 fp 12 add {
30292 /i exch def
30293 bot i get 0 eq {
30294 bot i 1 sub get 1 eq {
30295 1
30296 } {
30297 sep i 1 sub get 0 eq {1} {0} ifelse
30298 } ifelse
30299 } {
30300 0
30301 } ifelse
30302 sep exch i exch put
30303 } for
30304 /f3 [1 1 1 1 1 1 1 1 1 0 1 1 1] def
30305 true 0 1 12 {dup bot exch fp add get exch f3 exch get eq and} for {
30306 % Right shifted module for value 3 finder
30307 sep fp [ 0 0 0 0 0 0 0 0 0 0 1 0 0 ] putinterval
30308 } if
30309 } def
30310 /sep [ bot {1 exch sub} forall ] def
30311 sep 0 [ 0 0 0 0 ] putinterval
30312 sep sep length 4 sub [ 0 0 0 0 ] putinterval
30313 18 sepfinder
30314
30315 usematrix not {
30316
30317 currentpoint
30318
30319 % Plot the 2D part
30320 1 linheight 1 add rmoveto comp options //gs1-cc exec //renmatrix exec
30321
30322 linheight add moveto <<
30323 /ren /renmatrix
30324 /pixs sep
30325 /pixx sep length
30326 /pixy 1
30327 /height 1 72 div
30328 /width sep length 72 div
30329 /opt options
30330 >> //renmatrix exec
30331
30332 grestore
30333 } {
30334 /compsym comp options //gs1-cc exec def
30335 /ccpixs compsym /pixs get def
30336 /ccpixx compsym /pixx get def
30337
30338 /linwidth sep length def % 50
30339 % ccpixx is 55 for both 2-col CC-A and 2-col CC-B
30340 /pixs [
30341 0 ccpixx ccpixs length 1 sub { % Left pad composite with 1 space
30342 /i exch def
30343 0 ccpixs i ccpixx getinterval aload pop
30344 } for
30345 sep aload pop 0 0 0 0 0 0
30346 0 linwidth linpixs length 1 sub { % Right pad linear with 6 spaces
30347 /i exch def
30348 linpixs i linwidth getinterval aload pop 0 0 0 0 0 0
30349 } for
30350 ] def
30351 /pixx ccpixx 1 add def % 56
30352
30353 /pixy pixs length pixx idiv def
30354 <<
30355 /ren /renmatrix
30356 /pixs pixs
30357 /pixx pixx
30358 /pixy pixy
30359 /height pixy 72 div
30360 /width pixx 72 div
30361 /opt options
30362 >>
30363
30364 dontdraw not {
30365 gsave
30366 //renmatrix exec
30367 grestore
30368 } if
30369 } ifelse
30370
30371 end
30372
30373 }
30374 [/barcode] {null def} forall
30375 bind def
30376 /databarstackedomnicomposite dup load /uk.co.terryburton.bwipp defineresource pop
30377 end
30378 /setpacking where {pop setpacking} if
30379 %%EndData
30380 %%EndResource
30381 % --END ENCODER databarstackedomnicomposite--
30382
30383 % --BEGIN ENCODER databartruncatedcomposite--
30384 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process rendertext renlinear renmatrix databaromni databartruncated micropdf417 pdf417 gs1-cc--
30385 % --DESC: GS1 DataBar Truncated Composite
30386 % --EXAM: (01)09521234543213|(11)990102
30387 % --EXOP:
30388 % --RNDR: renlinear renmatrix
30389 %%BeginResource: uk.co.terryburton.bwipp databartruncatedcomposite 0.0 2025111800 107456 110681
30390 %%BeginData: 150 ASCII Lines
30391 /setpacking where {pop currentpacking true setpacking} if
30392 10 dict
30393 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
30394 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
30395 dup /databartruncated dup /uk.co.terryburton.bwipp findresource put
30396 dup /gs1-cc dup /uk.co.terryburton.bwipp findresource put
30397 dup /gs1process dup /uk.co.terryburton.bwipp findresource put
30398 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
30399 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
30400 begin
30401 /databartruncatedcomposite {
30402
30403 20 dict begin % Confine variables to local scope
30404
30405 /ctx null def
30406 /dontdraw false def
30407 /usematrix false def
30408 /parse false def
30409 /dontlint false def
30410 /lintreqs true def
30411
30412 //processoptions exec /options exch def
30413 /barcode exch def
30414
30415 dontdraw { /usematrix true def } if
30416
30417 % Split the linear and composite parts
30418 barcode (|) search {
30419 /linear exch def
30420 pop
30421 /comp exch def
30422 } {
30423 pop /bwipp.missingCompositeComponent (A Composite Component must be provided following a pipe character) //raiseerror exec
30424 } ifelse
30425
30426 usematrix not { gsave } if
30427
30428 options (lintype) (databartruncated) put
30429 options (linkage) true put
30430 options (inkspreadv) 0.0 put
30431 options (dontdraw) true put
30432 options (dontlint) true put
30433
30434 % Lint the combined AI element strings
30435 linear length comp length add string
30436 dup 0 linear putinterval
30437 dup linear length comp putinterval
30438 /ai //gs1process exec pop pop pop
30439
30440 % Plot the linear part
30441 linear options //databartruncated exec
30442 dup (sbs) get /linsbs exch def
30443 dup (bhs) get 0 get 72 mul /linheight exch def
30444 usematrix not { //renlinear exec } { pop } ifelse
30445
30446 % Plot the separator
30447 /sepfinder {
30448 /fp exch def
30449 fp 1 fp 12 add {
30450 /i exch def
30451 bot i get 0 eq {
30452 bot i 1 sub get 1 eq {
30453 1
30454 } {
30455 sep i 1 sub get 0 eq {1} {0} ifelse
30456 } ifelse
30457 } {
30458 0
30459 } ifelse
30460 sep exch i exch put
30461 } for
30462 /f3 [1 1 1 1 1 1 1 1 1 0 1 1 1] def
30463 true 0 1 12 {dup bot exch fp add get exch f3 exch get eq and} for {
30464 % Right shifted module for value 3 finder
30465 sep fp [ 0 0 0 0 0 0 0 0 0 0 1 0 0 ] putinterval
30466 } if
30467 } def
30468 mark
30469 0 linsbs {1 index 1 eq {{0}} {{1}} ifelse repeat} forall
30470 counttomark 1 sub array astore /bot exch def pop pop
30471 /sep [ bot {1 exch sub} forall ] def
30472 sep 0 [0 0 0] putinterval
30473 sep sep length 4 sub [0 0 0 0] putinterval
30474 18 sepfinder 64 sepfinder
30475
30476 usematrix not {
30477
30478 currentpoint
30479
30480 % Plot the 2D part
30481 -5 linheight 1 add rmoveto comp options //gs1-cc exec //renmatrix exec
30482
30483 linheight add moveto <<
30484 /ren /renmatrix
30485 /pixs sep
30486 /pixx sep length
30487 /pixy 1
30488 /height 1 72 div
30489 /width sep length 72 div
30490 /opt options
30491 >> //renmatrix exec
30492
30493 grestore
30494 } {
30495 /compsym comp options //gs1-cc exec def
30496 /ccpixs compsym /pixs get def
30497 /ccpixx compsym /pixx get def
30498
30499 /linpixs [ 0 % Begin with left guard space
30500 linsbs { cvi 1 index 0 eq {{1}} {{0}} ifelse repeat } forall % Alternates i 1/0's
30501 ] def
30502 /sep [ 0 sep aload pop ] def % Offset by 1
30503
30504 /linheight linheight cvi def
30505 % ccpixx is 99 for both 4-col CC-A and 4-col CC-B; linpixs length is 96
30506 /pixs [
30507 0 ccpixx ccpixs length 1 sub { % Right pad composite with 1 space
30508 /i exch def
30509 ccpixs i ccpixx getinterval aload pop 0
30510 } for
30511 0 0 0 0 sep aload pop linheight { 0 0 0 0 linpixs aload pop } repeat % Left pad with 4 spaces
30512 ] def
30513 /pixx ccpixx 1 add def % 100
30514
30515 /pixy pixs length pixx idiv def
30516 <<
30517 /ren /renmatrix
30518 /pixs pixs
30519 /pixx pixx
30520 /pixy pixy
30521 /height pixy 72 div
30522 /width pixx 72 div
30523 /opt options
30524 >>
30525
30526 dontdraw not {
30527 gsave
30528 //renmatrix exec
30529 grestore
30530 } if
30531 } ifelse
30532
30533 end
30534
30535 }
30536 [/barcode] {null def} forall
30537 bind def
30538 /databartruncatedcomposite dup load /uk.co.terryburton.bwipp defineresource pop
30539 end
30540 /setpacking where {pop setpacking} if
30541 %%EndData
30542 %%EndResource
30543 % --END ENCODER databartruncatedcomposite--
30544
30545 % --BEGIN ENCODER databarlimitedcomposite--
30546 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process rendertext renlinear renmatrix databarlimited micropdf417 pdf417 gs1-cc--
30547 % --DESC: GS1 DataBar Limited Composite
30548 % --EXAM: (01)09521234543213|(21)abcdefghijklmnopqrst
30549 % --EXOP:
30550 % --RNDR: renlinear renmatrix
30551 %%BeginResource: uk.co.terryburton.bwipp databarlimitedcomposite 0.0 2025111800 103367 106074
30552 %%BeginData: 140 ASCII Lines
30553 /setpacking where {pop currentpacking true setpacking} if
30554 10 dict
30555 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
30556 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
30557 dup /databarlimited dup /uk.co.terryburton.bwipp findresource put
30558 dup /gs1-cc dup /uk.co.terryburton.bwipp findresource put
30559 dup /gs1process dup /uk.co.terryburton.bwipp findresource put
30560 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
30561 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
30562 begin
30563 /databarlimitedcomposite {
30564
30565 20 dict begin % Confine variables to local scope
30566
30567 /ctx null def
30568 /dontdraw false def
30569 /usematrix false def
30570 /parse false def
30571 /dontlint false def
30572 /lintreqs true def
30573
30574 //processoptions exec /options exch def
30575 /barcode exch def
30576
30577 dontdraw { /usematrix true def } if
30578
30579 % Split the linear and composite parts
30580 barcode (|) search {
30581 /linear exch def
30582 pop
30583 /comp exch def
30584 } {
30585 pop /bwipp.missingCompositeComponent (A Composite Component must be provided following a pipe character) //raiseerror exec
30586 } ifelse
30587
30588 usematrix not { gsave } if
30589
30590 options (lintype) (databarlimited) put
30591 options (linkage) true put
30592 options (inkspreadv) 0.0 put
30593 options (dontdraw) true put
30594 options (dontlint) true put
30595
30596 % Lint the combined AI element strings
30597 linear length comp length add string
30598 dup 0 linear putinterval
30599 dup linear length comp putinterval
30600 /ai //gs1process exec pop pop pop
30601
30602 % Plot the linear part
30603 linear options //databarlimited exec
30604 dup (sbs) get /linsbs exch def
30605 dup (bhs) get 0 get 72 mul /linheight exch def
30606 usematrix not { //renlinear exec } { pop } ifelse
30607
30608 % Plot the separator
30609 mark
30610 1 linsbs {1 index 0 eq {{1}} {{0}} ifelse repeat} forall
30611 counttomark 1 sub array astore /sep exch def pop pop
30612 sep 0 [0 0 0] putinterval
30613 sep sep length 9 sub [0 0 0 0 0 0 0 0 0] putinterval % 4 + 5 right guard spaces
30614
30615 usematrix not {
30616
30617 currentpoint
30618
30619 % Plot the 2D part
30620 comp options //gs1-cc exec
30621 dup (pixx) get 72 exch sub linheight 1 add rmoveto
30622 //renmatrix exec
30623
30624 linheight add moveto <<
30625 /ren /renmatrix
30626 /pixs sep
30627 /pixx sep length
30628 /pixy 1
30629 /height 1 72 div
30630 /width sep length 72 div
30631 /opt options
30632 >> //renmatrix exec
30633
30634 grestore
30635 } {
30636 /compsym comp options //gs1-cc exec def
30637 /ccpixs compsym /pixs get def
30638 /ccpixx compsym /pixx get def
30639
30640 /linpixs [ 0 % Begin with left guard space
30641 linsbs { cvi 1 index 0 eq {{1}} {{0}} ifelse repeat } forall % Alternates i 1/0's
30642 ] def
30643 /sep [ 0 sep aload pop ] def % Offset by 1
30644
30645 /linheight linheight cvi def
30646 % ccpixx is 72 for CC-A and 82 for CC-B; linpixs length is 79
30647 ccpixx 72 eq { % 3-col CC-A
30648 /pixs [
30649 0 ccpixx ccpixs length 1 sub { % Left pad composite with 1 space & right pad with 1 space + 5 right guard spaces
30650 /i exch def
30651 0 ccpixs i ccpixx getinterval aload pop 0 0 0 0 0 0
30652 } for
30653 sep aload pop linheight { linpixs aload pop } repeat
30654 ] def
30655 /pixx linpixs length def % 79
30656 } { % 3-col CC-B
30657 /pixs [
30658 0 ccpixx ccpixs length 1 sub { % Right pad composite with 1 space + 5 right guard spaces
30659 /i exch def
30660 ccpixs i ccpixx getinterval aload pop 0 0 0 0 0 0
30661 } for
30662 0 0 0 0 0 0 0 0 0 sep aload pop linheight { 0 0 0 0 0 0 0 0 0 linpixs aload pop } repeat % Left pad with 9 spaces
30663 ] def
30664 /pixx ccpixx 6 add def % 88
30665 } ifelse
30666
30667 /pixy pixs length pixx idiv def
30668 <<
30669 /ren /renmatrix
30670 /pixs pixs
30671 /pixx pixx
30672 /pixy pixy
30673 /height pixy 72 div
30674 /width pixx 72 div
30675 /opt options
30676 >>
30677
30678 dontdraw not {
30679 gsave
30680 //renmatrix exec
30681 grestore
30682 } if
30683 } ifelse
30684
30685 end
30686
30687 }
30688 [/barcode] {null def} forall
30689 bind def
30690 /databarlimitedcomposite dup load /uk.co.terryburton.bwipp defineresource pop
30691 end
30692 /setpacking where {pop setpacking} if
30693 %%EndData
30694 %%EndResource
30695 % --END ENCODER databarlimitedcomposite--
30696
30697 % --BEGIN ENCODER databarexpandedcomposite--
30698 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process rendertext renlinear renmatrix databarexpanded micropdf417 pdf417 gs1-cc--
30699 % --DESC: GS1 DataBar Expanded Composite
30700 % --EXAM: (01)09521234543213(3103)001234|(91)1A2B3C4D5E
30701 % --EXOP:
30702 % --RNDR: renlinear renmatrix
30703 %%BeginResource: uk.co.terryburton.bwipp databarexpandedcomposite 0.0 2025111800 109095 104676
30704 %%BeginData: 149 ASCII Lines
30705 /setpacking where {pop currentpacking true setpacking} if
30706 10 dict
30707 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
30708 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
30709 dup /databarexpanded dup /uk.co.terryburton.bwipp findresource put
30710 dup /gs1-cc dup /uk.co.terryburton.bwipp findresource put
30711 dup /gs1process dup /uk.co.terryburton.bwipp findresource put
30712 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
30713 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
30714 begin
30715 /databarexpandedcomposite {
30716
30717 20 dict begin % Confine variables to local scope
30718
30719 /ctx null def
30720 /dontdraw false def
30721 /usematrix false def
30722 /parse false def
30723 /dontlint false def
30724 /lintreqs true def
30725
30726 //processoptions exec /options exch def
30727 /barcode exch def
30728
30729 dontdraw { /usematrix true def } if
30730
30731 % Split the linear and composite parts
30732 barcode (|) search {
30733 /linear exch def
30734 pop
30735 /comp exch def
30736 } {
30737 pop /bwipp.missingCompositeComponent (A Composite Component must be provided following a pipe character) //raiseerror exec
30738 } ifelse
30739
30740 usematrix not { gsave } if
30741
30742 options (lintype) (databarexpanded) put
30743 options (linkage) true put
30744 options (inkspreadv) 0.0 put
30745 options (dontdraw) true put
30746 options (dontlint) true put
30747
30748 % Lint the combined AI element strings
30749 linear length comp length add string
30750 dup 0 linear putinterval
30751 dup linear length comp putinterval
30752 /ai //gs1process exec pop pop pop
30753
30754 % Plot the linear part
30755 linear options //databarexpanded exec
30756 dup (sbs) get /linsbs exch def
30757 dup (bhs) get 0 get 72 mul /linheight exch def
30758 usematrix not { //renlinear exec } { pop } ifelse
30759
30760 % Plot the separator
30761 /sepfinder {
30762 /fp exch def
30763 fp 1 fp 12 add {
30764 /i exch def
30765 bot i get 0 eq {
30766 bot i 1 sub get 1 eq {
30767 1
30768 } {
30769 sep i 1 sub get 0 eq {1} {0} ifelse
30770 } ifelse
30771 } {
30772 0
30773 } ifelse
30774 sep exch i exch put
30775 } for
30776 } def
30777 mark
30778 0 linsbs {1 index 1 eq {{0}} {{1}} ifelse repeat} forall
30779 counttomark 1 sub array astore /bot exch def pop pop
30780 /sep [ bot {1 exch sub} forall ] def
30781 sep 0 [0 0 0] putinterval
30782 sep sep length 4 sub [0 0 0 0] putinterval
30783 [ % Finder pattern module positions
30784 18 98 bot length 13 sub {} for
30785 69 98 bot length 13 sub {} for
30786 ] {sepfinder} forall
30787
30788 usematrix not {
30789
30790 currentpoint
30791
30792 % Plot the 2D part
30793 1 linheight 1 add rmoveto comp options //gs1-cc exec //renmatrix exec
30794
30795 linheight add moveto <<
30796 /ren /renmatrix
30797 /pixs sep
30798 /pixx sep length
30799 /pixy 1
30800 /height 1 72 div
30801 /width sep length 72 div
30802 /opt options
30803 >> //renmatrix exec
30804
30805 grestore
30806 } {
30807 /compsym comp options //gs1-cc exec def
30808 /ccpixs compsym /pixs get def
30809 /ccpixx compsym /pixx get def
30810
30811 /linpixs [ 0 % Begin with left guard space
30812 linsbs { cvi 1 index 0 eq {{1}} {{0}} ifelse repeat } forall % Alternates i 1/0's
30813 ] def
30814 /sep [ 0 sep aload pop ] def % Offset by 1
30815
30816 /linheight linheight cvi def
30817 /diff linpixs length ccpixx sub def % Minimum linpixs length is 102, ccpixx is 99
30818 /ccrpad [ diff 2 sub {0} repeat ] def
30819 /pixs [
30820 0 ccpixx ccpixs length 1 sub {
30821 /i exch def
30822 0 0 ccpixs i ccpixx getinterval aload pop ccrpad aload pop
30823 } for
30824 sep aload pop linheight { linpixs aload pop } repeat
30825 ] def
30826
30827 /pixx linpixs length def
30828 /pixy pixs length pixx idiv def
30829 <<
30830 /ren /renmatrix
30831 /pixs pixs
30832 /pixx pixx
30833 /pixy pixy
30834 /height pixy 72 div
30835 /width pixx 72 div
30836 /opt options
30837 >>
30838
30839 dontdraw not {
30840 gsave
30841 //renmatrix exec
30842 grestore
30843 } if
30844 } ifelse
30845
30846 end
30847
30848 }
30849 [/barcode] {null def} forall
30850 bind def
30851 /databarexpandedcomposite dup load /uk.co.terryburton.bwipp defineresource pop
30852 end
30853 /setpacking where {pop setpacking} if
30854 %%EndData
30855 %%EndResource
30856 % --END ENCODER databarexpandedcomposite--
30857
30858 % --BEGIN ENCODER databarexpandedstackedcomposite--
30859 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process rendertext renlinear renmatrix databarexpanded databarexpandedstacked micropdf417 pdf417 gs1-cc--
30860 % --DESC: GS1 DataBar Expanded Stacked Composite
30861 % --EXAM: (01)09521234543213(10)ABCDEF|(21)12345678
30862 % --EXOP: segments=4
30863 % --RNDR: renmatrix renlinear
30864 %%BeginResource: uk.co.terryburton.bwipp databarexpandedstackedcomposite 0.0 2025111800 106257 105995
30865 %%BeginData: 140 ASCII Lines
30866 /setpacking where {pop currentpacking true setpacking} if
30867 10 dict
30868 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
30869 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
30870 dup /databarexpandedstacked dup /uk.co.terryburton.bwipp findresource put
30871 dup /gs1-cc dup /uk.co.terryburton.bwipp findresource put
30872 dup /gs1process dup /uk.co.terryburton.bwipp findresource put
30873 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
30874 begin
30875 /databarexpandedstackedcomposite {
30876
30877 20 dict begin % Confine variables to local scope
30878
30879 /ctx null def
30880 /dontdraw false def
30881 /usematrix false def
30882 /parse false def
30883 /dontlint false def
30884 /lintreqs true def
30885
30886 //processoptions exec /options exch def
30887 /barcode exch def
30888
30889 dontdraw { /usematrix true def } if
30890
30891 % Split the linear and composite parts
30892 barcode (|) search {
30893 /linear exch def
30894 pop
30895 /comp exch def
30896 } {
30897 pop /bwipp.missingCompositeComponent (A Composite Component must be provided following a pipe character) //raiseerror exec
30898 } ifelse
30899
30900 usematrix not { gsave } if
30901
30902 options (lintype) (databarexpandedstacked) put
30903 options (linkage) true put
30904 options (inkspreadv) 0.0 put
30905 options (dontdraw) true put
30906 options (dontlint) true put
30907
30908 % Lint the combined AI element strings
30909 linear length comp length add string
30910 dup 0 linear putinterval
30911 dup linear length comp putinterval
30912 /ai //gs1process exec pop pop pop
30913
30914 % Plot the linear part
30915 linear options //databarexpandedstacked exec
30916 dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def
30917 dup (pixy) get /linheight exch def
30918 usematrix not { //renmatrix exec } { /pixs get /linpixs exch def } ifelse
30919
30920 % Plot the separator
30921 /sepfinder {
30922 /fp exch def
30923 fp 1 fp 12 add {
30924 /i exch def
30925 bot i get 0 eq {
30926 bot i 1 sub get 1 eq {
30927 1
30928 } {
30929 sep i 1 sub get 0 eq {1} {0} ifelse
30930 } ifelse
30931 } {
30932 0
30933 } ifelse
30934 sep exch i exch put
30935 } for
30936 } def
30937 /sep [ bot {1 exch sub} forall ] def
30938 sep 0 [ 0 0 0 0 ] putinterval
30939 sep sep length 4 sub [ 0 0 0 0 ] putinterval
30940 [ % Finder pattern module positions
30941 19 98 bot length 13 sub {} for
30942 70 98 bot length 13 sub {} for
30943 ] {sepfinder} forall
30944
30945 usematrix not {
30946
30947 currentpoint
30948
30949 % Plot the 2D part
30950 bot 0 get 0 eq {2} {0} ifelse linheight 1 add rmoveto
30951 comp options //gs1-cc exec //renmatrix exec
30952
30953 linheight add moveto <<
30954 /ren /renmatrix
30955 /pixs sep
30956 /pixx sep length
30957 /pixy 1
30958 /height 1 72 div
30959 /width sep length 72 div
30960 /opt options
30961 >> //renmatrix exec
30962
30963 grestore
30964 } {
30965 /compsym comp options //gs1-cc exec def
30966 /ccpixs compsym /pixs get def
30967 /ccpixx compsym /pixx get def
30968
30969 /pixx sep length def
30970 /cclpad [ pixx ccpixx sub 1 add 2 idiv {0} repeat ] def % Add 1 to allow for odd difference
30971 /ccrpad [ pixx ccpixx sub 2 idiv {0} repeat ] def
30972 /pixs [
30973 0 ccpixx ccpixs length 1 sub { % Centre align composite
30974 /i exch def
30975 cclpad aload pop ccpixs i ccpixx getinterval aload pop ccrpad aload pop
30976 } for
30977 sep aload pop linpixs aload pop
30978 ] def
30979
30980 /pixy pixs length pixx idiv def
30981 <<
30982 /ren /renmatrix
30983 /pixs pixs
30984 /pixx pixx
30985 /pixy pixy
30986 /height pixy 72 div
30987 /width pixx 72 div
30988 /opt options
30989 >>
30990
30991 dontdraw not {
30992 gsave
30993 //renmatrix exec
30994 grestore
30995 } if
30996 } ifelse
30997
30998 end
30999
31000 }
31001 [/barcode] {null def} forall
31002 bind def
31003 /databarexpandedstackedcomposite dup load /uk.co.terryburton.bwipp defineresource pop
31004 end
31005 /setpacking where {pop setpacking} if
31006 %%EndData
31007 %%EndResource
31008 % --END ENCODER databarexpandedstackedcomposite--
31009
31010 % --BEGIN ENCODER gs1-128composite--
31011 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process rendertext renlinear renmatrix code128 gs1-128 micropdf417 pdf417 gs1-cc--
31012 % --DESC: GS1-128 Composite
31013 % --EXAM: (00)095287654321012346|(02)09521234543213(37)24(10)1234567ABCDEFG
31014 % --EXOP: ccversion=c
31015 % --RNDR: renlinear renmatrix
31016 %%BeginResource: uk.co.terryburton.bwipp gs1-128composite 0.0 2025111800 114599 114307
31017 %%BeginData: 165 ASCII Lines
31018 /setpacking where {pop currentpacking true setpacking} if
31019 10 dict
31020 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
31021 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
31022 dup /gs1-128 dup /uk.co.terryburton.bwipp findresource put
31023 dup /gs1-cc dup /uk.co.terryburton.bwipp findresource put
31024 dup /gs1process dup /uk.co.terryburton.bwipp findresource put
31025 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
31026 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
31027 begin
31028 /gs1-128composite {
31029
31030 20 dict begin % Confine variables to local scope
31031
31032 /ctx null def
31033 /dontdraw false def
31034 /usematrix false def
31035 /parse false def
31036 /dontlint false def
31037 /lintreqs true def
31038
31039 //processoptions exec /options exch def
31040 /barcode exch def
31041
31042 dontdraw { /usematrix true def } if
31043
31044 % Split the linear and composite parts
31045 barcode (|) search {
31046 /linear exch def
31047 pop
31048 /comp exch def
31049 } {
31050 pop /bwipp.missingCompositeComponent (A Composite Component must be provided following a pipe character) //raiseerror exec
31051 } ifelse
31052
31053 usematrix not { gsave } if
31054
31055 options (inkspreadv) 0.0 put
31056 options (dontdraw) true put
31057 options (dontlint) true put
31058
31059 % Lint the combined AI element strings
31060 linear length comp length add string
31061 dup 0 linear putinterval
31062 dup linear length comp putinterval
31063 /ai //gs1process exec pop pop pop
31064
31065 % Dummy plot of linear part with CC-A to get width
31066 options (linkagea) true put
31067 linear << options {} forall >> //gs1-128 exec
31068 (sbs) get 0 exch {add} forall /linwidth exch def
31069
31070 % Create 2D part and determine type
31071 options (lintype) (gs1-128) put
31072 options (linwidth) linwidth put
31073 comp << options {} forall >> //gs1-cc exec /compsym exch def
31074 compsym (pixx) get 99 eq {(a)} {(c)} ifelse /linktype exch def
31075 compsym (borderbottom) 0 put
31076
31077 % Plot linear part
31078 linktype (a) eq {
31079 options (linkagea) true put
31080 options (linkagec) false put
31081 } {
31082 options (linkagea) false put
31083 options (linkagec) true put
31084 } ifelse
31085 linear << options {} forall >> //gs1-128 exec
31086 dup (sbs) get /linsbs exch def
31087 dup (bhs) get 0 get 72 mul /linheight exch def
31088 usematrix not { //renlinear exec } { pop } ifelse
31089
31090 % Plot the separator
31091 mark
31092 1 linsbs {1 index 0 eq {{1}} {{0}} ifelse repeat} forall
31093 counttomark 1 sub array astore /sep exch def pop pop
31094
31095 % Plot the 2D part
31096 linktype (a) eq {
31097 /s linwidth 2 sub 11 idiv def
31098 /p s 9 sub 2 idiv def
31099 /x s p sub 1 sub 11 mul 10 add p 0 eq {2 add} if 99 sub def
31100 } {
31101 /x -7 def
31102 } ifelse
31103
31104 usematrix not {
31105
31106 currentpoint
31107
31108 x linheight 1 add rmoveto compsym //renmatrix exec
31109
31110 linheight add moveto <<
31111 /ren /renmatrix
31112 /pixs sep
31113 /pixx sep length
31114 /pixy 1
31115 /height 1 72 div
31116 /width sep length 72 div
31117 /opt options
31118 >> //renmatrix exec
31119
31120 grestore
31121 } {
31122 /ccpixs compsym /pixs get def
31123 /ccpixx compsym /pixx get def
31124
31125 /linpixs [
31126 linsbs { 1 index 1 eq {{0}} {{1}} ifelse repeat } forall % Alternates i 1/0's (linsbs always begins with "2")
31127 ] def
31128
31129 x 0 gt { % Left pad composite
31130 /cclpad [ x {0} repeat ] def
31131 /linlpad 0 array def
31132 } { % Left pad linear
31133 /cclpad 0 array def
31134 /linlpad [ x neg {0} repeat ] def
31135 } ifelse
31136
31137 /diff linwidth ccpixx x add sub def
31138 diff 0 gt { % Right pad composite
31139 /ccrpad [ diff {0} repeat ] def
31140 /linrpad 0 array def
31141 } { % Right pad linear
31142 /ccrpad 0 array def
31143 /linrpad [ diff neg {0} repeat ] def
31144 } ifelse
31145
31146 /linheight linheight cvi def
31147 /pixs [
31148 0 ccpixx ccpixs length 1 sub {
31149 /i exch def
31150 cclpad aload pop ccpixs i ccpixx getinterval aload pop ccrpad aload pop
31151 } for
31152 linlpad aload pop sep aload pop linrpad aload pop
31153 linheight { linlpad aload pop linpixs aload pop linrpad aload pop } repeat
31154 ] def
31155
31156 /pixx cclpad length ccpixx add ccrpad length add def
31157 /pixy pixs length pixx idiv def
31158 <<
31159 /ren /renmatrix
31160 /pixs pixs
31161 /pixx pixx
31162 /pixy pixy
31163 /height pixy 72 div
31164 /width pixx 72 div
31165 /opt options
31166 >>
31167
31168 dontdraw not {
31169 gsave
31170 //renmatrix exec
31171 grestore
31172 } if
31173 } ifelse
31174
31175 end
31176
31177 }
31178 [/barcode] {null def} forall
31179 bind def
31180 /gs1-128composite dup load /uk.co.terryburton.bwipp defineresource pop
31181 end
31182 /setpacking where {pop setpacking} if
31183 %%EndData
31184 %%EndResource
31185 % --END ENCODER gs1-128composite--
31186
31187 % --BEGIN ENCODER gs1datamatrix--
31188 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process rendertext renmatrix datamatrix--
31189 % --DESC: GS1 Data Matrix
31190 % --EXAM: (01)09521234543213(17)120508(10)ABCD1234(410)9501101020917
31191 % --EXOP:
31192 % --RNDR: renmatrix
31193 %%BeginResource: uk.co.terryburton.bwipp gs1datamatrix 0.0 2025111800 80885 84131
31194 %%BeginData: 81 ASCII Lines
31195 /setpacking where {pop currentpacking true setpacking} if
31196 10 dict
31197 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
31198 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
31199 dup /gs1process dup /uk.co.terryburton.bwipp findresource put
31200 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
31201 dup /datamatrix dup /uk.co.terryburton.bwipp findresource put
31202 begin
31203 /gs1datamatrix {
31204
31205 20 dict begin % Confine variables to local scope
31206
31207 /ctx null def
31208 /dontdraw false def
31209 /parse false def
31210 /dontlint false def
31211 /lintreqs true def
31212 /gssep false def
31213
31214 //processoptions exec /options exch def
31215 /barcode exch def
31216
31217 barcode /ai //gs1process exec
31218 /fncs exch def
31219 /vals exch def
31220 /ais exch def
31221
31222 % Create the datamatrix data
31223 /fnc1 -1 def
31224 /dmtx [ fnc1 ] def
31225 0 1 ais length 1 sub {
31226 /i exch def
31227 /ai ais i get def
31228 /val vals i get def
31229 dmtx length ai length add val length add array
31230 dup 0 dmtx putinterval
31231 dup dmtx length ai [ exch {} forall ] putinterval
31232 dup dmtx length ai length add val [ exch {} forall ] putinterval
31233 /dmtx exch def
31234 i ais length 1 sub ne fncs i get and { % Append FNC1
31235 dmtx length 1 add array
31236 dup 0 dmtx putinterval
31237 dup dmtx length gssep {29} {fnc1} ifelse put
31238 /dmtx exch def
31239 } if
31240 } for
31241
31242 % Compose input to datamatrix
31243 /barcode dmtx length 1 add 5 mul string def
31244 /i 0 def /j 0 def {
31245 i dmtx length eq {exit} if
31246 dmtx i get dup fnc1 eq {
31247 pop barcode j (^FNC1) putinterval
31248 /j j 4 add def
31249 } {
31250 barcode exch j exch put
31251 } ifelse
31252 /i i 1 add def
31253 /j j 1 add def
31254 } loop
31255 /barcode barcode 0 j getinterval def
31256
31257 % Get the result of encoding with datamatrix
31258 options (parse) undef
31259 options (dontdraw) true put
31260 options (parsefnc) true put
31261 /args barcode options //datamatrix exec def
31262
31263 args (opt) options put
31264 args
31265
31266 dontdraw not //renmatrix if
31267
31268 end
31269
31270 }
31271 [/barcode] {null def} forall
31272 bind def
31273 /gs1datamatrix dup load /uk.co.terryburton.bwipp defineresource pop
31274 end
31275 /setpacking where {pop setpacking} if
31276 %%EndData
31277 %%EndResource
31278 % --END ENCODER gs1datamatrix--
31279
31280 % --BEGIN ENCODER gs1datamatrixrectangular--
31281 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process rendertext renmatrix datamatrix--
31282 % --DESC: GS1 Data Matrix Rectangular
31283 % --EXAM: (01)09521234543213(17)120508(10)ABCD1234(410)9501101020917
31284 % --EXOP:
31285 % --RNDR: renmatrix
31286 %%BeginResource: uk.co.terryburton.bwipp gs1datamatrixrectangular 0.0 2025111800 81224 84355
31287 %%BeginData: 82 ASCII Lines
31288 /setpacking where {pop currentpacking true setpacking} if
31289 10 dict
31290 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
31291 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
31292 dup /gs1process dup /uk.co.terryburton.bwipp findresource put
31293 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
31294 dup /datamatrix dup /uk.co.terryburton.bwipp findresource put
31295 begin
31296 /gs1datamatrixrectangular {
31297
31298 20 dict begin % Confine variables to local scope
31299
31300 /ctx null def
31301 /parse false def
31302 /dontlint false def
31303 /lintreqs true def
31304 /dontdraw false def
31305 /gssep false def
31306
31307 //processoptions exec /options exch def
31308 /barcode exch def
31309
31310 barcode /ai //gs1process exec
31311 /fncs exch def
31312 /vals exch def
31313 /ais exch def
31314
31315 % Create the datamatrix data
31316 /fnc1 -1 def
31317 /dmtx [ fnc1 ] def
31318 0 1 ais length 1 sub {
31319 /i exch def
31320 /ai ais i get def
31321 /val vals i get def
31322 dmtx length ai length add val length add array
31323 dup 0 dmtx putinterval
31324 dup dmtx length ai [ exch {} forall ] putinterval
31325 dup dmtx length ai length add val [ exch {} forall ] putinterval
31326 /dmtx exch def
31327 i ais length 1 sub ne fncs i get and { % Append FNC1
31328 dmtx length 1 add array
31329 dup 0 dmtx putinterval
31330 dup dmtx length gssep {29} {fnc1} ifelse put
31331 /dmtx exch def
31332 } if
31333 } for
31334
31335 % Compose input to datamatrix
31336 /barcode dmtx length 1 add 5 mul string def
31337 /i 0 def /j 0 def {
31338 i dmtx length eq {exit} if
31339 dmtx i get dup fnc1 eq {
31340 pop barcode j (^FNC1) putinterval
31341 /j j 4 add def
31342 } {
31343 barcode exch j exch put
31344 } ifelse
31345 /i i 1 add def
31346 /j j 1 add def
31347 } loop
31348 /barcode barcode 0 j getinterval def
31349
31350 % Get the result of encoding with datamatrix
31351 options (parse) undef
31352 options (dontdraw) true put
31353 options (parsefnc) true put
31354 options (format) (rectangle) put
31355 /args barcode options //datamatrix exec def
31356
31357 args (opt) options put
31358 args
31359
31360 dontdraw not //renmatrix if
31361
31362 end
31363
31364 }
31365 [/barcode] {null def} forall
31366 bind def
31367 /gs1datamatrixrectangular dup load /uk.co.terryburton.bwipp defineresource pop
31368 end
31369 /setpacking where {pop setpacking} if
31370 %%EndData
31371 %%EndResource
31372 % --END ENCODER gs1datamatrixrectangular--
31373
31374 % --BEGIN ENCODER gs1dldatamatrix--
31375 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process rendertext renmatrix datamatrix--
31376 % --DESC: GS1 Digital Link Data Matrix
31377 % --EXAM: https://id.gs1.org/01/09521234543213/22/ABC%2D123?99=XYZ-987
31378 % --EXOP: includetext
31379 % --RNDR: renmatrix
31380 %%BeginResource: uk.co.terryburton.bwipp gs1dldatamatrix 0.0 2025111800 76198 79446
31381 %%BeginData: 61 ASCII Lines
31382 /setpacking where {pop currentpacking true setpacking} if
31383 10 dict
31384 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
31385 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
31386 dup /gs1process dup /uk.co.terryburton.bwipp findresource put
31387 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
31388 dup /datamatrix dup /uk.co.terryburton.bwipp findresource put
31389 begin
31390 /gs1dldatamatrix {
31391
31392 20 dict begin % Confine variables to local scope
31393
31394 /ctx null def
31395 /parse false def
31396 /dontlint false def
31397 /lintreqs true def
31398 /dontdraw false def
31399
31400 //processoptions exec /options exch def
31401 /barcode exch def
31402
31403 % Parse the input
31404 /fncvals <<
31405 /parse parse
31406 /parseonly true
31407 /parsefnc false
31408 >> def
31409 /barcode barcode fncvals //parseinput exec def
31410
31411 barcode /dl //gs1process exec pop
31412 0 get /val exch def
31413 0 get /key exch def
31414
31415 /hri key length val length add 2 add string def
31416 hri 0 40 put
31417 hri 1 key putinterval
31418 hri key length 1 add 41 put
31419 hri key length 2 add val putinterval
31420
31421 % Get the result of encoding with datamatrix
31422 options (parse) undef
31423 options (dontdraw) true put
31424 /args barcode options //datamatrix exec def
31425
31426 args (opt) options put
31427 args (alttext) hri put
31428 args (textyoffset) -1.0 put
31429 args (textfont) /Helvetica put
31430 args (textsize) 5 put
31431 args
31432
31433 dontdraw not //renmatrix if
31434
31435 end
31436
31437 }
31438 [/barcode] {null def} forall
31439 bind def
31440 /gs1dldatamatrix dup load /uk.co.terryburton.bwipp defineresource pop
31441 end
31442 /setpacking where {pop setpacking} if
31443 %%EndData
31444 %%EndResource
31445 % --END ENCODER gs1dldatamatrix--
31446
31447 % --BEGIN ENCODER gs1qrcode--
31448 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process rendertext renmatrix qrcode--
31449 % --DESC: GS1 QR Code
31450 % --EXAM: (01)09521234543213(8200)http://www.abc.net(10)ABCD1234(410)9501101020917
31451 % --EXOP:
31452 % --RNDR: renmatrix
31453 %%BeginResource: uk.co.terryburton.bwipp gs1qrcode 0.0 2025111800 80507 83887
31454 %%BeginData: 79 ASCII Lines
31455 /setpacking where {pop currentpacking true setpacking} if
31456 10 dict
31457 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
31458 dup /gs1process dup /uk.co.terryburton.bwipp findresource put
31459 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
31460 dup /qrcode dup /uk.co.terryburton.bwipp findresource put
31461 begin
31462 /gs1qrcode {
31463
31464 20 dict begin % Confine variables to local scope
31465
31466 /ctx null def
31467 /parse false def
31468 /dontlint false def
31469 /lintreqs true def
31470 /dontdraw false def
31471
31472 //processoptions exec /options exch def
31473 /barcode exch def
31474
31475 barcode /ai //gs1process exec
31476 /fncs exch def
31477 /vals exch def
31478 /ais exch def
31479
31480 % Create the qrcode data
31481 /fnc1 -1 def
31482 /qrc [ fnc1 ] def
31483 0 1 ais length 1 sub {
31484 /i exch def
31485 /ai ais i get def
31486 /val vals i get def
31487 qrc length ai length add val length add array
31488 dup 0 qrc putinterval
31489 dup qrc length ai [ exch {} forall ] putinterval
31490 dup qrc length ai length add val [ exch {} forall ] putinterval
31491 /qrc exch def
31492 i ais length 1 sub ne fncs i get and { % Append FNC1
31493 qrc length 1 add array
31494 dup 0 qrc putinterval
31495 dup qrc length fnc1 put
31496 /qrc exch def
31497 } if
31498 } for
31499
31500 % Compose input to qrcode
31501 /barcode qrc length 1 add 5 mul string def
31502 /i 0 def /j 0 def {
31503 i qrc length eq {exit} if
31504 qrc i get dup fnc1 eq {
31505 pop barcode j (^FNC1) putinterval
31506 /j j 4 add def
31507 } {
31508 barcode exch j exch put
31509 } ifelse
31510 /i i 1 add def
31511 /j j 1 add def
31512 } loop
31513 /barcode barcode 0 j getinterval def
31514
31515 % Get the result of encoding with qrcode
31516 options (parse) undef
31517 options (dontdraw) true put
31518 options (parsefnc) true put
31519 /args barcode options //qrcode exec def
31520
31521 args (opt) options put
31522 args
31523
31524 dontdraw not //renmatrix if
31525
31526 end
31527
31528 }
31529 [/barcode] {null def} forall
31530 bind def
31531 /gs1qrcode dup load /uk.co.terryburton.bwipp defineresource pop
31532 end
31533 /setpacking where {pop setpacking} if
31534 %%EndData
31535 %%EndResource
31536 % --END ENCODER gs1qrcode--
31537
31538 % --BEGIN ENCODER gs1dlqrcode--
31539 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process rendertext renmatrix qrcode--
31540 % --DESC: GS1 Digital Link QR Code
31541 % --EXAM: HTTPS://ID.GS1.ORG/01/09521234543213/22/ABC%2D123?99=XYZ-987
31542 % --EXOP: includetext
31543 % --RNDR: renmatrix
31544 %%BeginResource: uk.co.terryburton.bwipp gs1dlqrcode 0.0 2025111800 76046 75994
31545 %%BeginData: 61 ASCII Lines
31546 /setpacking where {pop currentpacking true setpacking} if
31547 10 dict
31548 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
31549 dup /parseinput dup /uk.co.terryburton.bwipp findresource put
31550 dup /gs1process dup /uk.co.terryburton.bwipp findresource put
31551 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
31552 dup /qrcode dup /uk.co.terryburton.bwipp findresource put
31553 begin
31554 /gs1dlqrcode {
31555
31556 20 dict begin % Confine variables to local scope
31557
31558 /ctx null def
31559 /parse false def
31560 /dontlint false def
31561 /lintreqs true def
31562 /dontdraw false def
31563
31564 //processoptions exec /options exch def
31565 /barcode exch def
31566
31567 % Parse the input
31568 /fncvals <<
31569 /parse parse
31570 /parseonly true
31571 /parsefnc false
31572 >> def
31573 /barcode barcode fncvals //parseinput exec def
31574
31575 barcode /dl //gs1process exec pop
31576 0 get /val exch def
31577 0 get /key exch def
31578
31579 /hri key length val length add 2 add string def
31580 hri 0 40 put
31581 hri 1 key putinterval
31582 hri key length 1 add 41 put
31583 hri key length 2 add val putinterval
31584
31585 % Get the result of encoding with qrcode
31586 options (parse) undef
31587 options (dontdraw) true put
31588 /args barcode options //qrcode exec def
31589
31590 args (opt) options put
31591 args (alttext) hri put
31592 args (textyoffset) -4.0 put
31593 args (textfont) /Helvetica put
31594 args (textsize) 5 put
31595 args
31596
31597 dontdraw not //renmatrix if
31598
31599 end
31600
31601 }
31602 [/barcode] {null def} forall
31603 bind def
31604 /gs1dlqrcode dup load /uk.co.terryburton.bwipp defineresource pop
31605 end
31606 /setpacking where {pop setpacking} if
31607 %%EndData
31608 %%EndResource
31609 % --END ENCODER gs1dlqrcode--
31610
31611 % --BEGIN ENCODER gs1dotcode--
31612 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process rendertext renmatrix dotcode--
31613 % --DESC: GS1 DotCode
31614 % --EXAM: (235)5vBZIF%!<B;?oa%(01)09521234543213(8008)19052001
31615 % --EXOP: rows=16
31616 % --RNDR: renmatrix
31617 %%BeginResource: uk.co.terryburton.bwipp gs1dotcode 0.0 2025111800 80586 83860
31618 %%BeginData: 80 ASCII Lines
31619 /setpacking where {pop currentpacking true setpacking} if
31620 10 dict
31621 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
31622 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
31623 dup /gs1process dup /uk.co.terryburton.bwipp findresource put
31624 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
31625 dup /dotcode dup /uk.co.terryburton.bwipp findresource put
31626 begin
31627 /gs1dotcode {
31628
31629 20 dict begin % Confine variables to local scope
31630
31631 /ctx null def
31632 /dontdraw false def
31633 /parse false def
31634 /dontlint false def
31635 /lintreqs true def
31636
31637 //processoptions exec /options exch def
31638 /barcode exch def
31639
31640 barcode /ai //gs1process exec
31641 /fncs exch def
31642 /vals exch def
31643 /ais exch def
31644
31645 % Create the dotcode data
31646 /fnc1 -1 def
31647 /dmtx [ fnc1 ] def
31648 0 1 ais length 1 sub {
31649 /i exch def
31650 /ai ais i get def
31651 /val vals i get def
31652 dmtx length ai length add val length add array
31653 dup 0 dmtx putinterval
31654 dup dmtx length ai [ exch {} forall ] putinterval
31655 dup dmtx length ai length add val [ exch {} forall ] putinterval
31656 /dmtx exch def
31657 i ais length 1 sub ne fncs i get and { % Append FNC1
31658 dmtx length 1 add array
31659 dup 0 dmtx putinterval
31660 dup dmtx length fnc1 put
31661 /dmtx exch def
31662 } if
31663 } for
31664
31665 % Compose input to dotcode
31666 /barcode dmtx length 1 add 5 mul string def
31667 /i 0 def /j 0 def {
31668 i dmtx length eq {exit} if
31669 dmtx i get dup fnc1 eq {
31670 pop barcode j (^FNC1) putinterval
31671 /j j 4 add def
31672 } {
31673 barcode exch j exch put
31674 } ifelse
31675 /i i 1 add def
31676 /j j 1 add def
31677 } loop
31678 /barcode barcode 0 j getinterval def
31679
31680 % Get the result of encoding with dotcode
31681 options (parse) undef
31682 options (dontdraw) true put
31683 options (parsefnc) true put
31684 /args barcode options //dotcode exec def
31685
31686 args (opt) options put
31687 args
31688
31689 dontdraw not //renmatrix if
31690
31691 end
31692
31693 }
31694 [/barcode] {null def} forall
31695 bind def
31696 /gs1dotcode dup load /uk.co.terryburton.bwipp defineresource pop
31697 end
31698 /setpacking where {pop setpacking} if
31699 %%EndData
31700 %%EndResource
31701 % --END ENCODER gs1dotcode--
31702
31703 % --BEGIN ENCODER hibccode39--
31704 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions rendertext renlinear code39--
31705 % --DESC: HIBC Code 39
31706 % --EXAM: A999BJC5D6E71
31707 % --EXOP: includetext
31708 % --RNDR: renlinear
31709 %%BeginResource: uk.co.terryburton.bwipp hibccode39 0.0 2025111800 70461 70465
31710 %%BeginData: 92 ASCII Lines
31711 /setpacking where {pop currentpacking true setpacking} if
31712 10 dict
31713 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
31714 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
31715 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
31716 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
31717 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
31718 dup /code39 dup /uk.co.terryburton.bwipp findresource put
31719 begin
31720 /hibccode39 {
31721
31722 20 dict begin % Confine variables to local scope
31723
31724 /ctx null def
31725 /dontdraw false def
31726 /textfont /Courier def
31727 /textsize 10.0 def
31728 /textyoffset -7.0 def
31729 /textxoffset 0.0 def
31730 /validatecheck false def
31731
31732 //processoptions exec /options exch def
31733 /barcode exch def
31734
31735 barcode () eq {
31736 /bwipp.hibccode39emptyData (The data must not be empty) //raiseerror exec
31737 } if
31738
31739 /hibccode39 //loadctx exec
31740
31741 % Create a string of the available characters
31742 {
31743 /barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def
31744 /charvals 43 dict def
31745 0 1 42 {charvals exch dup barchars exch 1 getinterval exch put} for
31746 } ctxdef
31747
31748 % Validate the input
31749 0 1 barcode length 1 sub {
31750 barcode exch 1 getinterval charvals exch known not {
31751 /bwipp.hibccode39badCharacter (HIBC Code 39 must contain only digits, capital letters, spaces and the symbols -.$/+%) //raiseerror exec
31752 } if
31753 } for
31754
31755 /barlen barcode length validatecheck {1 sub} if def
31756
31757 /checksum 41 def
31758 0 1 barlen 1 sub {
31759 barcode exch 1 getinterval charvals exch get
31760 checksum add /checksum exch def
31761 } for
31762 /checksum checksum 43 mod def
31763 validatecheck {
31764 barcode barlen get barchars checksum get ne {
31765 /bwipp.hibccode39badCheckDigit (Incorrect HIBC Code 39 check digit provided) //raiseerror exec
31766 } if
31767 /barcode barcode 0 barlen getinterval def
31768 } if
31769
31770 /barcode barlen 2 add string dup 1 barcode putinterval def
31771 barcode 0 43 put
31772 barcode barlen 1 add barchars checksum get put
31773
31774 /text barlen 4 add string def
31775 text 0 42 put
31776 text 1 barcode putinterval
31777 text barlen 2 add barcode barlen 1 add get dup 32 eq {pop 95} if put
31778 text barlen 3 add 42 put
31779
31780 % Get the result of encoding with code39
31781 options (dontdraw) true put
31782 options (includecheck) false put
31783 options (validatecheck) false put
31784 /args barcode options //code39 exec def
31785
31786 args (txt) [ [text textxoffset textyoffset textfont textsize] ] put
31787 args (textxalign) (center) put
31788 args (opt) options put
31789 args
31790
31791 dontdraw not //renlinear if
31792
31793 //unloadctx exec
31794
31795 end
31796
31797 }
31798 [/barcode] {null def} forall
31799 bind def
31800 /hibccode39 dup load /uk.co.terryburton.bwipp defineresource pop
31801 end
31802 /setpacking where {pop setpacking} if
31803 %%EndData
31804 %%EndResource
31805 % --END ENCODER hibccode39--
31806
31807 % --BEGIN ENCODER hibccode128--
31808 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renlinear code128--
31809 % --DESC: HIBC Code 128
31810 % --EXAM: A999BJC5D6E71
31811 % --EXOP: includetext
31812 % --RNDR: renlinear
31813 %%BeginResource: uk.co.terryburton.bwipp hibccode128 0.0 2025111800 73390 73025
31814 %%BeginData: 91 ASCII Lines
31815 /setpacking where {pop currentpacking true setpacking} if
31816 10 dict
31817 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
31818 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
31819 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
31820 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
31821 dup /renlinear dup /uk.co.terryburton.bwipp findresource put
31822 dup /code128 dup /uk.co.terryburton.bwipp findresource put
31823 begin
31824 /hibccode128 {
31825
31826 20 dict begin % Confine variables to local scope
31827
31828 /ctx null def
31829 /dontdraw false def
31830 /textfont /Courier def
31831 /textsize 10.0 def
31832 /textyoffset -7.0 def
31833 /textxoffset 0.0 def
31834 /validatecheck false def
31835
31836 //processoptions exec /options exch def
31837 /barcode exch def
31838
31839 barcode () eq {
31840 /bwipp.hibccode128emptyData (The data must not be empty) //raiseerror exec
31841 } if
31842
31843 /hibccode128 //loadctx exec
31844
31845 % Create a string of the available characters
31846 {
31847 /barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def
31848 /charvals 43 dict def
31849 0 1 42 {charvals exch dup barchars exch 1 getinterval exch put} for
31850 } ctxdef
31851
31852 % Validate the input
31853 0 1 barcode length 1 sub {
31854 barcode exch 1 getinterval charvals exch known not {
31855 /bwipp.hibccode128badCharacter (HIBC Code 128 must contain only digits, capital letters, spaces and the symbols -.$/+%) //raiseerror exec
31856 } if
31857 } for
31858
31859 /barlen barcode length validatecheck {1 sub} if def
31860
31861 /checksum 41 def
31862 0 1 barlen 1 sub {
31863 barcode exch 1 getinterval charvals exch get
31864 checksum add /checksum exch def
31865 } for
31866 /checksum checksum 43 mod def
31867 validatecheck {
31868 barcode barlen get barchars checksum get ne {
31869 /bwipp.hibccode128badCheckDigit (Incorrect HIBC Code 128 check digit provided) //raiseerror exec
31870 } if
31871 /barcode barcode 0 barlen getinterval def
31872 } if
31873
31874 /barcode barlen 2 add string dup 1 barcode putinterval def
31875 barcode 0 43 put
31876 barcode barlen 1 add barchars checksum get put
31877
31878 /text barlen 4 add string def
31879 text 0 42 put
31880 text 1 barcode putinterval
31881 text barlen 2 add barcode barlen 1 add get dup 32 eq {pop 95} if put
31882 text barlen 3 add 42 put
31883
31884 % Get the result of encoding with code128
31885 options (dontdraw) true put
31886 options (validatecheck) false put
31887 /args barcode options //code128 exec def
31888
31889 args (txt) [ [text textxoffset textyoffset textfont textsize] ] put
31890 args (textxalign) (center) put
31891 args (opt) options put
31892 args
31893
31894 dontdraw not //renlinear if
31895
31896 //unloadctx exec
31897
31898 end
31899
31900 }
31901 [/barcode] {null def} forall
31902 bind def
31903 /hibccode128 dup load /uk.co.terryburton.bwipp defineresource pop
31904 end
31905 /setpacking where {pop setpacking} if
31906 %%EndData
31907 %%EndResource
31908 % --END ENCODER hibccode128--
31909
31910 % --BEGIN ENCODER hibcdatamatrix--
31911 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix datamatrix--
31912 % --DESC: HIBC Data Matrix
31913 % --EXAM: A999BJC5D6E71
31914 % --EXOP:
31915 % --RNDR: renmatrix
31916 %%BeginResource: uk.co.terryburton.bwipp hibcdatamatrix 0.0 2025111800 71524 74643
31917 %%BeginData: 79 ASCII Lines
31918 /setpacking where {pop currentpacking true setpacking} if
31919 10 dict
31920 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
31921 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
31922 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
31923 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
31924 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
31925 dup /datamatrix dup /uk.co.terryburton.bwipp findresource put
31926 begin
31927 /hibcdatamatrix {
31928
31929 20 dict begin % Confine variables to local scope
31930
31931 /ctx null def
31932 /dontdraw false def
31933 /validatecheck false def
31934
31935 //processoptions exec /options exch def
31936 /barcode exch def
31937
31938 barcode () eq {
31939 /bwipp.hibcdatamatrixEmptyData (The data must not be empty) //raiseerror exec
31940 } if
31941
31942 /hibcdatamatrix //loadctx exec
31943
31944 % Create a string of the available characters
31945 {
31946 /barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def
31947 /charvals 43 dict def
31948 0 1 42 {charvals exch dup barchars exch 1 getinterval exch put} for
31949 } ctxdef
31950
31951 % Validate the input
31952 0 1 barcode length 1 sub {
31953 barcode exch 1 getinterval charvals exch known not {
31954 /bwipp.hibcdatamatrixBadCharacter (HIBC Data Matrix must contain only digits, capital letters, spaces and the symbols -.$/+%) //raiseerror exec
31955 } if
31956 } for
31957
31958 /barlen barcode length validatecheck {1 sub} if def
31959
31960 /checksum 41 def
31961 0 1 barlen 1 sub {
31962 barcode exch 1 getinterval charvals exch get
31963 checksum add /checksum exch def
31964 } for
31965 /checksum checksum 43 mod def
31966 validatecheck {
31967 barcode barlen get barchars checksum get ne {
31968 /bwipp.hibcdatamatrixBadCheckDigit (Incorrect HIBC Data Matrix check digit provided) //raiseerror exec
31969 } if
31970 /barcode barcode 0 barlen getinterval def
31971 } if
31972
31973 /barcode barlen 2 add string dup 1 barcode putinterval def
31974 barcode 0 43 put
31975 barcode barlen 1 add barchars checksum get put
31976
31977 % Get the result of encoding with datamatrix
31978 options (dontdraw) true put
31979 options (validatecheck) false put
31980 /args barcode options //datamatrix exec def
31981
31982 args (opt) options put
31983 args
31984
31985 dontdraw not //renmatrix if
31986
31987 //unloadctx exec
31988
31989 end
31990
31991 }
31992 [/barcode] {null def} forall
31993 bind def
31994 /hibcdatamatrix dup load /uk.co.terryburton.bwipp defineresource pop
31995 end
31996 /setpacking where {pop setpacking} if
31997 %%EndData
31998 %%EndResource
31999 % --END ENCODER hibcdatamatrix--
32000
32001 % --BEGIN ENCODER hibcdatamatrixrectangular--
32002 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix datamatrix--
32003 % --DESC: HIBC Data Matrix Rectangular
32004 % --EXAM: A999BJC5D6E71
32005 % --EXOP:
32006 % --RNDR: renmatrix
32007 %%BeginResource: uk.co.terryburton.bwipp hibcdatamatrixrectangular 0.0 2025111800 71784 74963
32008 %%BeginData: 80 ASCII Lines
32009 /setpacking where {pop currentpacking true setpacking} if
32010 10 dict
32011 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
32012 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
32013 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
32014 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
32015 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
32016 dup /datamatrix dup /uk.co.terryburton.bwipp findresource put
32017 begin
32018 /hibcdatamatrixrectangular {
32019
32020 20 dict begin % Confine variables to local scope
32021
32022 /ctx null def
32023 /dontdraw false def
32024 /validatecheck false def
32025
32026 //processoptions exec /options exch def
32027 /barcode exch def
32028
32029 barcode () eq {
32030 /bwipp.hibcdatamatrixrectangularEmptyData (The data must not be empty) //raiseerror exec
32031 } if
32032
32033 /hibcdatamatrixrectangular //loadctx exec
32034
32035 % Create a string of the available characters
32036 {
32037 /barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def
32038 /charvals 43 dict def
32039 0 1 42 {charvals exch dup barchars exch 1 getinterval exch put} for
32040 } ctxdef
32041
32042 % Validate the input
32043 0 1 barcode length 1 sub {
32044 barcode exch 1 getinterval charvals exch known not {
32045 /bwipp.hibcdatamatrixrectangularBadCharacter (HIBC Data Matrix Rectangular must contain only digits, capital letters, spaces and the symbols -.$/+%) //raiseerror exec
32046 } if
32047 } for
32048
32049 /barlen barcode length validatecheck {1 sub} if def
32050
32051 /checksum 41 def
32052 0 1 barlen 1 sub {
32053 barcode exch 1 getinterval charvals exch get
32054 checksum add /checksum exch def
32055 } for
32056 /checksum checksum 43 mod def
32057 validatecheck {
32058 barcode barlen get barchars checksum get ne {
32059 /bwipp.hibcdatamatrixrectangularBadCheckDigit (Incorrect HIBC Data Matrix Rectangular check digit provided) //raiseerror exec
32060 } if
32061 /barcode barcode 0 barlen getinterval def
32062 } if
32063
32064 /barcode barlen 2 add string dup 1 barcode putinterval def
32065 barcode 0 43 put
32066 barcode barlen 1 add barchars checksum get put
32067
32068 % Get the result of encoding with datamatrix
32069 options (dontdraw) true put
32070 options (validatecheck) false put
32071 options (format) (rectangle) put
32072 /args barcode options //datamatrix exec def
32073
32074 args (opt) options put
32075 args
32076
32077 dontdraw not //renmatrix if
32078
32079 //unloadctx exec
32080
32081 end
32082
32083 }
32084 [/barcode] {null def} forall
32085 bind def
32086 /hibcdatamatrixrectangular dup load /uk.co.terryburton.bwipp defineresource pop
32087 end
32088 /setpacking where {pop setpacking} if
32089 %%EndData
32090 %%EndResource
32091 % --END ENCODER hibcdatamatrixrectangular--
32092
32093 % --BEGIN ENCODER hibcpdf417--
32094 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix pdf417--
32095 % --DESC: HIBC PDF417
32096 % --EXAM: A999BJC5D6E71
32097 % --EXOP:
32098 % --RNDR: renmatrix
32099 %%BeginResource: uk.co.terryburton.bwipp hibcpdf417 0.0 2025111800 71527 71180
32100 %%BeginData: 81 ASCII Lines
32101 /setpacking where {pop currentpacking true setpacking} if
32102 10 dict
32103 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
32104 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
32105 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
32106 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
32107 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
32108 dup /pdf417 dup /uk.co.terryburton.bwipp findresource put
32109 begin
32110 /hibcpdf417 {
32111
32112 20 dict begin % Confine variables to local scope
32113
32114 /ctx null def
32115 /dontdraw false def
32116 /columns 2 def
32117 /validatecheck false def
32118
32119 //processoptions exec /options exch def
32120 /barcode exch def
32121
32122 barcode () eq {
32123 /bwipp.hibcpdf417EmptyData (The data must not be empty) //raiseerror exec
32124 } if
32125
32126 /hibcpdf417 //loadctx exec
32127
32128 % Create a string of the available characters
32129 {
32130 /barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def
32131 /charvals 43 dict def
32132 0 1 42 {charvals exch dup barchars exch 1 getinterval exch put} for
32133 } ctxdef
32134
32135 % Validate the input
32136 0 1 barcode length 1 sub {
32137 barcode exch 1 getinterval charvals exch known not {
32138 /bwipp.hibcpdf417BadCharacter (HIBC PDF417 must contain only digits, capital letters, spaces and the symbols -.$/+%) //raiseerror exec
32139 } if
32140 } for
32141
32142 /barlen barcode length validatecheck {1 sub} if def
32143
32144 /checksum 41 def
32145 0 1 barlen 1 sub {
32146 barcode exch 1 getinterval charvals exch get
32147 checksum add /checksum exch def
32148 } for
32149 /checksum checksum 43 mod def
32150 validatecheck {
32151 barcode barlen get barchars checksum get ne {
32152 /bwipp.hibcpdf417BadCheckDigit (Incorrect HIBC PDF417 check digit provided) //raiseerror exec
32153 } if
32154 /barcode barcode 0 barlen getinterval def
32155 } if
32156
32157 /barcode barlen 2 add string dup 1 barcode putinterval def
32158 barcode 0 43 put
32159 barcode barlen 1 add barchars checksum get put
32160
32161 % Get the result of encoding with pdf417
32162 options (dontdraw) true put
32163 options (columns) columns put
32164 options (validatecheck) false put
32165 /args barcode options //pdf417 exec def
32166
32167 args (opt) options put
32168 args
32169
32170 dontdraw not //renmatrix if
32171
32172 //unloadctx exec
32173
32174 end
32175
32176 }
32177 [/barcode] {null def} forall
32178 bind def
32179 /hibcpdf417 dup load /uk.co.terryburton.bwipp defineresource pop
32180 end
32181 /setpacking where {pop setpacking} if
32182 %%EndData
32183 %%EndResource
32184 % --END ENCODER hibcpdf417--
32185
32186 % --BEGIN ENCODER hibcmicropdf417--
32187 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix micropdf417--
32188 % --DESC: HIBC MicroPDF417
32189 % --EXAM: A999BJC5D6E71
32190 % --EXOP:
32191 % --RNDR: renmatrix
32192 %%BeginResource: uk.co.terryburton.bwipp hibcmicropdf417 0.0 2025111800 71686 71343
32193 %%BeginData: 81 ASCII Lines
32194 /setpacking where {pop currentpacking true setpacking} if
32195 10 dict
32196 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
32197 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
32198 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
32199 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
32200 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
32201 dup /micropdf417 dup /uk.co.terryburton.bwipp findresource put
32202 begin
32203 /hibcmicropdf417 {
32204
32205 20 dict begin % Confine variables to local scope
32206
32207 /ctx null def
32208 /dontdraw false def
32209 /columns 2 def
32210 /validatecheck false def
32211
32212 //processoptions exec /options exch def
32213 /barcode exch def
32214
32215 barcode () eq {
32216 /bwipp.hibcmicropdf417EmptyData (The data must not be empty) //raiseerror exec
32217 } if
32218
32219 /hibcmicropdf417 //loadctx exec
32220
32221 % Create a string of the available characters
32222 {
32223 /barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def
32224 /charvals 43 dict def
32225 0 1 42 {charvals exch dup barchars exch 1 getinterval exch put} for
32226 } ctxdef
32227
32228 % Validate the input
32229 0 1 barcode length 1 sub {
32230 barcode exch 1 getinterval charvals exch known not {
32231 /bwipp.hibcmicropdf417BadCharacter (HIBC MicroPDF417 must contain only digits, capital letters, spaces and the symbols -.$/+%) //raiseerror exec
32232 } if
32233 } for
32234
32235 /barlen barcode length validatecheck {1 sub} if def
32236
32237 /checksum 41 def
32238 0 1 barlen 1 sub {
32239 barcode exch 1 getinterval charvals exch get
32240 checksum add /checksum exch def
32241 } for
32242 /checksum checksum 43 mod def
32243 validatecheck {
32244 barcode barlen get barchars checksum get ne {
32245 /bwipp.hibcmicropdf417BadCheckDigit (Incorrect HIBC MicroPDF417 check digit provided) //raiseerror exec
32246 } if
32247 /barcode barcode 0 barlen getinterval def
32248 } if
32249
32250 /barcode barlen 2 add string dup 1 barcode putinterval def
32251 barcode 0 43 put
32252 barcode barlen 1 add barchars checksum get put
32253
32254 % Get the result of encoding with micropdf417
32255 options (dontdraw) true put
32256 options (columns) columns put
32257 options (validatecheck) false put
32258 /args barcode options //micropdf417 exec def
32259
32260 args (opt) options put
32261 args
32262
32263 dontdraw not //renmatrix if
32264
32265 //unloadctx exec
32266
32267 end
32268
32269 }
32270 [/barcode] {null def} forall
32271 bind def
32272 /hibcmicropdf417 dup load /uk.co.terryburton.bwipp defineresource pop
32273 end
32274 /setpacking where {pop setpacking} if
32275 %%EndData
32276 %%EndResource
32277 % --END ENCODER hibcmicropdf417--
32278
32279 % --BEGIN ENCODER hibcqrcode--
32280 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix qrcode--
32281 % --DESC: HIBC QR Code
32282 % --EXAM: A999BJC5D6E71
32283 % --EXOP:
32284 % --RNDR: renmatrix
32285 %%BeginResource: uk.co.terryburton.bwipp hibcqrcode 0.0 2025111800 76084 75485
32286 %%BeginData: 79 ASCII Lines
32287 /setpacking where {pop currentpacking true setpacking} if
32288 10 dict
32289 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
32290 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
32291 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
32292 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
32293 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
32294 dup /qrcode dup /uk.co.terryburton.bwipp findresource put
32295 begin
32296 /hibcqrcode {
32297
32298 20 dict begin % Confine variables to local scope
32299
32300 /ctx null def
32301 /dontdraw false def
32302 /validatecheck false def
32303
32304 //processoptions exec /options exch def
32305 /barcode exch def
32306
32307 barcode () eq {
32308 /bwipp.hibcqrcodeEmptyData (The data must not be empty) //raiseerror exec
32309 } if
32310
32311 /hibcqrcode //loadctx exec
32312
32313 % Create a string of the available characters
32314 {
32315 /barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def
32316 /charvals 43 dict def
32317 0 1 42 {charvals exch dup barchars exch 1 getinterval exch put} for
32318 } ctxdef
32319
32320 % Validate the input
32321 0 1 barcode length 1 sub {
32322 barcode exch 1 getinterval charvals exch known not {
32323 /bwipp.hibcqrcodeBadCharacter (HIBC QR Code must contain only digits, capital letters, spaces and the symbols -.$/+%) //raiseerror exec
32324 } if
32325 } for
32326
32327 /barlen barcode length validatecheck {1 sub} if def
32328
32329 /checksum 41 def
32330 0 1 barlen 1 sub {
32331 barcode exch 1 getinterval charvals exch get
32332 checksum add /checksum exch def
32333 } for
32334 /checksum checksum 43 mod def
32335 validatecheck {
32336 barcode barlen get barchars checksum get ne {
32337 /bwipp.hibcqrcodeBadCheckDigit (Incorrect HIBC QR Code check digit provided) //raiseerror exec
32338 } if
32339 /barcode barcode 0 barlen getinterval def
32340 } if
32341
32342 /barcode barlen 2 add string dup 1 barcode putinterval def
32343 barcode 0 43 put
32344 barcode barlen 1 add barchars checksum get put
32345
32346 % Get the result of encoding with qrcode
32347 options (dontdraw) true put
32348 options (validatecheck) false put
32349 /args barcode options //qrcode exec def
32350
32351 args (opt) options put
32352 args
32353
32354 dontdraw not //renmatrix if
32355
32356 //unloadctx exec
32357
32358 end
32359
32360 }
32361 [/barcode] {null def} forall
32362 bind def
32363 /hibcqrcode dup load /uk.co.terryburton.bwipp defineresource pop
32364 end
32365 /setpacking where {pop setpacking} if
32366 %%EndData
32367 %%EndResource
32368 % --END ENCODER hibcqrcode--
32369
32370 % --BEGIN ENCODER hibccodablockf--
32371 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix codablockf--
32372 % --DESC: HIBC Codablock F
32373 % --EXAM: A999BJC5D6E71
32374 % --EXOP:
32375 % --RNDR: renmatrix
32376 %%BeginResource: uk.co.terryburton.bwipp hibccodablockf 0.0 2025111800 71380 71003
32377 %%BeginData: 79 ASCII Lines
32378 /setpacking where {pop currentpacking true setpacking} if
32379 10 dict
32380 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
32381 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
32382 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
32383 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
32384 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
32385 dup /codablockf dup /uk.co.terryburton.bwipp findresource put
32386 begin
32387 /hibccodablockf {
32388
32389 20 dict begin % Confine variables to local scope
32390
32391 /ctx null def
32392 /dontdraw false def
32393 /validatecheck false def
32394
32395 //processoptions exec /options exch def
32396 /barcode exch def
32397
32398 barcode () eq {
32399 /bwipp.hibccodablockfEmptyData (The data must not be empty) //raiseerror exec
32400 } if
32401
32402 /hibccodablockf //loadctx exec
32403
32404 % Create a string of the available characters
32405 {
32406 /barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def
32407 /charvals 43 dict def
32408 0 1 42 {charvals exch dup barchars exch 1 getinterval exch put} for
32409 } ctxdef
32410
32411 % Validate the input
32412 0 1 barcode length 1 sub {
32413 barcode exch 1 getinterval charvals exch known not {
32414 /bwipp.hibccodablockfBadCharacter (HIBC Codablock F must contain only digits, capital letters, spaces and the symbols -.$/+%) //raiseerror exec
32415 } if
32416 } for
32417
32418 /barlen barcode length validatecheck {1 sub} if def
32419
32420 /checksum 41 def
32421 0 1 barlen 1 sub {
32422 barcode exch 1 getinterval charvals exch get
32423 checksum add /checksum exch def
32424 } for
32425 /checksum checksum 43 mod def
32426 validatecheck {
32427 barcode barlen get barchars checksum get ne {
32428 /bwipp.hibccodablockfBadCheckDigit (Incorrect HIBC Codablock F check digit provided) //raiseerror exec
32429 } if
32430 /barcode barcode 0 barlen getinterval def
32431 } if
32432
32433 /barcode barlen 2 add string dup 1 barcode putinterval def
32434 barcode 0 43 put
32435 barcode barlen 1 add barchars checksum get put
32436
32437 % Get the result of encoding with codablockf
32438 options (dontdraw) true put
32439 options (validatecheck) false put
32440 /args barcode options //codablockf exec def
32441
32442 args (opt) options put
32443 args
32444
32445 dontdraw not //renmatrix if
32446
32447 //unloadctx exec
32448
32449 end
32450
32451 }
32452 [/barcode] {null def} forall
32453 bind def
32454 /hibccodablockf dup load /uk.co.terryburton.bwipp defineresource pop
32455 end
32456 /setpacking where {pop setpacking} if
32457 %%EndData
32458 %%EndResource
32459 % --END ENCODER hibccodablockf--
32460
32461 % --BEGIN ENCODER hibcazteccode--
32462 % --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput rendertext renmatrix azteccode--
32463 % --DESC: HIBC Aztec Code
32464 % --EXAM: A999BJC5D6E71
32465 % --EXOP:
32466 % --RNDR: renmatrix
32467 %%BeginResource: uk.co.terryburton.bwipp hibcazteccode 0.0 2025111800 71393 70996
32468 %%BeginData: 79 ASCII Lines
32469 /setpacking where {pop currentpacking true setpacking} if
32470 10 dict
32471 dup /loadctx dup /uk.co.terryburton.bwipp findresource put
32472 dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
32473 dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
32474 dup /processoptions dup /uk.co.terryburton.bwipp findresource put
32475 dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
32476 dup /azteccode dup /uk.co.terryburton.bwipp findresource put
32477 begin
32478 /hibcazteccode {
32479
32480 20 dict begin % Confine variables to local scope
32481
32482 /ctx null def
32483 /dontdraw false def
32484 /validatecheck false def
32485
32486 //processoptions exec /options exch def
32487 /barcode exch def
32488
32489 barcode () eq {
32490 /bwipp.hibcazteccodeEmptyData (The data must not be empty) //raiseerror exec
32491 } if
32492
32493 /hibcazteccode //loadctx exec
32494
32495 % Create a string of the available characters
32496 {
32497 /barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def
32498 /charvals 43 dict def
32499 0 1 42 {charvals exch dup barchars exch 1 getinterval exch put} for
32500 } ctxdef
32501
32502 % Validate the input
32503 0 1 barcode length 1 sub {
32504 barcode exch 1 getinterval charvals exch known not {
32505 /bwipp.hibcazteccodeBadCharacter (HIBC Aztec Code must contain only digits, capital letters, spaces and the symbols -.$/+%) //raiseerror exec
32506 } if
32507 } for
32508
32509 /barlen barcode length validatecheck {1 sub} if def
32510
32511 /checksum 41 def
32512 0 1 barlen 1 sub {
32513 barcode exch 1 getinterval charvals exch get
32514 checksum add /checksum exch def
32515 } for
32516 /checksum checksum 43 mod def
32517 validatecheck {
32518 barcode barlen get barchars checksum get ne {
32519 /bwipp.hibcazteccodeBadCheckDigit (Incorrect HIBC Aztec Code check digit provided) //raiseerror exec
32520 } if
32521 /barcode barcode 0 barlen getinterval def
32522 } if
32523
32524 /barcode barlen 2 add string dup 1 barcode putinterval def
32525 barcode 0 43 put
32526 barcode barlen 1 add barchars checksum get put
32527
32528 % Get the result of encoding with azteccode
32529 options (dontdraw) true put
32530 options (validatecheck) false put
32531 /args barcode options //azteccode exec def
32532
32533 args (opt) options put
32534 args
32535
32536 dontdraw not //renmatrix if
32537
32538 //unloadctx exec
32539
32540 end
32541
32542 }
32543 [/barcode] {null def} forall
32544 bind def
32545 /hibcazteccode dup load /uk.co.terryburton.bwipp defineresource pop
32546 end
32547 /setpacking where {pop setpacking} if
32548 %%EndData
32549 %%EndResource
32550 % --END ENCODER hibcazteccode--
32551
32552 % --END TEMPLATE--