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,118 @@
|
|
1
|
+
|
2
|
+
% --REQUIRES ean13--
|
3
|
+
% --DESC: ISBN
|
4
|
+
% --EXAM: 978-1-56592-479
|
5
|
+
% --EXOP: includetext guardwhitespace
|
6
|
+
% --RNDR: renlinear
|
7
|
+
/isbn {
|
8
|
+
|
9
|
+
0 begin
|
10
|
+
|
11
|
+
/options exch def % We are given an options string
|
12
|
+
/useropts options def
|
13
|
+
/isbntxt exch def % We are given the isbn text with dashes
|
14
|
+
|
15
|
+
/includetext false def % Enable/disable ISBN text
|
16
|
+
/isbnfont /Courier def
|
17
|
+
/isbnsize 9 def
|
18
|
+
/isbnpos (unset) def
|
19
|
+
/height 1 def
|
20
|
+
|
21
|
+
% Parse the input options
|
22
|
+
options {
|
23
|
+
token false eq {exit} if dup length string cvs (=) search
|
24
|
+
true eq {cvlit exch pop exch def} {cvlit true def} ifelse
|
25
|
+
} loop
|
26
|
+
|
27
|
+
/isbnfont isbnfont cvlit def
|
28
|
+
/isbnsize isbnsize cvr def
|
29
|
+
/height height cvr def
|
30
|
+
isbnpos (unset) eq {
|
31
|
+
/isbnpos height 72 mul 3 add def
|
32
|
+
} {
|
33
|
+
/isbnpos isbnpos cvr def
|
34
|
+
} ifelse
|
35
|
+
|
36
|
+
% Read the digits from isbntxt and calculate checksums
|
37
|
+
/isbn 13 string def
|
38
|
+
/checksum10 0 def
|
39
|
+
/checksum13 0 def
|
40
|
+
/i 0 def /n 0 def
|
41
|
+
{ % loop
|
42
|
+
/isbnchar isbntxt i get 48 sub def
|
43
|
+
isbnchar -3 ne { % Ignore dashes
|
44
|
+
isbn n isbnchar 48 add put
|
45
|
+
/checksum10 checksum10 10 n sub isbnchar mul add def
|
46
|
+
n 2 mod 0 eq {
|
47
|
+
/checksum13 isbnchar checksum13 add def
|
48
|
+
} {
|
49
|
+
/checksum13 isbnchar 3 mul checksum13 add def
|
50
|
+
} ifelse
|
51
|
+
/n n 1 add def
|
52
|
+
} if
|
53
|
+
/i i 1 add def
|
54
|
+
i isbntxt length eq {exit} if
|
55
|
+
} loop
|
56
|
+
|
57
|
+
% Add the ISBN header to the isbntxt
|
58
|
+
n 9 eq n 10 eq or {
|
59
|
+
/checksum 11 checksum10 11 mod sub 11 mod def
|
60
|
+
/isbn isbn 0 9 getinterval def
|
61
|
+
/pad 18 string def
|
62
|
+
} {
|
63
|
+
/checksum 10 checksum13 10 mod sub 10 mod def
|
64
|
+
/isbn isbn 0 12 getinterval def
|
65
|
+
/pad 22 string def
|
66
|
+
} ifelse
|
67
|
+
pad 0 (ISBN ) putinterval
|
68
|
+
pad 5 isbntxt putinterval % Add isbntxt to the pad
|
69
|
+
|
70
|
+
% Add checksum digit if isbntxt length is 11 or 15
|
71
|
+
isbntxt length 11 eq isbntxt length 12 eq or
|
72
|
+
isbntxt length 15 eq or isbntxt length 16 eq or {
|
73
|
+
pad pad length 2 sub 45 put % Put a dash
|
74
|
+
checksum 10 eq {
|
75
|
+
pad pad length 1 sub checksum 78 add put % Check digit for 10 is X
|
76
|
+
} {
|
77
|
+
pad pad length 1 sub checksum 48 add put % Put check digit
|
78
|
+
} ifelse
|
79
|
+
} if
|
80
|
+
/isbntxt pad def % isbntxt=pad
|
81
|
+
|
82
|
+
% Convert ISBN digits to EAN-13
|
83
|
+
/barcode 12 string def
|
84
|
+
isbn length 9 eq {
|
85
|
+
barcode 0 (978) putinterval
|
86
|
+
barcode 3 isbn putinterval
|
87
|
+
} {
|
88
|
+
barcode 0 isbn putinterval
|
89
|
+
} ifelse
|
90
|
+
|
91
|
+
% Get the result of encoding with ean13
|
92
|
+
/args barcode options ean13 def
|
93
|
+
|
94
|
+
% Add the ISBN text
|
95
|
+
includetext {
|
96
|
+
isbn length 9 eq {
|
97
|
+
/isbnxpos -1 def
|
98
|
+
} {
|
99
|
+
/isbnxpos -12 def
|
100
|
+
} ifelse
|
101
|
+
args (txt) known {
|
102
|
+
/txt args (txt) get def
|
103
|
+
/newtxt txt length 1 add array def
|
104
|
+
newtxt 0 txt putinterval
|
105
|
+
newtxt newtxt length 1 sub [isbntxt isbnxpos isbnpos isbnfont isbnsize] put
|
106
|
+
args (txt) newtxt put
|
107
|
+
} {
|
108
|
+
args (txt) [ [isbntxt isbnxpos isbnpos isbnfont isbnsize] ] put
|
109
|
+
} ifelse
|
110
|
+
} if
|
111
|
+
|
112
|
+
args (opt) useropts put
|
113
|
+
args
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
} bind def
|
118
|
+
/isbn load 0 1 dict put
|
@@ -0,0 +1,98 @@
|
|
1
|
+
|
2
|
+
% --DESC: Royal Dutch TPG Post KIX 4-State Barcode
|
3
|
+
% --EXAM: 1231FZ13XHS
|
4
|
+
% --EXOP: includetext includecheckintext
|
5
|
+
% --RNDR: renlinear
|
6
|
+
/kix {
|
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
|
+
/includecheckintext false def
|
16
|
+
/textfont /Courier def
|
17
|
+
/textsize 10 def
|
18
|
+
/textyoffset -7 def
|
19
|
+
/height 0.175 def
|
20
|
+
|
21
|
+
% Parse the input options
|
22
|
+
options {
|
23
|
+
token false eq {exit} if dup length string cvs (=) search
|
24
|
+
true eq {cvlit exch pop exch def} {cvlit true def} ifelse
|
25
|
+
} loop
|
26
|
+
|
27
|
+
/textfont textfont cvlit def
|
28
|
+
/textsize textsize cvr def
|
29
|
+
/textyoffset textyoffset cvr def
|
30
|
+
/height height cvr def
|
31
|
+
|
32
|
+
% Create an array containing the character mappings
|
33
|
+
/encs
|
34
|
+
[ (0033) (0123) (0132) (1023) (1032) (1122)
|
35
|
+
(0213) (0303) (0312) (1203) (1212) (1302)
|
36
|
+
(0231) (0321) (0330) (1221) (1230) (1320)
|
37
|
+
(2013) (2103) (2112) (3003) (3012) (3102)
|
38
|
+
(2031) (2121) (2130) (3021) (3030) (3120)
|
39
|
+
(2211) (2301) (2310) (3201) (3210) (3300)
|
40
|
+
] def
|
41
|
+
|
42
|
+
% Create a string of the available characters
|
43
|
+
/barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ) def
|
44
|
+
|
45
|
+
/barlen barcode length def
|
46
|
+
/encstr barlen 4 mul string def
|
47
|
+
/txt barlen array def
|
48
|
+
|
49
|
+
0 1 barlen 1 sub {
|
50
|
+
/i exch def
|
51
|
+
% Lookup the encoding for the each barcode character
|
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
|
+
encstr i 4 mul enc putinterval
|
58
|
+
txt i [barcode i 1 getinterval i 4 mul 3.312 mul textyoffset textfont textsize] put
|
59
|
+
} for
|
60
|
+
|
61
|
+
/bbs encstr length array def
|
62
|
+
/bhs encstr length array def
|
63
|
+
0 1 encstr length 1 sub {
|
64
|
+
/i exch def
|
65
|
+
/enc encstr i 1 getinterval def
|
66
|
+
enc (0) eq {
|
67
|
+
bbs i 3 height mul 8 div put
|
68
|
+
bhs i 2 height mul 8 div put
|
69
|
+
} if
|
70
|
+
enc (1) eq {
|
71
|
+
bbs i 0 height mul 8 div put
|
72
|
+
bhs i 5 height mul 8 div put
|
73
|
+
} if
|
74
|
+
enc (2) eq {
|
75
|
+
bbs i 3 height mul 8 div put
|
76
|
+
bhs i 5 height mul 8 div put
|
77
|
+
} if
|
78
|
+
enc (3) eq {
|
79
|
+
bbs i 0 height mul 8 div put
|
80
|
+
bhs i 8 height mul 8 div put
|
81
|
+
} if
|
82
|
+
} for
|
83
|
+
|
84
|
+
/retval 8 dict def
|
85
|
+
retval (ren) (renlinear) put
|
86
|
+
retval (bbs) bbs put
|
87
|
+
retval (bhs) bhs put
|
88
|
+
retval (sbs) [bhs length 1 sub {1.44 1.872} repeat 1.44] put
|
89
|
+
includetext {
|
90
|
+
retval (txt) txt put
|
91
|
+
} if
|
92
|
+
retval (opt) useropts put
|
93
|
+
retval
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
} bind def
|
98
|
+
/kix load 0 1 dict put
|
@@ -0,0 +1,307 @@
|
|
1
|
+
|
2
|
+
% --DESC: MaxiCode
|
3
|
+
% --EXAM: ^059^042^041^059^040^03001^02996152382802^029840^029001^0291Z00004951^029UPSN^02906X610^029159^0291234567^0291^0471^029^029Y^029634 ALPHA DR^029PITTSBURGH^029PA^030^062^004^063
|
4
|
+
% --EXOP: mode=2
|
5
|
+
% --RNDR: renmaximatrix
|
6
|
+
/maxicode {
|
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
|
+
/mode 4 def
|
15
|
+
/sam -1 def
|
16
|
+
|
17
|
+
% Parse the input options
|
18
|
+
options {
|
19
|
+
token false eq {exit} if dup length string cvs (=) search
|
20
|
+
true eq {cvlit exch pop exch def} {cvlit true def} ifelse
|
21
|
+
} loop
|
22
|
+
|
23
|
+
/mode mode cvi def
|
24
|
+
/sam sam cvi def
|
25
|
+
|
26
|
+
/txtvals (@ABCDEFGHIJKLMNOPQRSTUVWXYZ@@@@@ @@@@@@@@@@@@@@@0123456789@@@@@@) def
|
27
|
+
|
28
|
+
% Parse a given message into codewords
|
29
|
+
/maxiparse {
|
30
|
+
/txt exch def
|
31
|
+
/out txt length array def
|
32
|
+
/i 0 def /j 0 def
|
33
|
+
{ % loop
|
34
|
+
i txt length eq {exit} if
|
35
|
+
txt i 1 getinterval (^) eq {
|
36
|
+
% Codeword is given by the next three characters
|
37
|
+
/cw txt i 1 add 3 getinterval cvi def
|
38
|
+
/i i 4 add def
|
39
|
+
} {
|
40
|
+
% Codeword is the characters position in txtvals
|
41
|
+
txtvals txt i 1 getinterval search
|
42
|
+
pop length /cw exch def pop pop
|
43
|
+
/i i 1 add def
|
44
|
+
} ifelse
|
45
|
+
out j cw put
|
46
|
+
/j j 1 add def
|
47
|
+
} loop
|
48
|
+
out 0 j getinterval
|
49
|
+
} bind def
|
50
|
+
|
51
|
+
% Calcalate the structured append mode insert
|
52
|
+
/sami () def
|
53
|
+
sam -1 ne {
|
54
|
+
/sami (^033^000) 8 string copy def
|
55
|
+
sam 10 idiv 1 sub 8 mul sam 10 mod 1 sub add 10 2 string cvrs
|
56
|
+
dup length 8 exch sub sami exch 3 -1 roll putinterval
|
57
|
+
} if
|
58
|
+
|
59
|
+
% Message handling for modes 2 and 3
|
60
|
+
mode 2 eq mode 3 eq or {
|
61
|
+
|
62
|
+
/msg barcode def
|
63
|
+
|
64
|
+
% Normalise messages that begin with a field identifier [)>RS01GSyy
|
65
|
+
msg (^059^042^041^059^040^03001^029) search {
|
66
|
+
pop
|
67
|
+
dup length 2 add string /fid exch def
|
68
|
+
fid 0 3 -1 roll putinterval
|
69
|
+
dup fid fid length 2 sub 3 -1 roll 0 2 getinterval putinterval
|
70
|
+
dup length 2 sub 2 exch getinterval /msg exch def
|
71
|
+
} {
|
72
|
+
pop
|
73
|
+
/fid () def
|
74
|
+
} ifelse
|
75
|
+
|
76
|
+
% Read the postcode, country code and service code fields
|
77
|
+
msg (^029) search pop /pc exch def
|
78
|
+
pop (^029) search pop /cc exch def
|
79
|
+
pop (^029) search pop /sc exch def
|
80
|
+
pop /msg exch def
|
81
|
+
|
82
|
+
% Calculate the fixed-width binary values for the mode, postcode, country code and service
|
83
|
+
/mdb (0000) 4 string copy dup mode cvi 2 4 string cvrs dup length 4 exch sub exch putinterval def
|
84
|
+
/ccb (0000000000) 10 string copy dup cc cvi 2 10 string cvrs dup length 10 exch sub exch putinterval def
|
85
|
+
/scb (0000000000) 10 string copy dup sc cvi 2 10 string cvrs dup length 10 exch sub exch putinterval def
|
86
|
+
/pcb (000000000000000000000000000000000000) 36 string copy def
|
87
|
+
mode 2 eq {
|
88
|
+
% For numeric postcode, first six bits represent length and remaining 30 bits the value
|
89
|
+
pcb pc length 2 6 string cvrs dup length 6 exch sub exch putinterval
|
90
|
+
pcb pc cvi 2 30 string cvrs dup length 36 exch sub exch putinterval
|
91
|
+
} { % mode=3
|
92
|
+
% For alphanumeric postcode, trim or pad with spaces to 6 chars and encode to binary
|
93
|
+
/pccw ( ) 6 string copy dup 0 pc length 6 gt {pc 0 6 getinterval} {pc} ifelse putinterval maxiparse def
|
94
|
+
0 1 5 {
|
95
|
+
/i exch def
|
96
|
+
pcb pccw i get 2 6 string cvrs dup length 6 i mul 6 add exch sub exch putinterval
|
97
|
+
} for
|
98
|
+
} ifelse
|
99
|
+
|
100
|
+
% Convolute the binary values into the structured carrier message
|
101
|
+
/scm 60 string def
|
102
|
+
scm 2 mdb putinterval
|
103
|
+
scm 38 pcb 0 4 getinterval putinterval
|
104
|
+
scm 30 pcb 4 6 getinterval putinterval
|
105
|
+
scm 24 pcb 10 6 getinterval putinterval
|
106
|
+
scm 18 pcb 16 6 getinterval putinterval
|
107
|
+
scm 12 pcb 22 6 getinterval putinterval
|
108
|
+
scm 6 pcb 28 6 getinterval putinterval
|
109
|
+
scm 0 pcb 34 2 getinterval putinterval
|
110
|
+
scm 52 ccb 0 2 getinterval putinterval
|
111
|
+
scm 42 ccb 2 6 getinterval putinterval
|
112
|
+
scm 36 ccb 8 2 getinterval putinterval
|
113
|
+
scm 54 scb 0 6 getinterval putinterval
|
114
|
+
scm 48 scb 6 4 getinterval putinterval
|
115
|
+
|
116
|
+
% Evaluate the structured carrier message as codewords
|
117
|
+
/pri [ 0 0 0 0 0 0 0 0 0 0 ] def
|
118
|
+
0 1 59 {
|
119
|
+
/i exch def
|
120
|
+
/ps i 6 idiv def
|
121
|
+
/ep 2 5 i 6 mod sub exp cvi scm i get 48 sub mul def
|
122
|
+
pri ps pri ps get ep add put
|
123
|
+
} for
|
124
|
+
|
125
|
+
% Encode the secondary parts, including any SAM insert and field identifier
|
126
|
+
/sec [ 84 {33} repeat ] def
|
127
|
+
sec 0 [ sami maxiparse {} forall fid maxiparse {} forall msg maxiparse {} forall ] putinterval
|
128
|
+
|
129
|
+
} if
|
130
|
+
|
131
|
+
% Message handling for modes 4, 5 and 6
|
132
|
+
mode 4 eq mode 5 eq or mode 6 eq or {
|
133
|
+
|
134
|
+
% Prefix the message with the structured append insert
|
135
|
+
/msg sami length barcode length add string def
|
136
|
+
msg 0 sami putinterval
|
137
|
+
msg sami length barcode putinterval
|
138
|
+
|
139
|
+
% First symbol is the mode and the remainder are the padded message
|
140
|
+
/cws [ mode 5 eq {78} {94} ifelse {33} repeat ] def
|
141
|
+
cws 0 mode put
|
142
|
+
cws 1 msg maxiparse putinterval
|
143
|
+
|
144
|
+
% Fit the message into the primary and secondary components
|
145
|
+
/pri cws 0 10 getinterval def
|
146
|
+
/sec cws 10 cws length 10 sub getinterval def
|
147
|
+
|
148
|
+
} if
|
149
|
+
|
150
|
+
% Create the 64x64 Reed-Solomon table
|
151
|
+
/rstable 64 64 mul array def
|
152
|
+
rstable 0 [ 64 {0} repeat ] putinterval
|
153
|
+
rstable 64 [ 0 1 63 {} for ] putinterval
|
154
|
+
/prev 1 def
|
155
|
+
64 {
|
156
|
+
/next prev 1 bitshift def
|
157
|
+
next 64 and 0 ne {
|
158
|
+
/next next 67 xor def
|
159
|
+
} if
|
160
|
+
0 1 63 {
|
161
|
+
/j exch def
|
162
|
+
/nextcell {rstable 64 next mul j add} def
|
163
|
+
nextcell rstable 64 prev mul j add get 1 bitshift put
|
164
|
+
nextcell get 64 and 0 ne {
|
165
|
+
nextcell nextcell get 67 xor put
|
166
|
+
} if
|
167
|
+
} for
|
168
|
+
/prev next def
|
169
|
+
} repeat
|
170
|
+
|
171
|
+
% Calculate the parity codewords for primary codewords
|
172
|
+
/pgen [46 44 49 3 2 57 42 39 28 31 1] def
|
173
|
+
/rscodes [ 10 {0} repeat 9 -1 0 { pri exch get } for ] def
|
174
|
+
rscodes length 11 sub -1 0 {
|
175
|
+
/i exch def
|
176
|
+
0 1 10 {
|
177
|
+
/j exch def
|
178
|
+
rscodes i j add rscodes i j add get
|
179
|
+
rstable 64 pgen j get mul rscodes i 10 add get add get
|
180
|
+
xor put
|
181
|
+
} for
|
182
|
+
} for
|
183
|
+
/prichk [ 9 -1 0 { rscodes exch get } for ] def
|
184
|
+
|
185
|
+
% Split secondary codeword into odd and even elements
|
186
|
+
/seco [ 0 2 sec length 1 sub { sec exch get } for ] def
|
187
|
+
/sece [ 1 2 sec length 1 sub { sec exch get } for ] def
|
188
|
+
|
189
|
+
% Calculate the parity codewords for secondary codeword parts based on mode
|
190
|
+
sec length 84 eq { % SEC mode
|
191
|
+
/sgen [ 59 23 19 31 33 38 17 22 48 15 36 57 37 22 8 27 33 11 44 23 1 ] def
|
192
|
+
} { % EEC mode
|
193
|
+
/sgen [ 28 11 20 7 43 9 41 34 49 46 37 40 55 34 45 61 13 23 29 22 10 35 55 41 10 53 45 22 1 ] def
|
194
|
+
} ifelse
|
195
|
+
/scodes sgen length 1 sub def
|
196
|
+
/rscodes [ scodes {0} repeat seco length 1 sub -1 0 { seco exch get } for ] def
|
197
|
+
rscodes length scodes sub 1 sub -1 0 {
|
198
|
+
/i exch def
|
199
|
+
0 1 scodes {
|
200
|
+
/j exch def
|
201
|
+
rscodes i j add rscodes i j add get
|
202
|
+
rstable 64 sgen j get mul rscodes i scodes add get add get
|
203
|
+
xor put
|
204
|
+
} for
|
205
|
+
} for
|
206
|
+
/secochk [ scodes 1 sub -1 0 { rscodes exch get } for ] def
|
207
|
+
/rscodes [ scodes {0} repeat sece length 1 sub -1 0 { sece exch get } for ] def
|
208
|
+
rscodes length scodes sub 1 sub -1 0 {
|
209
|
+
/i exch def
|
210
|
+
0 1 scodes {
|
211
|
+
/j exch def
|
212
|
+
rscodes i j add rscodes i j add get
|
213
|
+
rstable 64 sgen j get mul rscodes i scodes add get add get
|
214
|
+
xor put
|
215
|
+
} for
|
216
|
+
} for
|
217
|
+
/secechk [ scodes 1 sub -1 0 { rscodes exch get } for ] def
|
218
|
+
|
219
|
+
% Recompose the secondary parity codewords
|
220
|
+
/secchk [ 0 1 scodes 1 sub { dup secochk exch get exch secechk exch get } for ] def
|
221
|
+
|
222
|
+
% Concatinate the data into final codewords
|
223
|
+
/codewords [
|
224
|
+
pri {} forall
|
225
|
+
prichk {} forall
|
226
|
+
sec {} forall
|
227
|
+
secchk {} forall
|
228
|
+
] def
|
229
|
+
|
230
|
+
% Convert the codewords into module bits
|
231
|
+
/mods [ 864 {0} repeat ] def
|
232
|
+
0 1 143 {
|
233
|
+
/i exch def
|
234
|
+
/cw [ codewords i get 2 6 string cvrs {48 sub} forall ] def
|
235
|
+
mods 6 i mul 6 cw length sub add cw putinterval
|
236
|
+
} for
|
237
|
+
|
238
|
+
% Maps modules to pixels in the grid
|
239
|
+
/modmap [
|
240
|
+
469 529 286 316 347 346 673 672 703 702 647 676 283 282 313 312 370 610 618 379
|
241
|
+
378 409 408 439 705 704 559 589 588 619 458 518 640 701 675 674 285 284 315 314
|
242
|
+
310 340 531 289 288 319 349 348 456 486 517 516 471 470 369 368 399 398 429 428
|
243
|
+
549 548 579 578 609 608 649 648 679 678 709 708 639 638 669 668 699 698 279 278
|
244
|
+
309 308 339 338 381 380 411 410 441 440 561 560 591 590 621 620 547 546 577 576
|
245
|
+
607 606 367 366 397 396 427 426 291 290 321 320 351 350 651 650 681 680 711 710
|
246
|
+
1 0 31 30 61 60 3 2 33 32 63 62 5 4 35 34 65 64 7 6
|
247
|
+
37 36 67 66 9 8 39 38 69 68 11 10 41 40 71 70 13 12 43 42
|
248
|
+
73 72 15 14 45 44 75 74 17 16 47 46 77 76 19 18 49 48 79 78
|
249
|
+
21 20 51 50 81 80 23 22 53 52 83 82 25 24 55 54 85 84 27 26
|
250
|
+
57 56 87 86 117 116 147 146 177 176 115 114 145 144 175 174 113 112 143 142
|
251
|
+
173 172 111 110 141 140 171 170 109 108 139 138 169 168 107 106 137 136 167 166
|
252
|
+
105 104 135 134 165 164 103 102 133 132 163 162 101 100 131 130 161 160 99 98
|
253
|
+
129 128 159 158 97 96 127 126 157 156 95 94 125 124 155 154 93 92 123 122
|
254
|
+
153 152 91 90 121 120 151 150 181 180 211 210 241 240 183 182 213 212 243 242
|
255
|
+
185 184 215 214 245 244 187 186 217 216 247 246 189 188 219 218 249 248 191 190
|
256
|
+
221 220 251 250 193 192 223 222 253 252 195 194 225 224 255 254 197 196 227 226
|
257
|
+
257 256 199 198 229 228 259 258 201 200 231 230 261 260 203 202 233 232 263 262
|
258
|
+
205 204 235 234 265 264 207 206 237 236 267 266 297 296 327 326 357 356 295 294
|
259
|
+
325 324 355 354 293 292 323 322 353 352 277 276 307 306 337 336 275 274 305 304
|
260
|
+
335 334 273 272 303 302 333 332 271 270 301 300 331 330 361 360 391 390 421 420
|
261
|
+
363 362 393 392 423 422 365 364 395 394 425 424 383 382 413 412 443 442 385 384
|
262
|
+
415 414 445 444 387 386 417 416 447 446 477 476 507 506 537 536 475 474 505 504
|
263
|
+
535 534 473 472 503 502 533 532 455 454 485 484 515 514 453 452 483 482 513 512
|
264
|
+
451 450 481 480 511 510 541 540 571 570 601 600 543 542 573 572 603 602 545 544
|
265
|
+
575 574 605 604 563 562 593 592 623 622 565 564 595 594 625 624 567 566 597 596
|
266
|
+
627 626 657 656 687 686 717 716 655 654 685 684 715 714 653 652 683 682 713 712
|
267
|
+
637 636 667 666 697 696 635 634 665 664 695 694 633 632 663 662 693 692 631 630
|
268
|
+
661 660 691 690 721 720 751 750 781 780 723 722 753 752 783 782 725 724 755 754
|
269
|
+
785 784 727 726 757 756 787 786 729 728 759 758 789 788 731 730 761 760 791 790
|
270
|
+
733 732 763 762 793 792 735 734 765 764 795 794 737 736 767 766 797 796 739 738
|
271
|
+
769 768 799 798 741 740 771 770 801 800 743 742 773 772 803 802 745 744 775 774
|
272
|
+
805 804 747 746 777 776 807 806 837 836 867 866 897 896 835 834 865 864 895 894
|
273
|
+
833 832 863 862 893 892 831 830 861 860 891 890 829 828 859 858 889 888 827 826
|
274
|
+
857 856 887 886 825 824 855 854 885 884 823 822 853 852 883 882 821 820 851 850
|
275
|
+
881 880 819 818 849 848 879 878 817 816 847 846 877 876 815 814 845 844 875 874
|
276
|
+
813 812 843 842 873 872 811 810 841 840 871 870 901 900 931 930 961 960 903 902
|
277
|
+
933 932 963 962 905 904 935 934 965 964 907 906 937 936 967 966 909 908 939 938
|
278
|
+
969 968 911 910 941 940 971 970 913 912 943 942 973 972 915 914 945 944 975 974
|
279
|
+
917 916 947 946 977 976 919 918 949 948 979 978 921 920 951 950 981 980 923 922
|
280
|
+
953 952 983 982 925 924 955 954 985 984 927 926 957 956 987 986 58 89 88 118
|
281
|
+
149 148 178 209 208 238 269 268 298 329 328 358 389 388 418 449 448 478 509 508
|
282
|
+
538 569 568 598 629 628 658 689 688 718 749 748 778 809 808 838 869 868 898 929
|
283
|
+
928 958 989 988
|
284
|
+
] def
|
285
|
+
|
286
|
+
% Lookup pixels for enabled modules from modmap
|
287
|
+
/pixs 864 array def
|
288
|
+
/j 0 def
|
289
|
+
0 1 mods length 1 sub {
|
290
|
+
/i exch def
|
291
|
+
mods i get 1 eq {
|
292
|
+
pixs j modmap i get put
|
293
|
+
/j j 1 add def
|
294
|
+
} if
|
295
|
+
} for
|
296
|
+
/pixs [ pixs 0 j getinterval {} forall 28 29 280 281 311 457 488 500 530 670 700 677 707 ] def
|
297
|
+
|
298
|
+
/retval 3 dict def
|
299
|
+
retval (ren) (renmaximatrix) put
|
300
|
+
retval (pixs) pixs put
|
301
|
+
retval (opt) useropts put
|
302
|
+
retval
|
303
|
+
|
304
|
+
end
|
305
|
+
|
306
|
+
} bind def
|
307
|
+
/maxicode load 0 1 dict put
|