Skip to content

Commit 5217fc2

Browse files
committed
mailmark: Uplift
1 parent 9f028b7 commit 5217fc2

1 file changed

Lines changed: 25 additions & 13 deletions

File tree

src/mailmark.ps.src

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
% Barcode Writer in Pure PostScript
22
% https://bwipp.terryburton.co.uk
33
%
4-
% Copyright (c) 2004-2024 Terry Burton
4+
% Copyright (c) 2004-2025 Terry Burton
55
%
66
% $Id$
77
%
@@ -45,9 +45,22 @@ dup /parseinput dup /uk.co.terryburton.bwipp findresource put
4545
dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
4646
dup /datamatrix dup /uk.co.terryburton.bwipp findresource put
4747
begin
48+
49+
/mailmark.typetoversion <<
50+
(7) (24x24)
51+
(9) (32x32)
52+
(29) (16x48)
53+
>> readonly def
54+
55+
/mailmark.typetoformat <<
56+
(7) (square)
57+
(9) (square)
58+
(29) (rectangle)
59+
>> readonly def
60+
4861
/mailmark {
4962

50-
20 dict begin % Confine variables to local scope
63+
20 dict begin
5164

5265
/ctx null def
5366
/type (unset) def % 7, 9 or 29
@@ -57,7 +70,9 @@ begin
5770
//processoptions exec /options exch def
5871
/barcode exch def
5972

73+
%
6074
% Parse ordinals of the form ^NNN to ASCII
75+
%
6176
/fncvals <<
6277
/parse parse
6378
/parseonly true
@@ -67,31 +82,28 @@ begin
6782
/barlen barcode length def
6883
options (parse) undef
6984

85+
%
7086
% Map the given type to a format and version of Data Matrix
87+
%
7188
/type load dup (7) ne exch dup (9) ne exch (29) ne and and {
7289
/bwipp.mailmarkBadType (Royal Mail Mailmark type must be 7, 9 or 29) //raiseerror exec
7390
} if
74-
<<
75-
(7) (24x24)
76-
(9) (32x32)
77-
(29) (16x48)
78-
>> /type load get /version exch def
79-
80-
<<
81-
(7) (square)
82-
(9) (square)
83-
(29) (rectangle)
84-
>> /type load get /format exch def
91+
//mailmark.typetoversion /type load get /version exch def
92+
//mailmark.typetoformat /type load get /format exch def
8593

94+
%
8695
% Validate the input
96+
%
8797
barcode length 45 lt {
8898
/bwipp.mailmarkBadLength (Royal Mail Mailmark must contain at least 45 characters of Mailmark formatted data, including any required space padding) //raiseerror exec
8999
} if
90100
barcode 0 4 getinterval (JGB ) ne {
91101
/bwipp.mailmarkBadIndicator (Royal Mail Mailmark must begin with JGB<space> identifier) //raiseerror exec
92102
} if
93103

104+
%
94105
% Get the result of encoding with datamatrix
106+
%
95107
options (dontdraw) true put
96108
options (version) version put
97109
options (format) format put

0 commit comments

Comments
 (0)