Repository navigation
Expand file tree
/
Copy pathfile.ps
More file actions
6217 lines (5481 loc) · 215 KB
/
Copy pathfile.ps
File metadata and controls
6217 lines (5481 loc) · 215 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%!PS-Adobe-2.0
%%Pages: (attend)
%%Creator: Elaphe powered by barcode.ps
%%BoundingBox: -16 -10 206 146
%%LanguageLevel: 2
%%EndComments
% --BEGIN ENCODER ean13--
% --DESC: EAN-13
% --EXAM: 977147396801
% --EXOP: includetext guardwhitespace
% --RNDR: renlinear
/ean13 {
0 begin
/options exch def % We are given an option string
/useropts options def
/barcode exch def % We are given a barcode string
/includetext false def % Enable/disable text
/textfont /Helvetica def
/textsize 12 def
/textyoffset -4 def
/height 1 def
% Parse the input options
options {
token false eq {exit} if dup length string cvs (=) search
true eq {cvlit exch pop exch def} {cvlit true def} ifelse
} loop
/textfont textfont cvlit def
/textsize textsize cvr def
/textyoffset textyoffset cvr def
/height height cvr def
% Add checksum digit
/pad 13 string def
/checksum 0 def
0 1 11 {
/i exch def
/barchar barcode i get 48 sub def
i 2 mod 0 eq {
/checksum barchar checksum add def
} {
/checksum barchar 3 mul checksum add def
} ifelse
} for
/checksum 10 checksum 10 mod sub 10 mod def
pad 0 barcode putinterval % Add barcode to the start of the pad
pad 12 checksum 48 add put % Put ascii for checksum at end of pad
/barcode pad def
% Create an array containing the character mappings
/encs
[ (3211) (2221) (2122) (1411) (1132)
(1231) (1114) (1312) (1213) (3112)
(111) (11111) (111)
] def
% Create a string of the available characters
/barchars (0123456789) def
% Digits to mirror on left side
/mirrormaps
[ (000000) (001011) (001101) (001110) (010011)
(011001) (011100) (010101) (010110) (011010)
] def
/sbs 59 string def
/txt 13 array def
% Put the start character
sbs 0 encs 10 get putinterval
% First digit - determine mirrormap by this and show before guard bars
/mirrormap mirrormaps barcode 0 get 48 sub get def
txt 0 [barcode 0 1 getinterval -10 textyoffset textfont textsize] put
% Left side - performs mirroring
1 1 6 {
% Lookup the encoding for the each barcode character
/i exch def
barcode i 1 getinterval barchars exch search
pop % Discard true leaving pre
length /indx exch def % indx is the length of pre
pop pop % Discard seek and post
/enc encs indx get def % Get the indxth encoding
mirrormap i 1 sub get 49 eq { % Reverse enc if 1 in this position in mirrormap
/enclen enc length def
/revenc enclen string def
0 1 enclen 1 sub {
/j exch def
/char enc j get def
revenc enclen j sub 1 sub char put
} for
/enc revenc def
} if
sbs i 1 sub 4 mul 3 add enc putinterval % Put encoded digit into sbs
txt i [barcode i 1 getinterval i 1 sub 7 mul 4 add textyoffset textfont textsize] put
} for
% Put the middle character
sbs 7 1 sub 4 mul 3 add encs 11 get putinterval
% Right side
7 1 12 {
% Lookup the encoding for the each barcode character
/i exch def
barcode i 1 getinterval barchars exch search
pop % Discard true leaving pre
length /indx exch def % indx is the length of pre
pop pop % Discard seek and post
/enc encs indx get def % Get the indxth encoding
sbs i 1 sub 4 mul 8 add enc putinterval % Put encoded digit into sbs
txt i [barcode i 1 getinterval i 1 sub 7 mul 8 add textyoffset textfont textsize] put
} for
% Put the end character
sbs 56 encs 12 get putinterval
% Return the arguments
<<
/ren (renlinear)
/sbs [sbs {48 sub} forall]
includetext {
/bhs [height height 12{height .075 sub}repeat height height 12{height .075 sub}repeat height height]
/bbs [0 0 12{.075}repeat 0 0 12{.075}repeat 0 0]
/txt txt
} {
/bhs [30{height}repeat]
/bbs [30{0}repeat]
} ifelse
/opt useropts
/guardrightpos 10
/borderbottom 5
>>
end
} bind def
/ean13 load 0 1 dict put
% --END ENCODER ean13--
% --BEGIN ENCODER ean8--
% --DESC: EAN-8
% --EXAM: 01335583
% --EXOP: includetext guardwhitespace height=0.5
% --RNDR: renlinear
/ean8 {
0 begin
/options exch def % We are given an option string
/useropts options def
/barcode exch def % We are given a barcode string
/includetext false def % Enable/disable text
/textfont /Helvetica def
/textsize 12 def
/textyoffset -4 def
/height 1 def
% Parse the input options
options {
token false eq {exit} if dup length string cvs (=) search
true eq {cvlit exch pop exch def} {cvlit true def} ifelse
} loop
/textfont textfont cvlit def
/textsize textsize cvr def
/textyoffset textyoffset cvr def
/height height cvr def
% Create an array containing the character mappings
/encs
[ (3211) (2221) (2122) (1411) (1132)
(1231) (1114) (1312) (1213) (3112)
(111) (11111) (111)
] def
% Create a string of the available characters
/barchars (0123456789) def
/sbs 43 string def
/txt 8 array def
% Put the start character
sbs 0 encs 10 get putinterval
% Left side
0 1 3 {
% Lookup the encoding for the each barcode character
/i exch def
barcode i 1 getinterval barchars exch search
pop % Discard true leaving pre
length /indx exch def % indx is the length of pre
pop pop % Discard seek and post
/enc encs indx get def % Get the indxth encoding
sbs i 4 mul 3 add enc putinterval % Put encoded digit into sbs
txt i [barcode i 1 getinterval i 7 mul 4 add textyoffset textfont textsize] put
} for
% Put the middle character
sbs 4 4 mul 3 add encs 11 get putinterval
% Right side
4 1 7 {
% Lookup the encoding for the each barcode character
/i exch def
barcode i 1 getinterval barchars exch search
pop % Discard true leaving pre
length /indx exch def % indx is the length of pre
pop pop % Discard seek and post
/enc encs indx get def % Get the indxth encoding
sbs i 4 mul 8 add enc putinterval % Put encoded digit into sbs
txt i [barcode i 1 getinterval i 7 mul 8 add textyoffset textfont textsize] put
} for
% Put the end character
sbs 40 encs 12 get putinterval
% Return the arguments
<<
/ren (renlinear)
/sbs [sbs {48 sub} forall]
includetext {
/bhs [height height 8{height .075 sub}repeat height height 8{height .075 sub}repeat height height]
/bbs [0 0 8{.075}repeat 0 0 8{.075}repeat 0 0]
/txt txt
} {
/bhs [22{height}repeat]
/bbs [22{0}repeat]
} ifelse
/opt useropts
/guardleftpos 10
/guardrightpos 10
/borderbottom 5
>>
end
} bind def
/ean8 load 0 1 dict put
% --END ENCODER ean8--
% --BEGIN ENCODER upca--
% --DESC: UPC-A
% --EXAM: 78858101497
% --EXOP: includetext
% --RNDR: renlinear
/upca {
0 begin
/options exch def
/useropts options def
/barcode exch def % We are given a barcode string
/includetext false def % Enable/disable text
/textfont /Helvetica def
/textsize 12 def
/textyoffset -4 def
/height 1 def
% Parse the input options
options {
token false eq {exit} if dup length string cvs (=) search
true eq {cvlit exch pop exch def} {cvlit true def} ifelse
} loop
/textfont textfont cvlit def
/textsize textsize cvr def
/textyoffset textyoffset cvr def
/height height cvr def
% Add checksum digit to barcode
/pad 12 string def % Create pad one bigger than barcode
/checksum 0 def
0 1 10 {
/i exch def
/barchar barcode i get 48 sub def
i 2 mod 0 ne {
/checksum checksum barchar add def
} {
/checksum checksum barchar 3 mul add def
} ifelse
} for
/checksum 10 checksum 10 mod sub 10 mod def
pad 0 barcode putinterval % Add barcode to the start of the pad
pad 11 checksum 48 add put % Put ascii for checksum at end of pad
/barcode pad def
% Create an array containing the character mappings
/encs
[ (3211) (2221) (2122) (1411) (1132)
(1231) (1114) (1312) (1213) (3112)
(111) (11111) (111)
] def
% Create a string of the available characters
/barchars (0123456789) def
/sbs 59 string def
/txt 12 array def
% Put the start character
sbs 0 encs 10 get putinterval
% Left side
0 1 5 {
% Lookup the encoding for the each barcode character
/i exch def
barcode i 1 getinterval barchars exch search
pop % Discard true leaving pre
length /indx exch def % indx is the length of pre
pop pop % Discard seek and post
/enc encs indx get def % Get the indxth encoding
sbs i 4 mul 3 add enc putinterval % Put encoded digit into sbs
i 0 eq { % First digit is before the guard bars
txt 0 [barcode 0 1 getinterval -7 textyoffset textfont textsize 2 sub] put
} {
txt i [barcode i 1 getinterval i 7 mul 4 add textyoffset textfont textsize] put
} ifelse
} for
% Put the middle character
sbs 6 4 mul 3 add encs 11 get putinterval
% Right side
6 1 11 {
% Lookup the encoding for the each barcode character
/i exch def
barcode i 1 getinterval barchars exch search
pop % Discard true leaving pre
length /indx exch def % indx is the length of pre
pop pop % Discard seek and post
/enc encs indx get def % Get the indxth encoding
sbs i 4 mul 8 add enc putinterval % Put encoded digit into sbs
i 11 eq { % Last digit is after guard bars
txt 11 [barcode 11 1 getinterval 96 textyoffset textfont textsize 2 sub] put
} {
txt i [barcode i 1 getinterval i 7 mul 8 add textyoffset textfont textsize] put
} ifelse
} for
% Put the end character
sbs 56 encs 12 get putinterval
% Return the arguments
<<
/ren (renlinear)
/sbs [sbs {48 sub} forall]
includetext {
/bhs [4{height}repeat 10{height .075 sub}repeat height height 10{height .075 sub}repeat 5{height}repeat]
/bbs [0 0 0 0 10{.075}repeat 0 0 10{.075}repeat 0 0 0 0 0]
/txt txt
} {
/bhs [31{height}repeat]
/bbs [31{0}repeat]
} ifelse
/opt useropts
/borderbottom 5
>>
end
} bind def
/upca load 0 1 dict put
% --END ENCODER upca--
% --BEGIN ENCODER upce--
% --DESC: UPC-E
% --EXAM: 0123456
% --EXOP: includetext height=0.4
% --RNDR: renlinear
/upce {
0 begin
/options exch def % We are given an option string
/useropts options def
/barcode exch def % We are given a barcode string
/includetext false def % Enable/disable text
/textfont /Helvetica def
/textsize 12 def
/textyoffset -4 def
/height 1 def
% Parse the input options
options {
token false eq {exit} if dup length string cvs (=) search
true eq {cvlit exch pop exch def} {cvlit true def} ifelse
} loop
/textfont textfont cvlit def
/textsize textsize cvr def
/textyoffset textyoffset cvr def
/height height cvr def
% Create an array containing the character mappings
/encs
[ (3211) (2221) (2122) (1411) (1132)
(1231) (1114) (1312) (1213) (3112)
(111) (1111111)
] def
% Create a string of the available characters
/barchars (0123456789) def
/mirrormaps
[ (000111) (001011) (001101) (001110) (010011)
(011001) (011100) (010101) (010110) (011010)
] def
% Derive the equivalent UPC-A for its checksum
/upcacode (00000000000) 11 string copy def
barcode 6 get 48 sub 2 le {
upcacode 1 barcode 1 2 getinterval putinterval
upcacode 3 barcode 6 1 getinterval putinterval
upcacode 8 barcode 3 3 getinterval putinterval
} if
barcode 6 get 48 sub 3 eq {
upcacode 1 barcode 1 3 getinterval putinterval
upcacode 9 barcode 4 2 getinterval putinterval
} if
barcode 6 get 48 sub 4 eq {
upcacode 1 barcode 1 4 getinterval putinterval
upcacode 10 barcode 5 1 getinterval putinterval
} if
barcode 6 get 48 sub 5 ge {
upcacode 1 barcode 1 5 getinterval putinterval
upcacode 10 barcode 6 1 getinterval putinterval
} if
/checksum 0 def
0 1 10 {
/i exch def
/barchar upcacode i get 48 sub def
i 2 mod 0 ne {
/checksum checksum barchar add def
} {
/checksum checksum barchar 3 mul add def
} ifelse
} for
/checksum 10 checksum 10 mod sub 10 mod def
/pad 8 string def
pad 0 barcode putinterval % Add barcode to the start of the pad
pad 7 checksum 48 add put % Put ascii for checksum at end of pad
/barcode pad def
/txt 8 array def
txt 0 [barcode 0 1 getinterval -7 textyoffset textfont textsize 2 sub] put
% Determine the mirror map based on checksum
/mirrormap mirrormaps checksum get def
% Invert the mirrormap if we are using a non-zero number system
barcode 0 get 48 eq {
/invt mirrormap length string def
0 1 mirrormap length 1 sub {
/i exch def
mirrormap i get 48 eq {
invt i 49 put
} {
invt i 48 put
} ifelse
} for
/mirrormap invt def
} if
/sbs 34 string def
% Put the start character
sbs 0 encs 10 get putinterval
1 1 6 {
/i exch def
% Lookup the encoding for the each barcode character
barcode i 1 getinterval barchars exch search
pop % Discard true leaving pre
length /indx exch def % indx is the length of pre
pop pop % Discard seek and post
/enc encs indx get def % Get the indxth encoding
mirrormap i 1 sub get 49 eq { % Reverse enc if 1 in this position in mirrormap
/enclen enc length def
/revenc enclen string def
0 1 enclen 1 sub {
/j exch def
/char enc j get def
revenc enclen j sub 1 sub char put
} for
/enc revenc def
} if
sbs i 1 sub 4 mul 3 add enc putinterval % Put encoded digit into sbs
txt i [barcode i 1 getinterval i 1 sub 7 mul 4 add textyoffset textfont textsize] put
} for
txt 7 [barcode 7 1 getinterval 6 7 mul 11 add textyoffset textfont textsize 2 sub] put
% Put the end character
sbs 27 encs 11 get putinterval
% Return the arguments
<<
/ren (renlinear)
/sbs [sbs {48 sub} forall]
includetext {
/bhs [height height 12{height .075 sub}repeat height height height]
/bbs [0 0 12{.075}repeat 0 0 0]
/txt txt
} {
/bhs [17{height}repeat]
/bbs [17{0}repeat]
} ifelse
/opt useropts
/borderbottom 5
>>
end
} bind def
/upce load 0 1 dict put
% --END ENCODER upce--
% --BEGIN ENCODER ean5--
% --DESC: EAN-5 (5 digit addon)
% --EXAM: 90200
% --EXOP: includetext guardwhitespace
% --RNDR: renlinear
/ean5 {
0 begin
/options exch def % We are given an option string
/useropts options def
/barcode exch def % We are given a barcode string
/includetext false def % Enable/disable text
/textfont /Helvetica def
/textsize 12 def
/textyoffset (unset) def
/height 0.7 def
% Parse the input options
options {
token false eq {exit} if dup length string cvs (=) search
true eq {cvlit exch pop exch def} {cvlit true def} ifelse
} loop
/textfont textfont cvlit def
/textsize textsize cvr def
/height height cvr def
textyoffset (unset) eq {
/textyoffset height 72 mul 1 add def
} {
/textyoffset textyoffset cvr def
} ifelse
% Create an array containing the character mappings
/encs
[ (3211) (2221) (2122) (1411) (1132)
(1231) (1114) (1312) (1213) (3112)
(112) (11)
] def
% Create a string of the available characters
/barchars (0123456789) def
% Determine the mirror map based on mod 10 checksum
/mirrormaps
[ (11000) (10100) (10010) (10001) (01100)
(00110) (00011) (01010) (01001) (00101)
] def
/checksum 0 def
0 1 4 {
/i exch def
/barchar barcode i get 48 sub def
i 2 mod 0 eq {
/checksum barchar 3 mul checksum add def
} {
/checksum barchar 9 mul checksum add def
} ifelse
} for
/checksum checksum 10 mod def
/mirrormap mirrormaps checksum get def
/sbs 31 string def
/txt 5 array def
0 1 4 {
/i exch def
% Prefix with either a start character or separator character
i 0 eq {
sbs 0 encs 10 get putinterval
} {
sbs i 1 sub 6 mul 7 add encs 11 get putinterval
} ifelse
% Lookup the encoding for the barcode character
barcode i 1 getinterval barchars exch search
pop % Discard true leaving pre
length /indx exch def % indx is the length of pre
pop pop % Discard seek and post
/enc encs indx get def % Get the indxth encoding
mirrormap i get 49 eq { % Reverse enc if 1 in this position in mirrormap
/enclen enc length def
/revenc enclen string def
0 1 enclen 1 sub {
/j exch def
/char enc j get def
revenc enclen j sub 1 sub char put
} for
/enc revenc def
} if
sbs i 6 mul 3 add enc putinterval % Put encoded digit into sbs
txt i [barcode i 1 getinterval i 1 sub 9 mul 13 add textyoffset textfont textsize] put
} for
% Return the arguments
<<
/ren (renlinear)
/sbs [sbs {48 sub} forall]
/bhs [16{height}repeat]
/bbs [16{0}repeat]
includetext {
/txt txt
} if
/opt useropts
/guardrightpos 10
/guardrightypos textyoffset 4 add
/bordertop 10
>>
end
} bind def
/ean5 load 0 1 dict put
% --END ENCODER ean5--
% --BEGIN ENCODER ean2--
% --DESC: EAN-2 (2 digit addon)
% --EXAM: 05
% --EXOP: includetext guardwhitespace
% --RNDR: renlinear
/ean2 {
0 begin
/options exch def % We are given an options string
/useropts options def
/barcode exch def % We are given a barcode string
/includetext false def % Enable/disable text
/textfont /Helvetica def
/textsize 12 def
/textyoffset (unset) def
/height 0.7 def
% Parse the input options
options {
token false eq {exit} if dup length string cvs (=) search
true eq {cvlit exch pop exch def} {cvlit true def} ifelse
} loop
/textfont textfont cvlit def
/textsize textsize cvr def
/height height cvr def
textyoffset (unset) eq {
/textyoffset height 72 mul 1 add def
} {
/textyoffset textyoffset cvr def
} ifelse
% Create an array containing the character mappings
/encs
[ (3211) (2221) (2122) (1411) (1132)
(1231) (1114) (1312) (1213) (3112)
(112) (11)
] def
% Create a string of the available characters
/barchars (0123456789) def
% Determine the mirror map based on mod 4 checksum
/mirrormap [(00) (01) (10) (11)] barcode 0 2 getinterval cvi 4 mod get def
/sbs 13 string def
/txt 2 array def
0 1 1 {
/i exch def
% Prefix with either a start character or separator character
i 0 eq {
sbs 0 encs 10 get putinterval
} {
sbs i 1 sub 6 mul 7 add encs 11 get putinterval
} ifelse
% Lookup the encoding for the barcode character
barcode i 1 getinterval barchars exch search
pop % Discard true leaving pre
length /indx exch def % indx is the length of pre
pop pop % Discard seek and post
/enc encs indx get def % Get the indxth encoding
mirrormap i get 49 eq { % Reverse enc if 1 in this position in mirrormap
/enclen enc length def
/revenc enclen string def
0 1 enclen 1 sub {
/j exch def
/char enc j get def
revenc enclen j sub 1 sub char put
} for
/enc revenc def
} if
sbs i 6 mul 3 add enc putinterval % Put encoded digit into sbs
txt i [barcode i 1 getinterval i 1 sub 9 mul 13 add textyoffset textfont textsize] put
} for
% Return the arguments
<<
/ren (renlinear)
/sbs [sbs {48 sub} forall]
/bhs [12{height}repeat]
/bbs [12{0}repeat]
includetext {
/txt txt
} if
/opt useropts
/guardrightpos 10
/guardrightypos textyoffset 4 add
/bordertop 10
>>
end
} bind def
/ean2 load 0 1 dict put
% --END ENCODER ean2--
% --BEGIN ENCODER isbn--
% --REQUIRES ean13--
% --DESC: ISBN
% --EXAM: 978-1-56592-479
% --EXOP: includetext guardwhitespace
% --RNDR: renlinear
/isbn {
0 begin
/options exch def % We are given an options string
/useropts options def
/isbntxt exch def % We are given the isbn text with dashes
/includetext false def % Enable/disable ISBN text
/isbnfont /Courier def
/isbnsize 9 def
/isbnpos (unset) def
/height 1 def
% Parse the input options
options {
token false eq {exit} if dup length string cvs (=) search
true eq {cvlit exch pop exch def} {cvlit true def} ifelse
} loop
/isbnfont isbnfont cvlit def
/isbnsize isbnsize cvr def
/height height cvr def
isbnpos (unset) eq {
/isbnpos height 72 mul 3 add def
} {
/isbnpos isbnpos cvr def
} ifelse
% Read the digits from isbntxt and calculate checksums
/isbn 13 string def
/checksum10 0 def
/checksum13 0 def
/i 0 def /n 0 def
{ % loop
/isbnchar isbntxt i get 48 sub def
isbnchar -3 ne { % Ignore dashes
isbn n isbnchar 48 add put
n 9 lt {
/checksum10 checksum10 10 n sub isbnchar mul add def
} if
n 12 lt {
n 2 mod 0 eq {
/checksum13 isbnchar checksum13 add def
} {
/checksum13 isbnchar 3 mul checksum13 add def
} ifelse
} if
/n n 1 add def
} if
/i i 1 add def
i isbntxt length eq {exit} if
} loop
% Add the ISBN header to the isbntxt
n 9 eq n 10 eq or {
/checksum 11 checksum10 11 mod sub 11 mod def
/isbn isbn 0 9 getinterval def
/pad 18 string def
} {
/checksum 10 checksum13 10 mod sub 10 mod def
/isbn isbn 0 12 getinterval def
/pad 22 string def
} ifelse
pad 0 (ISBN ) putinterval
pad 5 isbntxt putinterval % Add isbntxt to the pad
% Add checksum digit
pad pad length 2 sub 45 put % Put a dash
checksum 10 eq {
pad pad length 1 sub checksum 78 add put % Check digit for 10 is X
} {
pad pad length 1 sub checksum 48 add put % Put check digit
} ifelse
/isbntxt pad def
% Convert ISBN digits to EAN-13
/barcode 12 string def
isbn length 9 eq {
barcode 0 (978) putinterval
barcode 3 isbn putinterval
} {
barcode 0 isbn putinterval
} ifelse
% Get the result of encoding with ean13
/args barcode options ean13 def
% Add the ISBN text
includetext {
isbn length 9 eq {
/isbnxpos -1 def
} {
/isbnxpos -12 def
} ifelse
args (txt) known {
/txt args (txt) get def
/newtxt txt length 1 add array def
newtxt 0 txt putinterval
newtxt newtxt length 1 sub [isbntxt isbnxpos isbnpos isbnfont isbnsize] put
args (txt) newtxt put
} {
args (txt) [ [isbntxt isbnxpos isbnpos isbnfont isbnsize] ] put
} ifelse
} if
args (opt) useropts put
args
end
} bind def
/isbn load 0 1 dict put
% --END ENCODER isbn--
% --BEGIN ENCODER code128--
% --DESC: Code 128
% --EXAM: ^104^102Count^0990123456789^101!
% --EXOP: includetext
% --RNDR: renlinear
/code128 {
0 begin % Confine variables to local scope
/options exch def % We are given an option string
/useropts options def
/barcode exch def % We are given a barcode string
/includetext false def % Enable/disable text
/textfont /Courier def
/textsize 10 def
/textyoffset -7 def
/height 1 def
% Parse the input options
options {
token false eq {exit} if dup length string cvs (=) search
true eq {cvlit exch pop exch def} {cvlit true def} ifelse
} loop
/textfont textfont cvlit def
/textsize textsize cvr def
/textyoffset textyoffset cvr def
/height height cvr def
% Create an array containing the character mappings
/encs
[ (212222) (222122) (222221) (121223) (121322) (131222) (122213)
(122312) (132212) (221213) (221312) (231212) (112232) (122132)
(122231) (113222) (123122) (123221) (223211) (221132) (221231)
(213212) (223112) (312131) (311222) (321122) (321221) (312212)
(322112) (322211) (212123) (212321) (232121) (111323) (131123)
(131321) (112313) (132113) (132311) (211313) (231113) (231311)
(112133) (112331) (132131) (113123) (113321) (133121) (313121)
(211331) (231131) (213113) (213311) (213131) (311123) (311321)
(331121) (312113) (312311) (332111) (314111) (221411) (431111)
(111224) (111422) (121124) (121421) (141122) (141221) (112214)
(112412) (122114) (122411) (142112) (142211) (241211) (221114)
(413111) (241112) (134111) (111242) (121142) (121241) (114212)
(124112) (124211) (411212) (421112) (421211) (212141) (214121)
(412121) (111143) (111341) (131141) (114113) (114311) (411113)
(411311) (113141) (114131) (311141) (411131) (211412) (211214)
(211232) (2331112)
] def
% Create a string of the available characters for alphabets A and B
/barchars ( !"#$%&'\(\)*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~) def
/barlen barcode length def % Length of the code
/sbs barlen 6 mul string def % sbs is 6 times length of barcode
/txt barlen array def
/mode -1 def % A=0, B=1, C=2
/checksum barcode 1 3 getinterval cvi def % Initialise the checksum
/i 0 def /j 0 def
{ % loop
i barlen eq {exit} if
barcode i 1 getinterval (^) eq {
% indx is given by the next three characters
/indx barcode i 1 add 3 getinterval cvi def
txt j [( ) j 11 mul textyoffset textfont textsize] put
/i i 4 add def
} {
% indx depends on the mode
mode 2 eq {
/indx barcode i 2 getinterval cvi def
txt j [barcode i 2 getinterval j 11 mul textyoffset textfont textsize] put
/i i 2 add def
} {
barchars barcode i 1 getinterval search
pop % Discard true leaving pre
length /indx exch def % indx is the length of pre
pop pop % Discard seek and post
txt j [barchars indx 1 getinterval j 11 mul textyoffset textfont textsize] put
/i i 1 add def
} ifelse
} ifelse
/enc encs indx get def % Get the indxth encoding
sbs j 6 mul enc putinterval % Put encoded digit into sbs
% Update the mode
indx 101 eq indx 103 eq or {/mode 0 def} if
indx 100 eq indx 104 eq or {/mode 1 def} if
indx 99 eq indx 105 eq or {/mode 2 def} if
/checksum indx j mul checksum add def % checksum+=indx*j
/j j 1 add def
} loop
% Put the checksum character
/checksum checksum 103 mod def
sbs j 6 mul encs checksum get putinterval
% Put the end character
sbs j 6 mul 6 add encs 106 get putinterval
% Shrink sbs and txt to fit exactly
/sbs sbs 0 j 6 mul 13 add getinterval def
/txt txt 0 j getinterval def
% Return the arguments
<<
/ren (renlinear)
/sbs [sbs {48 sub} forall]
/bhs [sbs length 1 add 2 idiv {height} repeat]
/bbs [sbs length 1 add 2 idiv {0} repeat]
includetext {
/txt txt
} if
/opt useropts
>>
end
} bind def
/code128 load 0 1 dict put
% --END ENCODER code128--
% --BEGIN ENCODER code39--
% --DESC: Code 39
% --EXAM: THIS IS CODE 39
% --EXOP: includetext includecheck includecheckintext
% --RNDR: renlinear
/code39 {
0 begin % Confine variables to local scope
/options exch def % We are given an option string
/useropts options def
/barcode exch def % We are given a barcode string