rghost_barcode 0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. data/lib/doc/classes/RGhost.html +109 -0
  2. data/lib/doc/classes/RGhost/Barcode.html +147 -0
  3. data/lib/doc/classes/RGhost/Barcode/Auspost.html +113 -0
  4. data/lib/doc/classes/RGhost/Barcode/Azteccode.html +113 -0
  5. data/lib/doc/classes/RGhost/Barcode/Base.html +266 -0
  6. data/lib/doc/classes/RGhost/Barcode/Base.src/M000004.html +34 -0
  7. data/lib/doc/classes/RGhost/Barcode/Base.src/M000005.html +30 -0
  8. data/lib/doc/classes/RGhost/Barcode/Base.src/M000006.html +20 -0
  9. data/lib/doc/classes/RGhost/Barcode/Border.html +170 -0
  10. data/lib/doc/classes/RGhost/Barcode/Border.src/M000001.html +27 -0
  11. data/lib/doc/classes/RGhost/Barcode/Code11.html +113 -0
  12. data/lib/doc/classes/RGhost/Barcode/Code128.html +113 -0
  13. data/lib/doc/classes/RGhost/Barcode/Code2of5.html +113 -0
  14. data/lib/doc/classes/RGhost/Barcode/Code39.html +113 -0
  15. data/lib/doc/classes/RGhost/Barcode/Code93.html +113 -0
  16. data/lib/doc/classes/RGhost/Barcode/Datamatrix.html +113 -0
  17. data/lib/doc/classes/RGhost/Barcode/Ean13.html +113 -0
  18. data/lib/doc/classes/RGhost/Barcode/Ean2.html +113 -0
  19. data/lib/doc/classes/RGhost/Barcode/Ean5.html +113 -0
  20. data/lib/doc/classes/RGhost/Barcode/Ean8.html +113 -0
  21. data/lib/doc/classes/RGhost/Barcode/Guard.html +174 -0
  22. data/lib/doc/classes/RGhost/Barcode/Guard.src/M000003.html +27 -0
  23. data/lib/doc/classes/RGhost/Barcode/Interleaved2of5.html +113 -0
  24. data/lib/doc/classes/RGhost/Barcode/Isbn.html +113 -0
  25. data/lib/doc/classes/RGhost/Barcode/Kix.html +113 -0
  26. data/lib/doc/classes/RGhost/Barcode/Maxicode.html +113 -0
  27. data/lib/doc/classes/RGhost/Barcode/Msi.html +113 -0
  28. data/lib/doc/classes/RGhost/Barcode/Onecode.html +113 -0
  29. data/lib/doc/classes/RGhost/Barcode/Parameter.html +262 -0
  30. data/lib/doc/classes/RGhost/Barcode/Parameter.src/M000007.html +20 -0
  31. data/lib/doc/classes/RGhost/Barcode/Parameter.src/M000008.html +18 -0
  32. data/lib/doc/classes/RGhost/Barcode/Parameter.src/M000009.html +18 -0
  33. data/lib/doc/classes/RGhost/Barcode/Parameter.src/M000010.html +18 -0
  34. data/lib/doc/classes/RGhost/Barcode/Parameter.src/M000011.html +18 -0
  35. data/lib/doc/classes/RGhost/Barcode/Parameter.src/M000012.html +24 -0
  36. data/lib/doc/classes/RGhost/Barcode/Parameter.src/M000013.html +18 -0
  37. data/lib/doc/classes/RGhost/Barcode/Parameter.src/M000014.html +18 -0
  38. data/lib/doc/classes/RGhost/Barcode/Parameter.src/M000015.html +16 -0
  39. data/lib/doc/classes/RGhost/Barcode/Pdf417.html +113 -0
  40. data/lib/doc/classes/RGhost/Barcode/Pharmacode.html +113 -0
  41. data/lib/doc/classes/RGhost/Barcode/Plessey.html +113 -0
  42. data/lib/doc/classes/RGhost/Barcode/Postnet.html +113 -0
  43. data/lib/doc/classes/RGhost/Barcode/Qrcode.html +113 -0
  44. data/lib/doc/classes/RGhost/Barcode/Rationalizedcodabar.html +113 -0
  45. data/lib/doc/classes/RGhost/Barcode/Raw.html +113 -0
  46. data/lib/doc/classes/RGhost/Barcode/Royalmail.html +113 -0
  47. data/lib/doc/classes/RGhost/Barcode/Rss14.html +113 -0
  48. data/lib/doc/classes/RGhost/Barcode/Rssexpanded.html +113 -0
  49. data/lib/doc/classes/RGhost/Barcode/Rsslimited.html +113 -0
  50. data/lib/doc/classes/RGhost/Barcode/Symbol.html +113 -0
  51. data/lib/doc/classes/RGhost/Barcode/Text.html +193 -0
  52. data/lib/doc/classes/RGhost/Barcode/Text.src/M000002.html +30 -0
  53. data/lib/doc/classes/RGhost/Barcode/Upca.html +113 -0
  54. data/lib/doc/classes/RGhost/Barcode/Upce.html +113 -0
  55. data/lib/doc/classes/RGhost/Config.html +150 -0
  56. data/lib/doc/classes/RGhost/Config.src/M000016.html +45 -0
  57. data/lib/doc/classes/RGhost/Document.html +704 -0
  58. data/lib/doc/classes/RGhost/Document.src/M000017.html +19 -0
  59. data/lib/doc/classes/RGhost/Document.src/M000018.html +18 -0
  60. data/lib/doc/classes/RGhost/Document.src/M000019.html +18 -0
  61. data/lib/doc/classes/RGhost/Document.src/M000020.html +18 -0
  62. data/lib/doc/classes/RGhost/Document.src/M000021.html +18 -0
  63. data/lib/doc/classes/RGhost/Document.src/M000022.html +18 -0
  64. data/lib/doc/classes/RGhost/Document.src/M000023.html +18 -0
  65. data/lib/doc/classes/RGhost/Document.src/M000024.html +18 -0
  66. data/lib/doc/classes/RGhost/Document.src/M000025.html +18 -0
  67. data/lib/doc/classes/RGhost/Document.src/M000026.html +18 -0
  68. data/lib/doc/classes/RGhost/Document.src/M000027.html +18 -0
  69. data/lib/doc/classes/RGhost/Document.src/M000028.html +18 -0
  70. data/lib/doc/classes/RGhost/Document.src/M000029.html +18 -0
  71. data/lib/doc/classes/RGhost/Document.src/M000030.html +18 -0
  72. data/lib/doc/classes/RGhost/Document.src/M000031.html +18 -0
  73. data/lib/doc/classes/RGhost/Document.src/M000032.html +18 -0
  74. data/lib/doc/classes/RGhost/Document.src/M000033.html +18 -0
  75. data/lib/doc/classes/RGhost/Document.src/M000034.html +18 -0
  76. data/lib/doc/classes/RGhost/Document.src/M000035.html +18 -0
  77. data/lib/doc/classes/RGhost/Document.src/M000036.html +18 -0
  78. data/lib/doc/classes/RGhost/Document.src/M000037.html +18 -0
  79. data/lib/doc/classes/RGhost/Document.src/M000038.html +18 -0
  80. data/lib/doc/classes/RGhost/Document.src/M000039.html +18 -0
  81. data/lib/doc/classes/RGhost/Document.src/M000040.html +18 -0
  82. data/lib/doc/classes/RGhost/Document.src/M000041.html +18 -0
  83. data/lib/doc/classes/RGhost/Document.src/M000042.html +18 -0
  84. data/lib/doc/classes/RGhost/Document.src/M000043.html +18 -0
  85. data/lib/doc/classes/RGhost/Document.src/M000044.html +18 -0
  86. data/lib/doc/classes/RGhost/Document.src/M000045.html +18 -0
  87. data/lib/doc/classes/RGhost/Document.src/M000046.html +18 -0
  88. data/lib/doc/classes/RGhost/Document.src/M000047.html +18 -0
  89. data/lib/doc/classes/RGhost/Document.src/M000048.html +18 -0
  90. data/lib/doc/created.rid +1 -0
  91. data/lib/doc/files/rghost_barcode/rghost_barcode_adapter_rb.html +101 -0
  92. data/lib/doc/files/rghost_barcode/rghost_barcode_base_rb.html +101 -0
  93. data/lib/doc/files/rghost_barcode/rghost_barcode_classes_rb.html +101 -0
  94. data/lib/doc/files/rghost_barcode/rghost_barcode_examples_rb.html +101 -0
  95. data/lib/doc/files/rghost_barcode/rghost_barcode_version_rb.html +101 -0
  96. data/lib/doc/files/rghost_barcode_rb.html +111 -0
  97. data/lib/doc/files/teste_main_rb.html +110 -0
  98. data/lib/doc/fr_class_index.html +67 -0
  99. data/lib/doc/fr_file_index.html +33 -0
  100. data/lib/doc/fr_method_index.html +74 -0
  101. data/lib/doc/index.html +24 -0
  102. data/lib/rghost_barcode.rb +7 -0
  103. data/lib/rghost_barcode/ps/auspost.ps +192 -0
  104. data/lib/rghost_barcode/ps/azteccode.ps +357 -0
  105. data/lib/rghost_barcode/ps/barcode_template.eps +1193 -0
  106. data/lib/rghost_barcode/ps/code11.ps +128 -0
  107. data/lib/rghost_barcode/ps/code128.ps +121 -0
  108. data/lib/rghost_barcode/ps/code2of5.ps +106 -0
  109. data/lib/rghost_barcode/ps/code39.ps +109 -0
  110. data/lib/rghost_barcode/ps/code93.ps +117 -0
  111. data/lib/rghost_barcode/ps/datamatrix.ps +328 -0
  112. data/lib/rghost_barcode/ps/ean13.ps +183 -0
  113. data/lib/rghost_barcode/ps/ean2.ps +101 -0
  114. data/lib/rghost_barcode/ps/ean5.ps +116 -0
  115. data/lib/rghost_barcode/ps/ean8.ps +101 -0
  116. data/lib/rghost_barcode/ps/interleaved2of5.ps +132 -0
  117. data/lib/rghost_barcode/ps/isbn.ps +118 -0
  118. data/lib/rghost_barcode/ps/kix.ps +98 -0
  119. data/lib/rghost_barcode/ps/maxicode.ps +307 -0
  120. data/lib/rghost_barcode/ps/msi.ps +104 -0
  121. data/lib/rghost_barcode/ps/onecode.ps +276 -0
  122. data/lib/rghost_barcode/ps/pdf417.ps +428 -0
  123. data/lib/rghost_barcode/ps/pharmacode.ps +69 -0
  124. data/lib/rghost_barcode/ps/plessey.ps +121 -0
  125. data/lib/rghost_barcode/ps/postnet.ps +114 -0
  126. data/lib/rghost_barcode/ps/qrcode.ps +530 -0
  127. data/lib/rghost_barcode/ps/rationalizedcodabar.ps +117 -0
  128. data/lib/rghost_barcode/ps/raw.ps +35 -0
  129. data/lib/rghost_barcode/ps/render.ps +307 -0
  130. data/lib/rghost_barcode/ps/render.ps~ +308 -0
  131. data/lib/rghost_barcode/ps/royalmail.ps +119 -0
  132. data/lib/rghost_barcode/ps/rss14.ps +237 -0
  133. data/lib/rghost_barcode/ps/rssexpanded.ps +211 -0
  134. data/lib/rghost_barcode/ps/rsslimited.ps +191 -0
  135. data/lib/rghost_barcode/ps/symbol.ps +49 -0
  136. data/lib/rghost_barcode/ps/upca.ps +128 -0
  137. data/lib/rghost_barcode/ps/upce.ps +157 -0
  138. data/lib/rghost_barcode/rghost_barcode_adapter.rb +249 -0
  139. data/lib/rghost_barcode/rghost_barcode_base.rb +210 -0
  140. data/lib/rghost_barcode/rghost_barcode_classes.rb +96 -0
  141. data/lib/rghost_barcode/rghost_barcode_examples.rb +35 -0
  142. data/lib/rghost_barcode/rghost_barcode_version.rb +8 -0
  143. data/lib/teste_main.rb +94 -0
  144. metadata +218 -0
