-
-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathdatabaromnicomposite.ps.src
188 lines (166 loc) · 5.81 KB
/
databaromnicomposite.ps.src
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
% Barcode Writer in Pure PostScript
% https://bwipp.terryburton.co.uk
%
% Copyright (c) 2004-2024 Terry Burton
%
% $Id$
%
% Permission is hereby granted, free of charge, to any
% person obtaining a copy of this software and associated
% documentation files (the "Software"), to deal in the
% Software without restriction, including without
% limitation the rights to use, copy, modify, merge,
% publish, distribute, sublicense, and/or sell copies of
% the Software, and to permit persons to whom the Software
% is furnished to do so, subject to the following
% conditions:
%
% The above copyright notice and this permission notice
% shall be included in all copies or substantial portions
% of the Software.
%
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
% KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
% THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
% PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
% THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
% DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
% CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
% CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
% IN THE SOFTWARE.
% --BEGIN ENCODER databaromnicomposite--
% --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process renlinear renmatrix databaromni micropdf417 pdf417 gs1-cc--
% --DESC: GS1 DataBar Omnidirectional Composite
% --EXAM: (01)09521234543213|(11)990102
% --EXOP:
% --RNDR: renlinear renmatrix
/setpacking where {pop currentpacking true setpacking} if
10 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /processoptions dup /uk.co.terryburton.bwipp findresource put
dup /databaromni dup /uk.co.terryburton.bwipp findresource put
dup /gs1-cc dup /uk.co.terryburton.bwipp findresource put
dup /gs1process dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
begin
/databaromnicomposite {
20 dict begin % Confine variables to local scope
/ctx null def
/dontdraw false def
/usematrix false def
/parse false def
/dontlint false def
/lintreqs true def
//processoptions exec /options exch def
/barcode exch def
dontdraw { /usematrix true def } if
% Split the linear and composite parts
barcode (|) search {
/linear exch def
pop
/comp exch def
} {
pop /bwipp.missingCompositeComponent (A Composite Component must be provided following a pipe character) //raiseerror exec
} ifelse
usematrix not { gsave } if
options (lintype) (databaromni) put
options (linkage) true put
options (inkspreadv) 0.0 put
options (dontdraw) true put
options (dontlint) true put
% Lint the combined AI element strings
linear length comp length add string
dup 0 linear putinterval
dup linear length comp putinterval
/ai //gs1process exec pop pop pop
% Plot the linear part
linear options //databaromni exec
dup (sbs) get /linsbs exch def
dup (bhs) get 0 get 72 mul /linheight exch def
usematrix not { //renlinear exec } { pop } ifelse
% Plot the separator
/sepfinder {
/fp exch def
fp 1 fp 12 add {
/i exch def
bot i get 0 eq {
bot i 1 sub get 1 eq {
1
} {
sep i 1 sub get 0 eq {1} {0} ifelse
} ifelse
} {
0
} ifelse
sep exch i exch put
} for
/f3 [1 1 1 1 1 1 1 1 1 0 1 1 1] def
true 0 1 12 {dup bot exch fp add get exch f3 exch get eq and} for {
% Right shifted module for value 3 finder
sep fp [ 0 0 0 0 0 0 0 0 0 0 1 0 0 ] putinterval
} if
} def
mark
0 linsbs {1 index 1 eq {{0}} {{1}} ifelse repeat} forall
counttomark 1 sub array astore /bot exch def pop pop
/sep [ bot {1 exch sub} forall ] def
sep 0 [0 0 0] putinterval
sep sep length 4 sub [0 0 0 0] putinterval
18 sepfinder 64 sepfinder
usematrix not {
currentpoint
% Plot the 2D part
-5 linheight 1 add rmoveto comp options //gs1-cc exec //renmatrix exec
linheight add moveto <<
/ren /renmatrix
/pixs sep
/pixx sep length
/pixy 1
/height 1 72 div
/width sep length 72 div
/opt options
>> //renmatrix exec
grestore
} {
/compsym comp options //gs1-cc exec def
/ccpixs compsym /pixs get def
/ccpixx compsym /pixx get def
/linpixs [ 0 % Begin with left guard space
linsbs { cvi 1 index 0 eq {{1}} {{0}} ifelse repeat } forall % Alternates i 1/0's
] def
/sep [ 0 sep aload pop ] def % Offset by 1
/linheight linheight cvi def
% ccpixx is 99 for both 4-col CC-A and 4-col CC-B; linpixs length is 96
/pixs [
0 ccpixx ccpixs length 1 sub { % Right pad composite with 1 space
/i exch def
ccpixs i ccpixx getinterval aload pop 0
} for
0 0 0 0 sep aload pop linheight { 0 0 0 0 linpixs aload pop } repeat % Left pad with 4 spaces
] def
/pixx ccpixx 1 add def % 100
/pixy pixs length pixx idiv def
<<
/ren /renmatrix
/pixs pixs
/pixx pixx
/pixy pixy
/height pixy 72 div
/width pixx 72 div
/opt options
>>
dontdraw not {
gsave
//renmatrix exec
grestore
} if
} ifelse
end
}
[/barcode] {null def} forall
bind def
/databaromnicomposite dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
% --END ENCODER databaromnicomposite--