rghost_barcode 0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/doc/classes/RGhost.html +109 -0
- data/lib/doc/classes/RGhost/Barcode.html +147 -0
- data/lib/doc/classes/RGhost/Barcode/Auspost.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Azteccode.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Base.html +266 -0
- data/lib/doc/classes/RGhost/Barcode/Base.src/M000004.html +34 -0
- data/lib/doc/classes/RGhost/Barcode/Base.src/M000005.html +30 -0
- data/lib/doc/classes/RGhost/Barcode/Base.src/M000006.html +20 -0
- data/lib/doc/classes/RGhost/Barcode/Border.html +170 -0
- data/lib/doc/classes/RGhost/Barcode/Border.src/M000001.html +27 -0
- data/lib/doc/classes/RGhost/Barcode/Code11.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Code128.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Code2of5.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Code39.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Code93.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Datamatrix.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Ean13.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Ean2.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Ean5.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Ean8.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Guard.html +174 -0
- data/lib/doc/classes/RGhost/Barcode/Guard.src/M000003.html +27 -0
- data/lib/doc/classes/RGhost/Barcode/Interleaved2of5.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Isbn.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Kix.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Maxicode.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Msi.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Onecode.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Parameter.html +262 -0
- data/lib/doc/classes/RGhost/Barcode/Parameter.src/M000007.html +20 -0
- data/lib/doc/classes/RGhost/Barcode/Parameter.src/M000008.html +18 -0
- data/lib/doc/classes/RGhost/Barcode/Parameter.src/M000009.html +18 -0
- data/lib/doc/classes/RGhost/Barcode/Parameter.src/M000010.html +18 -0
- data/lib/doc/classes/RGhost/Barcode/Parameter.src/M000011.html +18 -0
- data/lib/doc/classes/RGhost/Barcode/Parameter.src/M000012.html +24 -0
- data/lib/doc/classes/RGhost/Barcode/Parameter.src/M000013.html +18 -0
- data/lib/doc/classes/RGhost/Barcode/Parameter.src/M000014.html +18 -0
- data/lib/doc/classes/RGhost/Barcode/Parameter.src/M000015.html +16 -0
- data/lib/doc/classes/RGhost/Barcode/Pdf417.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Pharmacode.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Plessey.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Postnet.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Qrcode.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Rationalizedcodabar.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Raw.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Royalmail.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Rss14.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Rssexpanded.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Rsslimited.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Symbol.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Text.html +193 -0
- data/lib/doc/classes/RGhost/Barcode/Text.src/M000002.html +30 -0
- data/lib/doc/classes/RGhost/Barcode/Upca.html +113 -0
- data/lib/doc/classes/RGhost/Barcode/Upce.html +113 -0
- data/lib/doc/classes/RGhost/Config.html +150 -0
- data/lib/doc/classes/RGhost/Config.src/M000016.html +45 -0
- data/lib/doc/classes/RGhost/Document.html +704 -0
- data/lib/doc/classes/RGhost/Document.src/M000017.html +19 -0
- data/lib/doc/classes/RGhost/Document.src/M000018.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000019.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000020.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000021.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000022.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000023.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000024.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000025.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000026.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000027.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000028.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000029.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000030.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000031.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000032.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000033.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000034.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000035.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000036.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000037.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000038.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000039.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000040.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000041.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000042.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000043.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000044.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000045.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000046.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000047.html +18 -0
- data/lib/doc/classes/RGhost/Document.src/M000048.html +18 -0
- data/lib/doc/created.rid +1 -0
- data/lib/doc/files/rghost_barcode/rghost_barcode_adapter_rb.html +101 -0
- data/lib/doc/files/rghost_barcode/rghost_barcode_base_rb.html +101 -0
- data/lib/doc/files/rghost_barcode/rghost_barcode_classes_rb.html +101 -0
- data/lib/doc/files/rghost_barcode/rghost_barcode_examples_rb.html +101 -0
- data/lib/doc/files/rghost_barcode/rghost_barcode_version_rb.html +101 -0
- data/lib/doc/files/rghost_barcode_rb.html +111 -0
- data/lib/doc/files/teste_main_rb.html +110 -0
- data/lib/doc/fr_class_index.html +67 -0
- data/lib/doc/fr_file_index.html +33 -0
- data/lib/doc/fr_method_index.html +74 -0
- data/lib/doc/index.html +24 -0
- data/lib/rghost_barcode.rb +7 -0
- data/lib/rghost_barcode/ps/auspost.ps +192 -0
- data/lib/rghost_barcode/ps/azteccode.ps +357 -0
- data/lib/rghost_barcode/ps/barcode_template.eps +1193 -0
- data/lib/rghost_barcode/ps/code11.ps +128 -0
- data/lib/rghost_barcode/ps/code128.ps +121 -0
- data/lib/rghost_barcode/ps/code2of5.ps +106 -0
- data/lib/rghost_barcode/ps/code39.ps +109 -0
- data/lib/rghost_barcode/ps/code93.ps +117 -0
- data/lib/rghost_barcode/ps/datamatrix.ps +328 -0
- data/lib/rghost_barcode/ps/ean13.ps +183 -0
- data/lib/rghost_barcode/ps/ean2.ps +101 -0
- data/lib/rghost_barcode/ps/ean5.ps +116 -0
- data/lib/rghost_barcode/ps/ean8.ps +101 -0
- data/lib/rghost_barcode/ps/interleaved2of5.ps +132 -0
- data/lib/rghost_barcode/ps/isbn.ps +118 -0
- data/lib/rghost_barcode/ps/kix.ps +98 -0
- data/lib/rghost_barcode/ps/maxicode.ps +307 -0
- data/lib/rghost_barcode/ps/msi.ps +104 -0
- data/lib/rghost_barcode/ps/onecode.ps +276 -0
- data/lib/rghost_barcode/ps/pdf417.ps +428 -0
- data/lib/rghost_barcode/ps/pharmacode.ps +69 -0
- data/lib/rghost_barcode/ps/plessey.ps +121 -0
- data/lib/rghost_barcode/ps/postnet.ps +114 -0
- data/lib/rghost_barcode/ps/qrcode.ps +530 -0
- data/lib/rghost_barcode/ps/rationalizedcodabar.ps +117 -0
- data/lib/rghost_barcode/ps/raw.ps +35 -0
- data/lib/rghost_barcode/ps/render.ps +307 -0
- data/lib/rghost_barcode/ps/render.ps~ +308 -0
- data/lib/rghost_barcode/ps/royalmail.ps +119 -0
- data/lib/rghost_barcode/ps/rss14.ps +237 -0
- data/lib/rghost_barcode/ps/rssexpanded.ps +211 -0
- data/lib/rghost_barcode/ps/rsslimited.ps +191 -0
- data/lib/rghost_barcode/ps/symbol.ps +49 -0
- data/lib/rghost_barcode/ps/upca.ps +128 -0
- data/lib/rghost_barcode/ps/upce.ps +157 -0
- data/lib/rghost_barcode/rghost_barcode_adapter.rb +249 -0
- data/lib/rghost_barcode/rghost_barcode_base.rb +210 -0
- data/lib/rghost_barcode/rghost_barcode_classes.rb +96 -0
- data/lib/rghost_barcode/rghost_barcode_examples.rb +35 -0
- data/lib/rghost_barcode/rghost_barcode_version.rb +8 -0
- data/lib/teste_main.rb +94 -0
- metadata +218 -0
@@ -0,0 +1,101 @@
|
|
1
|
+
|
2
|
+
% --DESC: EAN-2 (2 digit addon)
|
3
|
+
% --EXAM: 05
|
4
|
+
% --EXOP: includetext guardwhitespace
|
5
|
+
% --RNDR: renlinear
|
6
|
+
/ean2 {
|
7
|
+
|
8
|
+
0 begin
|
9
|
+
|
10
|
+
/options exch def % We are given an options string
|
11
|
+
/useropts options def
|
12
|
+
/barcode exch def % We are given a barcode string
|
13
|
+
|
14
|
+
/includetext false def % Enable/disable text
|
15
|
+
/textfont /Helvetica def
|
16
|
+
/textsize 12 def
|
17
|
+
/textyoffset (unset) def
|
18
|
+
/height 0.7 def
|
19
|
+
|
20
|
+
% Parse the input options
|
21
|
+
options {
|
22
|
+
token false eq {exit} if dup length string cvs (=) search
|
23
|
+
true eq {cvlit exch pop exch def} {cvlit true def} ifelse
|
24
|
+
} loop
|
25
|
+
|
26
|
+
/textfont textfont cvlit def
|
27
|
+
/textsize textsize cvr def
|
28
|
+
/height height cvr def
|
29
|
+
textyoffset (unset) eq {
|
30
|
+
/textyoffset height 72 mul 1 add def
|
31
|
+
} {
|
32
|
+
/textyoffset textyoffset cvr def
|
33
|
+
} ifelse
|
34
|
+
|
35
|
+
/barlen barcode length def % Length of the code
|
36
|
+
|
37
|
+
% Create an array containing the character mappings
|
38
|
+
/encs
|
39
|
+
[ (3211) (2221) (2122) (1411) (1132)
|
40
|
+
(1231) (1114) (1312) (1213) (3112)
|
41
|
+
(112) (11)
|
42
|
+
] def
|
43
|
+
|
44
|
+
% Create a string of the available characters
|
45
|
+
/barchars (0123456789) def
|
46
|
+
|
47
|
+
% Determine the mirror map based on mod 4 checksum
|
48
|
+
/mirrormap [(00) (01) (10) (11)] barcode 0 2 getinterval cvi 4 mod get def
|
49
|
+
|
50
|
+
/sbs 13 string def
|
51
|
+
/txt 2 array def
|
52
|
+
|
53
|
+
0 1 1 {
|
54
|
+
/i exch def
|
55
|
+
|
56
|
+
% Prefix with either a start character or separator character
|
57
|
+
i 0 eq {
|
58
|
+
sbs 0 encs 10 get putinterval
|
59
|
+
} {
|
60
|
+
sbs i 1 sub 6 mul 7 add encs 11 get putinterval
|
61
|
+
} ifelse
|
62
|
+
|
63
|
+
% Lookup the encoding for the barcode character
|
64
|
+
barcode i 1 getinterval barchars exch search
|
65
|
+
pop % Discard true leaving pre
|
66
|
+
length /indx exch def % indx is the length of pre
|
67
|
+
pop pop % Discard seek and post
|
68
|
+
/enc encs indx get def % Get the indxth encoding
|
69
|
+
mirrormap i get 49 eq { % Reverse enc if 1 in this position in mirrormap
|
70
|
+
/enclen enc length def
|
71
|
+
/revenc enclen string def
|
72
|
+
0 1 enclen 1 sub {
|
73
|
+
/j exch def
|
74
|
+
/char enc j get def
|
75
|
+
revenc enclen j sub 1 sub char put
|
76
|
+
} for
|
77
|
+
/enc revenc def
|
78
|
+
} if
|
79
|
+
sbs i 6 mul 3 add enc putinterval % Put encoded digit into sbs
|
80
|
+
txt i [barcode i 1 getinterval i 1 sub 9 mul 13 add textyoffset textfont textsize] put
|
81
|
+
} for
|
82
|
+
|
83
|
+
% Return the arguments
|
84
|
+
/retval 8 dict def
|
85
|
+
retval (ren) (renlinear) put
|
86
|
+
retval (sbs) [sbs {48 sub} forall] put
|
87
|
+
retval (bhs) [12{height}repeat] put
|
88
|
+
retval (bbs) [12{0}repeat] put
|
89
|
+
includetext {
|
90
|
+
retval (txt) txt put
|
91
|
+
} if
|
92
|
+
retval (opt) useropts put
|
93
|
+
retval (guardrightpos) 10 put
|
94
|
+
retval (guardrightypos) textyoffset 4 add put
|
95
|
+
retval (bordertop) 10 put
|
96
|
+
retval
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
} bind def
|
101
|
+
/ean2 load 0 1 dict put
|
@@ -0,0 +1,116 @@
|
|
1
|
+
|
2
|
+
% --DESC: EAN-5 (5 digit addon)
|
3
|
+
% --EXAM: 90200
|
4
|
+
% --EXOP: includetext guardwhitespace
|
5
|
+
% --RNDR: renlinear
|
6
|
+
/ean5 {
|
7
|
+
|
8
|
+
0 begin
|
9
|
+
|
10
|
+
/options exch def % We are given an option string
|
11
|
+
/useropts options def
|
12
|
+
/barcode exch def % We are given a barcode string
|
13
|
+
|
14
|
+
/includetext false def % Enable/disable text
|
15
|
+
/textfont /Helvetica def
|
16
|
+
/textsize 12 def
|
17
|
+
/textyoffset (unset) def
|
18
|
+
/height 0.7 def
|
19
|
+
|
20
|
+
% Parse the input options
|
21
|
+
options {
|
22
|
+
token false eq {exit} if dup length string cvs (=) search
|
23
|
+
true eq {cvlit exch pop exch def} {cvlit true def} ifelse
|
24
|
+
} loop
|
25
|
+
|
26
|
+
/textfont textfont cvlit def
|
27
|
+
/textsize textsize cvr def
|
28
|
+
/height height cvr def
|
29
|
+
textyoffset (unset) eq {
|
30
|
+
/textyoffset height 72 mul 1 add def
|
31
|
+
} {
|
32
|
+
/textyoffset textyoffset cvr def
|
33
|
+
} ifelse
|
34
|
+
|
35
|
+
/barlen barcode length def % Length of the code
|
36
|
+
|
37
|
+
% Create an array containing the character mappings
|
38
|
+
/encs
|
39
|
+
[ (3211) (2221) (2122) (1411) (1132)
|
40
|
+
(1231) (1114) (1312) (1213) (3112)
|
41
|
+
(112) (11)
|
42
|
+
] def
|
43
|
+
|
44
|
+
% Create a string of the available characters
|
45
|
+
/barchars (0123456789) def
|
46
|
+
|
47
|
+
% Determine the mirror map based on mod 10 checksum
|
48
|
+
/mirrormaps
|
49
|
+
[ (11000) (10100) (10010) (10001) (01100)
|
50
|
+
(00110) (00011) (01010) (01001) (00101)
|
51
|
+
] def
|
52
|
+
/checksum 0 def
|
53
|
+
0 1 4 {
|
54
|
+
/i exch def
|
55
|
+
/barchar barcode i get 48 sub def
|
56
|
+
i 2 mod 0 eq {
|
57
|
+
/checksum barchar 3 mul checksum add def
|
58
|
+
} {
|
59
|
+
/checksum barchar 9 mul checksum add def
|
60
|
+
} ifelse
|
61
|
+
} for
|
62
|
+
/checksum checksum 10 mod def
|
63
|
+
/mirrormap mirrormaps checksum get def
|
64
|
+
|
65
|
+
/sbs 31 string def
|
66
|
+
/txt 5 array def
|
67
|
+
|
68
|
+
0 1 4 {
|
69
|
+
/i exch def
|
70
|
+
|
71
|
+
% Prefix with either a start character or separator character
|
72
|
+
i 0 eq {
|
73
|
+
sbs 0 encs 10 get putinterval
|
74
|
+
} {
|
75
|
+
sbs i 1 sub 6 mul 7 add encs 11 get putinterval
|
76
|
+
} ifelse
|
77
|
+
|
78
|
+
% Lookup the encoding for the barcode character
|
79
|
+
barcode i 1 getinterval barchars exch search
|
80
|
+
pop % Discard true leaving pre
|
81
|
+
length /indx exch def % indx is the length of pre
|
82
|
+
pop pop % Discard seek and post
|
83
|
+
/enc encs indx get def % Get the indxth encoding
|
84
|
+
mirrormap i get 49 eq { % Reverse enc if 1 in this position in mirrormap
|
85
|
+
/enclen enc length def
|
86
|
+
/revenc enclen string def
|
87
|
+
0 1 enclen 1 sub {
|
88
|
+
/j exch def
|
89
|
+
/char enc j get def
|
90
|
+
revenc enclen j sub 1 sub char put
|
91
|
+
} for
|
92
|
+
/enc revenc def
|
93
|
+
} if
|
94
|
+
sbs i 6 mul 3 add enc putinterval % Put encoded digit into sbs
|
95
|
+
txt i [barcode i 1 getinterval i 1 sub 9 mul 13 add textyoffset textfont textsize] put
|
96
|
+
} for
|
97
|
+
|
98
|
+
% Return the arguments
|
99
|
+
/retval 8 dict def
|
100
|
+
retval (ren) (renlinear) put
|
101
|
+
retval (sbs) [sbs {48 sub} forall] put
|
102
|
+
retval (bhs) [16{height}repeat] put
|
103
|
+
retval (bbs) [16{0}repeat] put
|
104
|
+
includetext {
|
105
|
+
retval (txt) txt put
|
106
|
+
} if
|
107
|
+
retval (opt) useropts put
|
108
|
+
retval (guardrightpos) 10 put
|
109
|
+
retval (guardrightypos) textyoffset 4 add put
|
110
|
+
retval (bordertop) 10 put
|
111
|
+
retval
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
} bind def
|
116
|
+
/ean5 load 0 1 dict put
|
@@ -0,0 +1,101 @@
|
|
1
|
+
|
2
|
+
% --DESC: EAN-8
|
3
|
+
% --EXAM: 01335583
|
4
|
+
% --EXOP: includetext guardwhitespace height=0.5
|
5
|
+
% --RNDR: renlinear
|
6
|
+
/ean8 {
|
7
|
+
|
8
|
+
0 begin
|
9
|
+
|
10
|
+
/options exch def % We are given an option string
|
11
|
+
/useropts options def
|
12
|
+
/barcode exch def % We are given a barcode string
|
13
|
+
|
14
|
+
/includetext false def % Enable/disable text
|
15
|
+
/textfont /Helvetica def
|
16
|
+
/textsize 12 def
|
17
|
+
/textyoffset -4 def
|
18
|
+
/height 1 def
|
19
|
+
|
20
|
+
% Parse the input options
|
21
|
+
options {
|
22
|
+
token false eq {exit} if dup length string cvs (=) search
|
23
|
+
true eq {cvlit exch pop exch def} {cvlit true def} ifelse
|
24
|
+
} loop
|
25
|
+
|
26
|
+
/textfont textfont cvlit def
|
27
|
+
/textsize textsize cvr def
|
28
|
+
/textyoffset textyoffset cvr def
|
29
|
+
/height height cvr def
|
30
|
+
|
31
|
+
% Create an array containing the character mappings
|
32
|
+
/encs
|
33
|
+
[ (3211) (2221) (2122) (1411) (1132)
|
34
|
+
(1231) (1114) (1312) (1213) (3112)
|
35
|
+
(111) (11111) (111)
|
36
|
+
] def
|
37
|
+
|
38
|
+
% Create a string of the available characters
|
39
|
+
/barchars (0123456789) def
|
40
|
+
|
41
|
+
/barlen barcode length def % Length of the code
|
42
|
+
/sbs barlen 4 mul 11 add string def
|
43
|
+
/txt barlen array def
|
44
|
+
|
45
|
+
% Put the start character
|
46
|
+
sbs 0 encs 10 get putinterval
|
47
|
+
|
48
|
+
% Left side
|
49
|
+
0 1 3 {
|
50
|
+
% Lookup the encoding for the each barcode character
|
51
|
+
/i exch def
|
52
|
+
barcode i 1 getinterval barchars exch search
|
53
|
+
pop % Discard true leaving pre
|
54
|
+
length /indx exch def % indx is the length of pre
|
55
|
+
pop pop % Discard seek and post
|
56
|
+
/enc encs indx get def % Get the indxth encoding
|
57
|
+
sbs i 4 mul 3 add enc putinterval % Put encoded digit into sbs
|
58
|
+
txt i [barcode i 1 getinterval i 7 mul 4 add textyoffset textfont textsize] put
|
59
|
+
} for
|
60
|
+
|
61
|
+
% Put the middle character
|
62
|
+
sbs 4 4 mul 3 add encs 11 get putinterval
|
63
|
+
|
64
|
+
% Right side
|
65
|
+
4 1 7 {
|
66
|
+
% Lookup the encoding for the each barcode character
|
67
|
+
/i exch def
|
68
|
+
barcode i 1 getinterval barchars exch search
|
69
|
+
pop % Discard true leaving pre
|
70
|
+
length /indx exch def % indx is the length of pre
|
71
|
+
pop pop % Discard seek and post
|
72
|
+
/enc encs indx get def % Get the indxth encoding
|
73
|
+
sbs i 4 mul 8 add enc putinterval % Put encoded digit into sbs
|
74
|
+
txt i [barcode i 1 getinterval i 7 mul 8 add textyoffset textfont textsize] put
|
75
|
+
} for
|
76
|
+
|
77
|
+
% Put the end character
|
78
|
+
sbs barlen 4 mul 8 add encs 12 get putinterval
|
79
|
+
|
80
|
+
% Return the arguments
|
81
|
+
/retval 8 dict def
|
82
|
+
retval (ren) (renlinear) put
|
83
|
+
retval (sbs) [sbs {48 sub} forall] put
|
84
|
+
includetext {
|
85
|
+
retval (bhs) [height height 8{height .075 sub}repeat height height 8{height .075 sub}repeat height height] put
|
86
|
+
retval (bbs) [0 0 8{.075}repeat 0 0 8{.075}repeat 0 0] put
|
87
|
+
retval (txt) txt put
|
88
|
+
} {
|
89
|
+
retval (bhs) [22{height}repeat] put
|
90
|
+
retval (bbs) [22{0}repeat] put
|
91
|
+
} ifelse
|
92
|
+
retval (opt) useropts put
|
93
|
+
retval (guardleftpos) 10 put
|
94
|
+
retval (guardrightpos) 10 put
|
95
|
+
retval (borderbottom) 5 put
|
96
|
+
retval
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
} bind def
|
101
|
+
/ean8 load 0 1 dict put
|
@@ -0,0 +1,132 @@
|
|
1
|
+
|
2
|
+
% --DESC: Interleaved 2 of 5 (ITF)
|
3
|
+
% --EXAM: 24012345678905
|
4
|
+
% --EXOP: showborder borderwidth=4 borderleft=15 borderright=15 height=0.5 includecheck includetext includecheckintext textyoffset=-10
|
5
|
+
% --RNDR: renlinear
|
6
|
+
/interleaved2of5 {
|
7
|
+
|
8
|
+
0 begin % Confine variables to local scope
|
9
|
+
|
10
|
+
/options exch def % We are given an option string
|
11
|
+
/useropts options def
|
12
|
+
/barcode exch def % We are given a barcode string
|
13
|
+
|
14
|
+
/includecheck false def % Enable/disable checkdigit
|
15
|
+
/includetext false def % Enable/disable text
|
16
|
+
/includecheckintext false def
|
17
|
+
/textfont /Courier def
|
18
|
+
/textsize 10 def
|
19
|
+
/textyoffset -7 def
|
20
|
+
/height 1 def
|
21
|
+
|
22
|
+
% Parse the input options
|
23
|
+
options {
|
24
|
+
token false eq {exit} if dup length string cvs (=) search
|
25
|
+
true eq {cvlit exch pop exch def} {cvlit true def} ifelse
|
26
|
+
} loop
|
27
|
+
|
28
|
+
/textfont textfont cvlit def
|
29
|
+
/textsize textsize cvr def
|
30
|
+
/textyoffset textyoffset cvr def
|
31
|
+
/height height cvr def
|
32
|
+
|
33
|
+
/barlen barcode length def % Length of the code
|
34
|
+
|
35
|
+
% Prefix 0 to barcode if length is even and including checkdigit
|
36
|
+
% or length is odd and not including checkdigit
|
37
|
+
barlen 2 mod 0 eq includecheck and % even & includecheck
|
38
|
+
barlen 2 mod 0 ne includecheck not and or { % odd & !includecheck
|
39
|
+
/pad barlen 1 add string def % Create pad one bigger than barcode
|
40
|
+
pad 0 48 put % Put ascii 0 at start of pad
|
41
|
+
pad 1 barcode putinterval % Add barcode to the end of pad
|
42
|
+
/barcode pad def % barcode=pad
|
43
|
+
/barlen barlen 1 add def % barlen++
|
44
|
+
} if
|
45
|
+
|
46
|
+
% Add checksum to end of barcode
|
47
|
+
includecheck {
|
48
|
+
/checksum 0 def
|
49
|
+
0 1 barlen 1 sub {
|
50
|
+
/i exch def
|
51
|
+
i 2 mod 0 eq {
|
52
|
+
/checksum checksum barcode i get 48 sub 3 mul add def
|
53
|
+
} {
|
54
|
+
/checksum checksum barcode i get 48 sub add def
|
55
|
+
} ifelse
|
56
|
+
} for
|
57
|
+
/checksum 10 checksum 10 mod sub 10 mod def
|
58
|
+
/pad barlen 1 add string def % Create pad one bigger than barcode
|
59
|
+
pad 0 barcode putinterval % Add barcode to the start of pad
|
60
|
+
pad barlen checksum 48 add put % Add checksum to end of pad
|
61
|
+
/barcode pad def % barcode=pad
|
62
|
+
/barlen barlen 1 add def % barlen++
|
63
|
+
} if
|
64
|
+
|
65
|
+
% Create an array containing the character mappings
|
66
|
+
/encs
|
67
|
+
[ (11331) (31113) (13113) (33111) (11313)
|
68
|
+
(31311) (13311) (11133) (31131) (13131)
|
69
|
+
(1111) (3111)
|
70
|
+
] def
|
71
|
+
|
72
|
+
% Create a string of the available characters
|
73
|
+
/barchars (0123456789) def
|
74
|
+
/sbs barlen 5 mul 8 add string def
|
75
|
+
/txt barlen array def
|
76
|
+
|
77
|
+
% Put the start character
|
78
|
+
sbs 0 encs 10 get putinterval
|
79
|
+
|
80
|
+
0 2 barlen 1 sub {
|
81
|
+
/i exch def
|
82
|
+
% Lookup the encodings for two consecutive barcode characters
|
83
|
+
barcode i 1 getinterval barchars exch search
|
84
|
+
pop % Discard true leaving pre
|
85
|
+
length /indx exch def % indx is the length of pre
|
86
|
+
pop pop % Discard seek and post
|
87
|
+
/enca encs indx get def % Get the indxth encoding
|
88
|
+
|
89
|
+
barcode i 1 add 1 getinterval barchars exch search
|
90
|
+
pop % Discard true leaving pre
|
91
|
+
length /indx exch def % indx is the length of pre
|
92
|
+
pop pop % Discard seek and post
|
93
|
+
/encb encs indx get def % Get the indxth encoding
|
94
|
+
|
95
|
+
% Interleave the two character encodings
|
96
|
+
/intl enca length 2 mul string def
|
97
|
+
0 1 enca length 1 sub {
|
98
|
+
/j exch def
|
99
|
+
/achar enca j get def
|
100
|
+
/bchar encb j get def
|
101
|
+
intl j 2 mul achar put
|
102
|
+
intl j 2 mul 1 add bchar put
|
103
|
+
} for
|
104
|
+
|
105
|
+
sbs i 5 mul 4 add intl putinterval % Put encoded digit into sbs
|
106
|
+
txt i [barcode i 1 getinterval i 9 mul 4 add textyoffset textfont textsize] put
|
107
|
+
includecheck includecheckintext not and barlen 2 sub i eq and {
|
108
|
+
txt i 1 add [( ) i 1 add 9 mul 4 add textyoffset textfont textsize] put
|
109
|
+
} {
|
110
|
+
txt i 1 add [barcode i 1 add 1 getinterval i 1 add 9 mul 4 add textyoffset textfont textsize] put
|
111
|
+
} ifelse
|
112
|
+
} for
|
113
|
+
|
114
|
+
% Put the end character
|
115
|
+
sbs barlen 5 mul 4 add encs 11 get putinterval
|
116
|
+
|
117
|
+
% Return the arguments
|
118
|
+
/retval 8 dict def
|
119
|
+
retval (ren) (renlinear) put
|
120
|
+
retval (sbs) [sbs {48 sub} forall] put
|
121
|
+
retval (bhs) [sbs length 1 add 2 idiv {height} repeat] put
|
122
|
+
retval (bbs) [sbs length 1 add 2 idiv {0} repeat] put
|
123
|
+
includetext {
|
124
|
+
retval (txt) txt put
|
125
|
+
} if
|
126
|
+
retval (opt) useropts put
|
127
|
+
retval
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
} bind def
|
132
|
+
/interleaved2of5 load 0 1 dict put
|