@@ -0,0 +1,117 @@
1
+
2
+ % --DESC: Code 93
3
+ % --EXAM: THIS IS CODE 93
4
+ % --EXOP: includetext includecheck
5
+ % --RNDR: renlinear
6
+ /code93 {
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
+ /textfont /Courier def
17
+ /textsize 10 def
18
+ /textyoffset -7 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
+ /textfont textfont cvlit def
28
+ /textsize textsize cvr def
29
+ /textyoffset textyoffset cvr def
30
+ /height height cvr def
31
+
32
+ /encs
33
+ [ (131112) (111213) (111312) (111411) (121113)
34
+ (121212) (121311) (111114) (131211) (141111)
35
+ (211113) (211212) (211311) (221112) (221211)
36
+ (231111) (112113) (112212) (112311) (122112)
37
+ (132111) (111123) (111222) (111321) (121122)
38
+ (131121) (212112) (212211) (211122) (211221)
39
+ (221121) (222111) (112122) (112221) (122121)
40
+ (123111) (121131) (311112) (311211) (321111)
41
+ (112131) (113121) (211131) (121221) (312111)
42
+ (311121) (122211) (111141) (1111411)
43
+ ] def
44
+
45
+ % Create a string of the available characters
46
+ /barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def
47
+
48
+ /barlen barcode length def % Length of the code
49
+ barcode {
50
+ (^) search false eq {pop exit} if
51
+ pop pop /barlen barlen 3 sub def
52
+ } loop
53
+
54
+ includecheck {
55
+ /sbs barlen 6 mul 25 add string def
56
+ } {
57
+ /sbs barlen 6 mul 13 add string def
58
+ } ifelse
59
+ /txt barlen array def
60
+
61
+ % Put the start character
62
+ sbs 0 encs 47 get putinterval
63
+
64
+ /checksum1 0 def /checksum2 0 def
65
+
66
+ /i 0 def /j 0 def
67
+ { % loop
68
+ j barlen eq {exit} if
69
+ barcode i 1 getinterval (^) eq {
70
+ % indx is given by the next three characters
71
+ /indx barcode i 1 add 3 getinterval cvi def
72
+ txt j [( ) j 9 mul 9 add textyoffset textfont textsize] put
73
+ /i i 4 add def
74
+ } {
75
+ barchars barcode i 1 getinterval search
76
+ pop % Discard true leaving pre
77
+ length /indx exch def % indx is the length of pre
78
+ pop pop % Discard seek and post
79
+ txt j [barchars indx 1 getinterval j 9 mul 9 add textyoffset textfont textsize] put
80
+ /i i 1 add def
81
+ } ifelse
82
+ /enc encs indx get def % Get the indxth encoding
83
+ sbs j 6 mul 6 add enc putinterval % Put encoded digit into sbs
84
+ /checksum1 checksum1 barlen j sub 1 sub 20 mod 1 add indx mul add def
85
+ /checksum2 checksum2 barlen j sub 15 mod 1 add indx mul add def
86
+ /j j 1 add def
87
+ } loop
88
+
89
+ includecheck {
90
+ % Put the first checksum character
91
+ /checksum1 checksum1 47 mod def
92
+ /checksum2 checksum2 checksum1 add 47 mod def
93
+ sbs j 6 mul 6 add encs checksum1 get putinterval
94
+ sbs j 6 mul 12 add encs checksum2 get putinterval
95
+ % Put the end character
96
+ sbs j 6 mul 18 add encs 48 get putinterval
97
+ } {
98
+ % Put the end character
99
+ sbs j 6 mul 6 add encs 48 get putinterval
100
+ } ifelse
101
+
102
+ % Return the arguments
103
+ /retval 8 dict def
104
+ retval (ren) (renlinear) put
105
+ retval (sbs) [sbs {48 sub} forall] put
106
+ retval (bhs) [sbs length 1 add 2 idiv {height} repeat] put
107
+ retval (bbs) [sbs length 1 add 2 idiv {0} repeat] put
108
+ includetext {
109
+ retval (txt) txt put
110
+ } if
111
+ retval (opt) useropts put
112
+ retval
113
+
114
+ end
115
+
116
+ } bind def
117
+ /code93 load 0 1 dict put
@@ -0,0 +1,328 @@
1
+
2
+ % --DESC: Data Matrix
3
+ % --EXAM: ^142^164^186
4
+ % --EXOP: rows=32 columns=32
5
+ % --RNDR: renmatrix
6
+ /datamatrix {
7
+
8
+ 0 begin
9
+
10
+ /options exch def
11
+ /useropts options def
12
+ /barcode exch def
13
+
14
+ /columns 0 def
15
+ /rows 0 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
+ /columns columns cvi def
24
+ /rows rows cvi def
25
+
26
+ % Split the input barcode into an array of codewords
27
+ /cws barcode length array def
28
+ /i 0 def /j 0 def
29
+ { % loop
30
+ i barcode length eq {exit} if
31
+ /cw barcode i 1 add 3 getinterval cvi def
32
+ cws j cw put
33
+ /i i 4 add def
34
+ /j j 1 add def
35
+ } loop
36
+ /cws cws 0 j getinterval def
37
+
38
+ % Basic metrics for the each symbol
39
+ % rows cols regh regv rscw rsbl
40
+ /metrics [
41
+ % Standard square symbols
42
+ [ 10 10 1 1 5 1 ]
43
+ [ 12 12 1 1 7 1 ]
44
+ [ 14 14 1 1 10 1 ]
45
+ [ 16 16 1 1 12 1 ]
46
+ [ 18 18 1 1 14 1 ]
47
+ [ 20 20 1 1 18 1 ]
48
+ [ 22 22 1 1 20 1 ]
49
+ [ 24 24 1 1 24 1 ]
50
+ [ 26 26 1 1 28 1 ]
51
+ [ 32 32 2 2 36 1 ]
52
+ [ 36 36 2 2 42 1 ]
53
+ [ 40 40 2 2 48 1 ]
54
+ [ 44 44 2 2 56 1 ]
55
+ [ 48 48 2 2 68 1 ]
56
+ [ 52 52 2 2 84 2 ]
57
+ [ 64 64 4 4 112 2 ]
58
+ [ 72 72 4 4 144 4 ]
59
+ [ 80 80 4 4 192 4 ]
60
+ [ 88 88 4 4 224 4 ]
61
+ [ 96 96 4 4 272 4 ]
62
+ [ 104 104 4 4 336 6 ]
63
+ [ 120 120 6 6 408 6 ]
64
+ [ 132 132 6 6 496 8 ]
65
+ [ 144 144 6 6 620 10 ]
66
+ % Optional rectangular symbols
67
+ [ 8 18 1 1 7 1 ]
68
+ [ 8 32 1 2 11 1 ]
69
+ [ 12 26 1 1 14 1 ]
70
+ [ 12 36 1 2 18 1 ]
71
+ [ 16 36 1 2 24 1 ]
72
+ [ 16 48 1 2 28 1 ]
73
+ ] def
74
+
75
+ % Select metrics of an appropriate symbol
76
+ /urows rows def
77
+ /ucols columns def
78
+ /i 0 def
79
+ { % loop
80
+ /m metrics i get def
81
+ /rows m 0 get def % Rows in symbol
82
+ /cols m 1 get def % Columns in symbol
83
+ /regh m 2 get def % Horizontal regions
84
+ /regv m 3 get def % Vertical regions
85
+ /rscw m 4 get def % Error correction codewords
86
+ /rsbl m 5 get def % Error correction blocks
87
+ /mrows rows 2 regh mul sub def % Rows in the mapping matrix
88
+ /mcols cols 2 regv mul sub def % Columns in the mapping matrix
89
+ /rrows mrows regh idiv def % Rows per region
90
+ /rcols mcols regv idiv def % Columns per region
91
+ /ncws mrows mcols mul 8 idiv rscw sub def % Data codewords
92
+ /okay true def
93
+ cws length ncws gt {/okay false def} if
94
+ urows 0 ne urows rows ne and {/okay false def} if
95
+ ucols 0 ne ucols cols ne and {/okay false def} if
96
+ okay {exit} if
97
+ /i i 1 add def
98
+ } loop
99
+
100
+ % Extend cws to ncws codewords by addition of pseudo-randomised pad characters
101
+ cws length ncws lt {
102
+ /datlen cws length def
103
+ /cws [ cws {} forall ncws datlen sub {129} repeat ] def
104
+ datlen 1 add 1 ncws 1 sub {
105
+ /i exch def
106
+ i 1 add 149 mul 253 mod 1 add 129 add
107
+ dup 254 gt {254 sub} if
108
+ cws exch i exch put
109
+ } for
110
+ } if
111
+
112
+ % De-interleave the codewords into blocks
113
+ /cwbs rsbl array def % Array of data codeword blocks
114
+ /ecbs rsbl array def % Array of error correction blocks
115
+ 0 1 rsbl 1 sub {
116
+ /i exch def
117
+ cws length 1558 ne {
118
+ /cwbsize cws length rsbl idiv def
119
+ } {
120
+ i 7 le {/cwbsize 156 def} {/cwbsize 155 def} ifelse
121
+ } ifelse
122
+ /cwb cwbsize array def
123
+ 0 1 cwbsize 1 sub {
124
+ /j exch def
125
+ cwb j cws j rsbl mul i add get put
126
+ } for
127
+ cwbs i cwb put
128
+ ecbs i [ rscw rsbl idiv {0} repeat ] put
129
+ } for
130
+
131
+ % Calculate the log and anti-log tables
132
+ /rslog [ -255 255 {0} repeat ] def
133
+ /rsalog [ 1 255 {0} repeat ] def
134
+ 1 1 255 {
135
+ /i exch def
136
+ rsalog i rsalog i 1 sub get 2 mul put
137
+ rsalog i get 256 ge { rsalog i rsalog i get 301 xor put } if
138
+ rslog rsalog i get i put
139
+ } for
140
+
141
+ % Function to calculate the product in the field
142
+ /rsprod {
143
+ /y exch def
144
+ /x exch def
145
+ x y mul 0 ne {
146
+ rsalog rslog x get rslog y get add 255 mod get
147
+ } {
148
+ 0
149
+ } ifelse
150
+ } bind def
151
+
152
+ % Generate the coefficients
153
+ /coeffs [ 1 rscw rsbl idiv {0} repeat ] def
154
+ 1 1 rscw rsbl idiv {
155
+ /i exch def
156
+ coeffs i coeffs i 1 sub get put
157
+ i 1 sub -1 1 {
158
+ /j exch def
159
+ coeffs j coeffs j 1 sub get coeffs j get rsalog i get rsprod xor put
160
+ } for
161
+ coeffs 0 coeffs 0 get rsalog i get rsprod put
162
+ } for
163
+ /coeffs coeffs 0 coeffs length 1 sub getinterval def
164
+
165
+ % Calculate the error correction codewords for each block
166
+ 0 1 cwbs length 1 sub {
167
+ /i exch def
168
+ /cwb cwbs i get def
169
+ /ecb ecbs i get def
170
+ 0 1 cwb length 1 sub {
171
+ /t exch cwb exch get ecb 0 get xor def
172
+ ecb length 1 sub -1 0 {
173
+ /j exch def
174
+ /p ecb length j sub 1 sub def
175
+ t 0 eq {
176
+ ecb p 0 put
177
+ } {
178
+ ecb p rsalog rslog t get rslog coeffs j get get add 255 mod get put
179
+ } ifelse
180
+ j 0 gt { ecb p ecb p 1 add get ecb p get xor put } if
181
+ } for
182
+ } for
183
+ ecbs i ecb put
184
+ } for
185
+
186
+ % Extend codewords with the interleaved error correction codes
187
+ /cws [ cws {} forall rscw {0} repeat ] def
188
+ 0 1 rscw 1 sub {
189
+ /i exch def
190
+ cws ncws i add ecbs i rsbl mod get i rsbl idiv get put
191
+ } for
192
+
193
+ % Create the module placement matrix
194
+ /module {
195
+ /tmpc exch def
196
+ /tmpr exch def
197
+ tmpr 0 lt {
198
+ /tmpr tmpr mrows add def
199
+ /tmpc tmpc 4 mrows 4 add 8 mod sub add def
200
+ } if
201
+ tmpc 0 lt {
202
+ /tmpc tmpc mcols add def
203
+ /tmpr tmpr 4 mcols 4 add 8 mod sub add def
204
+ } if
205
+ mmat tmpr mcols mul tmpc add bit put
206
+ /bit bit 1 add def
207
+ } bind def
208
+
209
+ /mmat [ mrows mcols mul {-1} repeat ] def
210
+ /bit 0 def /row 4 def /col 0 def
211
+ { % loop
212
+
213
+ row mrows eq col 0 eq and {
214
+ [ [mrows 1 sub 0] [mrows 1 sub 1] [mrows 1 sub 2] [0 mcols 2 sub]
215
+ [0 mcols 1 sub] [1 mcols 1 sub] [2 mcols 1 sub] [3 mcols 1 sub] ]
216
+ {{} forall module} forall
217
+ } if
218
+ row mrows 2 sub eq col 0 eq and mcols 4 mod 0 ne and {
219
+ [ [mrows 3 sub 0] [mrows 2 sub 0] [mrows 1 sub 0] [0 mcols 4 sub]
220
+ [0 mcols 3 sub] [0 mcols 2 sub] [0 mcols 1 sub] [1 mcols 1 sub] ]
221
+ {{} forall module} forall
222
+ } if
223
+ row mrows 2 sub eq col 0 eq and mcols 8 mod 4 eq and {
224
+ [ [mrows 3 sub 0] [mrows 2 sub 0] [mrows 1 sub 0] [0 mcols 2 sub]
225
+ [0 mcols 1 sub] [1 mcols 1 sub] [2 mcols 1 sub] [3 mcols 1 sub] ]
226
+ {{} forall module} forall
227
+ } if
228
+ row mrows 4 add eq col 2 eq and mcols 8 mod 0 eq and {
229
+ [ [mrows 1 sub 0] [mrows 1 sub mcols 1 sub] [0 mcols 3 sub] [0 mcols 2 sub]
230
+ [0 mcols 1 sub] [1 mcols 3 sub] [1 mcols 2 sub] [1 mcols 1 sub] ]
231
+ {{} forall module} forall
232
+ } if
233
+
234
+ { % loop for sweeping upwards
235
+ row mrows lt col 0 ge and {
236
+ mmat row mcols mul col add get -1 eq {
237
+ [ [row 2 sub col 2 sub] [row 2 sub col 1 sub] [row 1 sub col 2 sub] [row 1 sub col 1 sub]
238
+ [row 1 sub col] [row col 2 sub] [row col 1 sub] [row col] ]
239
+ {{} forall module} forall
240
+ } if
241
+ } if
242
+ /row row 2 sub def
243
+ /col col 2 add def
244
+ row 0 ge col mcols lt and not {exit} if
245
+ } loop
246
+ /row row 1 add def
247
+ /col col 3 add def
248
+
249
+ { % loop for sweeping downwards
250
+ row 0 ge col mcols lt and {
251
+ mmat row mcols mul col add get -1 eq {
252
+ [ [row 2 sub col 2 sub] [row 2 sub col 1 sub] [row 1 sub col 2 sub] [row 1 sub col 1 sub]
253
+ [row 1 sub col] [row col 2 sub] [row col 1 sub] [row col] ]
254
+ {{} forall module} forall
255
+ } if
256
+ } if
257
+ /row row 2 add def
258
+ /col col 2 sub def
259
+ row mrows lt col 0 ge and not {exit} if
260
+ } loop
261
+ /row row 3 add def
262
+ /col col 1 add def
263
+
264
+ row mrows lt col mcols lt or not {exit} if
265
+ } loop
266
+
267
+ % Set checker pattern if required
268
+ mmat mrows mcols mul 1 sub get -1 eq {
269
+ mmat mrows mcols 1 sub mul 2 sub [-1 -2] putinterval
270
+ mmat mrows mcols mul 2 sub [-2 -1] putinterval
271
+ } if
272
+
273
+ % Invert the map to form the mapping matrix correcting the checker case
274
+ /modmap mrows mcols mul 8 idiv 8 mul array def
275
+ 0 1 mmat length 1 sub {
276
+ /i exch def
277
+ mmat i get 0 ge {
278
+ modmap mmat i get i put
279
+ } {
280
+ mmat i mmat i get 2 add put
281
+ } ifelse
282
+ } for
283
+
284
+ % Place the codewords in the matrix according to the mapping matrix
285
+ 0 1 cws length 1 sub {
286
+ /i exch def
287
+ [ 8 {0} repeat cws i get 2 8 string cvrs {48 sub} forall ]
288
+ dup length 8 sub 8 getinterval /bits exch def
289
+ 0 1 7 {
290
+ /j exch def
291
+ mmat modmap i 8 mul j add get bits j get put
292
+ } for
293
+ } for
294
+
295
+ % Place the modules onto a pixel map between alignment patterns
296
+ /pixs rows cols mul array def
297
+ /cwpos 0 def
298
+ 0 1 rows 1 sub {
299
+ /i exch def
300
+ i rrows 2 add mod 0 eq { pixs i cols mul [ cols 2 idiv {1 0} repeat ] putinterval } if
301
+ i rrows 2 add mod rrows 1 add eq { pixs i cols mul [ cols {1} repeat ] putinterval } if
302
+ i rrows 2 add mod 0 ne i rrows 2 add mod rrows 1 add ne and {
303
+ 0 1 cols 1 sub {
304
+ /j exch def
305
+ j rcols 2 add mod 0 eq { pixs i cols mul j add 1 put } if
306
+ j rcols 2 add mod rcols 1 add eq { pixs i cols mul j add i 2 mod put } if
307
+ j rcols 2 add mod 0 ne j rcols 2 add mod rcols 1 add ne and {
308
+ pixs i cols mul j add mmat cwpos get put
309
+ /cwpos cwpos 1 add def
310
+ } if
311
+ } for
312
+ } if
313
+ } for
314
+
315
+ /retval 7 dict def
316
+ retval (ren) (renmatrix) put
317
+ retval (pixs) pixs put
318
+ retval (pixx) cols put
319
+ retval (pixy) rows put
320
+ retval (height) rows 72 div 1.5 mul put
321
+ retval (width) cols 72 div 1.5 mul put
322
+ retval (opt) useropts put
323
+ retval
324
+
325
+ end
326
+
327
+ } bind def
328
+ /datamatrix load 0 1 dict put
@@ -0,0 +1,183 @@
1
+ %!PS-Adobe-2.0
2
+ %%Creator: Terry Burton
3
+ %%DocumentPaperSizes: a4
4
+ %%EndComments
5
+ %%EndProlog
6
+
7
+ % Barcode Writer in Pure PostScript - Version 2008-04-06-1
8
+ % http://www.terryburton.co.uk/barcodewriter/
9
+ %
10
+ % Copyright (c) 2008 Terry Burton - tez@terryburton.co.uk
11
+ %
12
+ % Permission is hereby granted, free of charge, to any
13
+ % person obtaining a copy of this software and associated
14
+ % documentation files (the "Software"), to deal in the
15
+ % Software without restriction, including without
16
+ % limitation the rights to use, copy, modify, merge,
17
+ % publish, distribute, sublicense, and/or sell copies of
18
+ % the Software, and to permit persons to whom the Software
19
+ % is furnished to do so, subject to the following
20
+ % conditions:
21
+ %
22
+ % The above copyright notice and this permission notice
23
+ % shall be included in all copies or substantial portions
24
+ % of the Software.
25
+ %
26
+ % THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
27
+ % KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
28
+ % THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
29
+ % PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
30
+ % THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
31
+ % DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
32
+ % CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33
+ % CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
34
+ % IN THE SOFTWARE.
35
+
36
+ % Uncomment this next line to allow these procedure definitions to
37
+ % remain resident within a printer's PostScript virtual machine
38
+ % so that the barcode generation capability persists between jobs.
39
+
40
+ % serverdict begin 0 exitserver
41
+
42
+ % --BEGIN TEMPLATE--
43
+
44
+ % --DESC: EAN-13
45
+ % --EXAM: 977147396801
46
+ % --EXOP: includetext guardwhitespace
47
+ % --RNDR: renlinear
48
+ /ean13 {
49
+
50
+ 0 begin
51
+
52
+ /options exch def % We are given an option string
53
+ /useropts options def
54
+ /barcode exch def % We are given a barcode string
55
+
56
+ /includetext false def % Enable/disable text
57
+ /textfont /Helvetica def
58
+ /textsize 12 def
59
+ /textyoffset -4 def
60
+ /height 1 def
61
+
62
+ % Parse the input options
63
+ options {
64
+ token false eq {exit} if dup length string cvs (=) search
65
+ true eq {cvlit exch pop exch def} {cvlit true def} ifelse
66
+ } loop
67
+
68
+ /textfont textfont cvlit def
69
+ /textsize textsize cvr def
70
+ /textyoffset textyoffset cvr def
71
+ /height height cvr def
72
+
73
+ /barlen barcode length def % Length of the code
74
+
75
+ % Add checksum digit to barcode if length is even
76
+ barlen 2 mod 0 eq {
77
+ /pad barlen 1 add string def % Create pad one bigger than barcode
78
+ /checksum 0 def
79
+ 0 1 barlen 1 sub {
80
+ /i exch def
81
+ /barchar barcode i get 48 sub def
82
+ i 2 mod 0 eq {
83
+ /checksum barchar checksum add def
84
+ } {
85
+ /checksum barchar 3 mul checksum add def
86
+ } ifelse
87
+ } for
88
+ /checksum 10 checksum 10 mod sub 10 mod def
89
+ pad 0 barcode putinterval % Add barcode to the start of the pad
90
+ pad barlen checksum 48 add put % Put ascii for checksum at end of pad
91
+ /barcode pad def % barcode=pad
92
+ /barlen barlen 1 add def % barlen++
93
+ } if
94
+
95
+ % Create an array containing the character mappings
96
+ /encs
97
+ [ (3211) (2221) (2122) (1411) (1132)
98
+ (1231) (1114) (1312) (1213) (3112)
99
+ (111) (11111) (111)
100
+ ] def
101
+
102
+ % Create a string of the available characters
103
+ /barchars (0123456789) def
104
+
105
+ % Digits to mirror on left side
106
+ /mirrormaps
107
+ [ (000000) (001011) (001101) (001110) (010011)
108
+ (011001) (011100) (010101) (010110) (011010)
109
+ ] def
110
+
111
+ /sbs barlen 1 sub 4 mul 11 add string def
112
+ /txt barlen array def
113
+
114
+ % Put the start character
115
+ sbs 0 encs 10 get putinterval
116
+
117
+ % First digit - determine mirrormap by this and show before guard bars
118
+ /mirrormap mirrormaps barcode 0 get 48 sub get def
119
+ txt 0 [barcode 0 1 getinterval -10 textyoffset textfont textsize] put
120
+
121
+ % Left side - performs mirroring
122
+ 1 1 6 {
123
+ % Lookup the encoding for the each barcode character
124
+ /i exch def
125
+ barcode i 1 getinterval barchars exch search
126
+ pop % Discard true leaving pre
127
+ length /indx exch def % indx is the length of pre
128
+ pop pop % Discard seek and post
129
+ /enc encs indx get def % Get the indxth encoding
130
+ mirrormap i 1 sub get 49 eq { % Reverse enc if 1 in this position in mirrormap
131
+ /enclen enc length def
132
+ /revenc enclen string def
133
+ 0 1 enclen 1 sub {
134
+ /j exch def
135
+ /char enc j get def
136
+ revenc enclen j sub 1 sub char put
137
+ } for
138
+ /enc revenc def
139
+ } if
140
+ sbs i 1 sub 4 mul 3 add enc putinterval % Put encoded digit into sbs
141
+ txt i [barcode i 1 getinterval i 1 sub 7 mul 4 add textyoffset textfont textsize] put
142
+ } for
143
+
144
+ % Put the middle character
145
+ sbs 7 1 sub 4 mul 3 add encs 11 get putinterval
146
+
147
+ % Right side
148
+ 7 1 12 {
149
+ % Lookup the encoding for the each barcode character
150
+ /i exch def
151
+ barcode i 1 getinterval barchars exch search
152
+ pop % Discard true leaving pre
153
+ length /indx exch def % indx is the length of pre
154
+ pop pop % Discard seek and post
155
+ /enc encs indx get def % Get the indxth encoding
156
+ sbs i 1 sub 4 mul 8 add enc putinterval % Put encoded digit into sbs
157
+ txt i [barcode i 1 getinterval i 1 sub 7 mul 8 add textyoffset textfont textsize] put
158
+ } for
159
+
160
+ % Put the end character
161
+ sbs barlen 1 sub 4 mul 8 add encs 12 get putinterval
162
+
163
+ % Return the arguments
164
+ /retval 8 dict def
165
+ retval (ren) (renlinear) put
166
+ retval (sbs) [sbs {48 sub} forall] put
167
+ includetext {
168
+ retval (bhs) [height height 12{height .075 sub}repeat height height 12{height .075 sub}repeat height height] put
169
+ retval (bbs) [0 0 12{.075}repeat 0 0 12{.075}repeat 0 0] put
170
+ retval (txt) txt put
171
+ } {
172
+ retval (bhs) [30{height}repeat] put
173
+ retval (bbs) [30{0}repeat] put
174
+ } ifelse
175
+ retval (opt) useropts put
176
+ retval (guardrightpos) 10 put
177
+ retval (borderbottom) 5 put
178
+ retval
179
+
180
+ end
181
+
182
+ } bind def
183
+ /ean13 load 0 1 dict put