-
-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathdatabarexpandedstackedcomposite.ps.src
178 lines (157 loc) · 5.48 KB
/
databarexpandedstackedcomposite.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
% 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 databarexpandedstackedcomposite--
% --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput gs1process renlinear renmatrix databarexpanded databarexpandedstacked micropdf417 pdf417 gs1-cc--
% --DESC: GS1 DataBar Expanded Stacked Composite
% --EXAM: (01)09521234543213(10)ABCDEF|(21)12345678
% --EXOP: segments=4
% --RNDR: renmatrix renlinear
/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 /databarexpandedstacked 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 /renmatrix dup /uk.co.terryburton.bwipp findresource put
begin
/databarexpandedstackedcomposite {
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) (databarexpandedstacked) 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 //databarexpandedstacked exec
dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def
dup (pixy) get /linheight exch def
usematrix not { //renmatrix exec } { /pixs get /linpixs exch def } 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
} def
/sep [ bot {1 exch sub} forall ] def
sep 0 [ 0 0 0 0 ] putinterval
sep sep length 4 sub [ 0 0 0 0 ] putinterval
[ % Finder pattern module positions
19 98 bot length 13 sub {} for
70 98 bot length 13 sub {} for
] {sepfinder} forall
usematrix not {
currentpoint
% Plot the 2D part
bot 0 get 0 eq {2} {0} ifelse 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
/pixx sep length def
/cclpad [ pixx ccpixx sub 1 add 2 idiv {0} repeat ] def % Add 1 to allow for odd difference
/ccrpad [ pixx ccpixx sub 2 idiv {0} repeat ] def
/pixs [
0 ccpixx ccpixs length 1 sub { % Centre align composite
/i exch def
cclpad aload pop ccpixs i ccpixx getinterval aload pop ccrpad aload pop
} for
sep aload pop linpixs aload pop
] def
/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
/databarexpandedstackedcomposite dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
% --END ENCODER databarexpandedstackedcomposite--