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%
3838currentglobal
3939true 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
4442dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
4543dup /processoptions dup /uk.co.terryburton.bwipp findresource put
4644dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
4745dup /micropdf417 dup /uk.co.terryburton.bwipp findresource put
4846begin
47+
48+ /hibcmicropdf417.barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) readonly def
49+
50+ /hibcmicropdf417.latevars dup 1 dict def load /init {
51+
52+ currentglobal
53+ true setglobal
54+
55+ //hibcmicropdf417.latevars begin
56+
57+ /charvals 43 dict def
58+ 0 1 42 {
59+ charvals exch dup //hibcmicropdf417.barchars exch 1 getinterval exch put
60+ } for
61+ /charvals charvals readonly def
62+
63+ /init { //hibcmicropdf417.latevars {def} forall } def
64+
65+ end
66+
67+ //hibcmicropdf417.latevars /init get exec
68+
69+ setglobal
70+
71+ } bind put
72+
4973/hibcmicropdf417 {
5074
51- 20 dict begin % Confine variables to local scope
75+ 20 dict begin
5276
5377 /ctx null def
78+
5479 /dontdraw false def
5580 /columns 2 def
5681 /validatecheck false def
5782
5883 //processoptions exec /options exch def
5984 /barcode exch def
6085
86+ //hibcmicropdf417.latevars /init get exec
87+
6188 barcode () eq {
6289 /bwipp.hibcmicropdf417EmptyData (The data must not be empty) //raiseerror exec
6390 } if
6491
65- /hibcmicropdf417 //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-
92+ %
7493 % Validate the input
94+ %
7595 0 1 barcode length 1 sub {
7696 barcode exch 1 getinterval charvals exch known not {
7797 /bwipp.hibcmicropdf417BadCharacter (HIBC MicroPDF417 must contain only digits, capital letters, spaces and the symbols -.$/+%) //raiseerror exec
@@ -87,17 +107,19 @@ begin
87107 } for
88108 /checksum checksum 43 mod def
89109 validatecheck {
90- barcode barlen get barchars checksum get ne {
110+ barcode barlen get //hibcmicropdf417. barchars checksum get ne {
91111 /bwipp.hibcmicropdf417BadCheckDigit (Incorrect HIBC MicroPDF417 check digit provided) //raiseerror exec
92112 } if
93113 /barcode barcode 0 barlen getinterval def
94114 } if
95115
96116 /barcode barlen 2 add string dup 1 barcode putinterval def
97117 barcode 0 43 put
98- barcode barlen 1 add barchars checksum get put
118+ barcode barlen 1 add //hibcmicropdf417. barchars checksum get put
99119
120+ %
100121 % Get the result of encoding with micropdf417
122+ %
101123 options (dontdraw) true put
102124 options (columns) columns put
103125 options (validatecheck) false put
@@ -108,8 +130,6 @@ begin
108130
109131 dontdraw not //renmatrix if
110132
111- //unloadctx exec
112-
113133 end
114134
115135}
0 commit comments