Skip to content

Commit 9db659e

Browse files
committed
hibcpdf417: Uplift
1 parent 64f8f18 commit 9db659e

1 file changed

Lines changed: 36 additions & 17 deletions

File tree

src/hibcpdf417.ps.src

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,41 @@
3838
currentglobal
3939
true setglobal
4040
/setpacking where {pop currentpacking true setpacking} if
41-
10 dict
42-
dup /loadctx dup /uk.co.terryburton.bwipp findresource put
43-
dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
41+
50 dict
4442
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
4543
dup /processoptions dup /uk.co.terryburton.bwipp findresource put
4644
dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
4745
dup /pdf417 dup /uk.co.terryburton.bwipp findresource put
4846
begin
47+
48+
/hibcpdf417.barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) readonly def
49+
50+
/hibcpdf417.latevars dup 1 dict def load /init {
51+
52+
currentglobal
53+
true setglobal
54+
55+
//hibcpdf417.latevars begin
56+
57+
/charvals 43 dict def
58+
0 1 42 {
59+
charvals exch dup //hibcpdf417.barchars exch 1 getinterval exch put
60+
} for
61+
/charvals charvals readonly def
62+
63+
/init { //hibcpdf417.latevars {def} forall } def
64+
65+
end
66+
67+
//hibcpdf417.latevars /init get exec
68+
69+
setglobal
70+
71+
} bind put
72+
4973
/hibcpdf417 {
5074

51-
20 dict begin % Confine variables to local scope
75+
20 dict begin
5276

5377
/ctx null def
5478
/dontdraw false def
@@ -58,20 +82,15 @@ begin
5882
//processoptions exec /options exch def
5983
/barcode exch def
6084

85+
//hibcpdf417.latevars /init get exec
86+
6187
barcode () eq {
6288
/bwipp.hibcpdf417EmptyData (The data must not be empty) //raiseerror exec
6389
} if
6490

65-
/hibcpdf417 //loadctx exec
66-
67-
% Create a string of the available characters
68-
{
69-
/barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def
70-
/charvals 43 dict def
71-
0 1 42 {charvals exch dup barchars exch 1 getinterval exch put} for
72-
} ctxdef
73-
91+
%
7492
% Validate the input
93+
%
7594
0 1 barcode length 1 sub {
7695
barcode exch 1 getinterval charvals exch known not {
7796
/bwipp.hibcpdf417BadCharacter (HIBC PDF417 must contain only digits, capital letters, spaces and the symbols -.$/+%) //raiseerror exec
@@ -87,17 +106,19 @@ begin
87106
} for
88107
/checksum checksum 43 mod def
89108
validatecheck {
90-
barcode barlen get barchars checksum get ne {
109+
barcode barlen get //hibcpdf417.barchars checksum get ne {
91110
/bwipp.hibcpdf417BadCheckDigit (Incorrect HIBC PDF417 check digit provided) //raiseerror exec
92111
} if
93112
/barcode barcode 0 barlen getinterval def
94113
} if
95114

96115
/barcode barlen 2 add string dup 1 barcode putinterval def
97116
barcode 0 43 put
98-
barcode barlen 1 add barchars checksum get put
117+
barcode barlen 1 add //hibcpdf417.barchars checksum get put
99118

119+
%
100120
% Get the result of encoding with pdf417
121+
%
101122
options (dontdraw) true put
102123
options (columns) columns put
103124
options (validatecheck) false put
@@ -108,8 +129,6 @@ begin
108129

109130
dontdraw not //renmatrix if
110131

111-
//unloadctx exec
112-
113132
end
114133

115134
}

0 commit comments

Comments
 (0)