%!PS % Barcode Writer in Pure PostScript - Version 2026-05-28 % https://bwipp.terryburton.co.uk % % Copyright (c) 2004-2024 Terry Burton % % 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 TEMPLATE-- % --BEGIN RESOURCE preamble-- %%BeginResource: Category uk.co.terryburton.bwipp 0.0 2026052800 28861 32102 %%BeginData: 6 ASCII Lines currentglobal true setglobal /Generic /Category findresource dup length 1 add dict copy dup /InstanceType /setpacking where {pop /packedarraytype} {/arraytype} ifelse put /uk.co.terryburton.bwipp exch /Category defineresource pop setglobal %%EndData %%EndResource % --END RESOURCE preamble-- % --BEGIN RESOURCE raiseerror-- % --REQUIRES preamble-- %%BeginResource: uk.co.terryburton.bwipp raiseerror 0.0 2026052800 38053 34460 %%BeginData: 18 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 10 dict begin /raiseerror { $error exch /errorinfo exch put $error exch /errorname exch put $error /command null put $error /newerror true put stop } [/barcode] {null def} forall bind def /raiseerror dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END RESOURCE raiseerror-- % --BEGIN RESOURCE setuphooks-- % --REQUIRES preamble-- %%BeginResource: uk.co.terryburton.bwipp setuphooks 0.0 2026052800 42779 39029 %%BeginData: 62 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 1 dict begin /setuphooks { currentdict 3 1 roll % ... targetdict /encodername [hooks] 8 dict begin /hooks exch def /encname exch dup length string cvs def % stringify /targetdict exch def % % Get hooks dict from global_ctx if enabledebug is set % /hooksdict null def /uk.co.terryburton.bwipp.global_ctx dup where { exch get dup /enabledebug known { /hooks 2 copy known {get /hooksdict exch def} {pop pop} ifelse } {pop} ifelse } {pop} ifelse hooks { dup length string cvs % stringify % % Build encodername.hookname % encname length 1 add 1 index length add string dup 0 encname putinterval dup encname length (.) putinterval dup encname length 1 add 3 index putinterval cvn % (hookname) /encodername.hookname exch cvn % /encodername.hookname /hookname % % Lookup procedure in hooks dict and define in caller's dictionary: % % encodername.hookname > hookname > {pop pop} % hooksdict null ne { hooksdict 2 index known {hooksdict 2 index get} { hooksdict 1 index known {hooksdict 1 index get} { {pop pop} } ifelse} ifelse } { {pop pop} } ifelse exch pop % /encodername.hookname {userhook} mark encname cvn 3 -1 roll /exec load ] cvx % /encodername.hookname {wrapper} targetdict 3 1 roll put } forall end } bind def /setuphooks dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END RESOURCE setuphooks-- % --BEGIN RESOURCE processoptions-- % --REQUIRES preamble raiseerror setuphooks-- %%BeginResource: uk.co.terryburton.bwipp processoptions 0.0 2026052800 78439 77567 %%BeginData: 253 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 16 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put begin % % Apply user options to defaults in currentdict with type checking. % Caller may pass a supplementary alias dict for encoder-specific aliases; % pass null when none are needed. % % options supaliases /apply //processoptions exec => optionsdict % /processoptions.typemap << /booleantype { false or } bind % Force a type error if not boolean value /stringtype { dup length string cvs } bind % Conversion to string to force a boolean to fail /nametype 1 index % Conversion original nametype to string is fine /realtype { dup cvr exch pop } bind /nulltype 1 index % We define "null" as the sentinel value of a realtype /integertype { dup cvr dup cvi ne {dup not} if cvi } bind % Force type error when precision is lost or boolean is given >> readonly def % Alias maps: old option names => canonical names /processoptions.aliases << (alttext) /text1 (alttextsubspace) /text1subspace (alttextsplit) /text1split (textsubspace) /text1subspace (textsplit) /text1split (textlinegaps) /text1linegaps (textcolor) /text1color (textxalign) /text1xalign (textyalign) /text1yalign (textdirection) /text1direction (textfont) /text1font (textsize) /text1size (textxoffset) /text1xoffset (textyoffset) /text1yoffset (textgaps) /text1gaps (extratext) /text2 (extratextsubspace) /text2subspace (extratextsplit) /text2split (extratextlinegaps) /text2linegaps (extratextcolor) /text2color (extratextxalign) /text2xalign (extratextyalign) /text2yalign (extratextdirection) /text2direction (extratextfont) /text2font (extratextsize) /text2size (extratextxoffset) /text2xoffset (extratextyoffset) /text2yoffset (extratextgaps) /text2gaps >> readonly def /processoptions.apply { % % Alias-search list: [ supaliases general ], or just [ general ] when no % supplementary dict was provided. % [ exch dup null eq { pop } if //processoptions.aliases ] exch % aliasdicts options % % Convert string to dict % dup type /stringtype eq { << exch { dup () eq {pop exit} if ( ) search not { () exch null exch } if exch pop (=) search not { true exch null exch } if exch pop % k => k = true exch 3 -1 roll } loop >> } if % % Pre-resolve aliases. We mutate options in place; iterating a snapshot % of its keys (rather than options itself) sidesteps the PostScript % "modify dict during forall" pitfall. % [ 1 index { pop } forall ] { % Iterate over a snapshot of keys 1 index 1 index get % aliasdicts opts k v 3 index { % For each aliasdict dup 3 index known { 2 index get % aliasdicts opts k v canonical 3 index 1 index known { pop % Canonical clash } { 3 index 1 index 3 index put % opts[canonical] = v pop exit % First hit wins } ifelse } { pop % No match in this dict } ifelse } forall pop pop % Drop k v } forall % % Apply resolved options that exist in currentdict, converting values to % existing types % mark exch dup { exch dup currentdict exch known { dup load type 3 -1 roll exch //processoptions.typemap exch get stopped { pop pop dup length string cvs dup length 24 add string dup 0 (Invalid type for option ) putinterval dup 24 4 -1 roll putinterval counttomark {exch pop} repeat exch pop % Drop aliasdicts (sat below mark) /bwipp.invalidOptionType exch //raiseerror exec } if def } { pop pop % Ignore unknown options } ifelse } forall exch pop exch pop % Drop mark and aliasdicts, returning resolved options } bind def % % Generate option definitions in currentdict for groups 1..N % % (prefix) N template /generategroup //processoptions exec % /processoptions.generate { % (prefix) N template -- currentdict 4 1 roll % Save caller's dict below args 16 dict begin /tmpl exch def /n exch def /pfx exch def /target exch def 1 1 n { /i exch def % Build base name: prefix + digit /base pfx length 1 add string def base 0 pfx putinterval base pfx length i 48 add put tmpl { /val exch def % Dict forall yields names; convert suffix to string for concatenation /sfx exch 127 string cvs def % Build full name: base + suffix base length sfx length add string dup 0 base putinterval dup base length sfx putinterval cvn val target 3 1 roll put % target /name value put } forall } for end } bind def % % Collect current option values into an array of dicts % % (prefix) N template /collectgroup //processoptions exec => [ <<...>> <<...>> ... ] % /processoptions.collect { % (prefix) N template => array 16 dict begin /tmpl exch def /n exch def /pfx exch def /result n array def 1 1 n { /i exch def % % Build base name: prefix + digit % /base pfx length 1 add string def base 0 pfx putinterval base pfx length i 48 add put % % Build suffix-keyed dict from currentdict values % /grpdict tmpl length 2 mul dict def tmpl { pop % ignore template default % Dict forall yields names; convert suffix to string for concatenation /sfx exch 127 string cvs def % Build full name: base + suffix, then load value from dict stack base length sfx length add string dup 0 base putinterval dup base length sfx putinterval cvn load % Store value in dict under suffix key grpdict exch sfx exch put } forall result i 1 sub grpdict put } for result end } bind def % % Dispatcher table % /processoptions.dispatch << /apply //processoptions.apply /generategroup //processoptions.generate /collectgroup //processoptions.collect >> readonly def /processoptions { //processoptions.dispatch exch get exec } [/barcode] {null def} forall bind def /processoptions dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END RESOURCE processoptions-- % --BEGIN RESOURCE parseinput-- % --REQUIRES preamble raiseerror setuphooks-- %%BeginResource: uk.co.terryburton.bwipp parseinput 0.0 2026052800 67145 66688 %%BeginData: 201 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 4 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put begin /parseinput.latevars dup 1 dict def load /init { currentglobal true setglobal //parseinput.latevars begin % % Identifiers for ASCII control characters % /ctrl << [ /NUL /SOH /STX /ETX /EOT /ENQ /ACK /BEL /BS /TAB /LF /VT /FF /CR () () % SO and SI prefix clash with SOH /DLE /DC1 /DC2 /DC3 /DC4 /NAK /SYN /ETB /CAN /EM /SUB /ESC /FS /GS /RS /US ] 0 exch { 1 index 1 add 3 1 roll exch 3 -1 roll } forall pop >> def /init { //parseinput.latevars {def} forall } def end //parseinput.latevars /init get exec setglobal } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//parseinput.latevars /init get exec} if } {pop} ifelse /parseinput { 4 dict begin { /fncvals exch def /barcode exch def /parse dup dup fncvals exch get def fncvals exch undef /parsefnc dup dup fncvals exch get def fncvals exch undef /parseonly dup dup fncvals exch known def fncvals exch undef /eci dup dup fncvals exch known def fncvals exch undef //parseinput.latevars /init get exec /msg barcode length array def /j 0 def barcode { % loop (^) search exch % Copy characters up to a "^" dup length exch msg exch j exch [ exch {} forall ] putinterval j add /j exch def { % Found a "^" escape character pop 1 { % common exit parse not parsefnc not and { % "^" as is msg j 94 put /j j 1 add def exit } if % Encode "^" to start with msg j 94 put /j j 1 add def % parse parse { dup length 3 ge { % "^XXX" byte dup 0 3 getinterval ctrl exch 2 copy known { /j j 1 sub def % Replace "^" with ordinal get msg exch j exch put /j j 1 add def dup length 3 sub 3 exch getinterval exit } { pop pop } ifelse } if dup length 2 ge { % "^XX" to byte dup 0 2 getinterval ctrl exch 2 copy known { /j j 1 sub def % Replace "^" with ordinal get msg exch j exch put /j j 1 add def dup length 2 sub 2 exch getinterval exit } { pop pop } ifelse } if dup length 3 ge { % "^NNN" to byte dup 0 3 getinterval true exch { dup 48 lt exch 57 gt or { pop false } if } forall { dup 0 3 getinterval cvi dup 255 gt { pop pop /bwipp.invalidOrdinal (Ordinal must be 000 to 255) //raiseerror exec } if /j j 1 sub def % Replace "^" with ordinal msg exch j exch put /j j 1 add def dup length 3 sub 3 exch getinterval } if } if } if parseonly parsefnc not or msg j 1 sub get 94 ne % Carat was substituted away or {exit} if % parsefnc /j j 1 sub def dup length 1 lt { pop /bwipp.truncatedCaret (Caret character truncated) //raiseerror exec } if dup 0 get 94 eq { % "^^" -> "^" msg j 94 put /j j 1 add def dup length 1 sub 1 exch getinterval exit } if dup length 3 lt { pop /bwipp.truncatedFNC (Function character truncated) //raiseerror exec } if dup 0 3 getinterval (ECI) eq eci and { % "^ECInnnnnn" -> -1nnnnnn dup length 9 lt { pop /bwipp.truncatedECI (ECI truncated) //raiseerror exec } if dup 3 6 getinterval dup { dup 48 lt exch 57 gt or { pop pop /bwipp.invalidECI (ECI must be 000000 to 999999) //raiseerror exec } if } forall 0 exch {48 sub sub 10 mul} forall 10 idiv 1000000 sub msg exch j exch put /j j 1 add def dup length 9 sub 9 exch getinterval exit } if dup length 4 lt { % "^FNCx" -> fncvals{FNCx} pop /bwipp.truncatedFNC (Function character truncated) //raiseerror exec } if dup 0 4 getinterval dup fncvals exch known not { dup length 28 add string dup 28 4 -1 roll putinterval dup 0 (Unknown function character: ) putinterval exch pop /bwipp.unknownFNC exch //raiseerror exec } if fncvals exch get msg exch j exch put /j j 1 add def dup length 4 sub 4 exch getinterval exit } repeat } { % No more "^" characters exit } ifelse } loop parseonly not { msg 0 j getinterval } { j string 0 1 j 1 sub { 1 index exch dup msg exch get put } for } ifelse } stopped {end stop} if end } [/barcode] {null def} forall bind def /parseinput dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END RESOURCE parseinput-- % --BEGIN RESOURCE gs1process-- % --REQUIRES preamble parseinput raiseerror-- %%BeginResource: uk.co.terryburton.bwipp gs1process 0.0 2026052800 602668 648326 %%BeginData: 3373 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 8 dict dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /raiseerror dup /uk.co.terryburton.bwipp findresource put begin /gs1process.primes [ 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 ] readonly def % % Note: Leap year is dealt with exceptionally % /gs1process.daysinmonth [ 31 -1 31 30 31 30 31 31 30 31 30 31 ] readonly def /gs1process.latevars dup 1 dict def load /init { currentglobal true setglobal //gs1process.latevars begin % Extracted from the GS1 Syntax Dictionary /gs1syntax << << /parts [ << /cset /N /min 18 /max 18 /opt false /linters [ /lintcsum /lintgcppos2 ] >> ] /dlpkey [ ] >> (00) exch dup pop << /parts [ << /cset /N /min 14 /max 14 /opt false /linters [ /lintcsum /lintgcppos2 ] >> ] /ex [ (255) (37) ] /dlpkey [ [ (22) (10) (21) ] [ (235) ] ] >> (01) exch dup pop << /parts [ << /cset /N /min 14 /max 14 /opt false /linters [ /lintcsum /lintgcppos2 ] >> ] /ex [ (01) (03) ] /req [ [ [ (37) ] ] ] >> (02) exch dup pop << /parts [ << /cset /N /min 14 /max 14 /opt false /linters [ /lintcsum /lintgcppos2 ] >> ] /ex [ (01) (02) (37) ] /dlattr false >> (03) exch dup pop << /parts [ << /cset /X /min 1 /max 20 /opt false /linters [] >> ] /req [ [ [ (01) ] [ (02) ] [ (03) ] [ (8006) ] [ (8026) ] ] ] >> (10) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [ /lintyymmd0 ] >> ] /req [ [ [ (01) ] [ (02) ] [ (03) ] [ (8006) ] [ (8026) ] ] ] >> (11) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [ /lintyymmd0 ] >> ] /req [ [ [ (8020) ] ] ] >> (12) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [ /lintyymmd0 ] >> ] /req [ [ [ (01) ] [ (02) ] [ (03) ] [ (8006) ] [ (8026) ] ] ] >> (13) exch dup (15) exch dup (16) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [ /lintyymmd0 ] >> ] /req [ [ [ (01) ] [ (02) ] [ (03) ] [ (255) ] [ (8006) ] [ (8026) ] ] ] >> (17) exch dup pop << /parts [ << /cset /N /min 2 /max 2 /opt false /linters [] >> ] /req [ [ [ (01) ] [ (02) ] [ (8006) ] [ (8026) ] ] ] >> (20) exch dup pop << /parts [ << /cset /X /min 1 /max 20 /opt false /linters [] >> ] /ex [ (235) ] /req [ [ [ (01) ] [ (03) ] [ (8006) ] ] ] /dlattr false >> (21) exch dup pop << /parts [ << /cset /X /min 1 /max 20 /opt false /linters [] >> ] /req [ [ [ (01) ] ] ] /dlattr false >> (22) exch dup pop << /parts [ << /cset /X /min 1 /max 28 /opt false /linters [] >> ] /req [ [ [ (01) ] ] ] /dlattr false >> (235) exch dup pop << /parts [ << /cset /X /min 1 /max 30 /opt false /linters [] >> ] /req [ [ [ (01) ] [ (02) ] [ (8006) ] [ (8026) ] ] ] >> (240) exch dup (241) exch dup pop << /parts [ << /cset /N /min 1 /max 6 /opt false /linters [] >> ] /req [ [ [ (01) ] [ (02) ] [ (8006) ] [ (8026) ] ] ] >> (242) exch dup pop << /parts [ << /cset /X /min 1 /max 20 /opt false /linters [] >> ] /req [ [ [ (01) ] ] ] >> (243) exch dup pop << /parts [ << /cset /X /min 1 /max 30 /opt false /linters [] >> ] /req [ [ [ (01) ] [ (8006) ] ] [ [ (21) ] ] ] >> (250) exch dup pop << /parts [ << /cset /X /min 1 /max 30 /opt false /linters [] >> ] /req [ [ [ (01) ] [ (8006) ] ] ] >> (251) exch dup pop << /parts [ << /cset /N /min 13 /max 13 /opt false /linters [ /lintcsum /lintgcppos1 ] >> << /cset /X /min 1 /max 17 /opt true /linters [] >> ] /dlpkey [ ] >> (253) exch dup pop << /parts [ << /cset /X /min 1 /max 20 /opt false /linters [] >> ] /req [ [ [ (414) ] ] ] /dlattr false >> (254) exch dup pop << /parts [ << /cset /N /min 13 /max 13 /opt false /linters [ /lintcsum /lintgcppos1 ] >> << /cset /N /min 1 /max 12 /opt true /linters [] >> ] /ex [ (01) (02) (415) (8006) (8020) (8026) ] /dlpkey [ ] >> (255) exch dup pop << /parts [ << /cset /N /min 1 /max 8 /opt false /linters [] >> ] /req [ [ [ (01) ] [ (02) ] ] ] >> (30) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (310n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3100) exch dup (3101) exch dup (3102) exch dup (3103) exch dup (3104) exch dup (3105) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (311n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3110) exch dup (3111) exch dup (3112) exch dup (3113) exch dup (3114) exch dup (3115) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (312n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3120) exch dup (3121) exch dup (3122) exch dup (3123) exch dup (3124) exch dup (3125) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (313n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3130) exch dup (3131) exch dup (3132) exch dup (3133) exch dup (3134) exch dup (3135) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (314n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3140) exch dup (3141) exch dup (3142) exch dup (3143) exch dup (3144) exch dup (3145) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (315n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3150) exch dup (3151) exch dup (3152) exch dup (3153) exch dup (3154) exch dup (3155) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (316n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3160) exch dup (3161) exch dup (3162) exch dup (3163) exch dup (3164) exch dup (3165) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (320n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3200) exch dup (3201) exch dup (3202) exch dup (3203) exch dup (3204) exch dup (3205) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (321n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3210) exch dup (3211) exch dup (3212) exch dup (3213) exch dup (3214) exch dup (3215) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (322n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3220) exch dup (3221) exch dup (3222) exch dup (3223) exch dup (3224) exch dup (3225) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (323n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3230) exch dup (3231) exch dup (3232) exch dup (3233) exch dup (3234) exch dup (3235) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (324n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3240) exch dup (3241) exch dup (3242) exch dup (3243) exch dup (3244) exch dup (3245) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (325n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3250) exch dup (3251) exch dup (3252) exch dup (3253) exch dup (3254) exch dup (3255) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (326n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3260) exch dup (3261) exch dup (3262) exch dup (3263) exch dup (3264) exch dup (3265) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (327n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3270) exch dup (3271) exch dup (3272) exch dup (3273) exch dup (3274) exch dup (3275) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (328n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3280) exch dup (3281) exch dup (3282) exch dup (3283) exch dup (3284) exch dup (3285) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (329n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3290) exch dup (3291) exch dup (3292) exch dup (3293) exch dup (3294) exch dup (3295) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (330n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3300) exch dup (3301) exch dup (3302) exch dup (3303) exch dup (3304) exch dup (3305) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (331n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3310) exch dup (3311) exch dup (3312) exch dup (3313) exch dup (3314) exch dup (3315) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (332n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3320) exch dup (3321) exch dup (3322) exch dup (3323) exch dup (3324) exch dup (3325) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (333n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3330) exch dup (3331) exch dup (3332) exch dup (3333) exch dup (3334) exch dup (3335) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (334n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3340) exch dup (3341) exch dup (3342) exch dup (3343) exch dup (3344) exch dup (3345) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (335n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3350) exch dup (3351) exch dup (3352) exch dup (3353) exch dup (3354) exch dup (3355) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (336n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3360) exch dup (3361) exch dup (3362) exch dup (3363) exch dup (3364) exch dup (3365) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (337n) ] /req [ [ [ (01) ] ] ] >> (3370) exch dup (3371) exch dup (3372) exch dup (3373) exch dup (3374) exch dup (3375) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (340n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3400) exch dup (3401) exch dup (3402) exch dup (3403) exch dup (3404) exch dup (3405) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (341n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3410) exch dup (3411) exch dup (3412) exch dup (3413) exch dup (3414) exch dup (3415) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (342n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3420) exch dup (3421) exch dup (3422) exch dup (3423) exch dup (3424) exch dup (3425) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (343n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3430) exch dup (3431) exch dup (3432) exch dup (3433) exch dup (3434) exch dup (3435) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (344n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3440) exch dup (3441) exch dup (3442) exch dup (3443) exch dup (3444) exch dup (3445) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (345n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3450) exch dup (3451) exch dup (3452) exch dup (3453) exch dup (3454) exch dup (3455) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (346n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3460) exch dup (3461) exch dup (3462) exch dup (3463) exch dup (3464) exch dup (3465) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (347n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3470) exch dup (3471) exch dup (3472) exch dup (3473) exch dup (3474) exch dup (3475) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (348n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3480) exch dup (3481) exch dup (3482) exch dup (3483) exch dup (3484) exch dup (3485) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (349n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3490) exch dup (3491) exch dup (3492) exch dup (3493) exch dup (3494) exch dup (3495) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (350n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3500) exch dup (3501) exch dup (3502) exch dup (3503) exch dup (3504) exch dup (3505) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (351n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3510) exch dup (3511) exch dup (3512) exch dup (3513) exch dup (3514) exch dup (3515) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (352n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3520) exch dup (3521) exch dup (3522) exch dup (3523) exch dup (3524) exch dup (3525) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (353n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3530) exch dup (3531) exch dup (3532) exch dup (3533) exch dup (3534) exch dup (3535) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (354n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3540) exch dup (3541) exch dup (3542) exch dup (3543) exch dup (3544) exch dup (3545) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (355n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3550) exch dup (3551) exch dup (3552) exch dup (3553) exch dup (3554) exch dup (3555) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (356n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3560) exch dup (3561) exch dup (3562) exch dup (3563) exch dup (3564) exch dup (3565) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (357n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3570) exch dup (3571) exch dup (3572) exch dup (3573) exch dup (3574) exch dup (3575) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (360n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3600) exch dup (3601) exch dup (3602) exch dup (3603) exch dup (3604) exch dup (3605) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (361n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3610) exch dup (3611) exch dup (3612) exch dup (3613) exch dup (3614) exch dup (3615) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (362n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3620) exch dup (3621) exch dup (3622) exch dup (3623) exch dup (3624) exch dup (3625) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (363n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3630) exch dup (3631) exch dup (3632) exch dup (3633) exch dup (3634) exch dup (3635) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (364n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3640) exch dup (3641) exch dup (3642) exch dup (3643) exch dup (3644) exch dup (3645) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (365n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3650) exch dup (3651) exch dup (3652) exch dup (3653) exch dup (3654) exch dup (3655) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (366n) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (3660) exch dup (3661) exch dup (3662) exch dup (3663) exch dup (3664) exch dup (3665) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (367n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3670) exch dup (3671) exch dup (3672) exch dup (3673) exch dup (3674) exch dup (3675) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (368n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3680) exch dup (3681) exch dup (3682) exch dup (3683) exch dup (3684) exch dup (3685) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (369n) ] /req [ [ [ (00) ] [ (01) ] ] ] >> (3690) exch dup (3691) exch dup (3692) exch dup (3693) exch dup (3694) exch dup (3695) exch dup pop << /parts [ << /cset /N /min 1 /max 8 /opt false /linters [] >> ] /req [ [ [ (00) ] ] [ [ (02) ] [ (8026) ] ] ] >> (37) exch dup pop << /parts [ << /cset /N /min 1 /max 15 /opt false /linters [] >> ] /ex [ (390n) (391n) (394n) (8111) ] /req [ [ [ (255) ] [ (8020) ] ] ] >> (3900) exch dup (3901) exch dup (3902) exch dup (3903) exch dup (3904) exch dup (3905) exch dup (3906) exch dup (3907) exch dup (3908) exch dup (3909) exch dup pop << /parts [ << /cset /N /min 3 /max 3 /opt false /linters [ /lintiso4217 ] >> << /cset /N /min 1 /max 15 /opt false /linters [] >> ] /ex [ (391n) ] /req [ [ [ (8020) ] ] ] >> (3910) exch dup (3911) exch dup (3912) exch dup (3913) exch dup (3914) exch dup (3915) exch dup (3916) exch dup (3917) exch dup (3918) exch dup (3919) exch dup pop << /parts [ << /cset /N /min 1 /max 15 /opt false /linters [] >> ] /ex [ (392n) (393n) ] /req [ [ [ (01) ] ] [ [ (30) ] [ (31nn) ] [ (32nn) ] [ (35nn) ] [ (36nn) ] ] ] >> (3920) exch dup (3921) exch dup (3922) exch dup (3923) exch dup (3924) exch dup (3925) exch dup (3926) exch dup (3927) exch dup (3928) exch dup (3929) exch dup pop << /parts [ << /cset /N /min 3 /max 3 /opt false /linters [ /lintiso4217 ] >> << /cset /N /min 1 /max 15 /opt false /linters [] >> ] /ex [ (393n) ] /req [ [ [ (30) ] [ (31nn) ] [ (32nn) ] [ (35nn) ] [ (36nn) ] ] ] >> (3930) exch dup (3931) exch dup (3932) exch dup (3933) exch dup (3934) exch dup (3935) exch dup (3936) exch dup (3937) exch dup (3938) exch dup (3939) exch dup pop << /parts [ << /cset /N /min 4 /max 4 /opt false /linters [] >> ] /ex [ (394n) (8111) ] /req [ [ [ (255) ] ] ] >> (3940) exch dup (3941) exch dup (3942) exch dup (3943) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /ex [ (392n) (393n) (395n) (8005) ] /req [ [ [ (30) ] [ (31nn) ] [ (32nn) ] [ (35nn) ] [ (36nn) ] ] ] >> (3950) exch dup (3951) exch dup (3952) exch dup (3953) exch dup (3954) exch dup (3955) exch dup pop << /parts [ << /cset /X /min 1 /max 30 /opt false /linters [] >> ] >> (400) exch dup pop << /parts [ << /cset /X /min 1 /max 30 /opt false /linters [ /lintgcppos1 ] >> ] /dlpkey [ ] >> (401) exch dup pop << /parts [ << /cset /N /min 17 /max 17 /opt false /linters [ /lintcsum /lintgcppos1 ] >> ] /dlpkey [ ] >> (402) exch dup pop << /parts [ << /cset /X /min 1 /max 30 /opt false /linters [] >> ] /req [ [ [ (00) ] ] ] >> (403) exch dup pop << /parts [ << /cset /N /min 13 /max 13 /opt false /linters [ /lintcsum /lintgcppos1 ] >> ] >> (410) exch dup (411) exch dup (412) exch dup (413) exch dup pop << /parts [ << /cset /N /min 13 /max 13 /opt false /linters [ /lintcsum /lintgcppos1 ] >> ] /dlpkey [ [ (254) ] [ (7040) ] ] >> (414) exch dup pop << /parts [ << /cset /N /min 13 /max 13 /opt false /linters [ /lintcsum /lintgcppos1 ] >> ] /req [ [ [ (8020) ] ] ] /dlpkey [ [ (8020) ] ] >> (415) exch dup pop << /parts [ << /cset /N /min 13 /max 13 /opt false /linters [ /lintcsum /lintgcppos1 ] >> ] >> (416) exch dup pop << /parts [ << /cset /N /min 13 /max 13 /opt false /linters [ /lintcsum /lintgcppos1 ] >> ] /dlpkey [ [ (7040) ] ] >> (417) exch dup pop << /parts [ << /cset /X /min 1 /max 20 /opt false /linters [] >> ] /ex [ (421) ] >> (420) exch dup pop << /parts [ << /cset /N /min 3 /max 3 /opt false /linters [ /lintiso3166 ] >> << /cset /X /min 1 /max 9 /opt false /linters [] >> ] /ex [ (4307) ] >> (421) exch dup pop << /parts [ << /cset /N /min 3 /max 3 /opt false /linters [ /lintiso3166 ] >> ] /ex [ (426) ] /req [ [ [ (01) ] [ (02) ] [ (8006) ] [ (8026) ] ] ] >> (422) exch dup pop << /parts [ << /cset /N /min 3 /max 3 /opt false /linters [ /lintiso3166 ] >> << /cset /N /min 3 /max 3 /opt true /linters [ /lintiso3166 ] >> << /cset /N /min 3 /max 3 /opt true /linters [ /lintiso3166 ] >> << /cset /N /min 3 /max 3 /opt true /linters [ /lintiso3166 ] >> << /cset /N /min 3 /max 3 /opt true /linters [ /lintiso3166 ] >> ] /ex [ (426) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (423) exch dup pop << /parts [ << /cset /N /min 3 /max 3 /opt false /linters [ /lintiso3166 ] >> ] /ex [ (426) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (424) exch dup pop << /parts [ << /cset /N /min 3 /max 3 /opt false /linters [ /lintiso3166 ] >> << /cset /N /min 3 /max 3 /opt true /linters [ /lintiso3166 ] >> << /cset /N /min 3 /max 3 /opt true /linters [ /lintiso3166 ] >> << /cset /N /min 3 /max 3 /opt true /linters [ /lintiso3166 ] >> << /cset /N /min 3 /max 3 /opt true /linters [ /lintiso3166 ] >> ] /ex [ (426) ] /req [ [ [ (01) ] [ (02) ] ] ] >> (425) exch dup pop << /parts [ << /cset /N /min 3 /max 3 /opt false /linters [ /lintiso3166 ] >> ] /req [ [ [ (01) ] [ (02) ] ] ] >> (426) exch dup pop << /parts [ << /cset /X /min 1 /max 3 /opt false /linters [] >> ] /req [ [ [ (01) ] [ (02) ] ] [ [ (422) ] ] ] >> (427) exch dup pop << /parts [ << /cset /X /min 1 /max 35 /opt false /linters [ /lintpcenc ] >> ] /req [ [ [ (00) ] ] ] >> (4300) exch dup (4301) exch dup pop << /parts [ << /cset /X /min 1 /max 70 /opt false /linters [ /lintpcenc ] >> ] /req [ [ [ (00) ] ] ] >> (4302) exch dup pop << /parts [ << /cset /X /min 1 /max 70 /opt false /linters [ /lintpcenc ] >> ] /req [ [ [ (4302) ] ] ] >> (4303) exch dup pop << /parts [ << /cset /X /min 1 /max 70 /opt false /linters [ /lintpcenc ] >> ] /req [ [ [ (00) ] ] ] >> (4304) exch dup (4305) exch dup (4306) exch dup pop << /parts [ << /cset /X /min 2 /max 2 /opt false /linters [ /lintiso3166alpha2 ] >> ] /req [ [ [ (00) ] ] ] >> (4307) exch dup pop << /parts [ << /cset /X /min 1 /max 30 /opt false /linters [] >> ] /req [ [ [ (00) ] ] ] >> (4308) exch dup pop << /parts [ << /cset /N /min 10 /max 10 /opt false /linters [ /lintlatitude ] >> << /cset /N /min 10 /max 10 /opt false /linters [ /lintlongitude ] >> ] /req [ [ [ (00) ] ] ] >> (4309) exch dup pop << /parts [ << /cset /X /min 1 /max 35 /opt false /linters [ /lintpcenc ] >> ] /req [ [ [ (00) ] ] ] >> (4310) exch dup (4311) exch dup pop << /parts [ << /cset /X /min 1 /max 70 /opt false /linters [ /lintpcenc ] >> ] /req [ [ [ (00) ] ] ] >> (4312) exch dup pop << /parts [ << /cset /X /min 1 /max 70 /opt false /linters [ /lintpcenc ] >> ] /req [ [ [ (4312) ] ] ] >> (4313) exch dup pop << /parts [ << /cset /X /min 1 /max 70 /opt false /linters [ /lintpcenc ] >> ] /req [ [ [ (00) ] ] ] >> (4314) exch dup (4315) exch dup (4316) exch dup pop << /parts [ << /cset /X /min 2 /max 2 /opt false /linters [ /lintiso3166alpha2 ] >> ] /req [ [ [ (00) ] ] ] >> (4317) exch dup pop << /parts [ << /cset /X /min 1 /max 20 /opt false /linters [] >> ] /req [ [ [ (00) ] ] ] >> (4318) exch dup pop << /parts [ << /cset /X /min 1 /max 30 /opt false /linters [] >> ] /req [ [ [ (00) ] ] ] >> (4319) exch dup pop << /parts [ << /cset /X /min 1 /max 35 /opt false /linters [ /lintpcenc ] >> ] /req [ [ [ (00) ] ] ] >> (4320) exch dup pop << /parts [ << /cset /N /min 1 /max 1 /opt false /linters [ /lintyesno ] >> ] /req [ [ [ (00) ] ] ] >> (4321) exch dup (4322) exch dup (4323) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [ /lintyymmd0 ] >> << /cset /N /min 4 /max 4 /opt false /linters [ /linthhmi ] >> ] /req [ [ [ (00) ] ] ] >> (4324) exch dup (4325) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [ /lintyymmdd ] >> ] /req [ [ [ (00) ] ] ] >> (4326) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> << /cset /X /min 1 /max 1 /opt true /linters [ /linthyphen ] >> ] /ex [ (4331) ] /req [ [ [ (00) ] ] ] >> (4330) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> << /cset /X /min 1 /max 1 /opt true /linters [ /linthyphen ] >> ] /ex [ (4330) ] /req [ [ [ (00) ] ] ] >> (4331) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> << /cset /X /min 1 /max 1 /opt true /linters [ /linthyphen ] >> ] /ex [ (4333) ] /req [ [ [ (00) ] ] ] >> (4332) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> << /cset /X /min 1 /max 1 /opt true /linters [ /linthyphen ] >> ] /ex [ (4332) ] /req [ [ [ (00) ] ] ] >> (4333) exch dup pop << /parts [ << /cset /N /min 13 /max 13 /opt false /linters [] >> ] /req [ [ [ (01) ] [ (02) ] [ (8006) ] [ (8026) ] ] ] >> (7001) exch dup pop << /parts [ << /cset /X /min 1 /max 30 /opt false /linters [] >> ] /req [ [ [ (01) ] [ (02) ] ] ] >> (7002) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [ /lintyymmdd ] >> << /cset /N /min 4 /max 4 /opt false /linters [ /linthhmi ] >> ] /req [ [ [ (01) ] [ (02) ] ] ] >> (7003) exch dup pop << /parts [ << /cset /N /min 1 /max 4 /opt false /linters [] >> ] /req [ [ [ (01) (10) ] ] ] >> (7004) exch dup pop << /parts [ << /cset /X /min 1 /max 12 /opt false /linters [] >> ] /req [ [ [ (01) ] [ (02) ] ] ] >> (7005) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [ /lintyymmdd ] >> ] /req [ [ [ (01) ] [ (02) ] ] ] >> (7006) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [ /lintyymmdd ] >> << /cset /N /min 6 /max 6 /opt true /linters [ /lintyymmdd ] >> ] /req [ [ [ (01) ] [ (02) ] ] ] >> (7007) exch dup pop << /parts [ << /cset /X /min 1 /max 3 /opt false /linters [] >> ] /req [ [ [ (01) ] [ (02) ] ] ] >> (7008) exch dup pop << /parts [ << /cset /X /min 1 /max 10 /opt false /linters [] >> ] /req [ [ [ (01) ] [ (02) ] ] ] >> (7009) exch dup pop << /parts [ << /cset /X /min 1 /max 2 /opt false /linters [] >> ] /req [ [ [ (01) ] [ (02) ] ] ] >> (7010) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [ /lintyymmdd ] >> << /cset /N /min 4 /max 4 /opt true /linters [ /linthhmi ] >> ] /req [ [ [ (01) ] [ (02) ] ] ] >> (7011) exch dup pop << /parts [ << /cset /X /min 1 /max 20 /opt false /linters [] >> ] /req [ [ [ (01) ] [ (8006) ] ] [ [ (416) ] ] ] >> (7020) exch dup pop << /parts [ << /cset /X /min 1 /max 20 /opt false /linters [] >> ] /req [ [ [ (01) ] [ (8006) ] ] ] >> (7021) exch dup pop << /parts [ << /cset /X /min 1 /max 20 /opt false /linters [] >> ] /req [ [ [ (7021) ] ] ] >> (7022) exch dup pop << /parts [ << /cset /X /min 1 /max 30 /opt false /linters [ /lintgcppos1 ] >> ] >> (7023) exch dup pop << /parts [ << /cset /N /min 3 /max 3 /opt false /linters [ /lintiso3166999 ] >> << /cset /X /min 1 /max 27 /opt false /linters [] >> ] /req [ [ [ (01) ] [ (02) ] ] ] >> (7030) exch dup (7031) exch dup (7032) exch dup (7033) exch dup (7034) exch dup (7035) exch dup (7036) exch dup (7037) exch dup (7038) exch dup (7039) exch dup pop << /parts [ << /cset /N /min 1 /max 1 /opt false /linters [] >> << /cset /X /min 1 /max 1 /opt false /linters [] >> << /cset /X /min 1 /max 1 /opt false /linters [] >> << /cset /X /min 1 /max 1 /opt false /linters [ /lintimporteridx ] >> ] /dlattr false >> (7040) exch dup pop << /parts [ << /cset /X /min 1 /max 4 /opt false /linters [ /lintpackagetype ] >> ] /req [ [ [ (00) ] ] ] /dlattr false >> (7041) exch dup pop << /parts [ << /cset /X /min 1 /max 20 /opt false /linters [] >> ] /req [ [ [ (01) ] ] ] >> (710) exch dup (711) exch dup (712) exch dup (713) exch dup (714) exch dup (715) exch dup (716) exch dup (717) exch dup pop << /parts [ << /cset /X /min 2 /max 2 /opt false /linters [] >> << /cset /X /min 1 /max 28 /opt false /linters [] >> ] /req [ [ [ (01) ] [ (8004) ] ] ] >> (7230) exch dup (7231) exch dup (7232) exch dup (7233) exch dup (7234) exch dup (7235) exch dup (7236) exch dup (7237) exch dup (7238) exch dup (7239) exch dup pop << /parts [ << /cset /X /min 1 /max 20 /opt false /linters [] >> ] /req [ [ [ (01) ] [ (8006) ] ] ] >> (7240) exch dup pop << /parts [ << /cset /N /min 2 /max 2 /opt false /linters [ /lintmediatype ] >> ] /req [ [ [ (8017) ] [ (8018) ] ] ] >> (7241) exch dup pop << /parts [ << /cset /X /min 1 /max 25 /opt false /linters [] >> ] /req [ [ [ (8017) ] [ (8018) ] ] ] >> (7242) exch dup pop << /parts [ << /cset /N /min 8 /max 8 /opt false /linters [ /lintyyyymmdd ] >> ] /ex [ (7251) ] /req [ [ [ (8018) ] ] ] >> (7250) exch dup pop << /parts [ << /cset /N /min 8 /max 8 /opt false /linters [ /lintyyyymmdd ] >> << /cset /N /min 4 /max 4 /opt false /linters [ /linthhmi ] >> ] /ex [ (7250) ] /req [ [ [ (8018) ] ] ] >> (7251) exch dup pop << /parts [ << /cset /N /min 1 /max 1 /opt false /linters [ /lintiso5218 ] >> ] /req [ [ [ (8018) ] ] ] >> (7252) exch dup pop << /parts [ << /cset /X /min 1 /max 40 /opt false /linters [ /lintpcenc ] >> ] /ex [ (7256) (7259) ] /req [ [ [ (8017) ] [ (8018) ] ] ] >> (7253) exch dup (7254) exch dup pop << /parts [ << /cset /X /min 1 /max 10 /opt false /linters [] >> ] /ex [ (7256) (7259) ] /req [ [ [ (8017) ] [ (8018) ] ] ] >> (7255) exch dup pop << /parts [ << /cset /X /min 1 /max 90 /opt false /linters [ /lintpcenc ] >> ] /req [ [ [ (8017) ] [ (8018) ] ] ] >> (7256) exch dup pop << /parts [ << /cset /X /min 1 /max 70 /opt false /linters [ /lintpcenc ] >> ] /req [ [ [ (8018) ] ] ] >> (7257) exch dup pop << /parts [ << /cset /X /min 3 /max 3 /opt false /linters [ /lintposinseqslash ] >> ] /req [ [ [ (8018) (7259) ] ] ] >> (7258) exch dup pop << /parts [ << /cset /X /min 1 /max 40 /opt false /linters [ /lintpcenc ] >> ] /ex [ (7256) ] /req [ [ [ (8018) ] ] ] >> (7259) exch dup pop << /parts [ << /cset /N /min 4 /max 4 /opt false /linters [ /lintnonzero ] >> << /cset /N /min 5 /max 5 /opt false /linters [ /lintnonzero ] >> << /cset /N /min 3 /max 3 /opt false /linters [ /lintnonzero ] >> << /cset /N /min 1 /max 1 /opt false /linters [ /lintwinding ] >> << /cset /N /min 1 /max 1 /opt false /linters [] >> ] /req [ [ [ (01) ] ] ] >> (8001) exch dup pop << /parts [ << /cset /X /min 1 /max 20 /opt false /linters [] >> ] >> (8002) exch dup pop << /parts [ << /cset /N /min 1 /max 1 /opt false /linters [ /lintzero ] >> << /cset /N /min 13 /max 13 /opt false /linters [ /lintcsum /lintgcppos1 ] >> << /cset /X /min 1 /max 16 /opt true /linters [] >> ] /dlpkey [ ] >> (8003) exch dup pop << /parts [ << /cset /X /min 1 /max 30 /opt false /linters [ /lintgcppos1 ] >> ] /dlpkey [ [ (7040) ] ] >> (8004) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [] >> ] /req [ [ [ (01) ] [ (02) ] ] ] >> (8005) exch dup pop << /parts [ << /cset /N /min 14 /max 14 /opt false /linters [ /lintcsum /lintgcppos2 ] >> << /cset /N /min 4 /max 4 /opt false /linters [ /lintpieceoftotal ] >> ] /ex [ (01) (37) ] /dlpkey [ [ (22) (10) (21) ] ] >> (8006) exch dup pop << /parts [ << /cset /X /min 1 /max 34 /opt false /linters [ /lintiban ] >> ] /req [ [ [ (415) ] ] ] >> (8007) exch dup pop << /parts [ << /cset /N /min 6 /max 6 /opt false /linters [ /lintyymmdd ] >> << /cset /N /min 2 /max 2 /opt false /linters [ /linthh ] >> << /cset /N /min 2 /max 2 /opt true /linters [ /lintmi ] >> << /cset /N /min 2 /max 2 /opt true /linters [ /lintss ] >> ] /req [ [ [ (01) ] [ (02) ] ] ] >> (8008) exch dup pop << /parts [ << /cset /X /min 1 /max 50 /opt false /linters [] >> ] /req [ [ [ (00) ] [ (01) ] ] ] >> (8009) exch dup pop << /parts [ << /cset /Y /min 1 /max 30 /opt false /linters [ /lintgcppos1 ] >> ] /dlpkey [ [ (8011) ] ] >> (8010) exch dup pop << /parts [ << /cset /N /min 1 /max 12 /opt false /linters [ /lintnozeroprefix ] >> ] /req [ [ [ (8010) ] ] ] /dlattr false >> (8011) exch dup pop << /parts [ << /cset /X /min 1 /max 20 /opt false /linters [] >> ] /req [ [ [ (01) ] [ (8006) ] ] ] >> (8012) exch dup pop << /parts [ << /cset /X /min 1 /max 25 /opt false /linters [ /lintcsumalpha /lintgcppos1 ] >> ] /dlpkey [ ] >> (8013) exch dup pop << /parts [ << /cset /X /min 1 /max 25 /opt false /linters [ /lintcsumalpha /lintgcppos1 /linthasnondigit ] >> ] /req [ [ [ (01) ] ] ] /dlattr false >> (8014) exch dup pop << /parts [ << /cset /N /min 18 /max 18 /opt false /linters [ /lintcsum /lintgcppos1 ] >> ] /ex [ (8018) ] /dlpkey [ [ (8019) ] ] >> (8017) exch dup pop << /parts [ << /cset /N /min 18 /max 18 /opt false /linters [ /lintcsum /lintgcppos1 ] >> ] /ex [ (8017) ] /dlpkey [ [ (8019) ] ] >> (8018) exch dup pop << /parts [ << /cset /N /min 1 /max 10 /opt false /linters [] >> ] /req [ [ [ (8017) ] [ (8018) ] ] ] /dlattr false >> (8019) exch dup pop << /parts [ << /cset /X /min 1 /max 25 /opt false /linters [] >> ] /req [ [ [ (415) ] ] ] /dlattr false >> (8020) exch dup pop << /parts [ << /cset /N /min 14 /max 14 /opt false /linters [ /lintcsum /lintgcppos2 ] >> << /cset /N /min 4 /max 4 /opt false /linters [ /lintpieceoftotal ] >> ] /ex [ (02) (8006) ] /req [ [ [ (37) ] ] ] >> (8026) exch dup pop << /parts [ << /cset /Z /min 1 /max 90 /opt false /linters [] >> ] /req [ [ [ (00) ] [ (01) (21) ] [ (253) ] [ (255) ] [ (8003) ] [ (8004) ] [ (8006) (21) ] [ (8010) (8011) ] [ (8017) ] [ (8018) ] ] ] >> (8030) exch dup pop << /parts [ << /cset /N /min 15 /max 15 /opt false /linters [] >> ] /req [ [ [ (01) (21) ] ] ] /dlattr false >> (8040) exch dup pop << /parts [ << /cset /N /min 15 /max 15 /opt false /linters [] >> ] /req [ [ [ (01) (21) (8040) ] ] ] /dlattr false >> (8041) exch dup pop << /parts [ << /cset /N /min 32 /max 32 /opt false /linters [] >> ] /req [ [ [ (01) (21) (8040) ] ] ] /dlattr false >> (8042) exch dup pop << /parts [ << /cset /N /min 18 /max 18 /opt false /linters [] >> << /cset /N /min 1 /max 2 /opt true /linters [] >> ] /req [ [ [ (01) (21) (8040) ] ] ] /dlattr false >> (8043) exch dup pop << /parts [ << /cset /X /min 1 /max 70 /opt false /linters [ /lintcouponcode ] >> ] >> (8110) exch dup pop << /parts [ << /cset /N /min 4 /max 4 /opt false /linters [] >> ] /req [ [ [ (255) ] ] ] >> (8111) exch dup pop << /parts [ << /cset /X /min 1 /max 70 /opt false /linters [ /lintcouponposoffer ] >> ] >> (8112) exch dup pop << /parts [ << /cset /X /min 1 /max 70 /opt false /linters [] >> ] /req [ [ [ (01) ] ] ] /dlattr false >> (8200) exch dup pop << /parts [ << /cset /X /min 1 /max 30 /opt false /linters [] >> ] >> (90) exch dup pop << /parts [ << /cset /X /min 1 /max 90 /opt false /linters [] >> ] >> (91) exch dup (92) exch dup (93) exch dup (94) exch dup (95) exch dup (96) exch dup (97) exch dup (98) exch dup (99) exch dup pop >> readonly def /aifixed << [ (00) (01) (02) (03) (04) (11) (12) (13) (14) (15) (16) (17) (18) (19) (20) % (23) % Reassigned to variable-length AI (235)! (31) (32) (33) (34) (35) (36) (41) ] {dup} forall >> readonly def /cset82 << 0 (!"%&'\(\)*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz) { exch dup 1 add } forall pop >> readonly def /cset39 << 0 (#-/0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ) { exch dup 1 add } forall pop >> readonly def /cset32 << 0 (23456789ABCDEFGHJKLMNPQRSTUVWXYZ) { exch dup 1 add } forall pop >> readonly def /cset64 << 0 (ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_) { exch dup 1 add } forall pop >> readonly def /iso3166 << [ /004 /008 /010 /012 /016 /020 /024 /028 /031 /032 /036 /040 /044 /048 /050 /051 /052 /056 /060 /064 /068 /070 /072 /074 /076 /084 /086 /090 /092 /096 /100 /104 /108 /112 /116 /120 /124 /132 /136 /140 /144 /148 /152 /156 /158 /162 /166 /170 /174 /175 /178 /180 /184 /188 /191 /192 /196 /203 /204 /208 /212 /214 /218 /222 /226 /231 /232 /233 /234 /238 /239 /242 /246 /248 /250 /254 /258 /260 /262 /266 /268 /270 /275 /276 /288 /292 /296 /300 /304 /308 /312 /316 /320 /324 /328 /332 /334 /336 /340 /344 /348 /352 /356 /360 /364 /368 /372 /376 /380 /384 /388 /392 /398 /400 /404 /408 /410 /414 /417 /418 /422 /426 /428 /430 /434 /438 /440 /442 /446 /450 /454 /458 /462 /466 /470 /474 /478 /480 /484 /492 /496 /498 /499 /500 /504 /508 /512 /516 /520 /524 /528 /531 /533 /534 /535 /540 /548 /554 /558 /562 /566 /570 /574 /578 /580 /581 /583 /584 /585 /586 /591 /598 /600 /604 /608 /612 /616 /620 /624 /626 /630 /634 /638 /642 /643 /646 /652 /654 /659 /660 /662 /663 /666 /670 /674 /678 /682 /686 /688 /690 /694 /702 /703 /704 /705 /706 /710 /716 /724 /728 /729 /732 /740 /744 /748 /752 /756 /760 /762 /764 /768 /772 /776 /780 /784 /788 /792 /795 /796 /798 /800 /804 /807 /818 /826 /831 /832 /833 /834 /840 /850 /854 /858 /860 /862 /876 /882 /887 /894 ] {dup} forall >> readonly def /iso3166alpha2 << [ /AD /AE /AF /AG /AI /AL /AM /AO /AQ /AR /AS /AT /AU /AW /AX /AZ /BA /BB /BD /BE /BF /BG /BH /BI /BJ /BL /BM /BN /BO /BQ /BR /BS /BT /BV /BW /BY /BZ /CA /CC /CD /CF /CG /CH /CI /CK /CL /CM /CN /CO /CR /CU /CV /CW /CX /CY /CZ /DE /DJ /DK /DM /DO /DZ /EC /EE /EG /EH /ER /ES /ET /FI /FJ /FK /FM /FO /FR /GA /GB /GD /GE /GF /GG /GH /GI /GL /GM /GN /GP /GQ /GR /GS /GT /GU /GW /GY /HK /HM /HN /HR /HT /HU /ID /IE /IL /IM /IN /IO /IQ /IR /IS /IT /JE /JM /JO /JP /KE /KG /KH /KI /KM /KN /KP /KR /KW /KY /KZ /LA /LB /LC /LI /LK /LR /LS /LT /LU /LV /LY /MA /MC /MD /ME /MF /MG /MH /MK /ML /MM /MN /MO /MP /MQ /MR /MS /MT /MU /MV /MW /MX /MY /MZ /NA /NC /NE /NF /NG /NI /NL /NO /NP /NR /NU /NZ /OM /PA /PE /PF /PG /PH /PK /PL /PM /PN /PR /PS /PT /PW /PY /QA /RE /RO /RS /RU /RW /SA /SB /SC /SD /SE /SG /SH /SI /SJ /SK /SL /SM /SN /SO /SR /SS /ST /SV /SX /SY /SZ /TC /TD /TF /TG /TH /TJ /TK /TL /TM /TN /TO /TR /TT /TV /TW /TZ /UA /UG /UM /US /UY /UZ /VA /VC /VE /VG /VI /VN /VU /WF /WS /YE /YT /ZA /ZM /ZW ] {dup} forall >> readonly def /iso4217 << [ /008 /012 /032 /036 /044 /048 /050 /051 /052 /060 /064 /068 /072 /084 /090 /096 /104 /108 /116 /124 /132 /136 /144 /152 /156 /170 /174 /188 /191 /192 /203 /208 /214 /222 /230 /232 /238 /242 /262 /270 /292 /320 /324 /328 /332 /340 /344 /348 /352 /356 /360 /364 /368 /376 /388 /392 /396 /398 /400 /404 /408 /410 /414 /417 /418 /422 /426 /430 /434 /446 /454 /458 /462 /480 /484 /496 /498 /504 /512 /516 /524 /532 /533 /548 /554 /558 /566 /578 /586 /590 /598 /600 /604 /608 /634 /643 /646 /654 /682 /690 /694 /702 /704 /706 /710 /728 /748 /752 /756 /760 /764 /776 /780 /784 /788 /800 /807 /818 /826 /834 /840 /858 /860 /882 /886 /901 /925 /927 /928 /929 /930 /931 /932 /933 /934 /936 /938 /940 /941 /943 /944 /946 /947 /948 /949 /950 /951 /952 /953 /955 /956 /957 /958 /959 /960 /961 /962 /963 /964 /965 /967 /968 /969 /970 /971 /972 /973 /975 /976 /977 /978 /979 /980 /981 /984 /985 /986 /990 /994 /997 /999 ] {dup} forall >> readonly def /aidcmediatype << [ /01 /02 /03 /04 /05 /06 /07 /08 /09 /10 /80 /81 /82 /83 /84 /85 /86 /87 /88 /89 /90 /91 /92 /93 /94 /95 /96 /97 /98 /99 ] {dup} forall >> readonly def /packagetype << [ /1A /1B /1D /1F /1G /1W /200 /201 /202 /203 /204 /205 /206 /210 /211 /212 /2C /3A /3H /43 /44 /4A /4B /4C /4D /4F /4G /4H /5H /5L /5M /6H /6P /7A /7B /8 /8A /8B /8C /9 /AA /AB /AC /AD /AF /AG /AH /AI /AJ /AL /AM /AP /APE/AT /AV /B4 /BB /BC /BD /BE /BF /BG /BGE /BH /BI /BJ /BK /BL /BM /BME /BN /BO /BP /BQ /BR /BRI /BS /BT /BU /BV /BW /BX /BY /BZ /CA /CB /CBL /CC /CCE /CD /CE /CF /CG /CH /CI /CJ /CK /CL /CM /CN /CO /CP /CQ /CR /CS /CT /CU /CV /CW /CX /CY /CZ /DA /DB /DC /DG /DH /DI /DJ /DK /DL /DM /DN /DP /DPE /DR /DS /DT /DU /DV /DW /DX /DY /E1 /E2 /E3 /EC /ED /EE /EF /EG /EH /EI /EN /FB /FC /FD /FE /FI /FL /FO /FOB /FP /FPE /FR /FT /FW /FX /GB /GI /GL /GR /GU /GY /GZ /HA /HB /HC /HG /HN /HR /IA /IB /IC /ID /IE /IF /IG /IH /IK /IL /IN /IZ /JB /JC /JG /JR /JT /JY /KG /KI /LAB /LE /LG /LT /LU /LV /LZ /MA /MB /MC /ME /MPE /MR /MS /MT /MW /MX /NA /NE /NF /NG /NS /NT /NU /NV /OA /OB /OC /OD /OE /OF /OK /OPE /OT /OU /P2 /PA /PAE /PB /PC /PD /PE /PF /PG /PH /PI /PJ /PK /PL /PLP /PN /PO /POP /PP /PPE /PR /PT /PU /PUE /PV /PX /PY /PZ /QA /QB /QC /QD /QF /QG /QH /QJ /QK /QL /QM /QN /QP /QQ /QR /QS /RB1 /RB2 /RB3 /RCB /RD /RG /RJ /RK /RL /RO /RT /RZ /S1 /SA /SB /SC /SD /SE /SEC /SH /SI /SK /SL /SM /SO /SP /SS /ST /STL /SU /SV /SW /SX /SY /SZ /T1 /TB /TC /TD /TE /TEV /TG /THE /TI /TK /TL /TN /TO /TR /TRE /TS /TT /TTE /TU /TV /TW /TWE /TY /TZ /UC /UN /UUE /VA /VG /VI /VK /VL /VN /VO /VP /VQ /VR /VS /VY /WA /WB /WC /WD /WF /WG /WH /WJ /WK /WL /WM /WN /WP /WQ /WR /WRP /WS /WT /WU /WV /WW /WX /WY /WZ /X11 /X12 /X15 /X16 /X17 /X18 /X19 /X20 /X3 /XA /XB /XC /XD /XF /XG /XH /XJ /XK /YA /YB /YC /YD /YF /YG /YH /YJ /YK /YL /YM /YN /YP /YQ /YR /YS /YT /YV /YW /YX /YY /YZ /ZA /ZB /ZC /ZD /ZF /ZG /ZH /ZJ /ZK /ZL /ZM /ZN /ZP /ZQ /ZR /ZS /ZT /ZU /ZV /ZW /ZX /ZY /ZZ ] {dup} forall >> readonly def /init { //gs1process.latevars {def} forall } def end //gs1process.latevars /init get exec setglobal } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//gs1process.latevars /init get exec} if } {pop} ifelse /gs1process { 32 dict begin { //gs1process.latevars /init get exec % Extract AIs and vals from provided GS1 data in the indicated format /ai eq { % Bracketed AI element string % Parse out AIs and values (\() anchorsearch not { pop /bwipp.GS1aiMissingOpenParen (AIs must start with '\(') //raiseerror exec } if pop mark exch { % loop dup () eq {pop exit} if (\)) search not { cleartomark /bwipp.GS1aiMissingCloseParen (AIs must end with '\)') //raiseerror exec } if exch pop exch (\() search { exch pop exch } { () } ifelse } loop counttomark dup 0 gt {dup 2 idiv 1 add -1 exch {-1 roll} for} {pop} ifelse counttomark 2 idiv array astore /ais exch def counttomark array astore [ exch { % Expand ordinals of the form ^NNN to ASCII << /parse parse /parseonly true /parsefnc false >> //parseinput exec } forall ] /vals exch def pop } { % Digital Link URI % Validate and strip the scheme (http://) anchorsearch not { (HTTP://) anchorsearch not { (https://) anchorsearch not { (HTTPS://) anchorsearch not { pop /bwipp.GS1dlURIbadScheme (Scheme must be http:// HTTP:// https:// or HTTPS://) //raiseerror exec } if} if} if} if pop % Strip the domain (/) search not { pop /bwipp.GS1dlMissingDomainOrPathInfo (URI must contain a domain and path info) //raiseerror exec } if pop pop % Fragment delimits end of data (#) search { exch pop exch pop } if % Query parameter marker splits path info and query parameters (?) search not { () exch null exch } if /pp exch def pop /qp exch def % Find positions of character immediately following "/" in the path info mark 0 0 pp { (/) search not {pop exit} if length 1 add exch pop 2 index add exch } loop counttomark 1 sub array astore /pipos exch def pop pop pipos length 1 le { /bwipp.GS1dlNoAIinfo (The path was too short to contain AI info) //raiseerror exec } if % Walk backwards to find the right-most path element that is a valid dlpkey false pipos length 2 sub -2 0 { dup dup pipos exch get exch pipos exch 1 add get 1 index sub 1 sub pp 3 1 roll getinterval dup gs1syntax exch known { gs1syntax exch get /dlpkey known { exch pop true exit } if } { pop } ifelse pop } for not { /bwipp.GS1dlNoAIinfo (The path does not contain a valid primary key) //raiseerror exec } if pipos exch get dup pp length exch sub pp 3 1 roll getinterval /pp exch def /uriunescape { /qq exch def % Is query parameter /in exch def /out in length string def /badhex false def 0 0 { 1 index in length ge {exit} if in 2 index get dup 43 eq qq and { % "+" -> " " in query params pop out 1 index 32 put 1 add exch 1 add exch } { dup 37 eq 3 index in length 2 sub lt and { % "%nn" -> ord pop in 2 index 1 add 2 getinterval 0 exch { dup dup 48 ge exch 57 le and {48 sub} { % 0-9 dup dup 65 ge exch 70 le and {55 sub} { % A-F dup dup 97 ge exch 102 le and {87 sub} { % a-f pop pop /badhex true def 0 exit } ifelse } ifelse } ifelse exch 16 mul add } forall badhex {pop pop exit} if out exch 2 index exch put 1 add exch 3 add exch } { out exch 2 index exch put 1 add exch 1 add exch } ifelse } ifelse } loop badhex { cleartomark /bwipp.GS1dlBadHexCharacter (Invalid hex character) //raiseerror exec } if out exch 0 exch getinterval /out exch def pop out } def /isvaliddlpkeyseq { /in exch def false gs1syntax in 0 get get /dlpkey get { /seq exch def /i 1 def /j 0 def { i in length ge {exit} if j seq length ge {exit} if in i get seq j get eq { /i i 1 add def } if /j j 1 add def } loop i in length eq {pop true exit} if } forall } def /ais 99 array def /vals 99 array def mark 0 % Mark for cleanup on error % Extract AIs from the path components pp { (/) search { ais exch 4 index exch put pop (/) search {exch pop} {() exch} ifelse vals exch 3 index exch false uriunescape put } { pop exit } ifelse exch 1 add exch } loop dup /plen exch def % Validate the key-qualifiers in the path info sequence dup 1 gt { ais 0 plen getinterval isvaliddlpkeyseq not { cleartomark /bwipp.GS1dlBadPathInfo (The AIs in the path are not a valid key-qualifier sequence for the key) //raiseerror exec } if } if % Extract AIs from the query parameters qp { dup () eq {pop exit} if (&) search {exch pop} {() exch} ifelse (=) search { true 1 index {dup 48 ge exch 57 le and and} forall { ais exch 5 index exch put pop vals exch 3 index exch true uriunescape put exch 1 add exch } { % Ignore non-numeric parameters pop pop pop } ifelse } { % Ignore singletons and empty parameters pop } ifelse } loop % Check for invalid DL data attributes in the query params ais plen 2 index plen sub getinterval { gs1syntax 1 index known { gs1syntax 1 index get /dlattr 2 copy known { get } { pop pop true } ifelse } { dontlint } ifelse not { dup length dup 46 add string dup 0 (AI \() putinterval dup 4 4 index putinterval dup 2 index 4 add (\) is not a valid GS1 DL URI data attribute) putinterval exch pop exch pop /bwipp.GS1dlInvalidDataAttribute exch counttomark 1 add 2 roll cleartomark //raiseerror exec } if pop } forall % Check for valid path info attributes in query params ais plen 2 index plen sub getinterval { plen -1 1 { % Trial the query param at each non-initial path info position 1 index [ ais 0 plen getinterval aload pop counttomark 3 add -2 roll exch 1 roll ] isvaliddlpkeyseq { exch pop dup length dup 50 add string dup 0 (AI \() putinterval dup 4 4 index putinterval dup 2 index 4 add (\) from query params should be in the path info) putinterval exch pop exch pop /bwipp.GS1dlAttributeMustBeQualifier exch counttomark 1 add 2 roll cleartomark //raiseerror exec } if } for pop } forall /ais ais 0 3 index getinterval def /vals vals 0 3 index getinterval def pop pop % Remove counter and mark % Expand any extracted GTINs 0 1 ais length 1 sub { dup ais exch get (01) eq { dup vals exch get dup length dup 8 eq exch dup 12 eq exch 13 eq or or { (00000000000000) 14 string copy dup 3 -1 roll dup length 14 exch sub exch putinterval vals exch 2 index exch put } { pop } ifelse } if pop } for } ifelse % Two-digit AI prefixes not requiring FNC1 separation /fncs [ ais { true exch dup length 2 ge { 0 2 getinterval aifixed exch known {pop false} if } { pop } ifelse } forall ] def % Linter routines for validating AI components /lintnumeric { true exch { dup 48 lt exch 57 gt or { pop false exit } if } forall not { pop /bwipp.GS1notNumeric (Not numeric) false exit } if } def /lintcset82 { true exch { cset82 exch known not { pop false exit } if } forall not { pop /bwipp.GS1badCSET82character (Invalid CSET 82 character) false exit } if } def /lintcset39 { true exch { cset39 exch known not { pop false exit } if } forall not { pop /bwipp.GS1badCSET39character (Invalid CSET 39 character) false exit } if } def /lintcset64 { % Trim and validate any padding. Padding is not compulsory. dup (=) search { exch pop dup length 3 mod exch 3 1 roll false 1 index 1 eq 3 index (=) eq and {pop true} if 1 index 2 eq 3 index () eq and {pop true} if not { pop pop pop pop pop /bwipp.GS1badCSET64padding (Invalid CSET 64 padding) false exit } if pop pop exch } if pop % Verify the character set of the remainder true exch { cset64 exch known not { pop false exit } if } forall not { pop /bwipp.GS1badCSET64character (Invalid CSET 64 character) false exit } if } def /lintgcppos1 { dup length 2 lt { pop pop /bwipp.GS1gcpTooShort (Value is too short to contain a GS1 Company Prefix) false exit } if dup 0 get dup 48 lt exch 57 gt or exch 1 get dup 48 lt exch 57 gt or or { pop /bwipp.GS1badGCP (Non-numeric GS1 Company Prefix) false exit } if } def /lintgcppos2 { dup length 1 lt { pop pop /bwipp.GS1valueTooShortForOffsetGCP (Value is too short to contain an offset GS1 Company Prefix) false exit } if dup length 1 sub 1 exch getinterval lintgcppos1 } def /lintimporteridx { (-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz) exch search not {pop pop /bwipp.GS1badImporterIndex (Invalid importer index) false exit} if pop pop pop } def /lintcsum { mark exch dup length 2 mod 0 eq {3} {1} ifelse exch { 48 sub 1 index mul exch 4 exch sub } forall pop 0 counttomark 1 sub {add} repeat exch pop 10 mod 0 ne { pop /bwipp.GS1badChecksum (Bad checksum) false exit } if } def /lintcsumalpha { dup length 2 lt { pop pop /bwipp.GS1alphaTooShort (Alphanumeric string is too short to check) false exit} if dup length 2 sub 2 copy 0 exch getinterval mark exch { dup cset82 exch known { cset82 exch get } { -1 exit } ifelse } forall dup -1 eq { cleartomark pop pop pop /bwipp.GS1UnknownCSET82Character (Unknown CSET 82 character) false exit} if counttomark array astore exch pop 3 1 roll 2 getinterval mark exch { dup cset32 exch known { cset32 exch get } { -1 exit } ifelse } forall dup -1 eq { cleartomark pop pop /bwipp.GS1UnknownCSET32Character (Unknown CSET 32 character) false exit} if counttomark array astore exch pop dup 0 get 5 bitshift exch 1 get add exch //gs1process.primes 1 index length dup 2 index length gt { pop pop pop pop pop /bwipp.GS1alphaTooLong (Alphanumeric string is too long to check) false exit} if 0 exch getinterval {exch} forall 0 exch { 3 -1 roll exch mul add } forall 1021 mod ne { pop /bwipp.GS1badAlphaCheckCharacters (Bad alphanumeric check characters) false exit} if } def /lintiso3166 { iso3166 exch known not { pop /bwipp.GS1UnknownCountry (Unknown country code) false exit } if } def /lintiso3166999 { dup /999 ne { iso3166 exch known not { pop /bwipp.GS1UnknownCountryOr999 (Unknown country code or not 999) false exit } if } { pop } ifelse } def /lintiso3166alpha2 { iso3166alpha2 exch known not { pop /bwipp.GS1UnknownCountryAlpha (Unknown country alpha code) false exit } if } def /lintiso4217 { iso4217 exch known not { pop /bwipp.GS1UnknownCurrency (Unknown currency code) false exit } if } def /lintiso5218 { dup (0) ne exch dup (1) ne exch dup (2) ne exch (9) ne and and and { pop /bwipp.GS1biologicalSexCode (Invalid biological sex code) false exit } if } def /lintiban { dup length 4 le { pop pop /bwipp.GS1tooShort (IBAN too short) false exit } if dup true exch { 1 string dup 0 4 -1 roll put (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ) exch search not { pop pop false exit } if pop pop pop } forall not { pop pop /bwipp.GS1badIBANcharacter (Invalid IBAN character) false exit } if dup mark exch mark exch {} forall counttomark -4 roll counttomark array astore exch pop { 48 sub dup 9 gt {7 sub dup 10 idiv exch 10 mod} if } forall counttomark array astore exch pop 0 exch {exch 10 mul add 97 mod} forall 1 ne { pop pop /bwipp.GS1badIBANchecksum (IBAN checksum incorrect) false exit } if 0 2 getinterval lintiso3166alpha2 } def /lintzero { (0) ne { pop /bwipp.GS1zeroRequired (Zero is required) false exit } if } def /lintnonzero { false exch { 48 ne {pop true} if } forall not { pop /bwipp.GS1zeroNotPermitted (Zero not permitted) false exit } if } def /lintnozeroprefix { dup length 1 gt exch 0 get 48 eq and { pop /bwipp.GS1badZeroPrefix (Zero prefix is not permitted) false exit } if } def /linthasnondigit { false exch { dup 48 lt exch 57 gt or {pop true exit} if } forall not { pop /bwipp.GS1requiresNonDigit (A non-digit character is required) false exit } if } def /linthyphen { (-) ne { pop /bwipp.GS1hyphenRequired (A hyphen is required) false exit } if } def /lintyyyymmd0 { dup 4 2 getinterval cvi dup dup 1 lt exch 12 gt or { pop pop pop /bwipp.GS1badMonth (Invalid month) false exit } if 2 eq { % Leap year? dup 0 4 getinterval cvi dup 400 mod 0 eq exch dup 4 mod 0 eq exch 100 mod 0 ne and or { 29 } { 28 } ifelse } { //gs1process.daysinmonth 1 index 4 2 getinterval cvi 1 sub get } ifelse exch 6 2 getinterval cvi lt { pop /bwipp.GS1badDay (Invalid day of month) false exit } if } def /lintyyyymmdd { dup length 8 ne { pop pop /bwipp.GS1badDateLength (Invalid length for yyyymmdd date) false exit } if dup 6 2 getinterval cvi 1 lt { pop pop /bwipp.GS1badDay (Invalid day of month) false exit } if lintyyyymmd0 } def /lintyymmd0 { dup 0 2 getinterval cvi dup 21 sub % Update 20YY periodically for century calculation dup 51 ge {pop (19)} { -50 le {(21)} {(20)} ifelse} ifelse exch pop % Century prefix 8 string dup 0 4 -1 roll putinterval dup 2 4 -1 roll putinterval lintyyyymmd0 } def /lintyymmdd { dup length 6 ne { pop pop /bwipp.GS1badDateLength (Invalid length for yymmdd date) false exit } if dup 4 2 getinterval cvi 1 lt { pop pop /bwipp.GS1badDay (Invalid day of month) false exit } if lintyymmd0 } def /linthh { 0 2 getinterval cvi 23 gt { pop /bwipp.GS1badHour (Invalid hour of day) false exit } if } def /lintmi { 0 2 getinterval cvi 59 gt { pop /bwipp.GS1badMinute (Invalid minute in the hour) false exit } if } def /lintss { 0 2 getinterval cvi 59 gt { pop /bwipp.GS1badSecond (Invalid second in the minute) false exit } if } def /linthhmi { dup 0 2 getinterval cvi 23 gt { pop pop /bwipp.GS1badHour (Invalid hour of day) false exit } if 2 2 getinterval cvi 59 gt { pop /bwipp.GS1badMinute (Invalid minute in the hour) false exit } if } def /lintmmoptss { dup length dup 2 ne exch 4 ne and { pop /bwipp.GS1badTimeLength (Invalid length for optional minutes and seconds) false exit } if dup 0 2 getinterval cvi 59 gt { pop pop /bwipp.GS1badMinute (Invalid minute in the hour) false exit } if dup length 4 ge { dup 2 2 getinterval cvi 59 gt { pop pop /bwipp.GS1badSecond (Invalid second in the minute) false exit } if } if pop } def /lintyesno { dup (0) ne exch (1) ne and { pop /bwipp.GS1badBoolean (Neither 0 nor 1 for yes or no) false exit } if } def /lintwinding { dup (0) ne exch dup (1) ne exch (9) ne and and { pop /bwipp.GS1badWinding (Invalid winding direction) false exit } if } def /lintpieceoftotal { dup length 2 mod 0 ne { pop pop /bwipp.GS1badPieceTotalLength (Invalid piece/total length) false exit } if dup dup length 2 idiv 0 exch getinterval cvi dup 0 eq { pop pop pop /bwipp.GS1badPieceNumber (Invalid piece number) false exit } if exch dup length 2 idiv dup getinterval cvi dup 0 eq { pop pop pop /bwipp.GS1badPieceTotal (Invalid total number) false exit } if gt { pop /bwipp.GS1pieceExceedsTotal (Piece number exceeds total) false exit } if } def /lintposinseqslash { (/) search not { pop pop /bwipp.invalidPosInSeqFormat (Invalid / format) false exit } if exch pop dup length 0 eq { pop pop pop /bwipp.invalidPosInSeqFormat (Invalid / format) false exit } if 1 index length 0 eq { pop pop pop /bwipp.invalidPosInSeqFormat (Invalid / format) false exit } if dup true exch { dup 48 lt exch 57 gt or { pop false exit } if } forall not { pop pop pop /bwipp.positionNotNumeric (Position is not numeric) false exit } if 1 index true exch { dup 48 lt exch 57 gt or { pop false exit } if } forall not { pop pop pop /bwipp.endNotNumeric (End is not numeric) false exit } if dup 0 get 48 eq {pop pop pop /bwipp.positionZeroPrefix (Position cannot have zero prefix) false exit} if 1 index 0 get 48 eq {pop pop pop /bwipp.endZeroPrefix (End cannot have zero prefix) false exit} if cvi exch cvi exch lt {pop /bwipp.positionExceedsEnd (Position exceeds end) false exit} if } def /lintpcenc { { (%) search not {pop exit} if pop pop dup length 2 lt { pop pop /bwipp.GS1badPercentEscape (Invalid % escape) false exit } if dup 0 2 getinterval true exch { 1 string dup 0 4 -1 roll put (0123456789ABCDEFabcdef) exch search not { pop pop false exit } if pop pop pop } forall not { pop pop /bwipp.GS1badPercentChars (Invalid characters for percent encoding) false exit } if } loop } def /lintcouponcode { dup true exch { dup 48 lt exch 57 gt or { pop false exit } if } forall not { pop pop /bwipp.GS1couponNotNumeric (Coupon not numeric) false exit } if % GCP VLI and value dup length 1 lt { pop pop /bwipp.GS1couponTooShortGCPVLI (Coupon too short: Missing GCP VLI) false exit } if dup 0 1 getinterval cvi dup 6 gt { pop pop pop /bwipp.GS1couponBadGCPVLI (Coupon GCP length indicator must be 0-6) false exit } if 6 add 1 add 2 copy exch length gt { pop pop pop /bwipp.GS1couponTooShortGCP (Coupon too short: GCP truncated) false exit } if dup 2 index length exch sub getinterval % Offer Code dup length 6 lt { pop pop /bwipp.GS1couponTooShortOfferCode (Coupon too short: Offer Code truncated) false exit } if dup length 6 sub 6 exch getinterval % Save Value VLI and value dup length 1 lt { pop pop /bwipp.GS1couponTooShortSaveValueVLI (Coupon too short: Missing Save Value VLI) false exit } if dup 0 1 getinterval cvi dup dup 1 lt exch 5 gt or { pop pop pop /bwipp.GS1couponBadSaveValueVLI (Coupon Save Value length indicator must be 1-5) false exit } if 1 add 2 copy exch length gt { pop pop pop /bwipp.GS1couponTooShortSaveValue (Coupon too short: Save Value truncated) false exit } if dup 2 index length exch sub getinterval % 1st Purchase Requirement VLI and value dup length 1 lt { pop pop /bwipp.GS1couponTooShort1stPurchaseRequirementVLI (Coupon too short: Missing 1st Purchase Requirement VLI) false exit } if dup 0 1 getinterval cvi dup dup 1 lt exch 5 gt or { pop pop pop /bwipp.GS1couponBad1stPurchaseRequirementVLI (Coupon 1st Purchase Requirement length indicator must be 1-5) false exit } if 1 add 2 copy exch length gt { pop pop pop /bwipp.GS1couponTooShort1stPurchaseRequirement (Coupon too short: 1st Purchase Requirement truncated) false exit } if dup 2 index length exch sub getinterval % 1st Purchase Requirement Code dup length 1 lt { pop pop /bwipp.GS1couponTooShort1stPurchaseRequirementCode (Coupon too short: Missing 1st Purchase Requirement Code) false exit } if dup 0 1 getinterval cvi dup 4 gt exch 9 ne and { pop pop /bwipp.GS1couponBad1stPurchaseRequirementCode (Coupon 1st Purchase Requirement Code must be 0-4 or 9) false exit } if dup length 1 sub 1 exch getinterval % 1st Purchase Family Code dup length 3 lt { pop pop /bwipp.GS1couponTooShort1stPurchaseFamilyCode (Coupon too short: 1st Purchase Family Code truncated) false exit } if dup length 3 sub 3 exch getinterval % Optional field 1 dup length 1 ge { dup 0 1 getinterval cvi 1 eq { 1 dup 2 index length exch sub getinterval % Additional Purchase Rules Code dup length 1 lt { pop pop /bwipp.GS1couponTooShortAdditionalPurchaseRulesCode (Coupon too short: Missing Additional Purchase Rules Code) false exit } if dup 0 1 getinterval cvi 3 gt { pop pop /bwipp.GS1couponBadAdditionalPurchaseRulesCode (Coupon Additional Purchase Rules Code must be 0-3) false exit } if dup length 1 sub 1 exch getinterval % 2nd Purchase RequirementVLI and value dup length 1 lt { pop pop /bwipp.GS1couponTooShort2ndPurchaseRequirementVLI (Coupon too short: Missing 2nd Purchase Requirement VLI) false exit } if dup 0 1 getinterval cvi dup dup 1 lt exch 5 gt or { pop pop pop /bwipp.GS1couponBad2ndPurchaseRequirementVLI (Coupon 2nd Purchase Requirement length indicator must be 1-5) false exit } if 1 add 2 copy exch length gt { pop pop pop /bwipp.GS1couponTooShort2ndPurchaseRequirement (Coupon too short: 2nd Purchase Requirement truncated) false exit } if dup 2 index length exch sub getinterval % 2nd Purchase Requirement Code dup length 1 lt { pop pop /bwipp.GS1couponTooShort2ndPurchaseRequirementCode (Coupon too short: Missing 2nd Purchase Requirement Code) false exit } if dup 0 1 getinterval cvi dup 4 gt exch 9 ne and { pop pop /bwipp.GS1couponBad2ndPurchaseRequirementCode (Coupon 2nd Purchase Requirement Code must be 0-4 or 9) false exit } if dup length 1 sub 1 exch getinterval % 2nd Purchase Family Code dup length 3 lt { pop pop /bwipp.GS1couponTooShort2ndPurchaseFamilyCode (Coupon too short: 2nd Purchase Family Code truncated) false exit } if dup length 3 sub 3 exch getinterval % 2nd Purchase GCP VLI and value dup length 1 lt { pop pop /bwipp.GS1couponTooShort2ndPurchaseGCPVLI (Coupon too short: Missing 2nd Purchase GCP VLI) false exit } if dup 0 1 getinterval cvi dup dup 6 gt exch 9 ne and { pop pop pop /bwipp.GS1couponBad2ndPurchaseGCPVLI (Coupon 2nd Purchase GCP length indicator must be 0-6 or 9) false exit } if dup 9 ne {6 add} {pop 0} ifelse 1 add 2 copy exch length gt { pop pop pop /bwipp.GS1couponTooShort2ndPurchaseGCP (Coupon too short: 2nd Purchase GCP truncated) false exit } if dup 2 index length exch sub getinterval } if } if % Optional field 2 dup length 1 ge { dup 0 1 getinterval cvi 2 eq { 1 dup 2 index length exch sub getinterval % 3rd Purchase RequirementVLI and value dup length 1 lt { pop pop /bwipp.GS1couponTooShort3rdPurchaseRequirementVLI (Coupon too short: Missing 3rd Purchase Requirement VLI) false exit } if dup 0 1 getinterval cvi dup dup 1 lt exch 5 gt or { pop pop pop /bwipp.GS1couponBad3rdPurchaseRequirementVLI (Coupon 3rd Purchase Requirement length indicator must be 1-5) false exit } if 1 add 2 copy exch length gt { pop pop pop /bwipp.GS1couponTooShort3rdPurchaseRequirement (Coupon too short: 3rd Purchase Requirement truncated) false exit } if dup 2 index length exch sub getinterval % 3rd Purchase Requirement Code dup length 1 lt { pop pop /bwipp.GS1couponTooShort3rdPurchaseRequirementCode (Coupon too short: Missing 3rd Purchase Requirement Code) false exit } if dup 0 1 getinterval cvi dup 4 gt exch 9 ne and { pop pop /bwipp.GS1couponBad3rdPurchaseRequirementCode (Coupon 3rd Purchase Requirement Code must be 0-4 or 9) false exit } if dup length 1 sub 1 exch getinterval % 3rd Purchase Family Code dup length 3 lt { pop pop /bwipp.GS1couponTooShort3rdPurchaseFamilyCode (Coupon too short: 3rd Purchase Family Code truncated) false exit } if dup length 3 sub 3 exch getinterval % 3rd Purchase GCP VLI and value dup length 1 lt { pop pop /bwipp.GS1couponTooShort3rdPurchaseGCPVLI (Coupon too short: Missing 3rd Purchase GCP VLI) false exit } if dup 0 1 getinterval cvi dup dup 6 gt exch 9 ne and { pop pop pop /bwipp.GS1couponBad3rdPurchaseGCPVLI (Coupon 3rd Purchase GCP length indicator must be 0-6 or 9) false exit } if dup 9 ne {6 add} {pop 0} ifelse 1 add 2 copy exch length gt { pop pop pop /bwipp.GS1couponTooShort3rdPurchaseGCP (Coupon too short: 3rd Purchase GCP truncated) false exit } if dup 2 index length exch sub getinterval } if } if % Optional field 3 /couponexpire -1 def dup length 1 ge { dup 0 1 getinterval cvi 3 eq { 1 dup 2 index length exch sub getinterval % Expiration date dup length 6 lt { pop pop /bwipp.GS1couponTooShortExpirationDate (Coupon too short: Expiration date) false exit } if dup 2 2 getinterval cvi dup dup 1 lt exch 12 gt or { pop pop pop /bwipp.GS1couponExpirationDateBadMonth (Invalid month in expiration date) false exit } if 2 eq { % Leap year? dup 0 2 getinterval cvi dup 21 sub % Update 20YY periodically for century calculation dup 51 ge {pop 1900 add} { -50 le {2100 add} {2000 add} ifelse} ifelse % YYYY dup 400 mod 0 eq exch dup 4 mod 0 eq exch 100 mod 0 ne and or { 29 } { 28 } ifelse } { //gs1process.daysinmonth 1 index 2 2 getinterval cvi 1 sub get } ifelse 1 index 4 2 getinterval cvi dup 3 1 roll lt exch 1 lt or { pop pop /bwipp.GS1couponExpirationDateBadDay (Invalid day of month in expiration date) false exit } if dup 0 6 getinterval cvi /couponexpire exch def dup length 6 sub 6 exch getinterval } if } if % Optional field 4 dup length 1 ge { dup 0 1 getinterval cvi 4 eq { 1 dup 2 index length exch sub getinterval % Start date dup length 6 lt { pop pop /bwipp.GS1couponTooShortStartDate (Coupon too short: Start date) false exit } if dup 2 2 getinterval cvi dup dup 1 lt exch 12 gt or { pop pop pop /bwipp.GS1couponStartDateBadMonth (Invalid month in start date) false exit } if 2 eq { % Leap year? dup 0 2 getinterval cvi dup 21 sub % Update 20YY periodically for century calculation dup 51 ge {pop 1900 add} { -50 le {2100 add} {2000 add} ifelse} ifelse % YYYY dup 400 mod 0 eq exch dup 4 mod 0 eq exch 100 mod 0 ne and or { 29 } { 28 } ifelse } { //gs1process.daysinmonth 1 index 2 2 getinterval cvi 1 sub get } ifelse 1 index 4 2 getinterval cvi dup 3 1 roll lt exch 1 lt or { pop pop /bwipp.GS1couponStartDateBadDay (Invalid day of month in start date) false exit } if dup 0 6 getinterval cvi /couponstart exch def couponexpire -1 ne couponexpire couponstart lt and { pop pop /bwipp.GS1couponExpireDateBeforeStartDate (Coupon expires before it starts) false exit } if dup length 6 sub 6 exch getinterval } if } if % Optional field 5 dup length 1 ge { dup 0 1 getinterval cvi 5 eq { 1 dup 2 index length exch sub getinterval % Serial Number VLI and value dup length 1 lt { pop pop /bwipp.GS1couponTooShortSerialNumberVLI (Coupon too short: Missing Serial Number VLI) false exit } if dup 0 1 getinterval cvi 6 add 1 add 2 copy exch length gt { pop pop pop /bwipp.GS1couponTooShortSerialNumber (Coupon too short: Serial Number truncated) false exit } if dup 2 index length exch sub getinterval } if } if % Optional field 6 dup length 1 ge { dup 0 1 getinterval cvi 6 eq { 1 dup 2 index length exch sub getinterval % Retailer GCP/GLN VLI and value dup length 1 lt { pop pop /bwipp.GS1couponTooShortRetailerGCPGLNVLI (Coupon too short: Missing Retailer GCP/GLN VLI) false exit } if dup 0 1 getinterval cvi dup dup 1 lt exch 7 gt or { pop pop pop /bwipp.GS1couponBadRetailerGCPGLNVLI (Coupon Retailer GCP/GLN length indicator must be 1-7) false exit } if 6 add 1 add 2 copy exch length gt { pop pop pop /bwipp.GS1couponTooShortRetailerGCPGLN (Coupon too short: Retailer GCP/GLN truncated) false exit } if dup 2 index length exch sub getinterval } if } if % Optional field 9 dup length 1 ge { dup 0 1 getinterval cvi 9 eq { 1 dup 2 index length exch sub getinterval % Save Value Code dup length 1 lt { pop pop /bwipp.GS1couponTooShortSaveValueCode (Coupon too short: Missing Save Value Code) false exit } if dup 0 1 getinterval cvi dup 6 gt exch dup 3 eq exch 4 eq or or { pop pop /bwipp.GS1couponBadSaveValueCode (Coupon Save Value Code must be 0,1,2,5 or 6) false exit } if dup length 1 sub 1 exch getinterval % Save Value Applies to Item dup length 1 lt { pop pop /bwipp.GS1couponTooShortSaveValueAppliesToItem (Coupon too short: Missing Save Value Applies to Item) false exit } if dup 0 1 getinterval cvi 2 gt { pop pop /bwipp.GS1couponBadSaveValueAppliesToItem (Coupon Save Value Applies to Item must be 0-2) false exit } if dup length 1 sub 1 exch getinterval % Store Coupon Flag dup length 1 lt { pop pop /bwipp.GS1couponTooShortStoreCouponFlag (Coupon too short: Missing Store Coupon Flag) false exit } if dup length 1 sub 1 exch getinterval % Don't Multiply Flag dup length 1 lt { pop pop /bwipp.GS1couponTooShortDontMultiplyFlag (Coupon too short: Missing Don't Multiply Flag) false exit } if dup 0 1 getinterval cvi 1 gt { pop pop /bwipp.GS1couponBadDontMultiplyFlag (Don't Multiply Flag must be 0 or 1) false exit } if dup length 1 sub 1 exch getinterval } if } if dup length 0 ne { pop pop /bwipp.GS1couponUnrecognisedOptionalField (Coupon fields must be 1,2,3,4,5,6 or 9, increasing order) false exit } if pop } def /lintcouponposoffer { dup true exch { dup 48 lt exch 57 gt or { pop false exit } if } forall not { pop pop /bwipp.GS1couponNotNumeric (Coupon not numeric) false exit } if % Format Code dup length 1 lt { pop pop /bwipp.GS1couponTooShortFormatCode (Coupon too short: Missing Format Code) false exit } if dup 0 1 getinterval dup (0) ne exch (1) ne and { pop pop /bwipp.GS1couponBadFormatCode (Coupon format must be 0 or 1) false exit } if dup length 1 sub 1 exch getinterval % Funder ID VLI and Funder ID dup length 1 lt { pop pop /bwipp.GS1couponTooShortFunderVLI (Coupon too short: Missing Funder VLI) false exit } if dup 0 1 getinterval cvi dup 6 gt { pop pop pop /bwipp.GS1couponBadFunderVLI (Coupon Funder length indicator must be 0-6) false exit } if 6 add 1 add 2 copy exch length gt { pop pop pop /bwipp.GS1couponTooShortFunder (Coupon too short: Truncated Funder ID) false exit } if dup 2 index length exch sub getinterval % Offer Code dup length 6 lt { pop pop /bwipp.GS1couponTooShortOfferCode (Coupon too short: Truncated Offer Code) false exit } if dup length 6 sub 6 exch getinterval % Serial Number VLI and Serial Number dup length 1 lt { pop pop /bwipp.GS1couponTooShortSnVLI (Coupon too short: Missing SN VLI) false exit } if dup 0 1 getinterval cvi 6 add 1 add 2 copy exch length gt { pop pop pop /bwipp.GS1couponTooShortSn (Coupon too short: Truncated SN) false exit } if dup 2 index length exch sub getinterval dup length 0 ne { pop pop /bwipp.GS1couponTooLong (Coupon too long) false exit } if pop } def /lintlatitude { dup length 10 ne { pop /bwipp.GS1badLatitudeLength (Invalid length for a latitude) false exit } if (1800000000) gt { pop /bwipp.GS1badLatitude (Invalid value for latitude) false exit } if } def /lintlongitude { dup length 10 ne { pop /bwipp.GS1badLongitudeLength (Invalid length for a longitude) false exit } if (3600000000) gt { pop /bwipp.GS1badLongitude (Invalid value for longitude) false exit } if } def /lintmediatype { aidcmediatype exch known not { pop /bwipp.GS1UnknownMediaType (Unknown AIDC media type) false exit } if } def /lintpackagetype { packagetype exch known not { pop /bwipp.GS1unknownPackageType (Unknown package type) false exit } if } def dontlint not { % Validate AI contents true 0 1 vals length 1 sub { dup ais exch get /ai exch def vals exch get /val exch def gs1syntax ai known { gs1syntax ai get /parts get % Overall length checks, e.g. to report "too long", not "checksum failure" dup 0 exch {dup /opt get {pop 0} {/min get} ifelse add} forall val length gt { pop pop /bwipp.GS1valueTooShort (Too short) false exit } if dup 0 exch {/max get add} forall val length lt { pop pop /bwipp.GS1valueTooLong (Too long) false exit } if { % Checks for each component of the AI /props exch def props /max get val length 2 copy gt {exch} if pop val exch 0 exch getinterval /eval exch def /val val eval length dup val length exch sub getinterval def eval length 0 eq { props /opt get not { pop /bwipp.GS1valueTooShort (Too short) false exit } if } { eval length props /min get lt { pop /bwipp.GS1valueTooShort (Too short) false exit } if << /N /lintnumeric /X /lintcset82 /Y /lintcset39 /Z /lintcset64 >> props /cset get get eval exch load exec props /linters get { eval exch load exec } forall } ifelse } forall dup not {exit} if val length 0 ne { % Not all data consumed by components pop /bwipp.GS1valueTooLong (Too long) false exit } if } { pop /bwipp.GS1unknownAI (Unrecognised AI) false exit } ifelse } for not { dup length ai length add 5 add string dup 0 (AI ) putinterval dup 3 ai putinterval dup 3 ai length add (: ) putinterval dup 5 ai length add 4 -1 roll putinterval //raiseerror exec } if % Search for "patt" matching an AIs, excluding "this" AI /aiexists { /this exch def /patt exch def 1 { % common exit aivals patt known {true exit} if % Fast path patt length 4 eq { patt 3 1 getinterval (n) eq { /pfxlen patt 2 1 getinterval (n) eq {2} {3} ifelse def false ais { dup dup this ne exch length 4 eq and { 0 pfxlen getinterval patt 0 pfxlen getinterval eq { pop true } if } { pop } ifelse } forall exit } if false exit } if false exit } repeat } def % Build AI dict and validate repeats /aivals vals length dict def 0 1 vals length 1 sub { dup ais exch get /ai exch def vals exch get /val exch def aivals ai known { aivals ai get val ne { ai length 40 add string dup 0 (Repeated AIs \() putinterval dup 14 ai putinterval dup 14 ai length add (\) must have the same value) putinterval /bwipp.GS1repeatedDifferingAIs exch //raiseerror exec } if } { aivals ai val put } ifelse } for % Validate ex and req pairings 0 1 vals length 1 sub { ais exch get /ai exch def gs1syntax ai get /ex 2 copy known { get { /patt exch def patt ai aiexists { ai length patt length add 36 add string dup 0 (AIs \() putinterval dup 5 ai putinterval dup 5 ai length add (\) and \() putinterval dup 12 ai length add patt putinterval dup 12 ai length add patt length add (\) are mutually exclusive) putinterval /bwipp.GS1exclusiveAIs exch //raiseerror exec } if } forall } { pop pop } ifelse lintreqs { gs1syntax ai get /req 2 copy known { get { % For each req attribute instance false exch { % And each AI sequence alternative true exch { % Check whether all AIs in the sequence are present ai aiexists not {pop false} if } forall { pop true exit } if % Wholly matching any of the alternatives is sufficient } forall not { [ gs1syntax ai get /req get { { { (+) } forall pop ( OR ) } forall pop ( WITH ) } forall pop ] dup 0 exch {length add} forall ai length 49 add dup 3 -1 roll add string exch 3 -1 roll { dup length 2 index add 3 index 4 2 roll putinterval } forall pop dup 0 (One of more requisite AIs for AI \() putinterval dup 34 ai putinterval dup 34 ai length add (\) are missing: ) putinterval /bwipp.GS1missingAIs exch //raiseerror exec } if } forall } { pop pop } ifelse } if } for } if % dontlint ais vals fncs } stopped {end stop} if end } [/barcode] {null def} forall bind def /gs1process dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END RESOURCE gs1process-- % --BEGIN RESOURCE setanycolor-- % --REQUIRES preamble setuphooks-- %%BeginResource: uk.co.terryburton.bwipp setanycolor 0.0 2026052800 47627 44058 %%BeginData: 58 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 1 dict begin /setanycolor { /anycolor exch def 1 { % Common exit anycolor length 1 lt { /bwipp.colorEnpty (Colors must not be empty) false exit } if anycolor 0 get 95 ne { % RGB or CMYK anycolor length dup 6 ne exch 8 ne and { /bwipp.colorBadLength (Colors must be 6 or 8 hexadecimal characters or a defined name beginning with underscore) false exit } if mark { 0 2 anycolor length 1 sub { anycolor exch 2 getinterval 0 exch { dup dup 48 ge exch 57 le and {48 sub} { % 0-9 dup dup 65 ge exch 70 le and {55 sub} { % A-F dup dup 97 ge exch 102 le and {87 sub} { % a-f cleartomark stop } ifelse } ifelse } ifelse exch 16 mul add } forall 255 div } for } stopped { /bwipp.colorBadCharacter (RGB and CMYK Colors must be in hexadecimal notation) false exit } if counttomark dup 3 eq { /DeviceRGB } { /DeviceCMYK } ifelse exch 2 add -1 roll pop % clear mark } { % Named color beginning "_..." /uk.co.terryburton.bwipp.global_ctx dup where {exch get} {0 dict} ifelse /named_colors 2 copy known {get} {pop pop 0 dict} ifelse anycolor 2 copy known not { pop pop /bwipp.colorUnknown (Color is not defined) false exit } if get mark exch aload pop counttomark 1 add -2 roll exch pop } ifelse { setcolorspace setcolor } stopped { /bwipp.colorFailedToSet (Failed to set color) false exit } if true exit } repeat } [/barcode] {null def} forall bind def /setanycolor dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END RESOURCE setanycolor-- % --BEGIN RESOURCE fifocache-- % --REQUIRES preamble-- %%BeginResource: uk.co.terryburton.bwipp fifocache 0.0 2026052800 45995 42351 %%BeginData: 108 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 10 dict begin /fifocache.fetch { 8 dict begin /self exch def /cardfn exch def /genfn exch def /key exch def /cache self /cache get def cache key known { % Hit % % Return the existing result % cache key get } { % Miss /fifo self /fifo get def /max self /max get def /limit self /limit get def % % Generate result in global VM % currentglobal true setglobal genfn exec /result exch def result cardfn exec /card exch def % Cardinality of the result card limit le { % % Sufficient space: Cache and return % self /state get begin % % Evict until sufficient space for result % { % loop total card add limit le cnt max lt and { exit } if fifo head get % old_key = fifo[head] cache 1 index get cardfn exec % old_card = cardfn(cache[old_key]) /total exch total exch sub def % total -= old_card cache exch undef % delete cache[old_key] /head head 1 add max mod def % head++ (mod max) /cnt cnt 1 sub def % cnt-- } loop % % Store the result under the new key % cache key result put % cache[key] = result fifo head cnt add max mod % tail = (head + cnt) mod max key put % fifo[tail] = key /cnt cnt 1 add def % cnt++ /total total card add def % total += card end % self.state } if setglobal result } ifelse end } bind def % % Initialisation routine % /fifocache { 8 dict begin /limit exch def /max exch def /cache max dict def /fifo max array def /state << /head 0 /cnt 0 /total 0 >> def /fetch currentdict [ exch { //fifocache.fetch exec } aload pop ] cvx def currentdict % Leave this on the stack end } bind def /fifocache dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END RESOURCE fifocache-- % --BEGIN RESOURCE rsecbinary-- % --REQUIRES preamble-- %%BeginResource: uk.co.terryburton.bwipp rsecbinary 0.0 2026052800 40129 36516 %%BeginData: 49 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 4 dict begin % % Reed-Solomon encoder for binary extension fields GF(2^n). % % Runs a streaming LFSR over nd data codewords using the generator polynomial % coeffs. The caller-owned lfsr is the shift register; on return, its first % nc cells are the ECC codewords. Addition is XOR; multiplication is delegated % to the caller-supplied rsprod procedure (typically a log/alog table lookup). % /rsecbinary { 7 dict begin /rsprod exch def % Implements GF multiplication. /lfsr exch def % Workspace of length at least nc /nc exch def % Number of ECC codewords to produce /coeffs exch def % Generator polynomial coefficients /nd exch def % Number of data codewords /getdata exch def % Implements fetching nth codeword 0 1 nc 1 sub {lfsr exch 0 put} for 0 1 nd 1 sub { % m getdata exec lfsr 0 get xor % fb = data[m] ^ S[0] 0 1 nc 2 sub { % j lfsr exch dup 1 add % ... lfsr j j+1 2 index exch get % ... lfsr j S[j+1] coeffs nc 3 index sub 1 sub get % ... coeffs[nc-1-j] 4 index % ... fb rsprod exec % p = coeffs[nc-1-j] * fb xor put % S[j] = S[j+1] ^ p } for lfsr nc 1 sub coeffs 0 get 3 index % S[nc-1] = coeffs[0] * fb rsprod exec put pop % fb } for end } bind def /rsecbinary dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END RESOURCE rsecbinary-- % --BEGIN RESOURCE rsecprime-- % --REQUIRES preamble-- %%BeginResource: uk.co.terryburton.bwipp rsecprime 0.0 2026052800 40415 36825 %%BeginData: 50 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 4 dict begin % % Reed-Solomon encoder for prime-field GF(p). % % Runs a streaming LFSR over nd data codewords using the generator polynomial % coeffs. The caller-owned lfsr is the shift register; on return, its first % nc cells are the ECC codewords in the negated form expected by callers % (pdf417, micropdf417, ultracode): this fuses what used to be a separate % post-pass of (p - cws[i]) mod p into the inner update. % /rsecprime { 7 dict begin /p exch def % Prime modulus /lfsr exch def % Workspace of length at least nc /nc exch def % Number of ECC codewords to produce /coeffs exch def % Generator polynomial coefficients /nd exch def % Number of data codewords /getdata exch def % Implements fetching nth codeword 0 1 nc 1 sub {lfsr exch 0 put} for 0 1 nd 1 sub { % m getdata exec lfsr 0 get sub p add p mod % fb = (data[m] - S[0]) mod p 0 1 nc 2 sub { % j lfsr exch dup 1 add % ... lfsr j j+1 2 index exch get % ... lfsr j S[j+1] coeffs nc 3 index sub 1 sub get % ... coeffs[nc-1-j] 4 index % ... fb mul p mod % prod = (coeffs[nc-1-j] * fb) mod p add p mod put % S[j] = (S[j+1] + prod) mod p } for lfsr nc 1 sub coeffs 0 get 3 index % S[nc-1] = (coeffs[0] * fb) mod p mul p mod put pop % fb } for end } bind def /rsecprime dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END RESOURCE rsecprime-- % --BEGIN RESOURCE render-- % --REQUIRES preamble raiseerror processoptions setanycolor-- %%BeginResource: uk.co.terryburton.bwipp render 0.0 2026052800 336144 391341 %%BeginData: 1198 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 48 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /setanycolor dup /uk.co.terryburton.bwipp findresource put begin % Text position lookup table /render.positions << % direction % x-align y-align (forward) << (offleft) { tw neg nudge sub } bind (below) { th neg nudge sub } bind (left) { 0 } bind (bottom) { 0 } bind (xcenter) { pixx tw sub 2 div } bind (ycenter) { pixy th sub 2 div } bind (right) { pixx tw sub } bind (top) { pixy th sub } bind (offright) { pixx nudge add } bind (above) { pixy nudge add } bind >> (backward) << (offleft) { 0 nudge sub } bind (below) { 0 nudge sub } bind (left) { tw } bind (bottom) { th } bind (xcenter) { pixx tw add 2 div } bind (ycenter) { pixy th add 2 div } bind (right) { pixx } bind (top) { pixy } bind (offright) { pixx tw add nudge add } bind (above) { pixy th add nudge add } bind >> (upward) << (offleft) { 0 nudge sub } bind (below) { tw neg nudge sub } bind (left) { th } bind (bottom) { 0 } bind (xcenter) { pixx th add 2 div } bind (ycenter) { pixy tw sub 2 div } bind (right) { pixx } bind (top) { pixy tw sub } bind (offright) { pixx th add nudge add } bind (above) { pixy nudge add } bind >> (downward) << (offleft) { th neg nudge sub } bind (below) { 0 nudge sub } bind (left) { 0 } bind (bottom) { tw } bind (xcenter) { pixx th sub 2 div } bind (ycenter) { pixy tw add 2 div } bind (right) { pixx th sub } bind (top) { pixy } bind (offright) { pixx nudge add } bind (above) { pixy tw add nudge add } bind >> >> readonly def % Rotation angle per direction (also serves as the direction-validity set) /render.directionrotate << (forward) 0 (backward) 180 (upward) 90 (downward) 270 >> readonly def % Template for text option groups /render.groupoptions << () () (subspace) () (split) () (linegaps) 1.2 (color) (unset) (xalign) (left) (yalign) (above) (direction) (forward) (font) (Courier) (size) 10.0 (xoffset) 0.0 (yoffset) 0.0 (gaps) 0.0 >> readonly def % Validation dicts /render.xalignopts << /offleft dup /left dup /center dup /right dup /offright dup /justify dup >> readonly def /render.yalignopts << /above dup /top dup /center dup /bottom dup /below dup /justify dup >> readonly def % % Validate a single text option dict % % grp textdict /validatetextoptions //render exec => bool [errorname errorstring |] % /render.validatetextoptions { 16 dict begin /td exch def /grp exch def % Build prefix: text | extratext | textN /pfx grp 1 eq { (text) } { grp 2 eq { (extratext) } { 5 string dup 0 (text) putinterval dup 4 grp 48 add put } ifelse } ifelse def /mkerr { % /property (msgtail) => errorname errorstring /msgtail exch def /prop exch 128 string cvs def pfx length 9 add prop length add string dup 0 (bwipp.) putinterval dup 6 pfx putinterval dup pfx length 6 add (Bad) putinterval dup pfx length 9 add prop putinterval cvn pfx length prop length add msgtail length add string dup 0 pfx putinterval dup pfx length prop putinterval dup pfx length prop length add msgtail putinterval } def 1 { % Common exit td (xalign) get dup (unset) ne { //render.xalignopts exch known not { /xalign ( must be offleft, left, center, right, offright or justify) mkerr false exit } if } { pop } ifelse td (yalign) get dup (unset) ne { //render.yalignopts exch known not { /yalign ( must be above, top, center, bottom, below or justify) mkerr false exit } if } { pop } ifelse //render.directionrotate td (direction) get known not { /direction ( must be forward, backward, upward or downward) mkerr false exit } if td (size) get dup 0 le exch 25 ge or { /size ( must be greater than zero and less than 25) mkerr false exit } if td (xoffset) get dup -150 lt exch 150 gt or { /xoffset ( must be from -150 to 150) mkerr false exit } if td (yoffset) get dup -150 lt exch 150 gt or { /yoffset ( must be from -150 to 150) mkerr false exit } if td (gaps) get dup -20 lt exch 20 gt or { /gaps ( must be from -20 to 20) mkerr false exit } if td (linegaps) get dup 0 lt exch 20 gt or { /linegaps ( must be from 0 to 20) mkerr false exit } if true exit } repeat end } bind def % % Render a single text element % % pixx pixy grp textdict /rendertext //render exec => bool [errorname errorstring |] % /render.rendertext { begin % td on dict stack 32 dict begin /grp exch def /pixy exch def /pixx exch def /makeerr { % /errname (errmsg) => /bwipp.PFXerrname (PFXerrmsg) /makeerr.msg exch def /makeerr.name exch 128 string cvs def grp 1 eq { (text) } { grp 2 eq { (extratext) } { 5 string dup 0 (text) putinterval dup 4 grp 48 add put } ifelse } ifelse /makeerr.pfx exch def makeerr.pfx length 6 add makeerr.name length add string dup 0 (bwipp.) putinterval dup 6 makeerr.pfx putinterval dup makeerr.pfx length 6 add makeerr.name putinterval cvn makeerr.pfx length makeerr.msg length add string dup 0 makeerr.pfx putinterval dup makeerr.pfx length makeerr.msg putinterval } def /positiontext { /th exch def /tw exch def /nudge 1 def //render.positions exch get dup 4 -1 roll dup (center) eq {pop (xcenter)} if get exec exch 3 -1 roll dup (center) eq {pop (ycenter)} if get exec } def 1 { % Common exit % % Encoder-positioned text % txt length 0 gt xalign (unset) eq and yalign (unset) eq and content () eq and { color (unset) ne { color //setanycolor exec not { false exit } if } if /s 0 def /fn () def /xoff 0 def /yoff 0 def { txt { aload pop 2 copy s ne exch fn ne or { dup 0 le { pop pop pop pop pop stop } if 2 copy /s exch def /fn exch def selectfont % Ink-centre offsets (0) stringwidth pop 2 div neg /xoff exch def gsave newpath 0 0 moveto (0) false charpath pathbbox grestore exch pop add 2 div neg /yoff exch def pop } { pop pop } ifelse moveto xoff yoff rmoveto show } forall } stopped { /bwipp.fontTooSmall (The font size is too small) false exit } if true exit } if % % Text content with alignment % % Extract text from txt array if content empty but txt available content () eq txt length 0 gt and { /txtchars [ txt { 0 get {} forall } forall ] def /tstr txtchars length string def 0 1 txtchars length 1 sub { dup txtchars exch get tstr 3 1 roll put } for /content tstr def } if % Nothing to render content () eq { true exit } if % Space replacement subspace () ne subspace length 1 ne and { /subspaceBad (subspace option must be a single character) makeerr false exit } if subspace () ne { 0 1 content length 1 sub { dup content exch 1 getinterval subspace exch search { content 4 index 32 put pop pop } if pop pop } for } if % Split into lines split () ne { split length 1 ne { /splitBad (split option must be a single character) makeerr false exit } if /textlines [ content { split search { exch pop exch } { exit } ifelse } loop ] def } { /textlines [ content ] def } ifelse color (unset) ne { color //setanycolor exec not { false exit } if } if font size selectfont % Find true ascent of font gsave newpath 0 0 moveto (0) false charpath pathbbox 4 1 roll pop pop pop grestore currentfont /PaintType known {currentfont /PaintType get 2 eq} {false} ifelse currentfont /StrokeWidth known and { currentfont /StrokeWidth get 2 div 0 exch currentfont /FontMatrix get dtransform dup mul exch dup mul add sqrt add } if /textascent exch def /textwidth 0 textlines { stringwidth pop 2 copy lt {exch} if pop } forall content length 1 sub gaps mul add def /textheight textlines length dup textascent mul exch 1 sub linegaps mul add def xalign (unset) eq { /xalign (center) def } if yalign (unset) eq { /yalign (below) def } if xalign (justify) eq { direction (forward) ne direction (backward) ne and { /xjustify (xalign=justify requires forward or backward text) makeerr false exit } if textwidth pixx lt content length 1 gt and { /gaps pixx textwidth sub content length 1 sub div def /xalign direction (forward) eq { (left) } { (right) } ifelse def } { /gaps 0.0 def /xalign (center) def } ifelse } if yalign (justify) eq { direction (upward) ne direction (downward) ne and { /yjustify (yalign=justify requires upward or downward text) makeerr false exit } if textwidth pixy lt content length 1 gt and { /gaps pixy textwidth sub content length 1 sub div def /yalign direction (upward) eq { (bottom) } { (top) } ifelse def } { /gaps 0.0 def /yalign (center) def } ifelse } if xalign yalign direction textwidth textheight positiontext exec moveto xoffset yoffset rmoveto gsave //render.directionrotate direction get rotate currentpoint translate 0 1 textlines length 1 sub { /i exch def 0 0 textascent linegaps add i mul add moveto gaps 0 textlines dup length i sub 1 sub get ashow } for grestore true exit } repeat end end % td } bind def % % Render text groups 1-9 % /render.textgroups { 4 dict begin /pixy exch def /pixx exch def /ok true def 1 1 9 { /textgrp exch def textopts textgrp 1 sub get () get () ne % Has manual contents textgrp 1 eq txt length 0 gt and includetext and or % or text1 with encoder txt and includetext { textopts textgrp 1 sub get dup (txt) textgrp 1 eq { txt } { [] } ifelse put dup dup () get (content) exch put pixx pixy textgrp 4 -1 roll //render.rendertext exec not { /ok false def exit } if } if } for ok end } bind def % % Application Specification Tables (ASTs) % /render.ast << /ean13 << /default << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 22.85 >> /gs1.sst1 1 index % << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 22.85 >> /gs1.sst2 << /xmin 0.495 /xnom 0.660 /xmax 0.660 /hnom 45.70 >> /gs1.sst3 1 index % << /xmin 0.495 /xnom 0.660 /xmax 0.660 /hnom 45.70 >> /gs1.sst4 5 index % << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 22.85 >> /gs1.sst6 << /xmin 0.170 /xnom 0.330 /xmax 0.660 /hnom 22.85 >> /gs1.sst8 5 index % << /xmin 0.495 /xnom 0.660 /xmax 0.660 /hnom 45.70 >> /gs1.sst10 5 index % << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 22.85 >> >> /upca 1 index /upce 1 index /isbn 1 index /ismn 1 index /issn 1 index /ean13composite 1 index /upcacomposite 1 index /upcecomposite 1 index /ean8 << /default << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 18.23 >> /gs1.sst1 1 index % << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 18.23 >> /gs1.sst2 << /xmin 0.495 /xnom 0.660 /xmax 0.660 /hnom 36.46 >> /gs1.sst3 1 index % << /xmin 0.495 /xnom 0.660 /xmax 0.660 /hnom 36.46 >> /gs1.sst4 5 index % << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 18.23 >> /gs1.sst6 << /xmin 0.170 /xnom 0.330 /xmax 0.660 /hnom 18.23 >> /gs1.sst8 5 index % << /xmin 0.495 /xnom 0.660 /xmax 0.660 /hnom 36.46 >> /gs1.sst10 5 index % << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 18.23 >> >> /ean8composite 1 index /itf14 << /default << /xmin 0.495 /xnom 0.495 /xmax 1.016 /hnom 31.75 >> /gs1.sst2 1 index % << /xmin 0.495 /xnom 0.495 /xmax 1.016 /hnom 31.75 >> /gs1.sst4 << /xmin 0.250 /xnom 0.495 /xmax 0.495 /hnom 12.70 >> /gs1.sst6 << /xmin 0.170 /xnom 0.495 /xmax 0.495 /hnom 12.70 >> /gs1.sst8 5 index % << /xmin 0.495 /xnom 0.495 /xmax 1.016 /hnom 31.75 >> /gs1.sst10 << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 12.70 >> >> /gs1-128 << /default << /xmin 0.170 /xmax 1.016 >> /gs1.sst2 << /xmin 0.495 /xnom 0.495 /xmax 1.016 /hnom 31.75 >> /gs1.sst4 << /xmin 0.250 /xnom 0.495 /xmax 0.495 /hnom 12.70 >> /gs1.sst5 << /xmin 0.495 /xnom 0.495 /xmax 0.940 /hnom 31.75 >> /gs1.sst6 << /xmin 0.170 /xnom 0.495 /xmax 0.495 /hnom 12.70 >> /gs1.sst8 7 index % << /xmin 0.495 /xnom 0.495 /xmax 1.016 /hnom 31.75 >> /gs1.sst9 << /xmin 0.250 /xnom 0.250 /xmax 0.495 /hnom 12.70 >> /gs1.sst10 << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 12.70 >> /gs1.sst11 << /xmin 0.170 /xnom 0.250 /xmax 0.495 /hnom 12.70 >> /gs1.sst12.group 7 index % << /xmin 0.495 /xnom 0.495 /xmax 1.016 /hnom 31.75 >> /gs1.sst12.logistic 13 index % << /xmin 0.495 /xnom 0.495 /xmax 0.940 /hnom 31.75 >> /gs1.sst13 << /xmin 0.495 /xmax 0.940 /hnom 12.70 >> >> /gs1-128composite 1 index /databaromni << /default << /xmin 0.170 /xmax 0.660 >> /gs1.sst1 << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 15.19 >> /gs1.sst2 << /xmin 0.495 /xnom 0.660 /xmax 0.660 /hnom 21.78 >> /gs1.sst3 << /xmin 0.495 /xnom 0.660 /xmax 0.660 /hnom 30.36 >> /gs1.sst4 << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 10.89 >> /gs1.sst6 << /xmin 0.170 /xnom 0.200 /xmax 0.660 /hnom 6.60 >> /gs1.sst8 7 index % << /xmin 0.495 /xnom 0.660 /xmax 0.660 /hnom 21.78 >> /gs1.sst10 5 index % << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 10.89 >> >> /databaromnicomposite 1 index /databartruncated << /default << /xmin 0.170 /xmax 0.660 >> /gs1.sst4 << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 4.29 >> /gs1.sst6 << /xmin 0.170 /xnom 0.200 /xmax 0.660 /hnom 2.60 >> /gs1.sst8 << /xmin 0.495 /xnom 0.660 /xmax 0.660 /hnom 8.58 >> /gs1.sst10 5 index % << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 4.29 >> >> /databartruncatedcomposite 1 index /databarstacked << /default << /xmin 0.170 /xmax 0.660 >> /gs1.sst2 << /xmin 0.495 /xnom 0.660 /xmax 0.660 /hnom 8.58 >> /gs1.sst4 3 index % << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 4.29 >> /gs1.sst6 << /xmin 0.170 /xnom 0.200 /xmax 0.660 /hnom 2.60 >> /gs1.sst8 5 index % << /xmin 0.495 /xnom 0.660 /xmax 0.660 /hnom 8.58 >> /gs1.sst10 5 index % << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 4.29 >> >> /databarstackedcomposite 1 index /databarstackedomni << /default << /xmin 0.170 /xmax 0.660 >> /gs1.sst1 << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 31.37 >> /gs1.sst2 << /xmin 0.495 /xnom 0.660 /xmax 0.660 /hnom 45.54 >> /gs1.sst3 << /xmin 0.495 /xnom 0.660 /xmax 0.660 /hnom 62.70 >> /gs1.sst4 << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 27.78 >> /gs1.sst6 << /xmin 0.170 /xnom 0.200 /xmax 0.660 /hnom 13.80 >> /gs1.sst8 7 index % << /xmin 0.495 /xnom 0.660 /xmax 0.660 /hnom 45.54 >> /gs1.sst10 << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 27.78 >> >> /databarstackedomnicomposite 1 index /databarlimited << /default << /xmin 0.170 /xmax 0.660 >> /gs1.sst2 << /xmin 0.495 /xnom 0.660 /xmax 0.660 /hnom 6.60 >> /gs1.sst4 << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 3.30 >> /gs1.sst6 << /xmin 0.170 /xnom 0.200 /xmax 0.660 /hnom 2.00 >> /gs1.sst8 5 index % << /xmin 0.495 /xnom 0.660 /xmax 0.660 /hnom 6.60 >> /gs1.sst10 5 index % << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 3.30 >> >> /databarlimitedcomposite 1 index /databarexpanded << /default << /xmin 0.170 /xmax 0.660 >> /gs1.sst1 << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 11.23 >> /gs1.sst2 << /xmin 0.495 /xnom 0.660 /xmax 0.660 /hnom 22.44 >> /gs1.sst3 1 index % << /xmin 0.495 /xnom 0.660 /xmax 0.660 /hnom 22.44 >> /gs1.sst4 5 index % << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 11.23 >> /gs1.sst6 << /xmin 0.170 /xnom 0.200 /xmax 0.660 /hnom 6.80 >> /gs1.sst8 5 index % << /xmin 0.495 /xnom 0.660 /xmax 0.660 /hnom 22.44 >> /gs1.sst10 5 index % << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 11.23 >> /gs1.sst11 1 index % << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 11.23 >> >> /databarexpandedcomposite 1 index /databarexpandedstacked << /default << /xmin 0.170 /xmax 0.660 >> /gs1.sst1 << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 23.44 >> /gs1.sst2 << /xmin 0.495 /xnom 0.660 /xmax 0.660 /hnom 46.86 >> /gs1.sst3 1 index % << /xmin 0.495 /xnom 0.660 /xmax 0.660 /hnom 46.86 >> /gs1.sst4 5 index % << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 23.44 >> /gs1.sst6 << /xmin 0.170 /xnom 0.200 /xmax 0.660 /hnom 14.20 >> /gs1.sst8 5 index % << /xmin 0.495 /xnom 0.660 /xmax 0.660 /hnom 46.86 >> /gs1.sst10 11 index % << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 23.44 >> /gs1.sst11 1 index % << /xmin 0.264 /xnom 0.330 /xmax 0.660 /hnom 23.44 >> >> /databarexpandedstackedcomposite 1 index /gs1northamericancoupon 1 index /gs1datamatrix << /default << /xmin 0.100 /xmax 3.500 >> /gs1.sst1 << /xmin 0.375 /xnom 0.625 /xmax 0.990 >> /gs1.sst1.ai8200 << /xmin 0.396 /xnom 0.495 /xmax 0.743 >> /gs1.sst1.dl 1 index % << /xmin 0.396 /xnom 0.495 /xmax 0.743 >> /gs1.sst2 << /xmin 0.743 /xnom 0.743 /xmax 1.500 >> /gs1.sst4 << /xmin 0.380 /xnom 0.380 /xmax 0.495 >> /gs1.sst5 3 index % << /xmin 0.743 /xnom 0.743 /xmax 1.500 >> /gs1.sst6 << /xmin 0.254 /xnom 0.380 /xmax 0.990 >> /gs1.sst7 << /xmin 0.254 /xnom 0.300 /xmax 0.615 >> /gs1.sst7.dpm.a << /xmin 0.100 /xnom 0.200 /xmax 0.300 >> /gs1.sst7.dpm.b << /xmin 0.200 /xnom 0.300 /xmax 0.495 >> /gs1.sst8 << /xmin 0.750 /xnom 0.750 /xmax 1.520 >> /gs1.sst9 13 index % << /xmin 0.380 /xnom 0.380 /xmax 0.495 >> /gs1.sst10 << /xmin 0.396 /xnom 0.495 /xmax 0.990 >> /gs1.sst11 << /xmin 0.254 /xnom 0.380 /xmax 0.495 >> /gs1.sst12.trade << /xmin 0.380 /xnom 0.380 /xmax 0.990 >> /gs1.sst12.group 9 index % << /xmin 0.750 /xnom 0.750 /xmax 1.520 >> /gs1.sst12.logistic 1 index % << /xmin 0.750 /xnom 0.750 /xmax 1.520 >> /gs1.sst13 << /xmin 0.495 /xmax 3.500 >> >> /gs1datamatrixrectangular 1 index /gs1datamatrixrectangularextension 1 index /gs1qrcode << /default << /xmin 0.254 /xmax 3.500 >> /gs1.sst1 << /xmin 0.375 /xnom 0.625 /xmax 0.990 >> /gs1.sst1.ai8200 << /xmin 0.396 /xnom 0.495 /xmax 0.743 >> /gs1.sst1.dl 1 index % << /xmin 0.396 /xnom 0.495 /xmax 0.743 >> /gs1.sst2 << /xmin 0.743 /xnom 0.743 /xmax 1.500 >> /gs1.sst4 << /xmin 0.380 /xnom 0.380 /xmax 0.495 >> /gs1.sst5 3 index % << /xmin 0.743 /xnom 0.743 /xmax 1.500 >> /gs1.sst7 << /xmin 0.254 /xnom 0.300 /xmax 0.615 >> /gs1.sst8 << /xmin 0.750 /xnom 0.750 /xmax 1.520 >> /gs1.sst9 7 index % << /xmin 0.380 /xnom 0.380 /xmax 0.495 >> /gs1.sst11 << /xmin 0.254 /xnom 0.380 /xmax 0.495 >> /gs1.sst12.trade << /xmin 0.380 /xnom 0.380 /xmax 0.990 >> /gs1.sst12.group 7 index % << /xmin 0.750 /xnom 0.750 /xmax 1.520 >> /gs1.sst12.logistic 1 index % << /xmin 0.750 /xnom 0.750 /xmax 1.520 >> /gs1.sst13 << /xmin 0.495 /xmax 3.500 >> >> /gs1dotcode << /default << /xmin 0.380 /xnom 0.380 /xmax 0.990 >> /gs1.sst12.trade 1 index % << /xmin 0.380 /xnom 0.380 /xmax 0.990 >> >> /gs1dldatamatrix << /default << /xmin 0.396 /xnom 0.495 /xmax 0.743 >> /gs1.sst1.dl 1 index % << /xmin 0.396 /xnom 0.495 /xmax 0.743 >> >> /gs1dlqrcode << /default << /xmin 0.396 /xnom 0.495 /xmax 0.743 >> /gs1.sst1.dl 1 index % << /xmin 0.396 /xnom 0.495 /xmax 0.743 >> >> % ISO/AIM symbology defaults (non-GS1) /code39 << /default << /xmin 0.191 >> >> /interleaved2of5 << /default << /xmin 0.191 >> >> /qrcode << /default << /xmin 0.250 >> >> /datamatrix << /default << /xmin 0.250 >> >> /d3aqr << /default << /xnom 1.440 >> (15) << /xnom 0.846 >> (25) 3 index % << /xnom 1.440 >> (40) << /xnom 2.290 >> (75) << /xnom 4.320 >> (150) << /xnom 8.460 >> >> /pharmacode << /default << /xnom 0.500 /hnom 8.000 >> >> /maxicode << /default << /xnom 0.880 >> >> % Postal symbology defaults /onecode << /default << /xmin 0.381 /xnom 0.508 /xmax 0.635 /hnom 3.683 >> >> >> readonly def % % Set xmin, xnom, xmax and hnom based on AST for an encoder % /render.apply_ast { currentdict 4 dict begin /tgt exch def /astname exch def /encname exch def 1 { % Common exit //render.ast encname 2 copy known not { pop pop astname /default eq exit } if get astname 2 copy known not { pop pop astname /default eq exit } if get { % key value tgt 2 index known { tgt 2 index get -1 eq { tgt 3 1 roll put } { % Skip if already defined pop pop } ifelse } { % Key not in caller's dict; skip pop pop } ifelse } forall true } repeat dup not { pop /bwipp.renderUnknownAST [ (Unknown AST ") astname (" for ) encname 40 string cvs ] dup 0 exch { length add } forall string exch 0 exch { dup length 2 index add 3 index 4 2 roll putinterval } forall pop false } if end } bind def % % Validate effective X dimension against spec bounds (low-level) % % xdim xmin xmax => true | /errorname (info) false % /render.validate_xdim { 3 dict begin /max exch def /min exch def /dim exch def min -1 ne dim min lt and { /bwipp.renderXdimTooSmall [ (Effective X-dimension ) dim 20 string cvs (mm is below the minimum ) min 20 string cvs (mm for the ast) ] } { max -1 ne dim max gt and { /bwipp.renderXdimTooLarge [ (Effective X-dimension ) dim 20 string cvs (mm is above the maximum ) max 20 string cvs (mm for the ast) ] } { null null % Sentinel: ok } ifelse } ifelse dup null eq { pop pop true } { dup 0 exch {length add} forall string exch 0 exch { dup length 2 index add 3 index 4 2 roll putinterval } forall pop false } ifelse end } bind def % % Resolve strictspec dimensions % /render.resolve_strictspec { % Validate spec mode mutual exclusivity (outermost encoder only) /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse not { strictspec loosespec and { /bwipp.renderSpecModeMutex (strictspec and loosespec are mutually exclusive) //raiseerror exec } if strictspec propspec and { /bwipp.renderSpecModeMutex (strictspec and propspec are mutually exclusive) //raiseerror exec } if loosespec propspec and { /bwipp.renderSpecModeMutex (loosespec and propspec are mutually exclusive) //raiseerror exec } if } if loosespec { /strictspec true def } if % Validate spec options are not orphaned (outermost encoder only) /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse not { strictspec not { xdim -1 ne { /bwipp.renderOrphanedXdim (xdim requires strictspec or loosespec) //raiseerror exec } if currentdict /hdim known { hdim -1 ne } { false } ifelse { /bwipp.renderOrphanedHdim (hdim requires strictspec or loosespec) //raiseerror exec } if mag 1.0 ne { /bwipp.renderOrphanedMag (mag requires strictspec or loosespec) //raiseerror exec } if } if strictspec not propspec not and { currentdict /ast known { ast (default) ne } { false } ifelse { /bwipp.renderOrphanedAST (ast requires strictspec, loosespec, or propspec) //raiseerror exec } if } if } if strictspec { /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse not { currentdict /height known { height -1.0 ne } { false } ifelse currentdict /width known { width 0 ne } { false } ifelse or { loosespec { /loosespec false def /strictspec false def } { /bwipp.renderStrictspecDimOverride (width and height options are not compatible with strictspec; use xdim and hdim to directly specify physical dimensions) //raiseerror exec } ifelse } if } if } if strictspec { mag 1.0 ne xdim -1 ne currentdict /hdim known { hdim -1 ne } { false } ifelse or and { /bwipp.renderMagExclusive (use either mag \(to scale nominal dimensions\) or explicit xdim/hdim options, not both) //raiseerror exec } if xdim -1 eq { xnom -1 eq { loosespec { /strictspec false def } { /bwipp.renderNeedXnom (strictspec requires a nominal X-dimension to be defined for the application or for xdim to be supplied) //raiseerror exec } ifelse } if strictspec { /xdim xnom mag mul def } if } if strictspec { currentdict /hdim known currentdict /hnom known and { hdim -1 eq hnom -1 ne and { /hdim hnom mag mul def } if } if xdim xmin xmax //render.validate_xdim exec not { loosespec { pop pop } { //raiseerror exec } ifelse } if } if } if } bind def % % Resolve linear bar height from spec proportions % % Returns derived height, current height, or -1 sentinel % /render.resolve_height { currentdict /hdim known { hdim -1 ne } { false } ifelse strictspec and { % strictspec with resolved hdim: derive from hdim/xdim hdim xdim div modunit mul 72 div } { hnom -1 ne strictspec propspec or and { xnom -1 eq { /bwipp.renderHnomNeedXnom (Proportional bar height derivation requires a nominal X-dimension to be defined for the application or for xdim to be supplied) //raiseerror exec } if hnom xnom div modunit mul strictspec not { round } if % Pixel-lock derived height 72 div propspec { height -1.0 ne { height mul } if } if % height is a multiplier under propspec } { height } ifelse } ifelse } bind def % % Snap module boundaries to device pixel grid % /render.gridfit { 16 dict begin % % magnitude: user units per module (e.g. 1 or 2) % xdim: target X in mm (0 = no spec bounds checking) % xmin: minimum X in mm (-1 = no minimum) % xmax: maximum X in mm (-1 = no maximum) % usefloor: true=floor (for forced width); false=round % snapy: true=snap y independently; false=uniform with x % /snapy exch def /usefloor exch def /xmax exch def /xmin exch def /xdim exch def /mag exch def % val => snapped; snaps to whole device pixels per module, clamps to minimum 1 /snapto { % val mode => snapped /snapmode exch def mag div snapmode 0 eq { round } { snapmode 1 eq { floor } { % 2 ceiling } ifelse } ifelse dup 0 le { pop 1 } if mag mul } def % snapped => effective X; compute effective X dimension from snapped device pixels /effx { xdim mul 1 0 gridmatrix dtransform abs exch abs 2 copy lt {exch} if pop div } def % % Determine device resolution % /usergriddpi griddpi 0 ne def gsave matrix defaultmatrix setmatrix 72 0 dtransform abs exch abs 2 copy lt {exch} if pop /hwxres exch def 0 72 dtransform abs exch abs 2 copy lt {exch} if pop /hwyres exch def grestore griddpi 0 eq { /griddpi hwxres def } if % % Guard against bogus auto-detected resolution (skip unless user provided griddpi) % 1 { % Common exit hwxres 1 gt hwxres 100000 lt and hwyres 1 gt hwyres 100000 lt and and not { usergriddpi not { true exit } if /hwxres griddpi def /hwyres griddpi def % Bogus hardware but user knows the target DPI } if % % CTM scaled to target DPI pixel coordinates, per axis % [ griddpi hwxres div 0 0 griddpi hwyres div 0 0 ] matrix currentmatrix matrix concatmatrix /gridmatrix exch def % % Snap basepoint to target pixel boundary % 0 0 gridmatrix transform round exch round exch gridmatrix itransform translate % % Snap module dimensions to whole target pixels % 1 0 gridmatrix dtransform abs exch abs 2 copy lt {exch} if pop % Snap mode used for x (0=round, 1=floor, 2=ceiling). The snapy % branch replays this against the y-axis devpx so square matrix % symbols stay square when the x-axis retry bumps to floor/ceiling. /xsnapmode 0 def xdim 0 ne { % strictspec is provided /devpx exch def /snapped devpx 0 snapto def snapped effx xmin xmax //render.validate_xdim exec not { pop pop % Discard error details /snap1 snapped def devpx mag div dup floor sub 0.5 lt { 2 } { 1 } ifelse dup /xsnapmode exch def devpx exch snapto /snapped exch def snapped effx xmin xmax //render.validate_xdim exec not { pop pop % Discard error details loosespec { % Pick whichever snap is closest to being in spec /eff1 snap1 effx def /eff2 snapped effx def /dist { % eff => distance outside [xmin,xmax] 0 xmin -1 ne { xmin 2 index sub dup 0 gt { add } { pop } ifelse } if xmax -1 ne { 1 index xmax sub dup 0 gt { add } { pop } ifelse } if exch pop } def eff1 dist eff2 dist lt { /snapped snap1 def /xsnapmode 0 def } if } { /bwipp.renderGridfitXdimOutOfSpec [ (No X-dimension within the permissible range ) xmin 20 string cvs ( to ) xmax 20 string cvs (mm produces a fixed pixel grid at ) griddpi cvi 20 string cvs ( DPI) ] dup 0 exch {length add} forall string exch 0 exch { dup length 2 index add 3 index 4 2 roll putinterval } forall pop false exit } ifelse } if } if snapped devpx div } { % No strictspec dup mag div usefloor { floor } { round } ifelse dup 0 le { pop 1 } if mag mul exch div } ifelse snapy { 0 1 gridmatrix dtransform abs exch abs 2 copy lt {exch} if pop dup xsnapmode snapto exch div } { dup } ifelse scale true } repeat % Common exit end } bind def % % Apply defaults from global context for properties common to all encoders % Guarded by _dontdraw so sub-encoders do not re-read global defaults % /render.global_encoder_defaults { /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse not { /uk.co.terryburton.bwipp.global_ctx dup where { exch get dup /loosespec 2 copy known { get { /loosespec true def } if } { pop pop } ifelse dup /strictspec 2 copy known { get { /strictspec true def } if } { pop pop } ifelse /propspec 2 copy known { get { /propspec true def } if } { pop pop } ifelse } {pop} ifelse } if } bind def % % Apply defaults from global context for properties common to all renderers % /render.global_renderer_defaults { /uk.co.terryburton.bwipp.global_ctx dup where { exch get % ctx barcolor (unset) eq { dup /default_barcolor 2 copy known {get /barcolor exch def} {pop pop} ifelse } if backgroundcolor (unset) eq { dup /default_backgroundcolor 2 copy known {get /backgroundcolor exch def} {pop pop} ifelse } if bordercolor (unset) eq { dup /default_bordercolor 2 copy known {get /bordercolor exch def} {pop pop} ifelse } if inkspread null eq { dup /default_inkspread 2 copy known {get /inkspread exch def} {pop pop} ifelse } if griddpi 0 eq { dup /default_griddpi 2 copy known {get /griddpi exch def} {pop pop} ifelse } if gridfit false eq { dup /default_gridfit 2 copy known {get /gridfit exch def} {pop pop} ifelse } if pop } { pop } ifelse } bind def % % Validate common renderer options % /render.validate_common { /textopts where { pop 1 1 9 { textopts 1 index 1 sub get //render.validatetextoptions exec not { //raiseerror exec } if } for } if inkspread -1 lt inkspread 1 gt or { /bwipp.renderBadInkspread (inkspread must be from -1 to 1) //raiseerror exec } if borderleft -1 lt borderleft 50 gt or { /bwipp.renderBadBorderleft (borderleft must be from -1 to 50) //raiseerror exec } if borderright -1 lt borderright 50 gt or { /bwipp.renderBadBorderright (borderright must be from -1 to 50) //raiseerror exec } if bordertop -1 lt bordertop 50 gt or { /bwipp.renderBadBordertop (bordertop must be from -1 to 50) //raiseerror exec } if borderbottom -1 lt borderbottom 50 gt or { /bwipp.renderBadBorderbottom (borderbottom must be from -1 to 50) //raiseerror exec } if borderwidth 0 lt borderwidth 10 gt or { /bwipp.renderBadBorderwidth (borderwidth must be from 0 to 10) //raiseerror exec } if griddpi 0 ne { griddpi 30 lt griddpi 9600 gt or { /bwipp.renderBadGriddpi (griddpi must be 0 or from 30 to 9600) //raiseerror exec } if } if } bind def % % Draw border, bearer bars, and background % /render.renderborder { 16 dict begin /yspread exch def /xspread exch def /pixy exch def /pixx exch def /showbearer /showbearer where { /showbearer get } { false } ifelse def % % Corner geometry % showborder showbearer or { /tl [ borderleft borderwidth 2 div add neg pixy bordertop add borderwidth 2 div add ] def /tr [ pixx borderright add borderwidth 2 div add pixy bordertop add borderwidth 2 div add ] def /bl [ borderleft borderwidth 2 div add neg borderbottom borderwidth 2 div add neg ] def /br [ pixx borderright add borderwidth 2 div add borderbottom borderwidth 2 div add neg ] def } { /tl [ borderleft neg xspread add pixy bordertop add yspread sub ] def /tr [ pixx borderright add xspread sub pixy bordertop add yspread sub ] def /bl [ borderleft neg xspread add borderbottom neg yspread add ] def /br [ pixx borderright add xspread sub borderbottom neg yspread add ] def } ifelse 1 { % Common exit % % Background fill % backgroundcolor (unset) ne { gsave newpath bl aload pop moveto [ br tr tl ] { aload pop lineto } forall closepath backgroundcolor //setanycolor exec not { grestore /bwipp.renderBadBackgroundColor (Invalid background color) false exit } if fill grestore } if % % Bearer bars (horizontal rules at top and bottom) % showbearer { borderwidth inkspread gt { gsave newpath bl aload pop moveto br aload pop lineto tl aload pop moveto tr aload pop lineto bordercolor (unset) ne { bordercolor //setanycolor exec not { grestore /bwipp.renderBadBorderColor (Invalid border color) false exit } if } if borderwidth inkspread sub setlinewidth stroke grestore } if } if % % Border (eofill rectangle frame) % showborder showbearer not and { /hw borderwidth inkspread sub 2 div def hw 0 gt { gsave bordercolor (unset) ne { bordercolor //setanycolor exec not { grestore /bwipp.renderBadBorderColor (Invalid border color) false exit } if } if newpath bl aload pop hw sub exch hw sub exch moveto br aload pop hw sub exch hw add exch lineto tr aload pop hw add exch hw add exch lineto tl aload pop hw add exch hw sub exch lineto closepath bl aload pop hw add exch hw add exch moveto tl aload pop hw sub exch hw add exch lineto tr aload pop hw sub exch hw sub exch lineto br aload pop hw add exch hw sub exch lineto closepath eofill grestore } if } if true exit } repeat end } bind def % % Draw whitespace guard brackets % % pixx /renderguards //render exec % /render.renderguards { /pixx exch def 1 { % Common exit guardwidth 0 lt guardwidth 20 gt or { /bwipp.renderBadGuardwidth (guardwidth must be from 0 to 20) false exit } if guardheight 0 lt guardheight 20 gt or { /bwipp.renderBadGuardheight (guardheight must be from 0 to 20) false exit } if guardleftpos -50 lt guardleftpos 150 gt or { /bwipp.renderBadGuardleftpos (guardleftpos must be from -50 to 150) false exit } if guardleftypos -50 lt guardleftypos 150 gt or { /bwipp.renderBadGuardleftypos (guardleftypos must be from -50 to 150) false exit } if guardrightpos -50 lt guardrightpos 150 gt or { /bwipp.renderBadGuardrightpos (guardrightpos must be from -50 to 150) false exit } if guardrightypos -50 lt guardrightypos 150 gt or { /bwipp.renderBadGuardrightypos (guardrightypos must be from -50 to 150) false exit } if guardwhitespace { 0.75 setlinewidth guardleftpos 0 ne { newpath guardleftpos neg guardwidth add guardleftypos guardheight 2 div add moveto guardwidth neg guardheight -2 div rlineto guardwidth guardheight -2 div rlineto stroke } if guardrightpos 0 ne { newpath guardrightpos pixx add guardwidth sub guardrightypos guardheight 2 div add moveto guardwidth guardheight -2 div rlineto guardwidth neg guardheight -2 div rlineto stroke } if } if true exit } repeat } bind def % % Dispatcher table % /render.dispatch << /apply_ast //render.apply_ast /ast //render.ast /groupoptions //render.groupoptions /textgroups //render.textgroups /rendertext //render.rendertext /validatetextoptions //render.validatetextoptions /gridfit //render.gridfit /global_encoder_defaults //render.global_encoder_defaults /global_renderer_defaults //render.global_renderer_defaults /validate_common //render.validate_common /renderborder //render.renderborder /renderguards //render.renderguards /validate_xdim //render.validate_xdim /resolve_strictspec //render.resolve_strictspec /resolve_height //render.resolve_height >> readonly def /render { //render.dispatch exch get exec } [/barcode] {null def} forall bind def /render dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END RESOURCE render-- % --BEGIN RENDERER renlinear-- % --REQUIRES preamble raiseerror processoptions setanycolor render-- %%BeginResource: uk.co.terryburton.bwipp renlinear 0.0 2026052800 82212 74988 %%BeginData: 225 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 8 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /setanycolor dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put begin /renlinear { 256 dict begin { % % Default options % /sbs [] def /bhs [] def /bbs [] def /txt [] def % text{1-9}* options with common defaults (text) 9 /groupoptions //render exec /generategroup //processoptions exec % Overrides permitting encoder-positioned text /text1xalign (unset) def /text1yalign (unset) def /includetext false def /barcolor (unset) def /backgroundcolor (unset) def /bordercolor (unset) def /inkspread null def /width 0.0 def /barratio 1.0 def /spaceratio 1.0 def /showborder false def /showbearer false def /borderleft 10.0 def /borderright 10.0 def /bordertop 0.0 def /borderbottom 0.0 def /borderwidth 0.5 def /guardwhitespace false def /guardleftpos 0.0 def /guardleftypos 0.0 def /guardrightpos 0.0 def /guardrightypos 0.0 def /guardwidth 5.0 def /guardheight 7.0 def /gridfit false def /griddpi 0 def /strictspec false def /loosespec false def /xdim -1.0 def /xmin -1.0 def /xmax -1.0 def /modunit 1 def {def} forall opt currentdict /opt undef null /apply //processoptions exec /options exch def /global_renderer_defaults //render exec % Collect text options into an array /textopts (text) 9 /groupoptions //render exec /collectgroup //processoptions exec def griddpi 0 ne { /gridfit true def } if inkspread null eq { /inkspread 0.15 def } if % Adjust inkspread to fixed physical amount under strictspec strictspec { /inkspread inkspread modunit mul 25.4 mul xdim 72 mul div def } if % Auto-disable gridfit for fractional-width bars (postal, pharmacode) gridfit { sbs { dup floor sub abs 0.001 gt { /gridfit false def exit } if } forall barratio floor barratio ne spaceratio floor spaceratio ne or { /gridfit false def } if } if % % Validate input % /validate_common //render exec barratio 0.1 lt barratio 5 gt or { /bwipp.renlinearBadBarratio (barratio must be from 0.1 to 5) //raiseerror exec } if spaceratio 0.1 lt spaceratio 5 gt or { /bwipp.renlinearBadSpaceratio (spaceratio must be from 0.1 to 5) //raiseerror exec } if width 0 ne { width 0.01 lt width 20 gt or { /bwipp.renlinearBadWidth (width must be 0 or from 0.01 to 20) //raiseerror exec } if } if sbs length 0 ne { sbs length 1 add 2 idiv % nbars bhs length 1 index lt bbs length 2 index lt or { pop /bwipp.renlinearBadBarHeightArrays (The bar height and baseline arrays must be at least as long as the number of bars) //raiseerror exec } if pop } if % % Create bar elements and put them into the bars array % /bars sbs length 1 add 2 idiv array def /pixx 0 def /pixy 0 def 0 1 sbs length 1 add 2 idiv 2 mul 2 sub { /i exch def i 2 mod 0 eq { % i is even /d sbs i get dup 0 eq { pop 0 } % 0 is zero-width regardless of ratio { barratio mul barratio sub 1 add } % d = digit*r-r+1 ifelse def sbs i get 0 ne { /h bhs i 2 idiv get 72 mul def % Height from bhs /c d 2 div pixx add def % Centre of the bar = pixx + d/2 /y bbs i 2 idiv get 72 mul def % Baseline from bbs /w d inkspread sub def % bar width = digit - inkspread bars i 2 idiv [h c y w] put % Add the bar entry h y add pixy gt {/pixy h y add def} if } { bars i 2 idiv -1 put % Dummy entry } ifelse } { /d sbs i get dup 0 eq { pop 0 } % 0 is zero-width regardless of ratio { spaceratio mul spaceratio sub 1 add } % d = digit*r-r+1 ifelse def } ifelse /pixx pixx d add def % pixx += d } for options /debugbars known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugbars [ bars { dup -1 ne { aload pop } { pop } ifelse } forall ] //raiseerror exec } if gsave currentpoint translate % % Force symbol to given width % width 0 ne pixx 0 ne and { width 72 mul pixx div 1 scale } if % % Scale to physical specification dimensions % strictspec { xdim 72 mul 25.4 div modunit div dup scale } if % % Grid fit: snap module boundaries to device pixel grid % gridfit { 1 strictspec { xdim xmin xmax } { 0 -1 -1 } ifelse width 0 ne % Floor when width forced false /gridfit //render exec not { grestore //raiseerror exec } if } if % % Display the border and background % pixx pixy inkspread 0 /renderborder //render exec % No inkspread in y for bars not { grestore //raiseerror exec } if % % Display the bars for elements in the bars array % gsave barcolor (unset) ne { barcolor //setanycolor exec not { grestore grestore //raiseerror exec } if } if newpath bars { dup -1 ne { aload pop % h x y w 2 index 1 index 2 div sub 2 index moveto 0 4 index rlineto dup 0 rlineto 0 4 index neg rlineto closepath pop pop pop pop } { pop } ifelse } forall fill grestore % % Display text{1-9} % pixx pixy /textgroups //render exec not { grestore //raiseerror exec } if % % Display the guard elements % pixx /renderguards //render exec not { grestore //raiseerror exec } if grestore } stopped {end stop} if end } [/barcode] {null def} forall bind def /renlinear dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END RENDERER renlinear-- % --BEGIN RENDERER renmatrix-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render-- %%BeginResource: uk.co.terryburton.bwipp renmatrix 0.0 2026052800 121741 121146 %%BeginData: 546 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 16 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /setuphooks dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /setanycolor dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put begin /renmatrix [/before /after] //setuphooks exec (setup.define) //renmatrix.before exec /renmatrix.left 1 def /renmatrix.right 2 def /renmatrix.up 4 def /renmatrix.down 8 def % % Direction lookup table indexed by 2x2 neighbourhood: % % +---+---+ % |A=8|B=4| % +---*---+ % |C=2|D=1| % +---+---+ % /renmatrix.tracestep [ % 0 0 null % ? % 0 0 % 0 0 {right} % +> % 0|1 % 0 0 {down} % -+ % 1v0 % 0 0 {right} % --> % 1 1 % 0^1 {up} % +- % 0 0 % 0^1 {up} % | % 0|1 % 0 1 0^1 {dup //renmatrix.right eq {down} {up} ifelse} bind % -+ or +- % 1v0 1 0 % 0^1 {up} % -+ % 1 1 % 1|0 {left} % <+ % 0 0 % 1|0 1 0 {dup //renmatrix.down eq {left} {right} ifelse} bind % <+ or +> % 0 1 0|1 % 1|0 {down} % | % 1v0 % 1|0 {right} % +> % 1 1 % 1 1 {left} % <-- % 0 0 % 1 1 {left} % <+ % 0|1 % 1 1 {down} % +- % 1v0 % 1 1 null % ? % 1 1 ] readonly def /renmatrix { 256 dict begin { (input.processoptions) //renmatrix.before exec % Default options /width 1.0 def /height 1.0 def /barcolor (unset) def /backgroundcolor (unset) def /bordercolor (unset) def /colormap (unset) def /dotty false def /inkspread null def % real sentinel /inkspreadh null def % real sentinel /inkspreadv null def % real sentinel /txt [] def % text{1-9}* options with common defaults (text) 9 /groupoptions //render exec /generategroup //processoptions exec % Overrides permitting encoder-positioned text /text1xalign (unset) def /text1yalign (unset) def /includetext false def /showborder false def /borderleft 0.0 def /borderright 0.0 def /bordertop 0.0 def /borderbottom 0.0 def /borderwidth 0.5 def /guardwhitespace false def /guardleftpos 0.0 def /guardleftypos 0.0 def /guardrightpos 0.0 def /guardrightypos 0.0 def /guardwidth 5.0 def /guardheight 7.0 def /gridfit false def /griddpi 0 def /strictspec false def /loosespec false def /xdim -1.0 def /xmin -1.0 def /xmax -1.0 def /modunit 2 def {def} forall opt currentdict /opt undef null /apply //processoptions exec /options exch def /global_renderer_defaults //render exec griddpi 0 ne { /gridfit true def } if inkspread null eq { /inkspread 0.15 def } if inkspreadh null eq {/inkspreadh inkspread def} if inkspreadv null eq {/inkspreadv inkspread def} if (input.processoptions) //renmatrix.after exec % Default rowheights to all 1s if not provided currentdict /rowheights known not { /rowheights [ pixy { 1 } repeat ] def } if /pixycomp rowheights length def /rowcumul pixycomp 1 add array def rowcumul 0 0 put 0 1 pixycomp 1 sub { % i dup rowcumul exch get % ... rowcumul[i] 1 index rowheights exch get add % ... rowcumul[i] + rowheights[i] exch 1 add exch rowcumul 3 1 roll put % rowcumul[i+1] = rowcumul[i]+rowheights[i] } for % % Input validation % (input.validate) //renmatrix.before exec % % Collect text options and validate % /textopts (text) 9 /groupoptions //render exec /collectgroup //processoptions exec def % % Validate input % /validate_common //render exec inkspreadh -1 lt inkspreadh 1 gt or { /bwipp.renmatrixBadInkspreadh (inkspreadh must be from -1 to 1) //raiseerror exec } if inkspreadv -1 lt inkspreadv 1 gt or { /bwipp.renmatrixBadInkspreadv (inkspreadv must be from -1 to 1) //raiseerror exec } if width 0.01 lt width 50 gt or { /bwipp.renmatrixBadWidth (width must be from 0.01 to 50) //raiseerror exec } if height 0.01 lt height 50 gt or { /bwipp.renmatrixBadHeight (height must be from 0.01 to 50) //raiseerror exec } if pixx 0 le pixy 0 le or { /bwipp.renmatrixBadDimensions (The symbol dimensions must be positive) //raiseerror exec } if pixs length pixx pixycomp mul lt { /bwipp.renmatrixBadPixelData (The pixel data is shorter than the symbol dimensions require) //raiseerror exec } if rowcumul pixycomp get pixy ne { /bwipp.renmatrixRowheightsMismatch (rowheights sum does not equal pixy) //raiseerror exec } if (input.validate) //renmatrix.after exec % % Convert pixs to string for efficient padding and comparison % /spixs pixs length string def 0 1 pixs length 1 sub { dup pixs exch get spixs 3 1 roll put } for /pixs spixs def % % Generate the symbol % /xyget { pixx mul add pixs exch get } def /cget { pixx mul add cache exch get and } def /cput { % Optimise by only storing "stem" corners dup dup //renmatrix.up eq exch //renmatrix.left eq or { % dir is up or left 3 1 roll pixx mul add cache exch 2 copy get 4 -1 roll or put } { pop pop pop } ifelse } def /abcd { pixx mul add dup 1 add % A B 1 index pixx add dup 1 add % C D pixs exch get exch pixs exch get 2 mul add exch pixs exch get 4 mul add exch pixs exch get 8 mul add } def /pack { pixxpad mul add } def % x y -> y*pixxpad+x /unpack { dup pixxpad mod exch pixxpad idiv } def % y*pixxpad+x -> x y % % Stack: x y dir -> (packed vertex?) x' y' dir' % /left { dup //renmatrix.left ne { 3 copy cput 2 index 2 index pack 4 1 roll } if pop exch 1 sub exch % x-- //renmatrix.left } def /right { dup //renmatrix.right ne { 3 copy cput 2 index 2 index pack 4 1 roll } if pop exch 1 add exch % x++ //renmatrix.right } def /up { dup //renmatrix.up ne { 3 copy cput 2 index 2 index pack 4 1 roll } if pop 1 sub % y-- //renmatrix.up } def /down { dup //renmatrix.down ne { 3 copy cput 2 index 2 index pack 4 1 roll } if pop 1 add % y++ //renmatrix.down } def % % Walk the outline of a region emitting edge coordinates of the path % /trace { /y exch def /x exch def /dir x 1 add y 1 add xyget 1 eq {//renmatrix.up} {//renmatrix.left} ifelse def /sx x def /sy y def /sdir dir def mark x y dir { % [vertex...] x y dir //renmatrix.tracestep 3 index 3 index abcdget get exec dup sdir eq { 1 index sy eq { 2 index sx eq { pop pop pop exit } if } if } if } loop counttomark array astore exch pop } def % % Plot a layer of single colour % /drawlayer { /pixsorig pixs def /pixs exch def (render.tracepaths) //renmatrix.before exec % Pad the bitmap on all sides (string is zero-initialized) /pixx pixx 2 add def /pixycomp pixycomp 2 add def /pixxpad pixx def pixx pixycomp mul { string } stopped { pop /bwipp.renmatrixBitmapTooLarge (The bitmap exceeds the implementation limits) //raiseerror exec } if /padded exch def 0 1 pixycomp 3 sub { /row exch def padded row 1 add pixx mul 1 add pixs row pixx 2 sub mul pixx 2 sub getinterval putinterval } for /pixs padded def % % Cache of visited corners for each direction (string is zero-initialized) % pixs length { string } stopped { pop /bwipp.renmatrixBitmapTooLarge (The bitmap exceeds the implementation limits) //raiseerror exec } if /cache exch def % % Pre-compute abcd values (printed neighbours) for all cells % /abcdw pixx 1 sub def abcdw pixycomp 1 sub mul { string } stopped { pop /bwipp.renmatrixBitmapTooLarge (The bitmap exceeds the implementation limits) //raiseerror exec } if /abcdcache exch def /abcdrow abcdw string def 0 1 pixycomp 2 sub { /j exch def 0 1 abcdw 1 sub { dup j abcd abcdrow 3 1 roll put } for abcdcache j abcdw mul abcdrow putinterval } for /abcdget { pixx 1 sub mul add abcdcache exch get } def % % Construct paths by tracing regions avoiding duplication by using the cache % /paths [ 0 1 pixycomp 2 sub { /j exch def 0 1 pixx 2 sub { /i exch def /k i j abcdget def k 2#0001 eq % Black region stem corners: k 2#1001 eq or { % //renmatrix.up i j cget 0 eq { % 0 0 1 0 i j trace % * and * } if % 0 1 0 1 } if k 2#1110 eq { % White region stem corner: //renmatrix.left i j cget 0 eq { % i j trace % 1 1 } if % * } if % 1 0 } for } for ] def % % Revert the bitmap size % /pixx pixx 2 sub def /pixycomp pixycomp 2 sub def options /debugpaths known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { grestore /bwipp.debugpaths [ paths { dup length 2 mul exch { unpack } forall } forall ] //raiseerror exec } if (render.tracepaths) //renmatrix.after exec % % Draw the image % (render.drawpaths) //renmatrix.before exec newpath paths { /p exch def /len p length def p len 1 sub get unpack rowcumul exch get p 0 get unpack rowcumul exch get 0 1 len 1 sub { % x1 y1 x2 y2 /i exch def p i 1 add len mod get unpack rowcumul exch get 6 -2 roll % x3 y3 x1 y1 x2 y2 5 index inkspreadh 2 div 4 index 4 -1 roll lt {add} {sub} ifelse % y3x1 ? y2+iv : y2-iv 4 -1 roll exch pixy exch sub i 0 eq {moveto} {lineto} ifelse } for % x2 y2 x3 y3 closepath pop pop pop pop } forall fill /pixs pixsorig def (render.drawpaths) //renmatrix.after exec } def /drawlayerdots { (render.drawdots) //renmatrix.before exec /pixsorig pixs def /pixs exch def newpath 0 1 pixs length 1 sub { dup pixx mod /x exch def pixx idiv /y exch def x y xyget 1 eq { rowcumul y get 1 rowcumul y 1 add get 1 sub { /vy exch def x 0.5 add pixy vy sub 0.5 sub moveto x 0.5 add pixy vy sub 0.5 sub 0.5 inkspread 2 div sub 0 360 arc } for } if } for fill /pixs pixsorig def (render.drawdots) //renmatrix.after exec } def gsave currentpoint translate % % Force symbol to given width % width pixx div 72 mul height pixy div 72 mul scale % % Scale to physical specification dimensions % strictspec { xdim 72 mul 25.4 div modunit div dup scale % Adjust inkspread to fixed physical amount modunit 25.4 mul xdim 72 mul div % scale factor on stack dup inkspread mul /inkspread exch def dup inkspreadh mul /inkspreadh exch def inkspreadv mul /inkspreadv exch def } if % % Grid fit: snap module boundaries to device pixel grid % gridfit { 1 strictspec { xdim xmin xmax } { 0 -1 -1 } ifelse false true /gridfit //render exec not { grestore //raiseerror exec } if } if % % Display the border and background % pixx pixy inkspread inkspread /renderborder //render exec % Inkspread in both axes for modules not { grestore //raiseerror exec } if % % Display the matrix % colormap (unset) eq { /colormap << 1 barcolor >> def } if colormap { dup (unset) ne { //setanycolor exec not { 3 -1 roll pop grestore //raiseerror exec } if } { pop } ifelse /key exch def key 1 eq colormap length 1 eq and { pixs % Single colour with key=1: pixs is already the binary layer } { pixs length { string } stopped { pop /bwipp.renmatrixBitmapTooLarge (The bitmap exceeds the implementation limits) //raiseerror exec } if /layer exch def 0 1 pixs length 1 sub { dup pixs exch get key eq {layer exch 1 put} {layer exch 0 put} ifelse } for layer } ifelse dotty {drawlayerdots} {drawlayer} ifelse } forall % % Display the text % pixx pixy /textgroups //render exec not { grestore //raiseerror exec } if % % Display the guard elements % pixx /renderguards //render exec not { grestore //raiseerror exec } if grestore } stopped {end stop} if end } [/barcode] {null def} forall bind def /renmatrix dup load /uk.co.terryburton.bwipp defineresource pop (setup.define) //renmatrix.after exec end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END RENDERER renmatrix-- % --BEGIN RENDERER renmaximatrix-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render-- %%BeginResource: uk.co.terryburton.bwipp renmaximatrix 0.0 2026052800 75639 68716 %%BeginData: 148 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 4 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /setanycolor dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put begin /renmaximatrix { 32 dict begin { % % Default options % /includetext false def /barcolor (unset) def /backgroundcolor (unset) def /bordercolor (unset) def /inkspread null def /showborder false def /borderleft 0.0 def /borderright 0.0 def /bordertop 0.0 def /borderbottom 0.0 def /borderwidth 0.5 def /txt [] def % text{1-9}* options with common defaults (text) 9 /groupoptions //render exec /generategroup //processoptions exec % Overrides permitting encoder-positioned text /text1xalign (unset) def /text1yalign (unset) def /gridfit false def /griddpi 0 def /strictspec false def /loosespec false def /xdim -1.0 def /xmin -1.0 def /xmax -1.0 def /modunit 2 def {def} forall opt currentdict /opt undef null /apply //processoptions exec /options exch def /global_renderer_defaults //render exec % Collect text options into an array /textopts (text) 9 /groupoptions //render exec /collectgroup //processoptions exec def griddpi 0 ne { /gridfit true def } if inkspread null eq { /inkspread 0.15 def } if % % Validate options % /validate_common //render exec options /debughexagons known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debughexagons pixs //raiseerror exec } if gsave currentpoint translate 2.4945 dup scale % from 1pt to 0.88mm % % Scale to physical specification dimensions % strictspec { xdim 72 mul 25.4 div 2.4945 div dup scale % Relative to existing 2.4945 scale /inkspread inkspread 2.4945 mul 25.4 mul xdim 72 mul div def % Fixed physical amount } if % % Grid fit: uniform even-pixel snap preserves hex aspect ratio % gridfit { 2 strictspec { xdim xmin xmax } { 0 -1 -1 } ifelse false false /gridfit //render exec not { grestore //raiseerror exec } if } if % % Display the border and background % 30 29 inkspread inkspread /renderborder //render exec % 30x29 hex grid not { grestore //raiseerror exec } if barcolor (unset) ne { barcolor //setanycolor exec not { grestore //raiseerror exec } if } if /g 0.06 inkspread add def 0.5 0.5774 translate newpath pixs { dup /x exch 30 mod def /y exch 30 idiv def y 2 mod 0 eq {x} {x 0.5 add} ifelse 32 y sub 0.8661 mul moveto 0 0.5774 g sub rmoveto -0.5 g add -0.2887 g 2 div add rlineto 0 -0.5774 g add rlineto 0.5 g sub -0.2887 g 2 div add rlineto 0.5 g sub 0.2887 g 2 div sub rlineto 0 0.5774 g sub rlineto -0.5 g add 0.2887 g 2 div sub rlineto closepath } forall fill % % Plot the locator symbol % newpath 14 13.8576 0.5774 inkspread add 0 360 arc closepath 14 13.8576 1.3359 inkspread sub 360 0 arcn closepath fill newpath 14 13.8576 2.1058 inkspread add 0 360 arc closepath 14 13.8576 2.8644 inkspread sub 360 0 arcn closepath fill newpath 14 13.8576 3.6229 inkspread add 0 360 arc closepath 14 13.8576 4.3814 inkspread sub 360 0 arcn closepath fill % % Display text{1-9} % 30 29 /textgroups //render exec not { grestore //raiseerror exec } if grestore } stopped {end stop} if end } [/barcode] {null def} forall bind def /renmaximatrix dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END RENDERER renmaximatrix-- % --BEGIN ENCODER ean5-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear-- % --DESC: EAN-5 (5 digit addon) % --EXAM: 90200 % --EXOP: includetext guardwhitespace % --RNDR: renlinear %%BeginResource: uk.co.terryburton.bwipp ean5 0.0 2026052800 72612 75864 %%BeginData: 169 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /ean5.encs [ (3211) (2221) (2122) (1411) (1132) (1231) (1114) (1312) (1213) (3112) (112) (11) ] readonly def /ean5.barchars (0123456789) readonly def /ean5.mirrormaps [ (11000) (10100) (10010) (10001) (01100) (00110) (00011) (01010) (01001) (00101) ] readonly def /ean5 { 32 dict begin { /dontdraw false def /includetext false def /text1font /Helvetica def /text1size 12.0 def /text1xoffset 3.25 def /text1yoffset null def % realtype sentinel /height -1.0 def /addondescent 5.0 def /width 0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Validate input % barcode length 5 ne { /bwipp.ean5badLength (EAN-5 add-on must be 5 digits) //raiseerror exec } if barcode { dup 48 lt exch 57 gt or { /bwipp.ean5badCharacter (EAN-5 add-on must contain only digits) //raiseerror exec } if } forall % % Apply AST spec overrides and resolve physical specification % /ean5 ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec /height /resolve_height //render exec dup -1 eq { pop 0.7 } if def /descent addondescent modunit mul 72 div def % Add-on bar descent text1yoffset null eq { /text1yoffset height 72 mul 5.75 add def } if /checksum 0 def 0 1 4 { /i exch def /barchar barcode i get 48 sub def i 2 mod 0 eq { /checksum barchar 3 mul checksum add def } { /checksum barchar 9 mul checksum add def } ifelse } for /checksum checksum 10 mod def /mirrormap //ean5.mirrormaps checksum get def /sbs 31 string def /txt 5 array def 0 1 4 { /i exch def % % Prefix with either a start character or separator character % i 0 eq { sbs 0 //ean5.encs 10 get putinterval } { sbs i 1 sub 6 mul 7 add //ean5.encs 11 get putinterval } ifelse % % Lookup the encoding for the barcode character % barcode i 1 getinterval //ean5.barchars exch search pop length /indx exch def pop pop /enc //ean5.encs indx get def mirrormap i get 49 eq { /enclen enc length def /revenc enclen string def 0 1 enclen 1 sub { /j exch def /char enc j get def revenc enclen j sub 1 sub char put } for /enc revenc def } if sbs i 6 mul 3 add enc putinterval % Put encoded digit into sbs txt i [barcode i 1 getinterval i 1 sub 9 mul 10 add text1xoffset add text1yoffset text1font text1size] put } for << /ren /renlinear /sbs [sbs {48 sub} forall] /bhs [16 {height descent add} repeat] /bbs [16 {descent neg} repeat] includetext { /txt txt } if /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options /guardrightpos 5.0 /guardrightypos text1yoffset /borderleft 12.0 /borderright 5.0 /bordertop 10.0 >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /ean5 dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER ean5-- % --BEGIN ENCODER ean2-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear-- % --DESC: EAN-2 (2 digit addon) % --EXAM: 05 % --EXOP: includetext guardwhitespace % --RNDR: renlinear %%BeginResource: uk.co.terryburton.bwipp ean2 0.0 2026052800 71123 74302 %%BeginData: 155 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /ean2.encs [ (3211) (2221) (2122) (1411) (1132) (1231) (1114) (1312) (1213) (3112) (112) (11) ] readonly def /ean2.barchars (0123456789) readonly def /ean2.mirrormaps [(00) (01) (10) (11)] readonly def /ean2 { 32 dict begin { /dontdraw false def /includetext false def /text1font /Helvetica def /text1size 12.0 def /text1xoffset 3.25 def /text1yoffset null def % sentinel realtype /height -1.0 def /addondescent 5.0 def /width 0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Validate input % barcode length 2 ne { /bwipp.ean2badLength (EAN-2 add-on must be 2 digits) //raiseerror exec } if barcode { dup 48 lt exch 57 gt or { /bwipp.ean2badCharacter (EAN-2 add-on must contain only digits) //raiseerror exec } if } forall % % Apply AST spec overrides and resolve physical specification % /ean2 ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec /height /resolve_height //render exec dup -1 eq { pop 0.7 } if def /descent addondescent modunit mul 72 div def % Add-on bar descent text1yoffset null eq { /text1yoffset height 72 mul 5.75 add def } if /mirrormap //ean2.mirrormaps barcode 0 2 getinterval cvi 4 mod get def /sbs 13 string def /txt 2 array def 0 1 1 { /i exch def % % Prefix with either a start character or separator character % i 0 eq { sbs 0 //ean2.encs 10 get putinterval } { sbs i 1 sub 6 mul 7 add //ean2.encs 11 get putinterval } ifelse % % Lookup the encoding for the barcode character % barcode i 1 getinterval //ean2.barchars exch search pop length /indx exch def pop pop /enc //ean2.encs indx get def mirrormap i get 49 eq { /enclen enc length def /revenc enclen string def 0 1 enclen 1 sub { /j exch def /char enc j get def revenc enclen j sub 1 sub char put } for /enc revenc def } if sbs i 6 mul 3 add enc putinterval % Put encoded digit into sbs txt i [barcode i 1 getinterval i 1 sub 9 mul 10 add text1xoffset add text1yoffset text1font text1size] put } for << /ren /renlinear /sbs [sbs {48 sub} forall] /bhs [12{height descent add}repeat] /bbs [12{descent neg}repeat] includetext { /txt txt } if /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options /guardrightpos 5.0 /guardrightypos text1yoffset /borderleft 12.0 /borderright 5.0 /bordertop 10.0 >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /ean2 dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER ean2-- % --BEGIN ENCODER ean13-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear ean5 ean2-- % --DESC: EAN-13 % --EXAM: 9520123456788 % --EXOP: includetext guardwhitespace % --RNDR: renlinear % --FMLY: Point Of Sale %%BeginResource: uk.co.terryburton.bwipp ean13 0.0 2026052800 96737 103201 %%BeginData: 262 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /ean2 dup /uk.co.terryburton.bwipp findresource put dup /ean5 dup /uk.co.terryburton.bwipp findresource put begin /ean13.encs [ (3211) (2221) (2122) (1411) (1132) (1231) (1114) (1312) (1213) (3112) (111) (11111) (111) ] readonly def /ean13.barchars (0123456789) readonly def /ean13.mirrormaps [ (000000) (001011) (001101) (001110) (010011) (011001) (011100) (010101) (010110) (011010) ] readonly def /ean13 { 32 dict begin { /dontdraw false def /includetext false def /text1font /Helvetica def /text1size 12.0 def /text1xoffset -7.75 def /text1yoffset -5.25 def /height -1.0 def /guarddescent 5.0 def /addondescent null def % realtype sentinel: defaults to guarddescent /width 0 def /addongap 12.0 def /addontextfont (unset) def /addontextsize null def % realtype sentinel /addontextxoffset null def % realtype sentinel /addontextyoffset null def % realtype sentinel /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Split off the addon % barcode ( ) search { /barcode exch def pop /addon exch def } { pop /addon () def } ifelse % % Validate the input % barcode length 12 ne barcode length 13 ne and { /bwipp.ean13badLength (EAN-13 must be 12 or 13 digits) //raiseerror exec } if barcode { dup 48 lt exch 57 gt or { /bwipp.ean13badCharacter (EAN-13 must contain only digits) //raiseerror exec } if } forall addon length 0 ne addon length 2 ne and addon length 5 ne and { /bwipp.ean13badAddOnLength (Add-on for EAN-13 must be 2 or 5 digits) //raiseerror exec } if % % Apply AST spec overrides and resolve physical specification % /ean13 ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec /descent guarddescent modunit mul 72 div def % Guard bar descent addondescent null eq { /addondescent guarddescent def } if % Default add-on descent to guard descent % % Add checksum digit % /pad 13 string def /checksum 0 def 0 1 11 { /i exch def /barchar barcode i get 48 sub def i 2 mod 0 eq { /checksum barchar checksum add def } { /checksum barchar 3 mul checksum add def } ifelse } for /checksum 10 checksum 10 mod sub 10 mod def barcode length 13 eq { barcode 12 get checksum 48 add ne { /bwipp.ean13badCheckDigit (Incorrect EAN-13 check digit provided) //raiseerror exec } if } if pad 0 barcode putinterval % Add barcode to the start of the pad pad 12 checksum 48 add put % Put ascii for checksum at end of pad /barcode pad def /sbs 59 string def /txt 13 array def % % Put the start character % sbs 0 //ean13.encs 10 get putinterval % % First digit - determine mirrormap by this and show before guard bars % /mirrormap //ean13.mirrormaps barcode 0 get 48 sub get def txt 0 [barcode 0 1 getinterval text1xoffset text1yoffset text1font text1size] put % % Left side - performs mirroring % 1 1 6 { % Lookup the encoding for the each barcode character /i exch def barcode i 1 getinterval //ean13.barchars exch search pop % Discard true leaving pre length /indx exch def % indx is the length of pre pop pop % Discard seek and post /enc //ean13.encs indx get def % Get the indxth encoding mirrormap i 1 sub get 49 eq { % Reverse enc if 1 in this position in mirrormap /enclen enc length def /revenc enclen string def 0 1 enclen 1 sub { /j exch def /char enc j get def revenc enclen j sub 1 sub char put } for /enc revenc def } if sbs i 1 sub 4 mul 3 add enc putinterval % Put encoded digit into sbs txt i [barcode i 1 getinterval i 1 sub 7 mul 15 add text1xoffset add text1yoffset text1font text1size] put } for % % Put the middle character % sbs 7 1 sub 4 mul 3 add //ean13.encs 11 get putinterval % % Right side % 7 1 12 { % Lookup the encoding for the each barcode character /i exch def barcode i 1 getinterval //ean13.barchars exch search pop % Discard true leaving pre length /indx exch def % indx is the length of pre pop pop % Discard seek and post /enc //ean13.encs indx get def % Get the indxth encoding sbs i 1 sub 4 mul 8 add enc putinterval % Put encoded digit into sbs txt i [barcode i 1 getinterval i 1 sub 7 mul 19 add text1xoffset add text1yoffset text1font text1size] put } for % % Put the end character % sbs 56 //ean13.encs 12 get putinterval /sbs [sbs {48 sub} forall] def /height /resolve_height //render exec dup -1 eq { pop 1.0 } if def includetext { /guardheight height descent add def /bhs [guardheight guardheight 12{height}repeat guardheight guardheight 12{height}repeat guardheight guardheight] def /bbs [descent neg descent neg 12{0}repeat descent neg descent neg 12{0}repeat descent neg descent neg] def } { /bhs [30{height}repeat] def /bbs [30{0}repeat] def /txt [] def } ifelse /guardrightypos -5.0 def % % Append the addon % addon () ne { /addopts << /includetext true /height height includetext { 0.15 sub } if /addondescent addondescent /text1xoffset addontextxoffset null ne {addontextxoffset} {98.25 addongap add} ifelse addontextyoffset null ne {/text1yoffset addontextyoffset} if /text1size addontextsize null ne {addontextsize} {text1size} ifelse /text1font addontextfont (unset) ne {addontextfont} {text1font} ifelse >> def /uk.co.terryburton.bwipp._dontdraw true def addon length 2 eq {addon addopts //ean2 exec} if addon length 5 eq {addon addopts //ean5 exec} if /addcode exch def /sbs [sbs aload pop addongap addcode (sbs) get aload pop] def /bhs [bhs aload pop addcode (bhs) get aload pop] def /bbs [bbs aload pop addcode (bbs) get aload pop] def /txt [txt aload pop addcode (txt) get aload pop] def /guardrightypos addcode (guardrightypos) get def } if << /ren /renlinear /sbs sbs /bhs bhs /bbs bbs /txt txt /opt options /guardrightpos addon () eq {7.0} {5.0} ifelse /guardrightypos guardrightypos /borderleft 11.0 /borderright addon () eq {7.0} {5.0} ifelse /bordertop 0.0 /borderbottom 5.0 guarddescent modunit mul add /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /ean13 dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER ean13-- % --BEGIN ENCODER ean8-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear ean5 ean2-- % --DESC: EAN-8 % --EXAM: 95200002 % --EXOP: includetext guardwhitespace % --RNDR: renlinear % --FMLY: Point Of Sale %%BeginResource: uk.co.terryburton.bwipp ean8 0.0 2026052800 94715 97758 %%BeginData: 248 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /ean2 dup /uk.co.terryburton.bwipp findresource put dup /ean5 dup /uk.co.terryburton.bwipp findresource put begin /ean8.encs [ (3211) (2221) (2122) (1411) (1132) (1231) (1114) (1312) (1213) (3112) (111) (11111) (111) ] readonly def /ean8.barchars (0123456789) readonly def /ean8 { 32 dict begin { /dontdraw false def /includetext false def % Enable/disable text /text1font /Helvetica def /text1size 12.0 def /text1xoffset 7.25 def /text1yoffset -5.25 def /height -1.0 def /guarddescent 5.0 def /addondescent null def % realtype sentinel: defaults to guarddescent /width 0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def /permitaddon false def /addongap 12.0 def /addontextfont (unset) def /addontextsize null def /addontextxoffset null def % realtype sentinel /addontextyoffset null def % realtype sentinel null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Split off the addon % barcode ( ) search { /barcode exch def pop /addon exch def } { pop /addon () def } ifelse % % Validate the input % barcode length 7 ne barcode length 8 ne and { /bwipp.ean8badLength (EAN-8 must be 7 or 8 digits) //raiseerror exec } if barcode { dup 48 lt exch 57 gt or { /bwipp.ean8badCharacter (EAN-8 must contain only digits) //raiseerror exec } if } forall addon length 0 ne addon length 2 ne and addon length 5 ne and { /bwipp.ean8badAddOnLength (Add-on for EAN-8 must be 2 or 5 digits) //raiseerror exec } if permitaddon not addon length 0 ne and { /bwipp.ean8badAddOnLength (Non-standard use of add-on for EAN-8 requires "permitaddon" option) //raiseerror exec } if % % Apply AST spec overrides and resolve physical specification % /ean8 ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec /descent guarddescent modunit mul 72 div def % Guard bar descent addondescent null eq { /addondescent guarddescent def } if % Default add-on descent to guard descent % % Add checksum digit % /pad 8 string def /checksum 0 def 0 1 6 { /i exch def /barchar barcode i get 48 sub def i 2 mod 0 ne { /checksum barchar checksum add def } { /checksum barchar 3 mul checksum add def } ifelse } for /checksum 10 checksum 10 mod sub 10 mod def barcode length 8 eq { barcode 7 get checksum 48 add ne { /bwipp.ean8badCheckDigit (Incorrect EAN-8 check digit provided) //raiseerror exec } if } if pad 0 barcode putinterval % Add barcode to the start of the pad pad 7 checksum 48 add put % Put ascii for checksum at end of pad /barcode pad def /sbs 43 string def /txt 8 array def % % Put the start character % sbs 0 //ean8.encs 10 get putinterval % % Left side % 0 1 3 { /i exch def barcode i 1 getinterval //ean8.barchars exch search pop % Discard true leaving pre length /indx exch def % indx is the length of pre pop pop % Discard seek and post /enc //ean8.encs indx get def % Get the indxth encoding sbs i 4 mul 3 add enc putinterval % Put encoded digit into sbs txt i [barcode i 1 getinterval i 7 mul text1xoffset add text1yoffset text1font text1size] put } for % % Put the middle character % sbs 4 4 mul 3 add //ean8.encs 11 get putinterval % % Right side % 4 1 7 { /i exch def barcode i 1 getinterval //ean8.barchars exch search pop % Discard true leaving pre length /indx exch def % indx is the length of pre pop pop % Discard seek and post /enc //ean8.encs indx get def % Get the indxth encoding sbs i 4 mul 8 add enc putinterval % Put encoded digit into sbs txt i [barcode i 1 getinterval i 7 mul text1xoffset add 4 add text1yoffset text1font text1size] put } for % % Put the end character % sbs 40 //ean8.encs 12 get putinterval /sbs [sbs {48 sub} forall] def /height /resolve_height //render exec dup -1 eq { pop 1.0 } if def includetext { /guardheight height descent add def /bhs [guardheight guardheight 8{height}repeat guardheight guardheight 8{height}repeat guardheight guardheight] def /bbs [descent neg descent neg 8{0}repeat descent neg descent neg 8{0}repeat descent neg descent neg] def } { /bhs [22{height}repeat] def /bbs [22{0}repeat] def /txt [] def } ifelse /guardrightypos -5.0 def % % Append the addon % addon () ne { /addopts << /includetext true /height height includetext { 0.15 sub } if /addondescent addondescent /text1xoffset addontextxoffset null ne {addontextxoffset} {70.25 addongap add} ifelse addontextyoffset null ne {/text1yoffset addontextyoffset} if /text1size addontextsize null ne {addontextsize} {text1size} ifelse /text1font addontextfont (unset) ne {addontextfont} {text1font} ifelse >> def /uk.co.terryburton.bwipp._dontdraw true def addon length 2 eq {addon addopts //ean2 exec} if addon length 5 eq {addon addopts //ean5 exec} if /addcode exch def /sbs [sbs aload pop addongap addcode (sbs) get aload pop] def /bhs [bhs aload pop addcode (bhs) get aload pop] def /bbs [bbs aload pop addcode (bbs) get aload pop] def /txt [txt aload pop addcode (txt) get aload pop] def /guardrightypos addcode (guardrightypos) get def } if << /ren /renlinear /sbs sbs /bhs bhs /bbs bbs /txt txt /opt options /guardleftpos 7.0 /guardleftypos -5.0 /guardrightpos addon () eq {7.0} {5.0} ifelse /guardrightypos guardrightypos /borderleft 7.0 /borderright addon () eq {7.0} {5.0} ifelse /bordertop 0.0 /borderbottom 5.0 guarddescent modunit mul add /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /ean8 dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER ean8-- % --BEGIN ENCODER upca-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear ean5 ean2-- % --DESC: UPC-A % --EXAM: 012345000058 % --EXOP: includetext % --RNDR: renlinear % --FMLY: Point Of Sale %%BeginResource: uk.co.terryburton.bwipp upca 0.0 2026052800 104737 104296 %%BeginData: 299 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /ean2 dup /uk.co.terryburton.bwipp findresource put dup /ean5 dup /uk.co.terryburton.bwipp findresource put begin /upca.encs [ (3211) (2221) (2122) (1411) (1132) (1231) (1114) (1312) (1213) (3112) (111) (11111) (111) ] readonly def /upca.barchars (0123456789) readonly def /upca { 32 dict begin { /dontdraw false def /includetext false def /text1font /Helvetica def /text1size 12.0 def /text1xoffset -5.75 def /text1yoffset -5.25 def /height -1.0 def /guarddescent 5.0 def /addondescent null def % realtype sentinel: defaults to guarddescent /width 0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def /addongap 12.0 def /addontextfont (unset) def /addontextsize null def % sentinel realtype /addontextxoffset null def % sentinel realtype /addontextyoffset null def % sentinel realtype null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Split off the addon % barcode ( ) search { /barcode exch def pop /addon exch def } { pop /addon () def } ifelse % % Expand a given UPC-E % barcode length 7 eq barcode length 8 eq or { % % Validate the input % barcode { dup 48 lt exch 57 gt or { /bwipp.upcAupcEbadCharacter (UPC-E must contain only digits) //raiseerror exec } if } forall barcode 0 get dup 48 ne exch 49 ne and { /bwipp.upcAupcEbadNumberSystem (UPC-E must have number system 0 or 1) //raiseerror exec } if 1 { % Common exit /upcacode barcode length 8 eq {12} {11} ifelse string def barcode 6 get 48 sub 2 le { upcacode 0 barcode 0 3 getinterval putinterval upcacode 3 barcode 6 1 getinterval putinterval upcacode 4 (0000) putinterval upcacode 8 barcode 3 3 getinterval putinterval exit } if barcode 6 get 48 sub 3 eq { upcacode 0 barcode 0 4 getinterval putinterval upcacode 4 (00000) putinterval upcacode 9 barcode 4 2 getinterval putinterval exit } if barcode 6 get 48 sub 4 eq { upcacode 0 barcode 0 5 getinterval putinterval upcacode 5 (00000) putinterval upcacode 10 barcode 5 1 getinterval putinterval exit } if barcode 6 get 48 sub 5 ge { upcacode 0 barcode 0 6 getinterval putinterval upcacode 6 (0000) putinterval upcacode 10 barcode 6 1 getinterval putinterval exit } if } repeat barcode length 8 eq { upcacode 11 barcode 7 1 getinterval putinterval } if /barcode upcacode def } if % % Validate the input % barcode length 11 ne barcode length 12 ne and { /bwipp.upcAbadLength (UPC-A must be 11 or 12 digits) //raiseerror exec } if barcode { dup 48 lt exch 57 gt or { /bwipp.upcAbadCharacter (UPC-A must contain only digits) //raiseerror exec } if } forall addon length 0 ne addon length 2 ne and addon length 5 ne and { /bwipp.upcAbadAddOnLength (Add-on for UPC-A must be 2 or 5 digits) //raiseerror exec } if % % Apply AST spec overrides and resolve physical specification % /upca ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec /descent guarddescent modunit mul 72 div def % Guard bar descent addondescent null eq { /addondescent guarddescent def } if % Default add-on descent to guard descent % % Add checksum digit to barcode % /pad 12 string def % Create pad one bigger than barcode /checksum 0 def 0 1 10 { /i exch def /barchar barcode i get 48 sub def i 2 mod 0 ne { /checksum checksum barchar add def } { /checksum checksum barchar 3 mul add def } ifelse } for /checksum 10 checksum 10 mod sub 10 mod def barcode length 12 eq { barcode 11 get checksum 48 add ne { /bwipp.upcAbadCheckDigit (Incorrect UPC check digit provided) //raiseerror exec } if } if pad 0 barcode putinterval % Add barcode to the start of the pad pad 11 checksum 48 add put % Put ascii for checksum at end of pad /barcode pad def /sbs 59 string def /txt 12 array def % % Put the start character % sbs 0 //upca.encs 10 get putinterval % % Left side % 0 1 5 { /i exch def barcode i 1 getinterval //upca.barchars exch search pop % Discard true leaving pre length /indx exch def % indx is the length of pre pop pop % Discard seek and post /enc //upca.encs indx get def % Get the indxth encoding sbs i 4 mul 3 add enc putinterval % Put encoded digit into sbs i 0 eq { % First digit is before the guard bars txt 0 [barcode 0 1 getinterval text1xoffset text1yoffset text1font text1size 2 sub] put } { txt i [barcode i 1 getinterval i 7 mul 13 add text1xoffset add text1yoffset text1font text1size] put } ifelse } for % % Put the middle character % sbs 6 4 mul 3 add //upca.encs 11 get putinterval % % Right side % 6 1 11 { /i exch def barcode i 1 getinterval //upca.barchars exch search pop % Discard true leaving pre length /indx exch def % indx is the length of pre pop pop % Discard seek and post /enc //upca.encs indx get def % Get the indxth encoding sbs i 4 mul 8 add enc putinterval % Put encoded digit into sbs i 11 eq { % Last digit is after guard bars txt 11 [barcode 11 1 getinterval text1xoffset 107 add text1yoffset text1font text1size 2 sub] put } { txt i [barcode i 1 getinterval i 7 mul text1xoffset add 17 add text1yoffset text1font text1size] put } ifelse } for % % Put the end character % sbs 56 //upca.encs 12 get putinterval /sbs [sbs {48 sub} forall] def /height /resolve_height //render exec dup -1 eq { pop 1.0 } if def includetext { /guardheight height descent add def /bhs [4{guardheight}repeat 10{height}repeat guardheight guardheight 10{height}repeat 4{guardheight}repeat] def /bbs [4{descent neg}repeat 10{0}repeat descent neg descent neg 10{0}repeat 4{descent neg}repeat] def } { /bhs [30{height}repeat] def /bbs [30{0}repeat] def /txt [] def } ifelse /guardrightypos -5.0 def % % Append the addon % addon () ne { /addopts << /includetext true /height height includetext { 0.15 sub } if /addondescent addondescent /text1xoffset addontextxoffset null ne {addontextxoffset} {98.25 addongap add} ifelse addontextyoffset null ne {/text1yoffset addontextyoffset} if /text1size addontextsize null ne {addontextsize} {text1size} ifelse /text1font addontextfont (unset) ne {addontextfont} {text1font} ifelse >> def /uk.co.terryburton.bwipp._dontdraw true def addon length 2 eq {addon addopts //ean2 exec} if addon length 5 eq {addon addopts //ean5 exec} if /addcode exch def /sbs [sbs aload pop addongap addcode (sbs) get aload pop] def /bhs [bhs aload pop addcode (bhs) get aload pop] def /bbs [bbs aload pop addcode (bbs) get aload pop] def /txt [txt aload pop addcode (txt) get aload pop] def /guardrightypos addcode (guardrightypos) get def } if << /ren /renlinear /sbs sbs /bhs bhs /bbs bbs /txt txt /opt options /guardrightpos addon () eq {9.0} {5.0} ifelse /guardrightypos guardrightypos /borderleft 9.0 /borderright addon () eq {9.0} {5.0} ifelse /bordertop 0.0 /borderbottom 5.0 guarddescent modunit mul add /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /upca dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER upca-- % --BEGIN ENCODER upce-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear ean5 ean2-- % --DESC: UPC-E % --EXAM: 01234558 % --EXOP: includetext % --RNDR: renlinear % --FMLY: Point Of Sale %%BeginResource: uk.co.terryburton.bwipp upce 0.0 2026052800 109341 112280 %%BeginData: 339 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /ean2 dup /uk.co.terryburton.bwipp findresource put dup /ean5 dup /uk.co.terryburton.bwipp findresource put begin /upce.encs [ (3211) (2221) (2122) (1411) (1132) (1231) (1114) (1312) (1213) (3112) (111) (111111) ] readonly def /upce.barchars (0123456789) readonly def /upce.mirrormaps [ (000111) (001011) (001101) (001110) (010011) (011001) (011100) (010101) (010110) (011010) ] readonly def /upce { 32 dict begin { /dontdraw false def /includetext false def % Enable/disable text /text1font /Helvetica def /text1size 12.0 def /text1xoffset -5.75 def /text1yoffset -5.25 def /height -1.0 def /guarddescent 5.0 def /addondescent null def % realtype sentinel: defaults to guarddescent /width 0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def /addongap 12.0 def /addontextfont (unset) def /addontextsize null def % sentinel realtype /addontextxoffset null def % sentinel realtype /addontextyoffset null def % sentinel realtype null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Split off the addon % barcode ( ) search { /barcode exch def pop /addon exch def } { pop /addon () def } ifelse % % Compress a given UPC-A % barcode length 11 eq barcode length 12 eq or { % % Validate the input % barcode { dup 48 lt exch 57 gt or { /bwipp.upcEupcAbadCharacter (UPC-A must contain only digits) //raiseerror exec } if } forall 1 { % Common exit /upcecode barcode length 12 eq {8} {7} ifelse string def barcode 3 get 48 sub 2 le barcode 4 4 getinterval (0000) eq and { upcecode 0 barcode 0 3 getinterval putinterval upcecode 3 barcode 8 3 getinterval putinterval upcecode 6 barcode 3 1 getinterval putinterval exit } if barcode 4 5 getinterval (00000) eq { upcecode 0 barcode 0 4 getinterval putinterval upcecode 4 barcode 9 2 getinterval putinterval upcecode 6 (3) putinterval exit } if barcode 5 5 getinterval (00000) eq { upcecode 0 barcode 0 5 getinterval putinterval upcecode 5 barcode 10 1 getinterval putinterval upcecode 6 (4) putinterval exit } if barcode 10 get 48 sub 5 ge barcode 6 4 getinterval (0000) eq and { upcecode 0 barcode 0 6 getinterval putinterval upcecode 6 barcode 10 1 getinterval putinterval exit } if /bwipp.upcEupcAnotCompressible (UPC-A cannot be converted to a UPC-E) //raiseerror exec } repeat barcode length 12 eq { upcecode 7 barcode 11 1 getinterval putinterval } if /barcode upcecode def } if % % Validate the input % barcode length 7 ne barcode length 8 ne and { /bwipp.upcEbadLength (UPC-E must be 7 or 8 digits) //raiseerror exec } if barcode { dup 48 lt exch 57 gt or { /bwipp.upcEbadCharacter (UPC-E must contain only digits) //raiseerror exec } if } forall addon length 0 ne addon length 2 ne and addon length 5 ne and { /bwipp.upcEbadAddOnLength (Add-on for UPC-E must be 2 or 5 digits) //raiseerror exec } if % % Ensure 0 or 1 number systems % barcode 0 get dup 48 ne exch 49 ne and { /bwipp.upcEbadNumberSystem (UPC-E must have number system 0 or 1) //raiseerror exec } if % % Apply AST spec overrides and resolve physical specification % /upce ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec /descent guarddescent modunit mul 72 div def % Guard bar descent addondescent null eq { /addondescent guarddescent def } if % Default add-on descent to guard descent % % Derive the equivalent UPC-A for its checksum % 1 { % Common exit /upcacode 11 string def barcode 6 get 48 sub 2 le { upcacode 0 barcode 0 3 getinterval putinterval upcacode 3 barcode 6 1 getinterval putinterval upcacode 4 (0000) putinterval upcacode 8 barcode 3 3 getinterval putinterval exit } if barcode 6 get 48 sub 3 eq { upcacode 0 barcode 0 4 getinterval putinterval upcacode 4 (00000) putinterval upcacode 9 barcode 4 2 getinterval putinterval exit } if barcode 6 get 48 sub 4 eq { upcacode 0 barcode 0 5 getinterval putinterval upcacode 5 (00000) putinterval upcacode 10 barcode 5 1 getinterval putinterval exit } if barcode 6 get 48 sub 5 ge { upcacode 0 barcode 0 6 getinterval putinterval upcacode 6 (0000) putinterval upcacode 10 barcode 6 1 getinterval putinterval exit } if } repeat /checksum 0 def 0 1 10 { /i exch def /barchar upcacode i get 48 sub def i 2 mod 0 ne { /checksum checksum barchar add def } { /checksum checksum barchar 3 mul add def } ifelse } for /checksum 10 checksum 10 mod sub 10 mod def barcode length 8 eq { barcode 7 get checksum 48 add ne { /bwipp.upcEbadCheckDigit (Incorrect UPC check digit provided) //raiseerror exec } if } if /pad 8 string def pad 0 barcode putinterval % Add barcode to the start of the pad pad 7 checksum 48 add put % Put ascii for checksum at end of pad /barcode pad def /txt 8 array def txt 0 [barcode 0 1 getinterval text1xoffset text1yoffset text1font text1size 2 sub] put % % Determine the mirror map based on checksum % /mirrormap //upce.mirrormaps checksum get def % % Invert the mirrormap if we are using a non-zero number system % barcode 0 get 48 eq { /invt mirrormap length string def 0 1 mirrormap length 1 sub { /i exch def mirrormap i get 48 eq { invt i 49 put } { invt i 48 put } ifelse } for /mirrormap invt def } if /sbs 33 string def % % Put the start character % sbs 0 //upce.encs 10 get putinterval 1 1 6 { /i exch def barcode i 1 getinterval //upce.barchars exch search pop % Discard true leaving pre length /indx exch def % indx is the length of pre pop pop % Discard seek and post /enc //upce.encs indx get def % Get the indxth encoding mirrormap i 1 sub get 49 eq { % Reverse enc if 1 in this position in mirrormap /enclen enc length def /revenc enclen string def 0 1 enclen 1 sub { /j exch def /char enc j get def revenc enclen j sub 1 sub char put } for /enc revenc def } if sbs i 1 sub 4 mul 3 add enc putinterval % Put encoded digit into sbs txt i [barcode i 1 getinterval i 1 sub 7 mul 13 add text1xoffset add text1yoffset text1font text1size] put } for txt 7 [barcode 7 1 getinterval 6 7 mul 21 add text1xoffset add text1yoffset text1font text1size 2 sub] put % % Put the end character % sbs 27 //upce.encs 11 get putinterval /sbs [sbs {48 sub} forall] def /height /resolve_height //render exec dup -1 eq { pop 1.0 } if def includetext { /guardheight height descent add def /bhs [guardheight guardheight 12{height}repeat guardheight guardheight guardheight] def /bbs [descent neg descent neg 12{0}repeat descent neg descent neg descent neg] def } { /bhs [17{height}repeat] def /bbs [17{0}repeat] def /txt [] def } ifelse /guardrightypos -5.0 def % % Append the addon % addon () ne { /addopts << /includetext true /height height includetext { 0.15 sub } if /addondescent addondescent /text1xoffset addontextxoffset null ne {addontextxoffset} {54.25 addongap add} ifelse addontextyoffset null ne {/text1yoffset addontextyoffset} if /text1size addontextsize null ne {addontextsize} {text1size} ifelse /text1font addontextfont (unset) ne {addontextfont} {text1font} ifelse >> def /uk.co.terryburton.bwipp._dontdraw true def addon length 2 eq {addon addopts //ean2 exec} if addon length 5 eq {addon addopts //ean5 exec} if /addcode exch def /sbs [sbs aload pop addongap addcode (sbs) get aload pop] def /bhs [bhs aload pop addcode (bhs) get aload pop] def /bbs [bbs aload pop addcode (bbs) get aload pop] def /txt [txt aload pop addcode (txt) get aload pop] def /guardrightypos addcode (guardrightypos) get def } if << /ren /renlinear /sbs sbs /bhs bhs /bbs bbs /txt txt /opt options /guardrightpos addon () eq {9.0} {5.0} ifelse /guardrightypos guardrightypos /borderleft 9.0 /borderright addon () eq {9.0} {5.0} ifelse /bordertop 0.0 /borderbottom 5.0 guarddescent modunit mul add /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /upce dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER upce-- % --BEGIN ENCODER isbn-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear ean5 ean2 ean13-- % --DESC: ISBN % --EXAM: 978-1-56581-231-4 90000 % --EXOP: includetext guardwhitespace % --RNDR: renlinear % --FMLY: Point Of Sale %%BeginResource: uk.co.terryburton.bwipp isbn 0.0 2026052800 112028 107876 %%BeginData: 310 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 5 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /ean13 dup /uk.co.terryburton.bwipp findresource put begin /isbn.aliases << (isbntext) /text2 (isbntextsubspace) /text2subspace (isbntextsplit) /text2split (isbntextlinegaps) /text2linegaps (isbntextcolor) /text2color (isbntextxalign) /text2xalign (isbntextyalign) /text2yalign (isbntextdirection) /text2direction (isbntextfont) /text2font (isbntextsize) /text2size (isbntextxoffset) /text2xoffset (isbntextyoffset) /text2yoffset (isbntextgaps) /text2gaps >> readonly def /isbn { 32 dict begin { /dontdraw false def /includetext false def % Enable/disable ISBN text /text2 (unset) def % sentinel: user-supplied label content overrides default /text2font (unset) def /text2size 9.0 def /text2xalign (unset) def % sentinel: user-supplied alignment opts out of default xoffset /text2xoffset null def % sentinel realtype /text2yoffset null def % sentinel realtype /height -1.0 def /width 0 def /addongap 12.0 def /legacy false def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def //isbn.aliases /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Split off the addon % barcode ( ) search { /barcode exch def pop /addon exch def } { pop /addon () def } ifelse % % Validate the input % barcode length 15 ne barcode length 17 ne and barcode length 11 ne barcode length 13 ne and and { /bwipp.isbnBadLength (ISBN-13 must be 15 or 17 characters including dashes. ISBN-10 must be 11 or 13 characters including dashes) //raiseerror exec } if addon length 0 ne addon length 2 ne and addon length 5 ne and { /bwipp.isbnBadAddOnLength (Add-on for ISBN must be 2 or 5 digits) //raiseerror exec } if barcode length 15 ge { % ISBN-13 barcode 0 4 getinterval dup (978-) ne exch (979-) ne and { /bwipp.isbn13badPrefix (ISBN-13 prefix must be 978- or 979-) //raiseerror exec } if /wasdash false def /numdash 0 def /numdigit 0 def barcode 5 9 getinterval { dup 45 eq { wasdash { pop /bwipp.isbn13adjacentDashes (ISBN-13 does not permit adjacent dashes) //raiseerror exec } if /wasdash true def /numdash numdash 1 add def } if dup 48 ge exch 57 le and { /wasdash false def /numdigit numdigit 1 add def } if } forall numdash 2 ne numdigit 7 ne or { /bwipp.isbn13numDashesDigits (Incorrect number of dashes and digits for ISBN-13) //raiseerror exec } if barcode 14 get dup 48 lt exch 57 gt or { /bwipp.isbn13character15 (ISBN-13 character 15 must be a digit) //raiseerror exec } if barcode length 17 eq { barcode 15 1 getinterval (-) ne { /bwipp.isbn13character16 (ISBN-13 penultimate character must be a dash) //raiseerror exec } if barcode 16 get dup 48 lt exch 57 gt or { /bwipp.isbn13character17 (ISBN-13 final character must be a digit) //raiseerror exec } if } if } { % ISBN-10 barcode 0 get dup 48 lt exch 57 gt or { /bwipp.isbn10FirstDigit (ISBN-10 first character must be a digit) //raiseerror exec } if /wasdash false def /numdash 0 def /numdigit 0 def barcode 1 9 getinterval { dup 45 eq { wasdash { pop /bwipp.isbn10adjacentDashes (ISBN-10 does not permit adjacent dashes) //raiseerror exec } if /wasdash true def /numdash numdash 1 add def } if dup 48 ge exch 57 le and { /wasdash false def /numdigit numdigit 1 add def } if } forall numdash 2 ne numdigit 7 ne or { /bwipp.isbn10numDashesDigits (Incorrect number of dashes and digits for ISBN-10) //raiseerror exec } if barcode 10 get dup 48 lt exch 57 gt or { /bwipp.isbn10character11 (ISBN-10 character 11 must be a digit) //raiseerror exec } if barcode length 13 eq { barcode 11 1 getinterval (-) ne { /bwipp.isbn10character12 (ISBN-10 penultimate character must be a dash) //raiseerror exec } if barcode 12 get dup dup 48 lt exch 57 gt or exch 88 ne and { /bwipp.isbn10character13 (ISBN-10 final character must be a digit or X) //raiseerror exec } if } if } ifelse /isbntxt barcode def % % Read the digits from isbntxt and validate checksum for ISBN-10 % isbntxt length 13 le { /isbn 10 string def /checksum 0 def /i 0 def /n 0 def { % loop /isbnchar isbntxt i get 48 sub def isbnchar -3 ne { % Ignore dashes isbn n isbnchar 48 add put n 9 lt { /checksum checksum 10 n sub isbnchar mul add def } if /n n 1 add def } if /i i 1 add def i isbntxt length eq {exit} if } loop /checksum 11 checksum 11 mod sub 11 mod dup 10 eq {pop 40} if 48 add def /isbn isbn 0 9 getinterval def isbntxt length 13 eq { isbntxt 12 get checksum ne { /bwipp.isbn10badCheckDigit (Incorrect ISBN-10 check digit provided) //raiseerror exec } if } if } if legacy not isbntxt length 15 ge or { % % Convert ISBN-10 to ISBN-13 % isbntxt length 13 le { /pad 15 string def pad 0 (978-) putinterval pad 4 isbntxt 0 11 getinterval putinterval /isbntxt pad def } if % % Read the digits from isbntxt and validate checksum for ISBN-13 % /isbn 13 string def /checksum 0 def /i 0 def /n 0 def { % loop /isbnchar isbntxt i get 48 sub def isbnchar -3 ne { % Ignore dashes isbn n isbnchar 48 add put n 12 lt { /checksum isbnchar n 2 mod 0 ne {3 mul} if checksum add def } if /n n 1 add def } if /i i 1 add def i isbntxt length eq {exit} if } loop /checksum 10 checksum 10 mod sub 10 mod 48 add def /isbn isbn 0 12 getinterval def isbntxt length 17 eq { isbntxt 16 get checksum ne { /bwipp.isbn13badCheckDigit (Incorrect ISBN-13 check digit provided) //raiseerror exec } if } if } if % % Add the ISBN header to the isbntxt % /pad isbn length 12 eq {22} {18} ifelse string def pad 0 (ISBN ) putinterval pad 5 isbntxt putinterval pad pad length 2 sub 45 put pad pad length 1 sub checksum put /isbntxt pad def % % Convert ISBN digits to EAN-13 % /barcode 12 string def isbn length 9 eq { barcode 0 (978) putinterval barcode 3 isbn putinterval } { barcode 0 isbn putinterval } ifelse % % Append the addon % addon () ne { 12 addon length add 1 add string dup 0 barcode putinterval dup 12 ( ) putinterval dup 13 addon putinterval /barcode exch def } if % % Apply AST spec overrides and resolve physical specification % /isbn ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec % % Get the result of encoding with ean13 % options (addongap) addongap put options (ast) undef options (mag) undef options (propspec) propspec put options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put options (hnom) hnom put options (modunit) modunit put includetext { options (text2) text2 (unset) eq { isbntxt } { text2 } ifelse put text2font (unset) ne { options (text2font) text2font put } if options (text2size) text2size put text2xalign (unset) eq { % Default xoffset is anchored to default left alignment options (text2xoffset) text2xoffset null eq { isbn length 9 eq {-1.0} {-12.0} ifelse } { text2xoffset } ifelse put } { options (text2xalign) text2xalign put text2xoffset null ne { options (text2xoffset) text2xoffset put } if } ifelse options (text2yoffset) text2yoffset null eq { 3 } { text2yoffset } ifelse put } if /uk.co.terryburton.bwipp._dontdraw true def barcode options //ean13 exec /args exch def args (opt) options put args _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /isbn dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER isbn-- % --BEGIN ENCODER ismn-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear ean5 ean2 ean13-- % --DESC: ISMN % --EXAM: 979-0-2605-3211-3 % --EXOP: includetext guardwhitespace % --RNDR: renlinear % --FMLY: Point Of Sale %%BeginResource: uk.co.terryburton.bwipp ismn 0.0 2026052800 108512 104357 %%BeginData: 289 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 5 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /ean13 dup /uk.co.terryburton.bwipp findresource put begin /ismn.aliases << (ismntext) /text2 (ismntextsubspace) /text2subspace (ismntextsplit) /text2split (ismntextlinegaps) /text2linegaps (ismntextcolor) /text2color (ismntextxalign) /text2xalign (ismntextyalign) /text2yalign (ismntextdirection) /text2direction (ismntextfont) /text2font (ismntextsize) /text2size (ismntextxoffset) /text2xoffset (ismntextyoffset) /text2yoffset (ismntextgaps) /text2gaps >> readonly def /ismn { 32 dict begin { /dontdraw false def /includetext false def /text2 (unset) def % sentinel: user-supplied label content overrides default /text2font (unset) def /text2size 9.0 def /text2xalign (unset) def % sentinel: user-supplied alignment opts out of default xoffset /text2xoffset null def % sentinel realtype /text2yoffset null def % sentinel realtype /height -1.0 def /width 0 def /addongap 12.0 def /legacy false def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def //ismn.aliases /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Split off the addon % barcode ( ) search { /barcode exch def pop /addon exch def } { pop /addon () def } ifelse % % Validate the input % barcode length 15 ne barcode length 17 ne and barcode length 11 ne barcode length 13 ne and and { /bwipp.ismnBadLength (ISMN-13 must be 15 or 17 characters including dashes. ISMN-10 must be 11 or 13 characters including dashes) //raiseerror exec } if addon length 0 ne addon length 2 ne and addon length 5 ne and { /bwipp.ismnBadAddOnLength (Add-on for ISMN must be 2 or 5 digits) //raiseerror exec } if barcode length 15 ge { % ISMN-13 barcode 0 4 getinterval (979-) ne { /bwipp.ismn13badPrefix (ISMN-13 prefix must be 979-) //raiseerror exec } if /wasdash false def /numdash 0 def /numdigit 0 def barcode 5 9 getinterval { dup 45 eq { wasdash { pop /bwipp.ismn13adjacentDashes (ISMN-13 does not permit adjacent dashes) //raiseerror exec } if /wasdash true def /numdash numdash 1 add def } if dup 48 ge exch 57 le and { /wasdash false def /numdigit numdigit 1 add def } if } forall numdash 2 ne numdigit 7 ne or { /bwipp.ismn13numDashesDigits (Incorrect number of dashes and digits for ISMN-13) //raiseerror exec } if barcode 14 get dup 48 lt exch 57 gt or { /bwipp.ismn13character15 (ISMN-13 character 15 must be a digit) //raiseerror exec } if barcode length 17 eq { barcode 15 1 getinterval (-) ne { /bwipp.ismn13character16 (ISMN-13 penultimate character must be a dash) //raiseerror exec } if barcode 16 get dup 48 lt exch 57 gt or { /bwipp.ismn13character17 (ISMN-13 final character must be a digit) //raiseerror exec } if } if } { % ISMN-10 barcode 0 2 getinterval (M-) ne { /bwipp.ismn10badPrefix (ISMN-10 prefix must be M-) //raiseerror exec } if barcode 2 get dup 48 lt exch 57 gt or { /bwipp.ismn10character3 (ISMN-10 character 3 must be a digit) //raiseerror exec } if /wasdash false def /numdash 0 def /numdigit 0 def barcode 3 7 getinterval { dup 45 eq { wasdash { pop /bwipp.ismn10adjacentDashes (ISMN-10 does not permit adjacent dashes) //raiseerror exec } if /wasdash true def /numdash numdash 1 add def } if dup 48 ge exch 57 le and { /wasdash false def /numdigit numdigit 1 add def } if } forall numdash 1 ne numdigit 6 ne or { /bwipp.ismn10numDashesDigits (Incorrect number of dashes and digits for ISMN-10) //raiseerror exec } if barcode 10 get dup 48 lt exch 57 gt or { /bwipp.ismn10character11 (ISMN-10 character 11 must be a digit) //raiseerror exec } if barcode length 13 eq { barcode 11 1 getinterval (-) ne { /bwipp.ismn10character12 (ISMN-10 penultimate character must be a dash) //raiseerror exec } if barcode 12 get dup dup 48 lt exch 57 gt or exch 88 ne and { /bwipp.ismn10character13 (ISMN-10 final character must be a digit or X) //raiseerror exec } if } if } ifelse /ismntxt barcode def % % Convert old ISMN to ISMN-13 % /legacytxt () def ismntxt length 13 le { /legacytxt ismntxt def /pad ismntxt length 4 add string def pad 0 (979-0-) putinterval pad 6 ismntxt 2 ismntxt length 2 sub getinterval putinterval /ismntxt pad def } if % % Read the digits from ismntxt and calculate checksums % /ismn 13 string def /checksum 0 def /i 0 def /n 0 def { % loop /ismnchar ismntxt i get 48 sub def ismnchar -3 ne { % Ignore dashes ismn n ismnchar 48 add put n 12 lt { n 2 mod 0 eq { /checksum ismnchar checksum add def } { /checksum ismnchar 3 mul checksum add def } ifelse } if /n n 1 add def } if /i i 1 add def i ismntxt length eq {exit} if } loop /checksum 10 checksum 10 mod sub 10 mod 48 add def % % Validate the checksum % barcode length 13 eq barcode length 17 eq or { barcode dup length 1 sub get checksum ne { /bwipp.ismnBadCheckDigit (Incorrect ISMN check digit provided) //raiseerror exec } if } if % % Add the ISMN header and checksum to the ismntxt % legacy legacytxt () ne and { /ismntxt legacytxt def /pad 18 string def } { /pad 22 string def } ifelse pad 0 (ISMN ) putinterval pad 5 ismntxt putinterval pad pad length 2 sub 45 put pad pad length 1 sub checksum put /ismntxt pad def % % Convert ISMN digits to EAN-13 % /barcode ismn 0 12 getinterval def % % Append the addon % addon () ne { 12 addon length add 1 add string dup 0 barcode putinterval dup 12 ( ) putinterval dup 13 addon putinterval /barcode exch def } if % % Apply AST spec overrides and resolve physical specification % /ismn ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec % % Get the result of encoding with ean13 % options (addongap) addongap put options (ast) undef options (mag) undef options (propspec) propspec put options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put options (hnom) hnom put options (modunit) modunit put includetext { options (text2) text2 (unset) eq { ismntxt } { text2 } ifelse put text2font (unset) ne { options (text2font) text2font put } if options (text2size) text2size put text2xalign (unset) eq { % Default xoffset is anchored to default left alignment options (text2xoffset) text2xoffset null eq { ismntxt length 18 eq {-1.0} {-12.0} ifelse } { text2xoffset } ifelse put } { options (text2xalign) text2xalign put text2xoffset null ne { options (text2xoffset) text2xoffset put } if } ifelse options (text2yoffset) text2yoffset null eq { 3 } { text2yoffset } ifelse put } if /uk.co.terryburton.bwipp._dontdraw true def barcode options //ean13 exec /args exch def args (opt) options put args _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /ismn dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER ismn-- % --BEGIN ENCODER issn-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear ean2 ean5 ean13-- % --DESC: ISSN % --EXAM: 0311-175X 00 17 % --EXOP: includetext guardwhitespace % --RNDR: renlinear % --FMLY: Point Of Sale %%BeginResource: uk.co.terryburton.bwipp issn 0.0 2026052800 95880 95297 %%BeginData: 236 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 5 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /ean13 dup /uk.co.terryburton.bwipp findresource put begin /issn.aliases << (issntext) /text2 (issntextsubspace) /text2subspace (issntextsplit) /text2split (issntextlinegaps) /text2linegaps (issntextcolor) /text2color (issntextxalign) /text2xalign (issntextyalign) /text2yalign (issntextdirection) /text2direction (issntextfont) /text2font (issntextsize) /text2size (issntextxoffset) /text2xoffset (issntextyoffset) /text2yoffset (issntextgaps) /text2gaps >> readonly def /issn { 32 dict begin { /dontdraw false def /includetext false def /text2 (unset) def % sentinel: user-supplied label content overrides default /text2font (unset) def /text2size 9.0 def /text2xalign (unset) def % sentinel: user-supplied alignment opts out of default xoffset /text2xoffset null def % sentinel realtype /text2yoffset null def % sentinel realtype /height -1.0 def /width 0 def /addongap 12.0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def //issn.aliases /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Split off the ISSN % barcode ( ) search { /barcode exch def pop /seqvar exch def } { pop /seqvar (00) def } ifelse % % Split off the sequence variant and addon % seqvar ( ) search { /seqvar exch def pop /addon exch def } { pop /addon () def } ifelse % % Validate the input % barcode length 8 ne barcode length 9 ne and { /bwipp.issnBadLength (ISSN must be 8 or 9 characters including dash, in the format XXXX-XXXX) //raiseerror exec } if barcode 0 4 getinterval { dup 48 lt exch 57 gt or { /bwipp.issnFirstThroughFourthNotNumeric (ISSN first four characters must be numeral characters) //raiseerror exec } if } forall barcode 4 1 getinterval (-) ne { /bwipp.issnNeedsDash (ISSN fifth character must be a dash) //raiseerror exec } if barcode 5 3 getinterval { dup 48 lt exch 57 gt or { /bwipp.issnSixthThroughEighthNotNumeric (ISSN sixth through eighth characters must be numerals) //raiseerror exec } if } forall barcode length 9 eq { barcode 8 get dup dup 48 lt exch 57 gt or exch 88 ne and { % Digits or X /bwipp.issnNinthCharacterBadFormat (ISSN ninth character must be a number or the character X) //raiseerror exec } if } if seqvar length 2 ne { /bwipp.issnBadSequenceVariantLength (Sequence variant for ISSN must be 2 digits) //raiseerror exec } if seqvar { dup 48 lt exch 57 gt or { /bwipp.issnSequenceVariantBadCharacter (Sequence variant for ISSN must contain only digits) //raiseerror exec } if } forall addon length 0 ne addon length 2 ne and addon length 5 ne and { /bwipp.issnBadAddOnLength (Add-on for ISSN must be 2 or 5 digits) //raiseerror exec } if % % Read the digits from barcode and calculate checksums % /issn 8 string def /checksum 0 def /i 0 def /n 0 def { % loop /issnchar barcode i get 48 sub def issnchar -3 ne { % Ignore dashes issn n issnchar 48 add put n 7 lt { /checksum checksum issnchar 8 n sub mul add def } if /n n 1 add def } if /i i 1 add def i barcode length eq {exit} if } loop /checksum 11 checksum 11 mod sub 11 mod def /checksum checksum 48 add dup 58 eq {pop 88} if def barcode length 9 eq { barcode 8 get checksum ne { /bwipp.issnBadCheckDigit (Incorrect ISSN check digit provided) //raiseerror exec } if } if % % Build the ISSN display text % /pad 14 string def pad 0 (ISSN ) putinterval pad 5 barcode putinterval % Add barcode to the pad pad 13 checksum put /issntxt pad def % % Convert ISSN digits to EAN-13 % /barcode issn 0 7 getinterval def % % Append the sequence variant % /barcode 12 string def barcode 0 (977) putinterval barcode 3 issn putinterval barcode 10 seqvar putinterval % % Append the addon % addon () ne { 12 addon length add 1 add string dup 0 barcode putinterval dup 12 ( ) putinterval dup 13 addon putinterval /barcode exch def } if % % Apply AST spec overrides and resolve physical specification % /issn ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec % % Get the result of encoding with ean13 % options (addongap) addongap put options (ast) undef options (mag) undef options (propspec) propspec put options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put options (hnom) hnom put options (modunit) modunit put includetext { options (text2) text2 (unset) eq { issntxt } { text2 } ifelse put text2font (unset) ne { options (text2font) text2font put } if options (text2size) text2size put text2xalign (unset) eq { % Default xoffset is anchored to default left alignment options (text2xoffset) text2xoffset null eq { 10.0 } { text2xoffset } ifelse put } { options (text2xalign) text2xalign put text2xoffset null ne { options (text2xoffset) text2xoffset put } if } ifelse options (text2yoffset) text2yoffset null eq { 3 } { text2yoffset } ifelse put } if /uk.co.terryburton.bwipp._dontdraw true def barcode options //ean13 exec /args exch def args (opt) options put args _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /issn dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER issn-- % --BEGIN ENCODER mands-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear ean2 ean5 ean8-- % --DESC: Marks & Spencer % --EXAM: 0642118 % --EXOP: includetext % --RNDR: renlinear % --FMLY: Specialist %%BeginResource: uk.co.terryburton.bwipp mands 0.0 2026052800 78398 78275 %%BeginData: 89 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 4 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /ean8 dup /uk.co.terryburton.bwipp findresource put begin /mands { 8 dict begin { /dontdraw false def /includetext false def null /apply //processoptions exec /options exch def /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def /barlen barcode length def % % Validate the input % barlen 7 ne barlen 8 ne and { /bwipp.MandSbadLength (M&S barcode must be 7 or 8 characters) //raiseerror exec } if barlen 7 eq { /barcode (00000000) 8 string copy dup 1 barcode putinterval def } if % % Get the result of encoding with ean8 % /uk.co.terryburton.bwipp._dontdraw true def barcode options //ean8 exec /args exch def % % Remove the centre guard % args (bbs) get dup dup 2 get 10 exch put dup 2 get 11 exch put args (bhs) get dup dup 2 get 10 exch put dup 2 get 11 exch put % % Fix up the text for 7-digit inputs and add the M and S guards % includetext { /txt args (txt) get def barlen 7 eq { 0 1 6 { txt exch 2 copy 1 add get 0 get 3 1 roll get 0 get exch 0 exch putinterval } for txt 7 get 0 get 0 ( ) putinterval } if 10 array dup 0 txt putinterval /txt exch def txt 0 get dup length array copy txt exch 8 exch put txt 0 get dup length array copy txt exch 9 exch put txt 8 get 0 (M) put txt 8 get 1 -12 put txt 9 get 0 (S) put txt 9 get 1 69 put args (txt) txt put } if args (opt) options put args _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /mands dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER mands-- % --BEGIN ENCODER code128-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor render renlinear-- % --DESC: Code 128 % --EXAM: Count01234567! % --EXOP: includetext % --RNDR: renlinear % --FMLY: One-dimensional symbols %%BeginResource: uk.co.terryburton.bwipp code128 0.0 2026052800 238734 237382 %%BeginData: 757 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 65 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin % % Special function characters % /code128.sta -1 def /code128.stb -2 def /code128.stc -3 def /code128.swa -4 def /code128.swb -5 def /code128.swc -6 def /code128.fn1 -7 def /code128.fn2 -8 def /code128.fn3 -9 def /code128.fn4 -10 def /code128.sft -11 def /code128.stp -12 def /code128.lka -13 def /code128.lkc -14 def % CC-A/B and CC-C linkage /sta //code128.sta def /stb //code128.stb def /stc //code128.stc def /swa //code128.swa def /swb //code128.swb def /swc //code128.swc def /fn1 //code128.fn1 def /fn2 //code128.fn2 def /fn3 //code128.fn3 def /fn4 //code128.fn4 def /sft //code128.sft def /stp //code128.stp def /lka //code128.lka def /lkc //code128.lkc def % % Character maps for each state, used by the legacy encoder % /code128.charmaps [ % A B C A B C A B C [ 32 32 (00) ] [ (!) (!) (01) ] [ (") (") (02) ] % 0-2 [ (#) (#) (03) ] [ ($) ($) (04) ] [ (%) (%) (05) ] % 3-5 [ (&) (&) (06) ] [ (') (') (07) ] [ 40 40 (08) ] % 6-8 [ 41 41 (09) ] [ (*) (*) (10) ] [ (+) (+) (11) ] % 9-11 [ (,) (,) (12) ] [ (-) (-) (13) ] [ (.) (.) (14) ] % 12-14 [ (/) (/) (15) ] [ (0) (0) (16) ] [ (1) (1) (17) ] % 15-17 [ (2) (2) (18) ] [ (3) (3) (19) ] [ (4) (4) (20) ] % 18-20 [ (5) (5) (21) ] [ (6) (6) (22) ] [ (7) (7) (23) ] % 21-23 [ (8) (8) (24) ] [ (9) (9) (25) ] [ (:) (:) (26) ] % 24-26 [ (;) (;) (27) ] [ (<) (<) (28) ] [ (=) (=) (29) ] % 27-29 [ (>) (>) (30) ] [ (?) (?) (31) ] [ (@) (@) (32) ] % 30-32 [ (A) (A) (33) ] [ (B) (B) (34) ] [ (C) (C) (35) ] % 33-35 [ (D) (D) (36) ] [ (E) (E) (37) ] [ (F) (F) (38) ] % 36-38 [ (G) (G) (39) ] [ (H) (H) (40) ] [ (I) (I) (41) ] % 39-41 [ (J) (J) (42) ] [ (K) (K) (43) ] [ (L) (L) (44) ] % 42-44 [ (M) (M) (45) ] [ (N) (N) (46) ] [ (O) (O) (47) ] % 45-47 [ (P) (P) (48) ] [ (Q) (Q) (49) ] [ (R) (R) (50) ] % 48-50 [ (S) (S) (51) ] [ (T) (T) (52) ] [ (U) (U) (53) ] % 51-53 [ (V) (V) (54) ] [ (W) (W) (55) ] [ (X) (X) (56) ] % 54-56 [ (Y) (Y) (57) ] [ (Z) (Z) (58) ] [ ([) ([) (59) ] % 57-59 [ 92 92 (60) ] [ (]) (]) (61) ] [ (^) (^) (62) ] % 60-62 [ (_) (_) (63) ] [ 0 (`) (64) ] [ 1 (a) (65) ] % 63-65 [ 2 (b) (66) ] [ 3 (c) (67) ] [ 4 (d) (68) ] % 66-68 [ 5 (e) (69) ] [ 6 (f) (70) ] [ 7 (g) (71) ] % 69-71 [ 8 (h) (72) ] [ 9 (i) (73) ] [ 10 (j) (74) ] % 72-74 [ 11 (k) (75) ] [ 12 (l) (76) ] [ 13 (m) (77) ] % 75-77 [ 14 (n) (78) ] [ 15 (o) (79) ] [ 16 (p) (80) ] % 78-80 [ 17 (q) (81) ] [ 18 (r) (82) ] [ 19 (s) (83) ] % 81-83 [ 20 (t) (84) ] [ 21 (u) (85) ] [ 22 (v) (86) ] % 84-86 [ 23 (w) (87) ] [ 24 (x) (88) ] [ 25 (y) (89) ] % 87-89 [ 26 (z) (90) ] [ 27 ({) (91) ] [ 28 (|) (92) ] % 90-92 [ 29 (}) (93) ] [ 30 (~) (94) ] [ 31 127 (95) ] % 93-95 [ fn3 fn3 (96) ] [ fn2 fn2 (97) ] [ sft sft (98) ] % 96-98 [ swc swc (99) ] [ swb fn4 swb ] [ fn4 swa swa ] % 99-101 [ fn1 fn1 fn1 ] [ sta sta sta ] [ stb stb stb ] % 102-104 [ stc stc stc ] [ stp stp stp ] % 105-106 ] readonly def % % State machine constants for new encoder % % - Encoder states are named A0, B0, C0, A1, B1, and C1. % - A, B, and C are the Code 128 code sets. % - 0 is for ASCII and 1 is for extended ASCII range. % % The encoder relies on this order a lot, but it uses the "state_priority" list % for prioritizing states. % % Strings are a convenient way of defining latch sequences. The strings map to % Code 128 instructions. % % The (dddc) sequences are never inserted, but they are in the lists to provide % the correct length. % % Prior state: A0 B0 C0 A1 B1 C1 /code128.latch_a0 [ () (e) (e) (ee) (eee) (eee) ] readonly def /code128.latch_b0 [ (d) () (d) (ddd) (dd) (ddd) ] readonly def /code128.latch_c0 [ (c) (c) () (eec) (ddc) (dddc) ] readonly def /code128.latch_a1 [ (ee) (eee) (eee) () (e) (e) ] readonly def /code128.latch_b1 [ (ddd) (dd) (ddd) (d) () (d) ] readonly def /code128.latch_c1 [ (eec) (ddc) (dddc) (c) (c) () ] readonly def /code128.latch_length_a0 [ code128.latch_a0 {length} bind forall ] readonly def /code128.latch_length_b0 [ code128.latch_b0 {length} bind forall ] readonly def /code128.latch_length_c0 [ code128.latch_c0 {length} bind forall ] readonly def /code128.latch_length_a1 [ code128.latch_a1 {length} bind forall ] readonly def /code128.latch_length_b1 [ code128.latch_b1 {length} bind forall ] readonly def /code128.latch_length_c1 [ code128.latch_c1 {length} bind forall ] readonly def % For backtracking support /code128.latch_sequence [ code128.latch_a0 code128.latch_b0 code128.latch_c0 code128.latch_a1 code128.latch_b1 code128.latch_c1 ] readonly def /code128.start_code [ 103 104 105 ] readonly def % State machine configuration /code128.state_priority [ 1 0 2 4 3 5 ] readonly def % Configure encoder to conform with existing tests /code128.start_state [ 0 1 2 0 1 2 ] readonly def % Encoding starts in ASCII /code128.start_length [ 1 1 1 1 1 1 ] readonly def % Room for start code % Reverse priority list for preprocessing latch lengths and final state /code128.reverse_priority [ [ 5 4 3 2 1 0 ] {code128.state_priority exch get } forall] readonly def % Preprocessed latch lengths for get_best_prior_state /code128.prioritized_latch_length_a0 [ code128.reverse_priority {dup dup code128.latch_length_a0 exch get exch} bind forall ] readonly def /code128.prioritized_latch_length_a1 [ code128.reverse_priority {dup dup code128.latch_length_a1 exch get exch} bind forall ] readonly def /code128.prioritized_latch_length_b0 [ code128.reverse_priority {dup dup code128.latch_length_b0 exch get exch} bind forall ] readonly def /code128.prioritized_latch_length_b1 [ code128.reverse_priority {dup dup code128.latch_length_b1 exch get exch} bind forall ] readonly def /code128.prioritized_latch_length_c0 [ code128.reverse_priority {dup dup code128.latch_length_c0 exch get exch} bind forall ] readonly def /code128.prioritized_latch_length_c1 [ code128.reverse_priority {dup dup code128.latch_length_c1 exch get exch} bind forall ] readonly def % % New encoder character sets - map special function characters to codewords % /code128.seta_new << fn3 96 fn2 97 fn1 102 stp 106 lka 100 lkc 99 >> readonly def /code128.setb_new << fn3 96 fn2 97 fn1 102 stp 106 lka 99 lkc 101 >> readonly def /code128.setc_new << fn1 102 stp 106 lka 101 lkc 100 >> readonly def % % Create an array containing the character mappings % /code128.encs [ (212222) (222122) (222221) (121223) (121322) (131222) (122213) (122312) (132212) (221213) (221312) (231212) (112232) (122132) (122231) (113222) (123122) (123221) (223211) (221132) (221231) (213212) (223112) (312131) (311222) (321122) (321221) (312212) (322112) (322211) (212123) (212321) (232121) (111323) (131123) (131321) (112313) (132113) (132311) (211313) (231113) (231311) (112133) (112331) (132131) (113123) (113321) (133121) (313121) (211331) (231131) (213113) (213311) (213131) (311123) (311321) (331121) (312113) (312311) (332111) (314111) (221411) (431111) (111224) (111422) (121124) (121421) (141122) (141221) (112214) (112412) (122114) (122411) (142112) (142211) (241211) (221114) (413111) (241112) (134111) (111242) (121142) (121241) (114212) (124112) (124211) (411212) (421112) (421211) (212141) (214121) (412121) (111143) (111341) (131141) (114113) (114311) (411113) (411311) (113141) (114131) (311141) (411131) (211412) (211214) (211232) (2331112) ] readonly def /code128.max_int 16#7FFFFFFF def /code128.latevars dup 8 dict def load /init { currentglobal true setglobal //code128.latevars begin % % Invert charmaps to give character to value maps for each state % /charvals_legacy [ 109 dict 109 dict 109 dict ] def 0 1 //code128.charmaps length 1 sub { /i exch def /encs //code128.charmaps i get def 0 1 2 { /j exch def encs j get dup type /stringtype eq {0 get} if % convert string to ASCII if required charvals_legacy j get exch i put } for } for /charvals_legacy charvals_legacy readonly def % % Legacy encoder character sets with pseudo characters for GS1-128 Composite linkage % /seta_legacy charvals_legacy 0 get dup dup //code128.swb get //code128.lka exch put dup dup //code128.swc get //code128.lkc exch put readonly def /setb_legacy charvals_legacy 1 get dup dup //code128.swc get //code128.lka exch put dup dup //code128.swa get //code128.lkc exch put readonly def /setc_legacy charvals_legacy 2 get dup dup //code128.swa get //code128.lka exch put dup dup //code128.swb get //code128.lkc exch put readonly def /init { //code128.latevars {def} forall } def end //code128.latevars /init get exec setglobal } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//code128.latevars /init get exec} if } {pop} ifelse /code128 { 64 dict begin { /dontdraw false def /includetext false def /text1font /Courier def /text1size 10.0 def /text1xoffset 0.0 def /text1yoffset -7.0 def /height -1.0 def /width 0 def /raw false def /newencoder false def /parse false def /parsefnc false def /suppressc false def % Suppress code set C /unlatchextbeforec false def % Suppress extended ASCII with code set C /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def barcode length 500 gt { /bwipp.code128inputTooLong (The input data is too long) //raiseerror exec } if % % Apply AST spec overrides and resolve physical specification % /code128 ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def //code128.latevars /init get exec % % Parse the input % /fncvals << /parse parse /parsefnc parsefnc (FNC1) //code128.fn1 (FNC2) //code128.fn2 (FNC3) //code128.fn3 % (FNC4) fn4 Not user accessible as encoded automatically (LNKA) //code128.lka (LNKC) //code128.lkc >> def barcode fncvals //parseinput exec /msg exch def /msglen msg length def /encoding (legacy) def newencoder {/encoding (new) def} if raw {/encoding (raw) def} if encoding (raw) eq { /cws barcode length array def /i 0 def /j 0 def { % loop i barcode length 3 sub ge {exit} if barcode i get 94 ne {exit} if barcode i 1 add 3 getinterval false 1 index { dup 48 lt exch 57 gt or { pop true } if } forall { pop exit } if cvi /cw exch def cw 106 gt { /bwipp.code128BadRawCodeword (Raw codewords must be 0 to 106) //raiseerror exec } if cws j cw put /i i 4 add def /j j 1 add def } loop i barcode length ne { /bwipp.code128BadRawFormat (Raw codewords must be formatted as ^NNN) //raiseerror exec } if /cws cws 0 j getinterval def /text () def } { /text msglen string def 0 1 msglen 1 sub { /i exch def text i msg i get dup 0 lt { pop 32 } if put } for } ifelse encoding (legacy) eq { % Character sets with pseudo characters for GS1-128 Composite linkage /seta seta_legacy def /setb setb_legacy def /setc setc_legacy def % % Standard and extended ASCII runlength at position % /numSA [ msglen {0} repeat 0 ] def /numEA [ msglen {0} repeat 0 ] def msglen 1 sub -1 0 { /i exch def msg i get 0 ge { msg i get 128 ge { numEA i numEA i 1 add get 1 add put } { numSA i numSA i 1 add get 1 add put } ifelse } if } for % % FNC4 codeword insertion for extended ASCII % /ea false def mark 0 1 msglen 1 sub { /i exch def /c msg i get def ea c 128 lt xor not c 0 ge and { % Other mode required ea {numSA} {numEA} ifelse i get dup % Runlength of other mode i add msglen eq {3} {5} ifelse % Does run terminate symbol lt { % Shift //code128.fn4 } { % Latch //code128.fn4 //code128.fn4 /ea ea not def } ifelse } if c 0 ge {c 127 and} {c} ifelse } for counttomark array astore /msg exch def pop /msglen msg length def % % Pre-compute setC digit runlength from each position; two parity % arrays because FNC1 only counts when s is even. % /numsAtEven [ msglen 1 add {0} repeat ] def /numsAtOdd [ msglen 1 add {0} repeat ] def msglen 1 sub -1 0 { /i exch def /c msg i get def c //code128.fn1 eq { numsAtEven i 2 numsAtEven i 1 add get add put numsAtOdd i 0 put } { c 48 ge c 57 le and { numsAtEven i 1 numsAtOdd i 1 add get add put numsAtOdd i 1 numsAtEven i 1 add get add put } { numsAtEven i 0 put numsAtOdd i 0 put } ifelse } ifelse } for /numsscr { numsAtEven exch get } bind def % % Encoding for each alphabet % /enca { seta exch get cws exch j exch put /j j 1 add def } def /encb { setb exch get cws exch j exch put /j j 1 add def } def /encc { dup type /arraytype ne { setc exch get } { aload pop 48 sub exch 48 sub 10 mul add } ifelse cws exch j exch put /j j 1 add def } def % % Character exclusively in either alphabet A or B % /anotb {dup seta exch known exch setb exch known not and} def /bnota {dup setb exch known exch seta exch known not and} def % % Pre-compute relative position of next anotb and next bnota characters % /nextanotb [ msg length {0} repeat 9999 ] def /nextbnota [ msg length {0} repeat 9999 ] def msg length 1 sub -1 0 { /i exch def msg i get anotb { nextanotb i 0 put } { nextanotb i nextanotb i 1 add get 1 add put } ifelse msg i get bnota { nextbnota i 0 put } { nextbnota i nextbnota i 1 add get 1 add put } ifelse } for % % Does a-only come before b-only after given position and vice versa % /abeforeb {dup nextanotb exch get exch nextbnota exch get lt} def /bbeforea {dup nextbnota exch get exch nextanotb exch get lt} def /cws barcode length 2 mul 3 add array def % % Select start character % /j 0 def msglen 0 gt {0 numsscr} {-1} ifelse /nums exch def { % common exit msglen 0 eq { //code128.stb enca /cset (setb) def exit } if msglen 2 eq nums 2 eq and { //code128.stc enca /cset (setc) def exit } if nums 4 ge { //code128.stc enca /cset (setc) def exit } if 0 abeforeb { //code128.sta enca /cset (seta) def exit } if //code128.stb enca /cset (setb) def exit } loop % % Main encoding loop % /i 0 def { i msglen eq {exit} if i numsscr /nums exch def % % Determine switches and shifts % { % common exit cset (seta) eq cset (setb) eq or nums 4 ge and msg i get //code128.fn1 ne and { nums 2 mod 0 eq { //code128.swc cset (seta) eq {enca} {encb} ifelse /cset (setc) def exit } { msg i get cset (seta) eq {enca} {encb} ifelse /i i 1 add def i numsscr 4 ge { //code128.swc cset (seta) eq {enca} {encb} ifelse /cset (setc) def exit } if } ifelse } if cset (setb) eq msg i get anotb and { i msglen 1 sub lt { i 1 add bbeforea { //code128.sft encb msg i get enca /i i 1 add def exit } if } if //code128.swa encb /cset (seta) def exit } if cset (seta) eq msg i get bnota and { i msglen 1 sub lt { i 1 add abeforeb { //code128.sft enca msg i get encb /i i 1 add def exit } if } if //code128.swb enca /cset (setb) def exit } if cset (setc) eq nums 2 lt and msg i get -1 gt msg i get //code128.fn4 eq or and { i abeforeb { //code128.swa encc /cset (seta) def exit } if //code128.swb encc /cset (setb) def exit } if % No switches or latches so encode cset (seta) eq { msg i get enca /i i 1 add def exit } if cset (setb) eq { msg i get encb /i i 1 add def exit } if cset (setc) eq { msg i get -1 le { msg i get encc /i i 1 add def } { msg i 2 getinterval encc /i i 2 add def } ifelse exit } if exit } loop } loop /cws cws 0 j getinterval def } if % legacy encoder encoding (new) eq { % % Character sets for special function characters % /seta //code128.seta_new def /setb //code128.setb_new def /setc //code128.setc_new def % % Backtracking needs a way of mapping states to encode procedures % /encode [ {enc_a0} {enc_b0} {enc_c} {enc_a1} {enc_b1} {enc_c} ] def % % Predicates for ability to encode % /can_a {c 0 ge {true} {seta c known} ifelse} def /can_b {c 0 ge {true} {setb c known} ifelse} def /can_c0 {num_digits 2 ge {true} {setc c known} ifelse} def /can_c1 {num_digits 2 ge {true} {setc c known} ifelse} def % % Predicates overruled by options % suppressc {/can_c0 {false} def} if suppressc unlatchextbeforec or {/can_c1 {false} def} if % % Output length % /out_a0 {1 c 0 ge {c 128 ge {1 add} if c 127 and 96 ge {1 add} if} if} def /out_a1 {1 c 0 ge {c 128 lt {1 add} if c 127 and 96 ge {1 add} if} if} def /out_b0 {1 c 0 ge {c 128 ge {1 add} if c 127 and 32 lt {1 add} if} if} def /out_b1 {1 c 0 ge {c 128 lt {1 add} if c 127 and 32 lt {1 add} if} if} def % % Encode % /map_ab {dup 32 lt {64 add} {32 sub} ifelse} def /enc_a0 {[c 0 lt {seta c get} {c 128 ge {101} if c 127 and dup 96 ge {98 exch} if map_ab} ifelse]} def /enc_a1 {[c 0 lt {seta c get} {c 128 lt {101} if c 127 and dup 96 ge {98 exch} if map_ab} ifelse]} def /enc_b0 {[c 0 lt {setb c get} {c 128 ge {100} if c 127 and dup 32 lt {98 exch} if map_ab} ifelse]} def /enc_b1 {[c 0 lt {setb c get} {c 128 lt {100} if c 127 and dup 32 lt {98 exch} if map_ab} ifelse]} def /enc_c {[c 0 lt {setc c get} {msg n get 48 sub 10 mul msg n 1 add get 48 sub add } ifelse]} def % % Get best prior state based on a prior row of lengths and a row of latch % lengths (unrolled and with preprocessed latch lengths on the stack) % /get_best_prior_state { bln_0 exch get add /len exch def /o exch def bln_0 exch get add dup len lt {/len exch def /o exch def} {pop pop} ifelse bln_0 exch get add dup len lt {/len exch def /o exch def} {pop pop} ifelse bln_0 exch get add dup len lt {/len exch def /o exch def} {pop pop} ifelse bln_0 exch get add dup len lt {/len exch def /o exch def} {pop pop} ifelse bln_0 exch get add len lt { /o exch def} { pop} ifelse o } def % % The encoder considers the current row and two rows back. % The circular history buffer size is 4 for convenience. % The names are short to keep the lines below reasonable % /bln_0 //code128.start_length def /bln_1 //code128.start_length def /bln [4 {[0 0 0 0 0 0]} repeat] def % Best Length /bps_0 //code128.start_state def /bps_1 //code128.start_state def /bps [4 {[0 0 0 0 0 0]} repeat] def % Best Prior State % % Path for backtracking % /path [msg length {[0 0 0 0 0 0]} repeat] def /make_tables { /num_digits 0 def 0 1 msg length 1 sub { /n exch def /c msg n get def % % Keep a tab on digits % /num_digits c 48 ge c 58 lt and {num_digits 1 add} {0} ifelse def % % Circular history buffer machinery % /bln_2 bln_1 def /bln_1 bln_0 def /bln_0 bln n 3 and get def /bps_2 bps_1 def /bps_1 bps_0 def /bps_0 bps n 3 and get def % % Pick history rows for code set c depending on digits % /bps_c num_digits 2 ge {bps_2} {bps_1} ifelse def /bln_c num_digits 2 ge {bln_2} {bln_1} ifelse def % % Use the best prior states and the prior best lengths to determine new best lengths and plot the path % bln_0 0 can_a {/p bps_1 0 get def path n get 0 p put bln_1 p get //code128.latch_length_a0 p get add out_a0 add} {//code128.max_int} ifelse put bln_0 3 can_a {/p bps_1 3 get def path n get 3 p put bln_1 p get //code128.latch_length_a1 p get add out_a1 add} {//code128.max_int} ifelse put bln_0 1 can_b {/p bps_1 1 get def path n get 1 p put bln_1 p get //code128.latch_length_b0 p get add out_b0 add} {//code128.max_int} ifelse put bln_0 4 can_b {/p bps_1 4 get def path n get 4 p put bln_1 p get //code128.latch_length_b1 p get add out_b1 add} {//code128.max_int} ifelse put bln_0 2 can_c0 {/p bps_c 2 get def path n get 2 p put bln_c p get //code128.latch_length_c0 p get add 1 add} {//code128.max_int} ifelse put bln_0 5 can_c1 {/p bps_c 5 get def path n get 5 p put bln_c p get //code128.latch_length_c1 p get add 1 add} {//code128.max_int} ifelse put % % Use the new best lengths to determine new best prior states % bps_0 0 //code128.prioritized_latch_length_a0 aload pop get_best_prior_state put bps_0 3 //code128.prioritized_latch_length_a1 aload pop get_best_prior_state put bps_0 1 //code128.prioritized_latch_length_b0 aload pop get_best_prior_state put bps_0 4 //code128.prioritized_latch_length_b1 aload pop get_best_prior_state put bps_0 2 //code128.prioritized_latch_length_c0 aload pop get_best_prior_state put bps_0 5 //code128.prioritized_latch_length_c1 aload pop get_best_prior_state put } for } def /backtrack { /n msg length def % % Get best final state and final length % //code128.reverse_priority {dup bln_0 exch get dup} forall pop /len exch def /state exch def 5 {len lt {/len exch def /state exch def} {pop pop} ifelse} repeat len array % Put output array on the stack { n 0 le {exit} if /prior_state path n 1 sub get state get def % Get prior state (following path) /latch [//code128.latch_sequence state get prior_state get {} forall] def % Get latch sequence and convert from string to array /n n state 2 eq state 5 eq or msg n 1 sub get 48 ge and {2} {1} ifelse sub def % Get intake and subtract it from the input index /c msg n get def % Get current character (the encoding below needs it) /enc encode state get exec def % Encode state /len len latch length sub enc length sub def % Subtract latch length and output length from output index dup len latch 3 copy putinterval length add enc putinterval % Copy latch and encoded entry to output /state prior_state def % Prepare for next iteration } loop dup 0 //code128.start_code state get put % Add start code } def make_tables backtrack /cws exch def } if % auto encoding % % Derive checksum and place stop character % /j cws length def /cws j 2 add array dup 0 cws putinterval def /csum cws 0 get def 1 1 j 1 sub { /i exch def /csum csum cws i get i mul add def } for /csum csum 103 mod def cws j csum put cws j 1 add 106 put % stp options /debugcws known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugcws cws //raiseerror exec } if % % Derive space bar succession % /sbs cws length 6 mul 1 add string def 0 1 cws length 1 sub { /i exch def sbs i 6 mul //code128.encs cws i get get putinterval } for /sbs [sbs {48 sub} forall] def /height /resolve_height //render exec dup -1 eq { pop 1.0 } if def << /ren /renlinear /sbs sbs /bhs [sbs length 1 add 2 idiv {height} repeat] /bbs [sbs length 1 add 2 idiv {0} repeat] /txt [ [text text1xoffset text1yoffset text1font text1size] ] /text1xalign (center) /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /code128 dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER code128-- % --BEGIN ENCODER gs1-128-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput gs1process setanycolor render renlinear code128-- % --DESC: GS1-128 % --EXAM: (01)09521234543213(3103)000123 % --EXOP: includetext % --RNDR: renlinear % --FMLY: Supply Chain %%BeginResource: uk.co.terryburton.bwipp gs1-128 0.0 2026052800 84037 84051 %%BeginData: 147 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 8 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /gs1process dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /code128 dup /uk.co.terryburton.bwipp findresource put begin /gs1-128 { 32 dict begin { /dontdraw false def /includetext false def /text1font /Courier def /text1size 10.0 def /text1xoffset 0.0 def /text1yoffset -7.0 def /height -1.0 def /width 0 def /linkagea false def /linkagec false def /parse false def /dontlint false def /lintreqs false def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def barcode length 500 gt { /bwipp.gs1128inputTooLong (The input data is too long) //raiseerror exec } if /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def linkagea linkagec and { /bwipp.gs1128badLinkage (linkagea and linkagec cannot be used together) //raiseerror exec } if /text barcode def barcode /ai //gs1process exec /fncs exch def /vals exch def /ais exch def % % Create the code128 data using stack-based accumulation % /fnc1 -1 def mark fnc1 0 1 ais length 1 sub { /i exch def ais i get { } forall % Push AI characters vals i get { } forall % Push value characters i ais length 1 sub ne fncs i get and { fnc1 % Push FNC1 separator } if } for counttomark array astore /c128 exch def pop % % Compose input to code128 % /barcode c128 length 1 add 5 mul string def /j 0 def c128 { dup fnc1 eq { pop barcode j (^FNC1) putinterval /j j 5 add def } { barcode exch j exch put /j j 1 add def } ifelse } forall linkagea linkagec or { barcode j linkagea {(^LNKA)} {(^LNKC)} ifelse putinterval /j j 5 add def } if /barcode barcode 0 j getinterval def % % Apply AST spec overrides and resolve physical specification % /gs1-128 ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec height -1.0 eq { propspec hnom -1 ne and not { /height 0.5 def } if } if % % Get the result of encoding with code128 % options (parse) undef options (height) height put options (parsefnc) true put options (propspec) propspec put options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (ast) undef options (mag) undef options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put options (hnom) hnom put options (modunit) modunit put /uk.co.terryburton.bwipp._dontdraw true def barcode options //code128 exec /args exch def args (txt) [ [text text1xoffset text1yoffset text1font text1size] ] put args (text1xalign) (center) put args (opt) options put args _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /gs1-128 dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER gs1-128-- % --BEGIN ENCODER ean14-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor render renlinear code128-- % --DESC: EAN-14 % --EXAM: (01) 0 952 8765 43210 8 % --EXOP: includetext % --RNDR: renlinear % --FMLY: Supply Chain %%BeginResource: uk.co.terryburton.bwipp ean14 0.0 2026052800 82212 78396 %%BeginData: 112 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 4 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /code128 dup /uk.co.terryburton.bwipp findresource put begin /ean14 { 16 dict begin { /dontdraw false def /includetext false def % Enable/disable text /text1font /Courier def /text1size 10.0 def /text1xoffset 0.0 def /text1yoffset -7.0 def /height -1.0 def null /apply //processoptions exec /options exch def /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Strip spaces from the given data % /text barcode def barcode dup length string exch 0 exch {dup 32 ne {3 copy put pop 1 add} {pop} ifelse} forall 0 exch getinterval /barcode exch def /hasspace text length barcode length ne def % % Validate the input % barcode length 17 ne barcode length 18 ne and { /bwipp.ean14badLength (EAN-14 must be 13 or 14 digits) //raiseerror exec } if barcode 0 4 getinterval (\(01\)) ne { /bwipp.ean14badAI (EAN-14 must begin with (01) application identifier) //raiseerror exec } if barcode 4 barcode length 4 sub getinterval { dup 48 lt exch 57 gt or { /bwipp.ean14badCharacter (EAN-14 must contain only digits) //raiseerror exec } if } forall % % Calculate checksum and add to end of barcode % /checksum 0 def 0 1 12 { /i exch def /checksum checksum barcode i 4 add get 48 sub i 2 mod 0 eq {3 mul} if add def } for /checksum 10 checksum 10 mod sub 10 mod def barcode length 18 eq { barcode 17 get checksum 48 add ne { /bwipp.ean14badCheckDigit (Incorrect EAN-14 check digit provided) //raiseerror exec } if } { 18 string dup 0 barcode putinterval dup 17 checksum 48 add put /barcode exch def text length hasspace {2} {1} ifelse add string dup dup length 2 sub ( ) putinterval dup dup length 1 sub checksum 48 add put dup 0 text putinterval /text exch def } ifelse /gtin barcode 4 14 getinterval def % % Compose input to code128 % /barcode 21 string def barcode 0 (^FNC101) putinterval barcode 7 gtin putinterval % % Get the result of encoding with code128 % options (parsefnc) true put /uk.co.terryburton.bwipp._dontdraw true def barcode options //code128 exec /args exch def args (txt) [ [text text1xoffset text1yoffset text1font text1size] ] put args (text1xalign) (center) put args (opt) options put args _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /ean14 dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER ean14-- % --BEGIN ENCODER sscc18-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor render renlinear code128-- % --DESC: SSCC-18 % --EXAM: (00) 0 9528765 432101234 6 % --EXOP: includetext % --RNDR: renlinear % --FMLY: Supply Chain %%BeginResource: uk.co.terryburton.bwipp sscc18 0.0 2026052800 82224 78403 %%BeginData: 112 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 4 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /code128 dup /uk.co.terryburton.bwipp findresource put begin /sscc18 { 16 dict begin { /dontdraw false def /includetext false def % Enable/disable text /text1font /Courier def /text1size 10.0 def /text1xoffset 0.0 def /text1yoffset -7.0 def /height -1.0 def null /apply //processoptions exec /options exch def /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Strip spaces from the given data % /text barcode def barcode dup length string exch 0 exch {dup 32 ne {3 copy put pop 1 add} {pop} ifelse} forall 0 exch getinterval /barcode exch def /hasspace text length barcode length ne def % % Validate the input % barcode length 21 ne barcode length 22 ne and { /bwipp.sscc18badLength (SSCC-18 must be 17 or 18 digits) //raiseerror exec } if barcode 0 4 getinterval (\(00\)) ne { /bwipp.sscc18badAI (SSCC-18 must begin with (00) application identifier) //raiseerror exec } if barcode 4 barcode length 4 sub getinterval { dup 48 lt exch 57 gt or { /bwipp.sscc18badCharacter (SSCC-18 must contain only digits) //raiseerror exec } if } forall % % Calculate checksum and add to end of barcode % /checksum 0 def 0 1 16 { /i exch def /checksum checksum barcode i 4 add get 48 sub i 2 mod 0 eq {3 mul} if add def } for /checksum 10 checksum 10 mod sub 10 mod def barcode length 22 eq { barcode 21 get checksum 48 add ne { /bwipp.sscc18badCheckDigit (Incorrect SSCC-18 check digit provided) //raiseerror exec } if } { 22 string dup 0 barcode putinterval dup 21 checksum 48 add put /barcode exch def text length hasspace {2} {1} ifelse add string dup dup length 2 sub ( ) putinterval dup dup length 1 sub checksum 48 add put dup 0 text putinterval /text exch def } ifelse /sscc barcode 4 18 getinterval def % % Compose input to code128 % /barcode 25 string def barcode 0 (^FNC100) putinterval barcode 7 sscc putinterval % % Get the result of encoding with code128 % options (parsefnc) true put /uk.co.terryburton.bwipp._dontdraw true def barcode options //code128 exec /args exch def args (txt) [ [text text1xoffset text1yoffset text1font text1size] ] put args (text1xalign) (center) put args (opt) options put args _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /sscc18 dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER sscc18-- % --BEGIN ENCODER code39-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear-- % --DESC: Code 39 % --EXAM: THIS IS CODE 39 % --EXOP: includetext includecheck includecheckintext % --RNDR: renlinear % --FMLY: One-dimensional symbols %%BeginResource: uk.co.terryburton.bwipp code39 0.0 2026052800 80456 87424 %%BeginData: 201 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /code39.encs [ (1113313111) (3113111131) (1133111131) (3133111111) (1113311131) (3113311111) (1133311111) (1113113131) (3113113111) (1133113111) (3111131131) (1131131131) (3131131111) (1111331131) (3111331111) (1131331111) (1111133131) (3111133111) (1131133111) (1111333111) (3111111331) (1131111331) (3131111311) (1111311331) (3111311311) (1131311311) (1111113331) (3111113311) (1131113311) (1111313311) (3311111131) (1331111131) (3331111111) (1311311131) (3311311111) (1331311111) (1311113131) (3311113111) (1331113111) (1313131111) (1313111311) (1311131311) (1113131311) (1311313111) ] readonly def /code39.barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) readonly def /code39.latevars dup 2 dict def load /init { currentglobal true setglobal //code39.latevars begin /charvals 43 dict def 0 1 42 { charvals exch dup //code39.barchars exch 1 getinterval exch put } for /charvals charvals readonly def /init { //code39.latevars {def} forall } def end //code39.latevars /init get exec setglobal } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//code39.latevars /init get exec} if } {pop} ifelse /code39 { 32 dict begin { /dontdraw false def /includecheck false def /validatecheck false def /includetext false def /includecheckintext false def /hidestars false def /text1font /Courier def /text1size 10.0 def /text1yoffset -7.0 def /height -1.0 def /width 0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def //code39.latevars /init get exec barcode () eq { /bwipp.code39emptyData (The data must not be empty) //raiseerror exec } if barcode length 500 gt { /bwipp.code39inputTooLong (The input data is too long) //raiseerror exec } if % % Validate the input % 0 1 barcode length 1 sub { barcode exch 1 getinterval charvals exch known not { /bwipp.code39badCharacter (Code 39 must contain only digits, capital letters, spaces and the symbols -.$/+%) //raiseerror exec } if } for % % Apply AST spec overrides and resolve physical specification % /code39 ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec /barlen barcode length validatecheck {1 sub} if def /checksum 0 def 0 1 barlen 1 sub { barcode exch 1 getinterval charvals exch get checksum add /checksum exch def } for /checksum checksum 43 mod def validatecheck { barcode barlen get //code39.barchars checksum get ne { /bwipp.code39badCheckDigit (Incorrect Code 39 check digit provided) //raiseerror exec } if /barcode barcode 0 barlen getinterval def /includecheck true def } if /sbs barlen includecheck {3} {2} ifelse add 10 mul string def % % Put the start character % sbs 0 //code39.encs 43 get putinterval 0 1 barlen 1 sub { /i exch def /indx charvals barcode i 1 getinterval get def sbs i 10 mul 10 add //code39.encs indx get putinterval } for % % Put the checksum and end characters % includecheck { sbs barlen 10 mul 10 add //code39.encs checksum get putinterval sbs barlen 10 mul 20 add //code39.encs 43 get putinterval } { sbs barlen 10 mul 10 add //code39.encs 43 get putinterval } ifelse % Build display text: [*] data [check] [*] /slen hidestars not { 2 } { 0 } ifelse barlen add includecheck includecheckintext and { 1 add } if def /text slen string def /tpos 0 def hidestars not { text tpos (*) putinterval /tpos tpos 1 add def } if text tpos barcode putinterval /tpos tpos barlen add def includecheck includecheckintext and { text tpos //code39.barchars checksum 1 getinterval putinterval /tpos tpos 1 add def } if hidestars not { text tpos (*) putinterval } if /sbs [sbs {48 sub} forall] def /height /resolve_height //render exec dup -1 eq { pop 1.0 } if def << /ren /renlinear /sbs sbs /bhs [sbs length 1 add 2 idiv {height} repeat] /bbs [sbs length 1 add 2 idiv {0} repeat] includetext { /txt [ [text 0 0 text1font text1size] ] /text1xalign (center) } if /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /code39 dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER code39-- % --BEGIN ENCODER code39ext-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor render renlinear code39-- % --DESC: Code 39 Extended % --EXAM: Code39 Ext! % --EXOP: includetext includecheck includecheckintext % --RNDR: renlinear % --FMLY: One-dimensional symbols %%BeginResource: uk.co.terryburton.bwipp code39ext 0.0 2026052800 77402 77035 %%BeginData: 112 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 8 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /code39 dup /uk.co.terryburton.bwipp findresource put begin % Extended alphabet to non-extended alphabet /code39ext.extencs [ (%U) ($A) ($B) ($C) ($D) ($E) ($F) ($G) ($H) ($I) ($J) ($K) ($L) ($M) ($N) ($O) ($P) ($Q) ($R) ($S) ($T) ($U) ($V) ($W) ($X) ($Y) ($Z) (%A) (%B) (%C) (%D) (%E) ( ) (/A) (/B) (/C) (/D) (/E) (/F) (/G) (/H) (/I) (/J) (/K) (/L) (-) (.) (/O) (0) (1) (2) (3) (4) (5) (6) (7) (8) (9) (/Z) (%F) (%G) (%H) (%I) (%J) (%V) (A) (B) (C) (D) (E) (F) (G) (H) (I) (J) (K) (L) (M) (N) (O) (P) (Q) (R) (S) (T) (U) (V) (W) (X) (Y) (Z) (%K) (%L) (%M) (%N) (%O) (%W) (+A) (+B) (+C) (+D) (+E) (+F) (+G) (+H) (+I) (+J) (+K) (+L) (+M) (+N) (+O) (+P) (+Q) (+R) (+S) (+T) (+U) (+V) (+W) (+X) (+Y) (+Z) (%P) (%Q) (%R) (%S) (%T) ] readonly def /code39ext { 16 dict begin { /dontdraw false def /includetext false def /hidestars false def /parse false def null /apply //processoptions exec /options exch def /barcode exch def barcode length 500 gt { /bwipp.code39extinputTooLong (The input data is too long) //raiseerror exec } if /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Parse ordinals of the form ^NNN to ASCII % /fncvals << /parse parse /parseonly true /parsefnc false >> def barcode fncvals //parseinput exec /barcode exch def /barlen barcode length def options (parse) undef % % Validate the input % barcode { 128 ge { /bwipp.code39extBadCharacter (Code 39 Extended must contain only ASCII characters) //raiseerror exec } if } forall /newcode barlen 2 mul string def /newtext barlen 2 mul string def /j 0 def 0 1 barlen 1 sub { /i exch def /extchar //code39ext.extencs barcode i get get def newcode j extchar putinterval newtext j barcode i get dup dup 32 lt exch 127 eq or { pop 32 } if put extchar length 1 ne { newtext j 1 add 32 put } if /j j extchar length add def } for /newcode newcode 0 j getinterval def /newtext newtext 0 j getinterval def % % Get the result of encoding with code39 % /uk.co.terryburton.bwipp._dontdraw true def newcode options //code39 exec /args exch def % % Replace data portion of txt text string with original characters % includetext { /txt args (txt) get def /txtstr txt 0 get 0 get def txtstr hidestars { 0 } { 1 } ifelse newtext putinterval args (txt) txt put } if args (opt) options put args _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /code39ext dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER code39ext-- % --BEGIN ENCODER code32-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear code39-- % --DESC: Italian Pharmacode % --EXAM: 01234567 % --EXOP: includetext % --RNDR: renlinear % --FMLY: Pharmaceutical Symbols %%BeginResource: uk.co.terryburton.bwipp code32 0.0 2026052800 73952 73680 %%BeginData: 107 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 4 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /code39 dup /uk.co.terryburton.bwipp findresource put begin /code32 { 16 dict begin { /dontdraw false def /includetext false def % Enable/disable code32 text /text1font /Courier def /text1size 10.0 def /text1yoffset -7.0 def /text1xoffset 0.0 def /height -1.0 def null /apply //processoptions exec /options exch def /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Validate the input % barcode length 8 ne barcode length 9 ne and { /bwipp.code32badLength (Italian Pharmacode must be 8 or 9 digits) //raiseerror exec } if barcode { dup 48 lt exch 57 gt or { /bwipp.code32badCharacter (Italian Pharmacode must contain only digits) //raiseerror exec } if } forall % % Calculate check digit % /checksum 0 def 0 1 7 { /i exch def barcode i get 48 sub i 2 mod 0 ne {2 mul} if dup 9 gt {9 sub} if checksum add /checksum exch def } for /checksum checksum 10 mod def barcode length 9 eq { barcode 8 get checksum 48 add ne { /bwipp.code32badCheckDigit (Incorrect Italian Pharmacode check digit provided) //raiseerror exec } if } if 10 string dup 0 barcode putinterval dup 8 checksum 48 add put /text exch def % % Convert number from base10 to base32 /val text cvi 32 6 string cvrs def /barcode 6 string def 0 1 5 {barcode exch 48 put} for barcode 6 val length sub val putinterval % % Convert base32 number to specified character set % 0 1 5 { dup barcode exch get dup (AEIO) {ge {1 add} if dup} forall pop barcode 3 1 roll put } for % % Format HRI % text 1 text 0 9 getinterval putinterval text 0 65 put % % Get the result of encoding with code39 % /uk.co.terryburton.bwipp._dontdraw true def barcode options //code39 exec /args exch def args (txt) [ [text text1xoffset text1yoffset text1font text1size] ] put args (text1xalign) (center) put args (opt) options put args _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /code32 dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER code32-- % --BEGIN ENCODER pzn-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear code39-- % --DESC: Pharmazentralnummer (PZN) % --EXAM: 123456 % --EXOP: includetext % --RNDR: renlinear % --FMLY: Pharmaceutical Symbols %%BeginResource: uk.co.terryburton.bwipp pzn 0.0 2026052800 74258 73940 %%BeginData: 104 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 4 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /code39 dup /uk.co.terryburton.bwipp findresource put begin /pzn { 16 dict begin { /dontdraw false def /includetext false def % Enable/disable code32 text /text1font /Courier def /text1size 10.0 def /text1yoffset -7.0 def /text1xoffset 0.0 def /height -1.0 def /pzn8 false def null /apply //processoptions exec /options exch def /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Validate the input % pzn8 { barcode length 7 ne barcode length 8 ne and { /bwipp.pzn8badLength (PZN8 must be 7 or 8 digits) //raiseerror exec } if } { barcode length 6 ne barcode length 7 ne and { /bwipp.pzn7badLength (PZN7 must be 6 or 7 digits) //raiseerror exec } if } ifelse barcode { dup 48 lt exch 57 gt or { /bwipp.pznBadCharacter (PZN must contain only digits) //raiseerror exec } if } forall % % Calculate check digit % /msglen pzn8 {9} {8} ifelse def /checksum 0 def 0 1 msglen 3 sub { /i exch def barcode i get 48 sub i pzn8 {1} {2} ifelse add mul checksum add /checksum exch def } for /checksum checksum 11 mod def checksum 10 eq { /bwipp.pznBadInputSequence (Incorrect PZN input sequence provided) //raiseerror exec } if barcode length msglen 1 sub eq { barcode msglen 2 sub get checksum 48 add ne { /bwipp.pznBadCheckDigit (Incorrect PZN check digit provided) //raiseerror exec } if } if msglen string dup 0 45 put dup 1 barcode putinterval dup msglen 1 sub checksum 48 add put /msg exch def % % Get the result of encoding with code39 % /uk.co.terryburton.bwipp._dontdraw true def msg options //code39 exec /args exch def % % Format HRI % /text msglen 5 add string def text 0 (PZN - ) putinterval text 6 msg 1 msglen 1 sub getinterval putinterval args (txt) [ [text text1xoffset text1yoffset text1font text1size] ] put args (text1xalign) (center) put args (opt) options put args _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /pzn dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER pzn-- % --BEGIN ENCODER code93-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor render renlinear-- % --DESC: Code 93 % --EXAM: THIS IS CODE 93 % --EXOP: includetext includecheck % --RNDR: renlinear % --FMLY: One-dimensional symbols %%BeginResource: uk.co.terryburton.bwipp code93 0.0 2026052800 89105 82018 %%BeginData: 203 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 17 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /code93.encs [ (131112) (111213) (111312) (111411) (121113) % 0-4 (121212) (121311) (111114) (131211) (141111) % 5-9 (211113) (211212) (211311) (221112) (221211) % A-E (231111) (112113) (112212) (112311) (122112) % F-J (132111) (111123) (111222) (111321) (121122) % K-O (131121) (212112) (212211) (211122) (211221) % P-T (221121) (222111) (112122) (112221) (122121) % U-Y (123111) (121131) (311112) (311211) (321111) % "Z" "-" "." " " "$" (112131) (113121) (211131) (121221) (312111) % "/" "+" "%" ($) (%) (311121) (122211) (111141) (1111411) % (/) (+) STA END ] readonly def /code93.barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) readonly def /code93.sft1 -1 def /code93.sft2 -2 def /code93.sft3 -3 def /code93.sft4 -4 def /code93.latevars dup 2 dict def load /init { currentglobal true setglobal //code93.latevars begin /charvals 47 dict def 0 1 42 { charvals exch dup //code93.barchars exch get exch put } for charvals //code93.sft1 43 put charvals //code93.sft2 44 put charvals //code93.sft3 45 put charvals //code93.sft4 46 put /charvals charvals readonly def /init { //code93.latevars {def} forall } def end //code93.latevars /init get exec setglobal } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//code93.latevars /init get exec} if } {pop} ifelse /code93 { 32 dict begin { /dontdraw false def /includecheck false def % Enable/disable checkdigit /includetext false def % Enable/disable text /text1font /Courier def /text1size 10.0 def /text1yoffset -7.0 def /height -1.0 def /width 0 def /parse false def /parsefnc false def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def barcode length 500 gt { /bwipp.code93inputTooLong (The input data is too long) //raiseerror exec } if /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def //code93.latevars /init get exec % % Special function characters % /fncvals << /parse parse /parsefnc parsefnc (SFT$) //code93.sft1 (SFT%) //code93.sft2 (SFT/) //code93.sft3 (SFT+) //code93.sft4 >> def barcode fncvals //parseinput exec /msg exch def /msglen msg length def % % Validate the input % msg { charvals exch known not { /bwipp.code93BadCharacter (Code 93 must only contain digits, capital letters, spaces, the symbols -.$/+ and shift non-data characters) //raiseerror exec } if } forall % % Apply AST spec overrides and resolve physical specification % /code93 ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec includecheck { /sbs msglen 6 mul 25 add string def } { /sbs msglen 6 mul 13 add string def } ifelse % % Put the start character % sbs 0 //code93.encs 47 get putinterval /checksum1 0 def /checksum2 0 def /text msglen string def 0 1 msglen 1 sub { /i exch def /indx charvals msg i get get def sbs i 6 mul 6 add //code93.encs indx get putinterval text i msg i get dup 0 lt { pop 32 } if put /checksum1 checksum1 msglen i sub 1 sub 20 mod 1 add indx mul add def /checksum2 checksum2 msglen i sub 15 mod 1 add indx mul add def } for includecheck { % Put the first checksum character /checksum1 checksum1 47 mod def /checksum2 checksum2 checksum1 add 47 mod def sbs msglen 6 mul 6 add //code93.encs checksum1 get putinterval sbs msglen 6 mul 12 add //code93.encs checksum2 get putinterval % % Put the end character % sbs msglen 6 mul 18 add //code93.encs 48 get putinterval } { % % Put the end character % sbs msglen 6 mul 6 add //code93.encs 48 get putinterval } ifelse /sbs [sbs {48 sub} forall] def /height /resolve_height //render exec dup -1 eq { pop 1.0 } if def << /ren /renlinear /sbs sbs /bhs [sbs length 1 add 2 idiv {height} repeat] /bbs [sbs length 1 add 2 idiv {0} repeat] includetext { /txt [ [text 0 0 text1font text1size] ] /text1xalign (center) } if /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /code93 dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER code93-- % --BEGIN ENCODER code93ext-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor render renlinear code93-- % --DESC: Code 93 Extended % --EXAM: Code93 Ext! % --EXOP: includetext includecheck % --RNDR: renlinear % --FMLY: One-dimensional symbols %%BeginResource: uk.co.terryburton.bwipp code93ext 0.0 2026052800 78016 77643 %%BeginData: 115 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 8 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /code93 dup /uk.co.terryburton.bwipp findresource put begin /code93ext.extencs [ (^SFT%U) (^SFT$A) (^SFT$B) (^SFT$C) (^SFT$D) (^SFT$E) (^SFT$F) (^SFT$G) (^SFT$H) (^SFT$I) (^SFT$J) (^SFT$K) (^SFT$L) (^SFT$M) (^SFT$N) (^SFT$O) (^SFT$P) (^SFT$Q) (^SFT$R) (^SFT$S) (^SFT$T) (^SFT$U) (^SFT$V) (^SFT$W) (^SFT$X) (^SFT$Y) (^SFT$Z) (^SFT%A) (^SFT%B) (^SFT%C) (^SFT%D) (^SFT%E) ( ) (^SFT/A) (^SFT/B) (^SFT/C) ($) (%) (^SFT/F) (^SFT/G) (^SFT/H) (^SFT/I) (^SFT/J) (+) (^SFT/L) (-) (.) (/) (0) (1) (2) (3) (4) (5) (6) (7) (8) (9) (^SFT/Z) (^SFT%F) (^SFT%G) (^SFT%H) (^SFT%I) (^SFT%J) (^SFT%V) (A) (B) (C) (D) (E) (F) (G) (H) (I) (J) (K) (L) (M) (N) (O) (P) (Q) (R) (S) (T) (U) (V) (W) (X) (Y) (Z) (^SFT%K) (^SFT%L) (^SFT%M) (^SFT%N) (^SFT%O) (^SFT%W) (^SFT+A) (^SFT+B) (^SFT+C) (^SFT+D) (^SFT+E) (^SFT+F) (^SFT+G) (^SFT+H) (^SFT+I) (^SFT+J) (^SFT+K) (^SFT+L) (^SFT+M) (^SFT+N) (^SFT+O) (^SFT+P) (^SFT+Q) (^SFT+R) (^SFT+S) (^SFT+T) (^SFT+U) (^SFT+V) (^SFT+W) (^SFT+X) (^SFT+Y) (^SFT+Z) (^SFT%P) (^SFT%Q) (^SFT%R) (^SFT%S) (^SFT%T) ] readonly def /code93ext { 16 dict begin { /dontdraw false def /includetext false def /parse false def null /apply //processoptions exec /options exch def /barcode exch def barcode length 500 gt { /bwipp.code93extinputTooLong (The input data is too long) //raiseerror exec } if /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Parse ordinals of the form ^NNN to ASCII % /fncvals << /parse parse /parseonly true /parsefnc false >> def barcode fncvals //parseinput exec /barcode exch def /barlen barcode length def options (parse) undef /newcode barlen 6 mul string def /newtext barlen 6 mul string def /j 0 def /k 0 def 0 1 barlen 1 sub { /i exch def barcode i get dup 127 gt { pop /bwipp.code93extbadCharacter (Code 93 Extended only support ASCII characters with values 0 to 127) //raiseerror exec } if //code93ext.extencs exch get /extchar exch def /extlen extchar length def newcode j extchar putinterval newtext k barcode i get dup dup 32 lt exch 127 eq or { pop 32 } if put extlen 1 ne { newtext k 1 add 32 put } if /j j extlen add def /k k extlen 1 eq {1} {2} ifelse add def } for /newcode newcode 0 j getinterval def /newtext newtext 0 k getinterval def % % Get the result of encoding with code93 % options (parsefnc) true put /uk.co.terryburton.bwipp._dontdraw true def newcode options //code93 exec /args exch def % % Replace txt text string with original characters % includetext { /txt args (txt) get def txt 0 get 0 newtext put args (txt) txt put } if args (opt) options put args _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /code93ext dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER code93ext-- % --BEGIN ENCODER interleaved2of5-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear-- % --DESC: Interleaved 2 of 5 (ITF) % --EXAM: 2401234567 % --EXOP: height=0.5 includecheck includetext includecheckintext % --RNDR: renlinear % --FMLY: One-dimensional symbols %%BeginResource: uk.co.terryburton.bwipp interleaved2of5 0.0 2026052800 75720 78845 %%BeginData: 191 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /interleaved2of5.encs [ (11221) (21112) (12112) (22111) (11212) (21211) (12211) (11122) (21121) (12121) (1111) (2111) ] readonly def /interleaved2of5.barchars (0123456789) readonly def /interleaved2of5 { 16 dict begin { /dontdraw false def /includecheck false def % Enable/disable checkdigit /includetext false def % Enable/disable text /includecheckintext false def /text1font /Courier def /text1size 10.0 def /text1yoffset -7.0 def /height -1.0 def /width 0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def barcode length 500 gt { /bwipp.interleaved2of5inputTooLong (The input data is too long) //raiseerror exec } if /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Validate the input % barcode { dup 48 lt exch 57 gt or { /bwipp.interleaved2of5badCharacter (Interleaved 2 of 5 must contain only digits) //raiseerror exec } if } forall % % Apply AST spec overrides and resolve physical specification % /interleaved2of5 ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec /barlen barcode length def % Length of the code % % Prefix 0 to barcode if length is even and including checkdigit % or length is odd and not including checkdigit % barlen 2 mod 0 eq includecheck and % even & includecheck barlen 2 mod 0 ne includecheck not and or { % odd & !includecheck /pad barlen 1 add string def % Create pad one bigger than barcode pad 0 48 put % Put ascii 0 at start of pad pad 1 barcode putinterval % Add barcode to the end of pad /barcode pad def % barcode=pad /barlen barlen 1 add def % barlen++ } if % % Add checksum to end of barcode % includecheck { /checksum 0 def 0 1 barlen 1 sub { /i exch def i 2 mod 0 eq { /checksum checksum barcode i get 48 sub 3 mul add def } { /checksum checksum barcode i get 48 sub add def } ifelse } for /checksum 10 checksum 10 mod sub 10 mod def /pad barlen 1 add string def % Create pad one bigger than barcode pad 0 barcode putinterval % Add barcode to the start of pad pad barlen checksum 48 add put % Add checksum to end of pad /barcode pad def % barcode=pad /barlen barlen 1 add def % barlen++ } if /sbs barlen 5 mul 8 add string def % % Put the start character % sbs 0 //interleaved2of5.encs 10 get putinterval 0 2 barlen 1 sub { /i exch def % % Lookup the encodings for two consecutive barcode characters % barcode i 1 getinterval //interleaved2of5.barchars exch search pop % Discard true leaving pre length /indx exch def % indx is the length of pre pop pop % Discard seek and post /enca //interleaved2of5.encs indx get def % Get the indxth encoding barcode i 1 add 1 getinterval //interleaved2of5.barchars exch search pop % Discard true leaving pre length /indx exch def % indx is the length of pre pop pop % Discard seek and post /encb //interleaved2of5.encs indx get def % Get the indxth encoding % % Interleave the two character encodings % /intl enca length 2 mul string def 0 1 enca length 1 sub { /j exch def /achar enca j get def /bchar encb j get def intl j 2 mul achar put intl j 2 mul 1 add bchar put } for sbs i 5 mul 4 add intl putinterval % Put encoded digit into sbs } for % % Put the end character % sbs barlen 5 mul 4 add //interleaved2of5.encs 11 get putinterval /text barcode 0 includecheck includecheckintext not and { barlen 1 sub } { barlen } ifelse getinterval def /sbs [sbs {48 sub} forall] def /height /resolve_height //render exec dup -1 eq { pop 1.0 } if def << /ren /renlinear /sbs sbs /bhs [sbs length 1 add 2 idiv {height} repeat] /bbs [sbs length 1 add 2 idiv {0} repeat] includetext { /txt [ [text 0 0 text1font text1size] ] /text1xalign (center) } if /barratio 2.0 /spaceratio 2.0 /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /interleaved2of5 dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER interleaved2of5-- % --BEGIN ENCODER itf14-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear interleaved2of5-- % --DESC: ITF-14 % --EXAM: 0 952 1234 54321 3 % --EXOP: includetext % --RNDR: renlinear % --FMLY: Supply Chain %%BeginResource: uk.co.terryburton.bwipp itf14 0.0 2026052800 79773 79694 %%BeginData: 148 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 5 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /interleaved2of5 dup /uk.co.terryburton.bwipp findresource put begin /itf14 { 32 dict begin { /dontdraw false def /includetext false def /includecheckintext true def /text1font /Courier def /text1size 10.0 def /text1xoffset 0.0 def /text1yoffset -3.5 def /height -1.0 def /width 0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def /showborder true def /borderwidth 4.0 def /borderleft 10.0 def /borderright 10.0 def /bordertop -0.2 def % Ensure border/bearer touches bars with default inkspread /borderbottom -0.2 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Strip spaces from the given data % /text barcode def barcode dup length string exch 0 exch {dup 32 ne {3 copy put pop 1 add} {pop} ifelse} forall 0 exch getinterval /barcode exch def /hasspace text length barcode length ne def % % Validate the input % barcode length 13 ne barcode length 14 ne and { /bwipp.itf14badLength (ITF-14 must be 13 or 14 digits) //raiseerror exec } if barcode { dup 48 lt exch 57 gt or { /bwipp.itf14badCharacter (ITF-14 must contain only digits) //raiseerror exec } if } forall % % Calculate ITF checksum and add to end of barcode % /checksum 0 def 0 1 12 { /i exch def /checksum checksum barcode i get 48 sub i 2 mod 0 eq {3 mul} if add def } for /checksum 10 checksum 10 mod sub 10 mod def barcode length 14 eq { barcode 13 get checksum 48 add ne { /bwipp.itf14badCheckDigit (Incorrect ITF-14 check digit provided) //raiseerror exec } if } { 14 string dup 0 barcode putinterval dup 13 checksum 48 add put /barcode exch def text length hasspace {2} {1} ifelse add string dup dup length 2 sub ( ) putinterval dup dup length 1 sub checksum 48 add put dup 0 text putinterval /text exch def } ifelse % % Apply AST spec overrides and resolve physical specification % /itf14 ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec height -1.0 eq { propspec hnom -1 ne and not { /height 0.5 def } if } if % % Get the result of encoding with interleaved2of5 % options (showborder) showborder put options (borderwidth) borderwidth put options (borderleft) borderleft put options (borderright) borderright put options (bordertop) bordertop put options (borderbottom) borderbottom put options (height) height put options (text1yoffset) text1yoffset put options (propspec) propspec put options (strictspec) strictspec put options (loosespec) loosespec put options (ast) undef options (mag) undef options (xdim) xdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put options (hnom) hnom put options (modunit) modunit put /uk.co.terryburton.bwipp._dontdraw true def barcode options //interleaved2of5 exec /args exch def args (txt) [ [text text1xoffset text1yoffset text1font text1size] ] put args (text1xalign) (center) put args (opt) options put args _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /itf14 dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER itf14-- % --BEGIN ENCODER identcode-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear interleaved2of5-- % --DESC: Deutsche Post Identcode % --EXAM: 563102430313 % --EXOP: includetext % --RNDR: renlinear % --FMLY: Postal Symbols %%BeginResource: uk.co.terryburton.bwipp identcode 0.0 2026052800 72832 72740 %%BeginData: 96 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 4 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /interleaved2of5 dup /uk.co.terryburton.bwipp findresource put begin /identcode { 16 dict begin { /dontdraw false def /includetext false def % Enable/disable text /text1font /Courier def /text1size 10.0 def /text1xoffset 0.0 def /text1yoffset -7.0 def /height -1.0 def null /apply //processoptions exec /options exch def /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Validate the input % barcode length 11 ne barcode length 12 ne and { /bwipp.identcodeBadLength (Deutsche Post Identcode must be 11 or 12 digits) //raiseerror exec } if barcode { dup 48 lt exch 57 gt or { /bwipp.identcodeBadCharacter (Deutsche Post Identcode must contain only digits) //raiseerror exec } if } forall % % Calculate checksum and add to end of barcode % /checksum 0 def 0 1 10 { /i exch def /checksum checksum barcode i get 48 sub i 2 mod 0 eq {4 mul} {9 mul} ifelse add def } for /checksum 10 checksum 10 mod sub 10 mod def barcode length 12 eq { barcode 11 get checksum 48 add ne { /bwipp.identcodeBadCheckDigit (Incorrect Deutsche Post Identcode check digit provided) //raiseerror exec } if } if 12 string dup 0 barcode putinterval dup 11 checksum 48 add put /barcode exch def % % Compose the human readable text % /text ( . . ) 16 string copy def text 0 barcode 0 2 getinterval putinterval text 3 barcode 2 3 getinterval putinterval text 7 barcode 5 3 getinterval putinterval text 11 barcode 8 3 getinterval putinterval text 15 barcode 11 1 getinterval putinterval % % Get the result of encoding with interleaved2of5 % options (includecheck) false put /uk.co.terryburton.bwipp._dontdraw true def barcode options //interleaved2of5 exec /args exch def args (txt) [ [text text1xoffset text1yoffset text1font text1size] ] put args (text1xalign) (center) put args (opt) options put args _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /identcode dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER identcode-- % --BEGIN ENCODER leitcode-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear interleaved2of5-- % --DESC: Deutsche Post Leitcode % --EXAM: 21348075016401 % --EXOP: includetext % --RNDR: renlinear % --FMLY: Postal Symbols %%BeginResource: uk.co.terryburton.bwipp leitcode 0.0 2026052800 72824 72736 %%BeginData: 96 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 4 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /interleaved2of5 dup /uk.co.terryburton.bwipp findresource put begin /leitcode { 16 dict begin { /dontdraw false def /includetext false def % Enable/disable text /text1font /Courier def /text1size 10.0 def /text1xoffset 0.0 def /text1yoffset -7.0 def /height -1.0 def null /apply //processoptions exec /options exch def /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Validate the input % barcode length 13 ne barcode length 14 ne and { /bwipp.leitcodeBadLength (Deutsche Post Leitcode must be 13 or 14 digits) //raiseerror exec } if barcode { dup 48 lt exch 57 gt or { /bwipp.leitcodeBadCharacter (Deutsche Post Leitcode must contain only digits) //raiseerror exec } if } forall % % Calculate checksum and add to end of barcode % /checksum 0 def 0 1 12 { /i exch def /checksum checksum barcode i get 48 sub i 2 mod 0 eq {4 mul} {9 mul} ifelse add def } for /checksum 10 checksum 10 mod sub 10 mod def barcode length 14 eq { barcode 13 get checksum 48 add ne { /bwipp.leitcodeBadCheckDigit (Incorrect Deutsche Post Leitcode check digit provided) //raiseerror exec } if } if 14 string dup 0 barcode putinterval dup 13 checksum 48 add put /barcode exch def % % Compose the human readable text % /text ( . . . ) 18 string copy def text 0 barcode 0 5 getinterval putinterval text 6 barcode 5 3 getinterval putinterval text 10 barcode 8 3 getinterval putinterval text 14 barcode 11 2 getinterval putinterval text 17 barcode 13 1 getinterval putinterval % % Get the result of encoding with interleaved2of5 % options (includecheck) false put /uk.co.terryburton.bwipp._dontdraw true def barcode options //interleaved2of5 exec /args exch def args (txt) [ [text text1xoffset text1yoffset text1font text1size] ] put args (text1xalign) (center) put args (opt) options put args _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /leitcode dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER leitcode-- % --BEGIN ENCODER databaromni-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear renmatrix-- % --DESC: GS1 DataBar Omnidirectional % --EXAM: (01)09521234543213 % --EXOP: % --RNDR: renlinear renmatrix % --FMLY: GS1 DataBar %%BeginResource: uk.co.terryburton.bwipp databaromni 0.0 2026052800 141384 140571 %%BeginData: 505 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 17 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render 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 /databaromni.tab164 [ 160 0 12 4 8 1 161 1 960 161 10 6 6 3 80 10 2014 961 8 8 4 5 31 34 2714 2015 6 10 3 6 10 70 2840 2715 4 12 1 8 1 126 ] readonly def /databaromni.tab154 [ 335 0 5 10 2 7 4 84 1035 336 7 8 4 5 20 35 1515 1036 9 6 6 3 48 10 1596 1516 11 4 8 1 81 1 ] readonly def /databaromni.checkweights [ 1 3 9 27 2 6 18 54 58 72 24 8 29 36 12 4 74 51 17 32 37 65 48 16 64 34 23 69 49 68 46 59 ] readonly def /databaromni.checkwidths [ 3 8 2 1 1 3 5 5 1 1 3 3 7 1 1 3 1 9 1 1 2 7 4 1 1 2 5 6 1 1 2 3 8 1 1 1 5 7 1 1 1 3 9 1 1 ] readonly def /databaromni.seppad [ 0 0 0 0 ] readonly def /databaromni.findersep [ 0 0 0 0 0 0 0 0 0 0 1 0 0 ] readonly def /databaromni.f3pat [ 1 1 1 1 1 1 1 1 1 0 1 1 1 ] readonly def /databaromni { 128 dict begin { /dontdraw false def /height -1.0 def /width 0 def /linkage false def /format (omni) def /barxmult 33 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def barcode length 17 ne barcode length 18 ne and { /bwipp.databaromniBadLength (GS1 DataBar Omnidirectional must be 13 or 14 digits) //raiseerror exec } if barcode 0 4 getinterval (\(01\)) ne { /bwipp.databaromniBadAI (GS1 DataBar Omnidirectional must begin with (01) application identifier) //raiseerror exec } if barcode 4 barcode length 4 sub getinterval { dup 48 lt exch 57 gt or { /bwipp.databaromniBadCharacter (GS1 DataBar Omnidirectional must contain only digits) //raiseerror exec } if } forall barxmult 33 lt { /bwipp.databarStackedOmniBarXmult (GS1 DataBar Stacked Omnidirectional must have a barxmult of at least 33) //raiseerror exec } if format (omni) ne format (stacked) ne and format (stackedomni) ne and format (truncated) ne and { /bwipp.databaromniBadFormat (Valid formats are omni, stacked, stackedomni and truncated) //raiseerror exec } if format (truncated) eq height -1.0 eq and {/height 13.0 72 div def} if % % Apply AST spec overrides and resolve physical specification % /databaromni ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec % % Calculate checksum and add to end of barcode % /checksum 0 def 0 1 12 { /i exch def /checksum checksum barcode i 4 add get 48 sub i 2 mod 0 eq {3 mul} if add def } for /checksum 10 checksum 10 mod sub 10 mod def barcode length 18 eq { barcode 17 get checksum 48 add ne { /bwipp.databaromniBadCheckDigit (Incorrect GS1 DataBar Omnidirectional check digit provided) //raiseerror exec } if } if 18 string dup 0 barcode putinterval dup 17 checksum 48 add put /barcode exch def % % Create the human readable text % /txt barcode length array def 0 1 barcode length 1 sub { /i exch def txt i [barcode i 1 getinterval 0 0 () 0] put } for /ncr { % n r 2 copy sub 2 copy lt {exch} if % n r maxd mind 1 1 5 3 roll % mind j=1 v=1 n maxd 1 add -1 exch { % mind j v n -1 maxd+1 mul % mind j v*i 1 index 3 index le { 1 index idiv exch 1 add exch } if } for { % mind j v 1 index 3 index gt {exit} if 1 index idiv exch 1 add exch } loop exch pop exch pop } def /getRSSwidths { /oe exch def /el exch def /mw exch def /nm exch def /val exch def /out el array def /mask 0 def 0 1 el 2 sub { /bar exch def /ew 1 def /mask mask 1 bar bitshift or def { /sval nm ew sub 1 sub el bar sub 2 sub ncr def oe mask 0 eq and nm ew sub el 2 mul sub bar 2 mul add -2 ge and { /sval sval nm ew sub el sub bar add el bar sub 2 sub ncr sub def } if el bar sub 2 gt { /lval 0 def nm ew sub el sub bar add 2 add -1 mw 1 add { nm exch sub ew sub 1 sub el bar sub 3 sub ncr /lval exch lval add def } for /sval sval lval el bar sub 1 sub mul sub def } { nm ew sub mw gt {/sval sval 1 sub def} if } ifelse /val val sval sub def val 0 lt {exit} if /ew ew 1 add def /mask mask 1 bar bitshift not and def } loop /val val sval add def /nm nm ew sub def out bar ew put } for out el 1 sub nm put out } def /binval [ linkage {1} {0} ifelse barcode 4 13 getinterval {48 sub} forall ] def 0 1 12 { /i exch def binval i 1 add 2 copy get binval i get 4537077 mod 10 mul add put binval i binval i get 4537077 idiv put } for /right binval 13 get 4537077 mod def binval 13 2 copy get 4537077 idiv put /left 0 def /i true def 0 1 13 { /j exch def binval j get dup 0 eq i and { pop } { /i false def /left left 3 -1 roll 10 13 j sub exp cvi mul add def } ifelse } for /d1 left 1597 idiv def /d2 left 1597 mod def /d3 right 1597 idiv def /d4 right 1597 mod def /i 0 def { d1 //databaromni.tab164 i get le { //databaromni.tab164 i 1 add 7 getinterval aload pop /d1te exch def /d1to exch def /d1mwe exch def /d1mwo exch def /d1ele exch def /d1elo exch def /d1gs exch def exit } if /i i 8 add def } loop /i 0 def { d2 //databaromni.tab154 i get le { //databaromni.tab154 i 1 add 7 getinterval aload pop /d2te exch def /d2to exch def /d2mwe exch def /d2mwo exch def /d2ele exch def /d2elo exch def /d2gs exch def exit } if /i i 8 add def } loop /i 0 def { d3 //databaromni.tab164 i get le { //databaromni.tab164 i 1 add 7 getinterval aload pop /d3te exch def /d3to exch def /d3mwe exch def /d3mwo exch def /d3ele exch def /d3elo exch def /d3gs exch def exit } if /i i 8 add def } loop /i 0 def { d4 //databaromni.tab154 i get le { //databaromni.tab154 i 1 add 7 getinterval aload pop /d4te exch def /d4to exch def /d4mwe exch def /d4mwo exch def /d4ele exch def /d4elo exch def /d4gs exch def exit } if /i i 8 add def } loop /d1wo d1 d1gs sub d1te idiv d1elo d1mwo 4 false getRSSwidths def /d1we d1 d1gs sub d1te mod d1ele d1mwe 4 true getRSSwidths def /d2wo d2 d2gs sub d2to mod d2elo d2mwo 4 true getRSSwidths def /d2we d2 d2gs sub d2to idiv d2ele d2mwe 4 false getRSSwidths def /d3wo d3 d3gs sub d3te idiv d3elo d3mwo 4 false getRSSwidths def /d3we d3 d3gs sub d3te mod d3ele d3mwe 4 true getRSSwidths def /d4wo d4 d4gs sub d4to mod d4elo d4mwo 4 true getRSSwidths def /d4we d4 d4gs sub d4to idiv d4ele d4mwe 4 false getRSSwidths def /d1w 8 array def 0 1 3 { /i exch def d1w i 2 mul d1wo i get put d1w i 2 mul 1 add d1we i get put } for /d2w 8 array def 0 1 3 { /i exch def d2w 7 i 2 mul sub d2wo i get put d2w 6 i 2 mul sub d2we i get put } for /d3w 8 array def 0 1 3 { /i exch def d3w 7 i 2 mul sub d3wo i get put d3w 6 i 2 mul sub d3we i get put } for /d4w 8 array def 0 1 3 { /i exch def d4w i 2 mul d4wo i get put d4w i 2 mul 1 add d4we i get put } for /widths [ d1w aload pop d2w aload pop d3w aload pop d4w aload pop ] def /checksum 0 def 0 1 31 { /i exch def /checksum checksum widths i get //databaromni.checkweights i get mul add def } for /checksum checksum 79 mod def checksum 8 ge {/checksum checksum 1 add def} if checksum 72 ge {/checksum checksum 1 add def} if /checklt //databaromni.checkwidths checksum 9 idiv 5 mul 5 getinterval def /checkrtrev //databaromni.checkwidths checksum 9 mod 5 mul 5 getinterval def /checkrt 5 array def 0 1 4 { /i exch def checkrt i checkrtrev 4 i sub get put } for % % Stacked format % format (omni) eq format (truncated) eq or { % linear /sbs [ 0 1 1 % 0-width placeholder + left guard (space + bar) d1w aload pop checklt aload pop d2w aload pop d4w aload pop checkrt aload pop d3w aload pop 1 1 % right guard (space + bar) ] def /height /resolve_height //render exec dup -1 eq { pop 33.0 72 div } if def << /ren /renlinear /sbs sbs /bhs [sbs length 1 add 2 idiv {height} repeat] /bbs [sbs length 1 add 2 idiv {0} repeat] /txt txt /text1xalign (center) /borderleft 0.0 /borderright 0.0 /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } { % 2D - stacked or stackedomni /top [ 1 1 d1w aload pop checklt aload pop d2w aload pop 1 1 0 ] def /bot [ 1 1 d4w aload pop checkrt aload pop d3w aload pop 1 1 0 ] def 0 2 24 { /i exch def top i get {0} repeat top i 1 add get {1} repeat } for 50 array astore /top exch def 0 2 24 { /i exch def bot i get {1} repeat bot i 1 add get {0} repeat } for 50 array astore /bot exch def % % Stacked % format (stacked) eq { /sep 50 array def sep 0 0 put 1 1 49 { /i exch def top i get bot i get eq { sep i 1 top i get sub put } { sep i 1 sep i 1 sub get sub put } ifelse } for sep 0 //databaromni.seppad putinterval sep 46 //databaromni.seppad putinterval /pixs [ top aload pop sep aload pop bot aload pop ] def /rowheights [5 1 7] def /pixy 13 def } if % % Stacked omnidirectional % format (stackedomni) eq { /sep1 [ top {1 exch sub} forall ] def sep1 0 //databaromni.seppad putinterval sep1 46 //databaromni.seppad putinterval 18 1 30 { /i exch def top i get 0 eq { top i 1 sub get 1 eq { 1 } { sep1 i 1 sub get 0 eq {1} {0} ifelse } ifelse } { 0 } ifelse sep1 exch i exch put } for /sep2 [ 0 0 0 0 21 { 0 1 } repeat 0 0 0 0 ] def /sep3 [ bot {1 exch sub} forall ] def sep3 0 //databaromni.seppad putinterval sep3 46 //databaromni.seppad putinterval 19 1 31 { /i exch def bot i get 0 eq { bot i 1 sub get 1 eq { 1 } { sep3 i 1 sub get 0 eq {1} {0} ifelse } ifelse } { 0 } ifelse sep3 exch i exch put } for true 0 1 12 {dup bot exch 19 add get exch //databaromni.f3pat exch get eq and} for { % Right shifted module for value 3 finder sep3 19 //databaromni.findersep putinterval } if /pixs [ top aload pop sep1 aload pop sep2 aload pop sep3 aload pop bot aload pop ] def /rowheights [barxmult 1 1 1 barxmult] def /pixy barxmult 2 mul 3 add def } if << /ren /renmatrix /pixs pixs /pixx 50 /pixy pixy /rowheights rowheights /height pixy 72 div /width 50 72 div /borderleft 0.0 /borderright 0.0 /bordertop 0.0 /borderbottom 0.0 /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } ifelse } stopped {end stop} if end } [/barcode] {null def} forall bind def /databaromni dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER databaromni-- % --BEGIN ENCODER databarstacked-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear renmatrix databaromni-- % --DESC: GS1 DataBar Stacked % --EXAM: (01)09521234543213 % --EXOP: % --RNDR: renmatrix % --FMLY: GS1 DataBar %%BeginResource: uk.co.terryburton.bwipp databarstacked 0.0 2026052800 77216 76837 %%BeginData: 113 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 5 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /databaromni dup /uk.co.terryburton.bwipp findresource put begin /databarstacked { 8 dict begin { /dontdraw false def /propspec false def /loosespec false def /strictspec false def /width 0 def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Validate the input % barcode length 17 ne barcode length 18 ne and { /bwipp.databarstackedBadLength (GS1 DataBar Stacked must be 13 or 14 digits) //raiseerror exec } if barcode 0 4 getinterval (\(01\)) ne { /bwipp.databarstackedBadAI (GS1 DataBar Stacked must begin with (01) application identifier) //raiseerror exec } if barcode 4 barcode length 4 sub getinterval { dup 48 lt exch 57 gt or { /bwipp.databarstackedBadCharacter (GS1 DataBar Stacked must contain only digits) //raiseerror exec } if } forall % % Calculate checksum and add to end of barcode % /checksum 0 def 0 1 12 { /i exch def /checksum checksum barcode i 4 add get 48 sub i 2 mod 0 eq {3 mul} if add def } for /checksum 10 checksum 10 mod sub 10 mod def barcode length 18 eq { barcode 17 get checksum 48 add ne { /bwipp.databarstackedBadCheckDigit (Incorrect GS1 DataBar Stacked check digit provided) //raiseerror exec } if } if 18 string dup 0 barcode putinterval dup 17 checksum 48 add put /barcode exch def % % Apply AST spec overrides and resolve physical specification % /databarstacked ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec % % Get the result of encoding with databaromni with format=stacked % options (format) (stacked) put options (ast) undef options (mag) undef options (propspec) propspec put options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put options (hnom) hnom put options (modunit) modunit put /uk.co.terryburton.bwipp._dontdraw true def barcode options //databaromni exec /args exch def args (opt) options put args _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /databarstacked dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER databarstacked-- % --BEGIN ENCODER databarstackedomni-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear renmatrix databaromni-- % --DESC: GS1 DataBar Stacked Omnidirectional % --EXAM: (01)24012345678905 % --EXOP: % --RNDR: renmatrix % --FMLY: GS1 DataBar %%BeginResource: uk.co.terryburton.bwipp databarstackedomni 0.0 2026052800 77312 76917 %%BeginData: 113 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 5 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /databaromni dup /uk.co.terryburton.bwipp findresource put begin /databarstackedomni { 8 dict begin { /dontdraw false def /propspec false def /loosespec false def /strictspec false def /width 0 def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Validate the input % barcode length 17 ne barcode length 18 ne and { /bwipp.databarstackedomniBadLength (GS1 DataBar Stacked Omnidirectional must be 13 or 14 digits) //raiseerror exec } if barcode 0 4 getinterval (\(01\)) ne { /bwipp.databarstackedomniBadAI (GS1 DataBar Stacked Omnidirectional must begin with (01) application identifier) //raiseerror exec } if barcode 4 barcode length 4 sub getinterval { dup 48 lt exch 57 gt or { /bwipp.databarstackedomniBadCharacter (GS1 DataBar Stacked Omnidirectional must contain only digits) //raiseerror exec } if } forall % % Calculate checksum and add to end of barcode % /checksum 0 def 0 1 12 { /i exch def /checksum checksum barcode i 4 add get 48 sub i 2 mod 0 eq {3 mul} if add def } for /checksum 10 checksum 10 mod sub 10 mod def barcode length 18 eq { barcode 17 get checksum 48 add ne { /bwipp.databarstackedomniBadCheckDigit (Incorrect GS1 DataBar Stacked Omnidirectional check digit provided) //raiseerror exec } if } if 18 string dup 0 barcode putinterval dup 17 checksum 48 add put /barcode exch def % % Apply AST spec overrides and resolve physical specification % /databarstackedomni ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec % % Get the result of encoding with databaromni with format=stackedomni % options (format) (stackedomni) put options (ast) undef options (mag) undef options (propspec) propspec put options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put options (hnom) hnom put options (modunit) modunit put /uk.co.terryburton.bwipp._dontdraw true def barcode options //databaromni exec /args exch def args (opt) options put args _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /databarstackedomni dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER databarstackedomni-- % --BEGIN ENCODER databartruncated-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear renmatrix databaromni-- % --DESC: GS1 DataBar Truncated % --EXAM: (01)09521234543213 % --EXOP: % --RNDR: renlinear renmatrix % --FMLY: GS1 DataBar %%BeginResource: uk.co.terryburton.bwipp databartruncated 0.0 2026052800 77240 76853 %%BeginData: 113 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 5 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /databaromni dup /uk.co.terryburton.bwipp findresource put begin /databartruncated { 8 dict begin { /dontdraw false def /propspec false def /loosespec false def /strictspec false def /width 0 def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Validate the input % barcode length 17 ne barcode length 18 ne and { /bwipp.databartruncatedBadLength (GS1 DataBar Truncated must be 13 or 14 digits) //raiseerror exec } if barcode 0 4 getinterval (\(01\)) ne { /bwipp.databartruncatedBadAI (GS1 DataBar Truncated must begin with (01) application identifier) //raiseerror exec } if barcode 4 barcode length 4 sub getinterval { dup 48 lt exch 57 gt or { /bwipp.databartruncatedBadCharacter (GS1 DataBar Truncated must contain only digits) //raiseerror exec } if } forall % % Calculate checksum and add to end of barcode % /checksum 0 def 0 1 12 { /i exch def /checksum checksum barcode i 4 add get 48 sub i 2 mod 0 eq {3 mul} if add def } for /checksum 10 checksum 10 mod sub 10 mod def barcode length 18 eq { barcode 17 get checksum 48 add ne { /bwipp.databartruncatedBadCheckDigit (Incorrect GS1 DataBar Truncated check digit provided) //raiseerror exec } if } if 18 string dup 0 barcode putinterval dup 17 checksum 48 add put /barcode exch def % % Apply AST spec overrides and resolve physical specification % /databartruncated ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec % % Get the result of encoding with databaromni with format=truncated % options (format) (truncated) put options (ast) undef options (mag) undef options (propspec) propspec put options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put options (hnom) hnom put options (modunit) modunit put /uk.co.terryburton.bwipp._dontdraw true def barcode options //databaromni exec /args exch def args (opt) options put args _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /databartruncated dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER databartruncated-- % --BEGIN ENCODER databarlimited-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear-- % --DESC: GS1 DataBar Limited % --EXAM: (01)09521234543213 % --EXOP: % --RNDR: renlinear % --FMLY: GS1 DataBar %%BeginResource: uk.co.terryburton.bwipp databarlimited 0.0 2026052800 106872 112993 %%BeginData: 343 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /databarlimited.linkval [ 2 0 1 5 1 3 3 5 3 1 0 9 6 ] readonly def /databarlimited.tab267 [ 183063 0 17 9 6 3 6538 28 820063 183064 13 13 5 4 875 728 1000775 820064 9 17 3 6 28 6454 1491020 1000776 15 11 5 4 2415 203 1979844 1491021 11 15 4 5 203 2408 1996938 1979845 19 7 8 1 17094 1 2013570 1996939 7 19 1 8 1 16632 ] readonly def /databarlimited.checkweights [ 1 3 9 27 81 65 17 51 64 14 42 37 22 66 20 60 2 6 18 54 73 41 34 13 39 28 84 74 ] readonly def /databarlimited.latevars dup 1 dict def load /init { currentglobal true setglobal //databarlimited.latevars begin /checkseq [ 0 1 43 {} for 45 52 57 63 1 66 {} for 73 1 79 {} for 82 126 1 130 {} for 132 141 1 146 {} for 210 1 217 {} for 220 316 1 320 {} for 322 323 326 337 ] readonly def /init { //databarlimited.latevars {def} forall } def end //databarlimited.latevars /init get exec setglobal } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//databarlimited.latevars /init get exec} if } {pop} ifelse /databarlimited { 64 dict begin { /dontdraw false def /height -1.0 def /width 0 def /linkage false def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def //databarlimited.latevars /init get exec % % Validate the input % barcode length 17 ne barcode length 18 ne and { /bwipp.databarlimitedBadLength (GS1 DataBar Limited must be 13 or 14 digits) //raiseerror exec } if barcode 0 4 getinterval (\(01\)) ne { /bwipp.databarlimitedBadAI (GS1 DataBar Limited must begin with (01) application identifier) //raiseerror exec } if barcode 4 get dup 48 lt exch 49 gt or { /bwipp.databarlimitedBadStartDigit (GS1 DataBar Limited must begin with 0 or 1) //raiseerror exec } if barcode 5 barcode length 5 sub getinterval { dup 48 lt exch 57 gt or { /bwipp.databarlimitedBadCharacter (GS1 DataBar Limited must contain only digits) //raiseerror exec } if } forall % % Apply AST spec overrides and resolve physical specification % /databarlimited ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec % % Calculate checksum and add to end of barcode % /checksum 0 def 0 1 12 { /i exch def /checksum checksum barcode i 4 add get 48 sub i 2 mod 0 eq {3 mul} if add def } for /checksum 10 checksum 10 mod sub 10 mod def barcode length 18 eq { barcode 17 get checksum 48 add ne { /bwipp.databarlimitedBadCheckDigit (Incorrect GS1 DataBar Limited check digit provided) //raiseerror exec } if } if 18 string dup 0 barcode putinterval dup 17 checksum 48 add put /barcode exch def % % Strip the AI and optional check digit % /binval [ barcode 4 13 getinterval {48 sub} forall ] def linkage { 0 1 binval length 1 sub { /i exch def binval i binval i get //databarlimited.linkval i get add put } for } if % % Create the human readable text % /txt barcode length array def 0 1 barcode length 1 sub { /i exch def txt i [barcode i 1 getinterval 0 0 () 0] put } for /ncr { % n r 2 copy sub 2 copy lt {exch} if % n r maxd mind 1 1 5 3 roll % mind j=1 v=1 n maxd 1 add -1 exch { % mind j v n -1 maxd+1 mul % mind j v*i 1 index 3 index le { 1 index idiv exch 1 add exch } if } for { % mind j v 1 index 3 index gt {exit} if 1 index idiv exch 1 add exch } loop exch pop exch pop } def /getRSSwidths { /oe exch def /el exch def /mw exch def /nm exch def /val exch def /out el array def /mask 0 def 0 1 el 2 sub { /bar exch def /ew 1 def /mask mask 1 bar bitshift or def { /sval nm ew sub 1 sub el bar sub 2 sub ncr def oe mask 0 eq and nm ew sub el 2 mul sub bar 2 mul add -2 ge and { /sval sval nm ew sub el sub bar add el bar sub 2 sub ncr sub def } if el bar sub 2 gt { /lval 0 def nm ew sub el sub bar add 2 add -1 mw 1 add { nm exch sub ew sub 1 sub el bar sub 3 sub ncr /lval exch lval add def } for /sval sval lval el bar sub 1 sub mul sub def } { nm ew sub mw gt {/sval sval 1 sub def} if } ifelse /val val sval sub def val 0 lt {exit} if /ew ew 1 add def /mask mask 1 bar bitshift not and def } loop /val val sval add def /nm nm ew sub def out bar ew put } for out el 1 sub nm put out } def 0 1 11 { /i exch def binval i 1 add 2 copy get binval i get 2013571 mod 10 mul add put binval i binval i get 2013571 idiv put } for /d2 binval 12 get 2013571 mod def binval 12 2 copy get 2013571 idiv put /d1 0 def /i true def 0 1 12 { /j exch def binval j get dup 0 eq i and { pop } { /i false def /d1 d1 3 -1 roll 10 12 j sub exp cvi mul add def } ifelse } for /i 0 def { d1 //databarlimited.tab267 i get le { //databarlimited.tab267 i 1 add 7 getinterval aload pop /d1te exch def /d1to exch def /d1mwe exch def /d1mwo exch def /d1ele exch def /d1elo exch def /d1gs exch def exit } if /i i 8 add def } loop /i 0 def { d2 //databarlimited.tab267 i get le { //databarlimited.tab267 i 1 add 7 getinterval aload pop /d2te exch def /d2to exch def /d2mwe exch def /d2mwo exch def /d2ele exch def /d2elo exch def /d2gs exch def exit } if /i i 8 add def } loop /d1wo d1 d1gs sub d1te idiv d1elo d1mwo 7 false getRSSwidths def /d1we d1 d1gs sub d1te mod d1ele d1mwe 7 true getRSSwidths def /d2wo d2 d2gs sub d2te idiv d2elo d2mwo 7 false getRSSwidths def /d2we d2 d2gs sub d2te mod d2ele d2mwe 7 true getRSSwidths def /d1w 14 array def 0 1 6 { /i exch def d1w i 2 mul d1wo i get put d1w i 2 mul 1 add d1we i get put } for /d2w 14 array def 0 1 6 { /i exch def d2w i 2 mul d2wo i get put d2w i 2 mul 1 add d2we i get put } for /widths [ d1w aload pop d2w aload pop ] def /checksum 0 def 0 1 27 { /i exch def /checksum checksum widths i get //databarlimited.checkweights i get mul add def } for /checksum checksum 89 mod def /seq checkseq checksum get def /swidths seq 21 idiv 8 3 6 false getRSSwidths def /bwidths seq 21 mod 8 3 6 false getRSSwidths def /checkwidths [0 0 0 0 0 0 0 0 0 0 0 0 1 1] def 0 1 5 { /i exch def checkwidths i 2 mul swidths i get put checkwidths i 2 mul 1 add bwidths i get put } for /sbs [ 0 1 1 % 0-width placeholder + left guard (space + bar) d1w aload pop checkwidths aload pop d2w aload pop 1 1 5 0 % right guard (space + bar + 5-module space) + 0-width placeholder so renlinear processes the trailing space ] def /height /resolve_height //render exec dup -1 eq { pop 10.0 72 div } if def << /ren /renlinear /sbs sbs /bhs [sbs length 1 add 2 idiv {height} repeat] /bbs [sbs length 1 add 2 idiv {0} repeat] /txt txt /text1xalign (center) /borderleft 0.0 /borderright 0.0 /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /databarlimited dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER databarlimited-- % --BEGIN ENCODER databarexpanded-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput gs1process setanycolor render renlinear renmatrix-- % --DESC: GS1 DataBar Expanded % --EXAM: (01)09521234543213(3103)000123 % --EXOP: % --RNDR: renlinear renmatrix % --FMLY: GS1 DataBar %%BeginResource: uk.co.terryburton.bwipp databarexpanded 0.0 2026052800 259505 265613 %%BeginData: 979 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 17 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /gs1process dup /uk.co.terryburton.bwipp findresource put dup /render 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 /databarexpanded.tab174 [ 347 0 12 5 7 2 87 4 1387 348 10 7 5 4 52 20 2947 1388 8 9 4 5 30 52 3987 2948 6 11 3 6 10 104 4191 3988 4 13 1 8 1 204 ] readonly def /databarexpanded.finderwidths [ 1 8 4 1 1 1 1 4 8 1 3 6 4 1 1 1 1 4 6 3 3 4 6 1 1 1 1 6 4 3 3 2 8 1 1 1 1 8 2 3 2 6 5 1 1 1 1 5 6 2 2 2 9 1 1 1 1 9 2 2 ] readonly def /databarexpanded.finderseq [ [0 1] [0 3 2] [0 5 2 7] [0 9 2 7 4] [0 9 2 7 6 11] [0 9 2 7 8 11 10] [0 1 2 3 4 5 6 7] [0 1 2 3 4 5 6 9 8] [0 1 2 3 4 5 6 9 10 11] [0 1 2 3 4 7 6 9 8 11 10] ] readonly def /databarexpanded.checkweights [ -1 -1 -1 -1 -1 -1 -1 -1 % A1L 77 96 32 81 27 9 3 1 % A1R 20 60 180 118 143 7 21 63 % A2L 205 209 140 117 39 13 145 189 % A2R 193 157 49 147 19 57 171 91 % B1L 132 44 85 169 197 136 186 62 % B1R 185 133 188 142 4 12 36 108 % B2L 50 87 29 80 97 173 128 113 % B2R 150 28 84 41 123 158 52 156 % C1L 166 196 206 139 187 203 138 46 % C1R 76 17 51 153 37 111 122 155 % C2L 146 119 110 107 106 176 129 43 % C2R 16 48 144 10 30 90 59 177 % D1L 164 125 112 178 200 137 116 109 % D1R 70 210 208 202 184 130 179 115 % D2L 190 204 68 93 31 151 191 134 % D2R 148 22 66 198 172 94 71 2 % E1L 40 154 192 64 162 54 18 6 % E1R 120 149 25 75 14 42 126 167 % E2L 175 199 207 69 23 78 26 79 % E2R 103 98 83 38 114 131 182 124 % F1L 159 53 88 170 127 183 61 161 % F1R 55 165 73 8 24 72 5 15 % F2L 89 100 174 58 160 194 135 45 % F2R ] readonly def /databarexpanded.fillpat [ 0 0 1 0 0 ] readonly def /databarexpanded.seppad [ 0 0 0 0 ] readonly def /databarexpanded.fnc1 -1 def /databarexpanded.lnumeric -2 def /databarexpanded.lalphanumeric -3 def /databarexpanded.liso646 -4 def /databarexpanded.latevars dup 1 dict def load /init { currentglobal true setglobal //databarexpanded.latevars begin /numeric << 0 1 119 { dup (00) 2 string copy dup 3 -1 roll 11 2 string cvrs dup length 2 exch sub exch putinterval dup 0 get 65 eq {dup 0 94 put} if dup 1 get 65 eq {dup 1 94 put} if exch 8 add (0000000) 7 string copy dup 3 -1 roll 2 7 string cvrs dup length 7 exch sub exch putinterval } for //databarexpanded.lalphanumeric (0000) >> readonly def /alphanumeric << 48 1 57 {dup 43 sub (00000) 5 string copy dup 3 -1 roll 2 5 string cvrs dup length 5 exch sub exch putinterval} for //databarexpanded.fnc1 (01111) 65 1 90 {dup 33 sub (000000) 6 string copy dup 3 -1 roll 2 6 string cvrs dup length 6 exch sub exch putinterval} for 42 (111010) 44 1 47 {dup 15 add (000000) 6 string copy dup 3 -1 roll 2 6 string cvrs dup length 6 exch sub exch putinterval} for //databarexpanded.lnumeric (000) //databarexpanded.liso646 (00100) >> readonly def /iso646 << 48 1 57 {dup 43 sub (00000) 5 string copy dup 3 -1 roll 2 5 string cvrs dup length 5 exch sub exch putinterval} for //databarexpanded.fnc1 (01111) 65 1 90 {dup 1 sub (0000000) 7 string copy dup 3 -1 roll 2 7 string cvrs dup length 7 exch sub exch putinterval} for 97 1 122 {dup 7 sub (0000000) 7 string copy dup 3 -1 roll 2 7 string cvrs dup length 7 exch sub exch putinterval} for 33 (11101000) 34 (11101001) 37 1 47 {dup 197 add (00000000) 8 string copy dup 3 -1 roll 2 8 string cvrs dup length 8 exch sub exch putinterval} for 58 1 63 {dup 187 add (00000000) 8 string copy dup 3 -1 roll 2 8 string cvrs dup length 8 exch sub exch putinterval} for 95 (11111011) 32 (11111100) //databarexpanded.lnumeric (000) //databarexpanded.lalphanumeric (00100) >> readonly def /init { //databarexpanded.latevars {def} forall } def end //databarexpanded.latevars /init get exec setglobal } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//databarexpanded.latevars /init get exec} if } {pop} ifelse /databarexpanded { 128 dict begin { /parse false def /dontlint false def /lintreqs true def /dontdraw false def /height -1.0 def /width 0 def /format (expanded) def /segments -1 def /linkage false def /barxmult 34 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def //databarexpanded.latevars /init get exec /fnc1 //databarexpanded.fnc1 def barxmult 34 lt { /bwipp.databarStackedOmniBarXmult (GS1 DataBar Expanded Stacked must have a barxmult of at least 34) //raiseerror exec } if format (expanded) ne format (expandedstacked) ne and { /bwipp.databarexpandedBadFormat (Valid formats are expanded and expandedstacked) //raiseerror exec } if segments -1 eq { /segments format (expandedstacked) eq {4} {22} ifelse def } { segments 2 lt segments 22 gt or segments 2 mod 0 ne or { /bwipp.gs1databarexpandedBadSegments (The number of segments must be even from 2 to 22) //raiseerror exec } if } ifelse % % Apply AST spec overrides and resolve physical specification % /databarexpanded ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec barcode /ai //gs1process exec /fncs exch def /vals exch def /ais exch def /isNdigits { % string N -- bool 1 index length ne { pop false } { true exch { dup 48 lt exch 57 gt or { pop false } if } forall } ifelse } def % % Method selection % { % common exit % (01)9...(3103)... ais length 2 eq { ais 0 get (01) eq ais 1 get (3103) eq and { vals 0 get 14 isNdigits vals 1 get 6 isNdigits and { vals 0 get 0 1 getinterval (9) eq vals 1 get cvi 32767 le and { (0100) false exit } if } if } if } if % (01)9...(3202)... ais length 2 eq { ais 0 get (01) eq ais 1 get (3202) eq and { vals 0 get 14 isNdigits vals 1 get 6 isNdigits and { vals 0 get 0 1 getinterval (9) eq vals 1 get cvi 9999 le and { (0101) false exit } if } if } if } if % (01)9...(3203)... ais length 2 eq { ais 0 get (01) eq ais 1 get (3203) eq and { vals 0 get 14 isNdigits vals 1 get 6 isNdigits and { vals 0 get 0 1 getinterval (9) eq vals 1 get cvi 22767 le and { (0101) false exit } if } if } if } if % (01)9...(310x/320x)...[(11/13/15/17)...] ais length dup 2 eq exch 3 eq or { /ai310x false 3100 1 3109 {10 4 string cvrs ais 1 get eq or} for def /ai320x false 3200 1 3209 {10 4 string cvrs ais 1 get eq or} for def ais length 3 eq { /aibad true [ (11) (13) (15) (17) ] {ais 2 get ne and} forall def } { /aibad false def } ifelse ais 0 get (01) eq ai310x ai320x or and aibad not and { ais length 3 eq { vals 0 get 14 isNdigits vals 1 get 6 isNdigits and vals 2 get 6 isNdigits and { vals 0 get 0 1 getinterval (9) eq vals 1 get cvi 99999 le and vals 2 get 2 2 getinterval cvi dup 1 ge exch 12 le and and % Month 1-12 vals 2 get 4 2 getinterval cvi dup 0 ge exch 31 le and and % Day 0-31 } { false } ifelse { ai310x ais 2 get (11) eq and { (0111000) false exit } if ai320x ais 2 get (11) eq and { (0111001) false exit } if ai310x ais 2 get (13) eq and { (0111010) false exit } if ai320x ais 2 get (13) eq and { (0111011) false exit } if ai310x ais 2 get (15) eq and { (0111100) false exit } if ai320x ais 2 get (15) eq and { (0111101) false exit } if ai310x ais 2 get (17) eq and { (0111110) false exit } if ai320x ais 2 get (17) eq and { (0111111) false exit } if } if } { vals 0 get 14 isNdigits vals 1 get 6 isNdigits and { vals 0 get 0 1 getinterval (9) eq vals 1 get cvi 99999 le and { ai310x { (0111000) false exit } if ai320x { (0111001) false exit } if } if } if } ifelse } if } if % (01)9...(392x)... ais length 2 ge { /ai392x false 3920 1 3923 {10 4 string cvrs ais 1 get eq or} for def ais 0 get (01) eq ai392x and vals 0 get 14 isNdigits and { vals 0 get 0 1 getinterval (9) eq { (01100) true exit } if } if } if % (01)9...(393x)... ais length 2 ge { /ai393x false 3930 1 3933 {10 4 string cvrs ais 1 get eq or} for def ais 0 get (01) eq ai393x and vals 0 get 14 isNdigits and { vals 0 get 0 1 getinterval (9) eq vals 1 get length 3 ge { vals 1 get 0 3 getinterval 3 isNdigits } { false } ifelse and { (01101) true exit } if } if } if % (01)... ais 0 get (01) eq vals 0 get 14 isNdigits and { (1) true exit } if % Freeform (00) true exit } loop /gpfallow exch def /method exch def /conv12to40 { (0000000000000000000000000000000000000000) 40 string copy 2 copy 0 10 getinterval exch 0 3 getinterval cvi 2 10 string cvrs dup length 10 exch sub exch putinterval 2 copy 10 10 getinterval exch 3 3 getinterval cvi 2 10 string cvrs dup length 10 exch sub exch putinterval 2 copy 20 10 getinterval exch 6 3 getinterval cvi 2 10 string cvrs dup length 10 exch sub exch putinterval 2 copy 30 10 getinterval exch 9 3 getinterval cvi 2 10 string cvrs dup length 10 exch sub exch putinterval exch pop } def /conv13to44 { (00000000000000000000000000000000000000000000) 44 string copy 2 copy 0 4 getinterval exch 0 1 getinterval cvi 2 4 string cvrs dup length 4 exch sub exch putinterval dup 3 -1 roll 1 12 getinterval conv12to40 4 exch putinterval } def /tobin { string dup length 1 sub 0 exch 1 exch {1 index exch 48 put} for dup 3 -1 roll 2 2 index length string cvrs dup length 2 index length exch sub exch putinterval } def method (00) eq { /cdf [] def /gpf [] def } if method (1) eq { /cdf vals 0 get 0 13 getinterval conv13to44 def /cdf [ cdf {48 sub} forall ] def /gpf [] def /ais ais 1 ais length 1 sub getinterval def /vals vals 1 vals length 1 sub getinterval def /fncs fncs 1 fncs length 1 sub getinterval def } if method (0100) eq { /cdf 55 string def cdf 0 vals 0 get 1 12 getinterval conv12to40 putinterval cdf 40 vals 1 get cvi 15 tobin putinterval /cdf [ cdf {48 sub} forall ] def /gpf [] def /ais [] def /vals [] def /fncs [] def } if method (0101) eq { /cdf 55 string def cdf 0 vals 0 get 1 12 getinterval conv12to40 putinterval ais 1 get (3202) eq { vals 1 get cvi 15 tobin } { vals 1 get cvi 10000 add 15 tobin } ifelse cdf exch 40 exch putinterval /cdf [ cdf {48 sub} forall ] def /gpf [] def /ais [] def /vals [] def /fncs [] def } if method length 7 eq { /cdf 76 string def cdf 0 vals 0 get 1 12 getinterval conv12to40 putinterval 6 string dup 0 ais 1 get 3 1 getinterval putinterval dup vals 1 get 1 5 getinterval 1 exch putinterval cvi 20 tobin cdf exch 40 exch putinterval ais length 3 eq { vals 2 get dup 0 2 getinterval cvi 384 mul exch dup 2 2 getinterval cvi 1 sub 32 mul exch 4 2 getinterval cvi add add } { 38400 } ifelse 16 tobin cdf exch 60 exch putinterval /cdf [ cdf {48 sub} forall ] def /gpf [] def /ais [] def /vals [] def /fncs [] def } if method (01100) eq { /cdf 42 string def cdf 0 vals 0 get 1 12 getinterval conv12to40 putinterval cdf 40 ais 1 get 3 1 getinterval cvi 2 tobin putinterval /cdf [ cdf {48 sub} forall ] def /gpf [ vals 1 get {} forall ais length 2 gt { fnc1 } if ] def /ais ais 2 ais length 2 sub getinterval def /vals vals 2 vals length 2 sub getinterval def /fncs fncs 2 fncs length 2 sub getinterval def } if method (01101) eq { /cdf 52 string def cdf 0 vals 0 get 1 12 getinterval conv12to40 putinterval cdf 40 ais 1 get 3 1 getinterval cvi 2 tobin putinterval cdf 42 vals 1 get 0 3 getinterval cvi 10 tobin putinterval /cdf [ cdf {48 sub} forall ] def /gpf [ vals 1 get dup length 3 sub 3 exch getinterval {} forall ais length 2 gt { fnc1 } if ] def /ais ais 2 ais length 2 sub getinterval def /vals vals 2 vals length 2 sub getinterval def /fncs fncs 2 fncs length 2 sub getinterval def } if % % Variable length symbol field % gpfallow { /vlf 2 array def } { /vlf [] def } ifelse % % Append the remaining AI data using stack-based accumulation % mark gpf aload pop 0 1 ais length 1 sub { /i exch def ais i get { } forall % Push AI characters vals i get { } forall % Push value characters i ais length 1 sub ne fncs i get and { fnc1 % Push FNC1 separator } if } for counttomark array astore /gpf exch def pop % % Calculate the number of bits remaining to the next valid symbol size % /rembits { dup 12 div ceiling cvi 12 mul % Round up to multiple of 12 48 2 copy lt {exch} if pop % At least 4 symbols dup 12 idiv dup segments mod 1 eq { % At least 2 symbols on last row of stacked symbol 1 add 12 mul exch pop } { pop } ifelse exch sub } def /encode { dup /raw ne {exch get} {pop} ifelse dup length j add 252 ge { pop /bwipp.gs1databarexpandedTooLong (Maximum length exceeded) //raiseerror exec } if [ exch {48 sub} forall ] dup length exch gpfenc exch j exch putinterval /j exch j add def } def % % Pre-compute alphanumeric and numeric runlengths and position of next ISO646-only characters % /numericruns [ gpf length {0} repeat 0 -1 ] def /alphanumericruns [ gpf length {0} repeat 0 ] def /nextiso646only [ gpf length {0} repeat 9999 ] def gpf length 1 sub -1 0 { /i exch def gpf i get (00) 2 string copy dup 0 gpf i get dup fnc1 eq {pop 94} if put i gpf length 1 sub lt {dup 1 gpf i 1 add get dup fnc1 eq {pop 94} if put} if numeric exch known { numericruns i numericruns i 2 add get 2 add put } { numericruns i 0 put } ifelse dup alphanumeric exch known { alphanumericruns i alphanumericruns i 1 add get 1 add put } { alphanumericruns i 0 put } ifelse dup iso646 exch known exch alphanumeric exch known not and { nextiso646only i 0 put } { nextiso646only i nextiso646only i 1 add get 1 add put } ifelse } for % % Encode the general purpose field % /gpfenc 252 array def /i 0 def /j 0 def /mode (numeric) def { % loop i gpf length eq {exit} if { % not a loop but common exit point mode (numeric) eq { i gpf length 2 sub le { 2 string dup 0 gpf i get dup fnc1 eq {pop 94} if put dup 1 gpf i 1 add get dup fnc1 eq {pop 94} if put dup numeric exch known { numeric encode /i i 2 add def exit } if pop //databarexpanded.lalphanumeric numeric encode /mode (alphanumeric) def exit } { gpf i get dup 48 lt exch 57 gt or { //databarexpanded.lalphanumeric numeric encode /mode (alphanumeric) def exit } if /rem 12 1 add method length add vlf length add cdf length add j add rembits def rem 4 ge rem 6 le and { % C1 + 1 into 4 to 6 bits (000000) 6 string copy 0 rem getinterval dup gpf i get 47 sub 2 4 string cvrs dup length 4 exch sub exch putinterval /raw encode /i i 1 add def exit } { % C1.FNC1 2 string dup 0 gpf i get put dup 1 94 put numeric encode /i i 1 add def exit } ifelse } ifelse } if mode (alphanumeric) eq { gpf i get fnc1 eq { fnc1 alphanumeric encode /mode (numeric) def /i i 1 add def exit } if gpf i get dup iso646 exch known exch alphanumeric exch known not and { //databarexpanded.liso646 alphanumeric encode /mode (iso646) def exit } if numericruns i get 6 ge { //databarexpanded.lnumeric alphanumeric encode /mode (numeric) def exit } if numericruns i get dup 4 ge exch i add gpf length eq and { //databarexpanded.lnumeric alphanumeric encode /mode (numeric) def exit } if gpf i get alphanumeric encode /i i 1 add def exit } if mode (iso646) eq { gpf i get fnc1 eq { fnc1 iso646 encode /mode (numeric) def /i i 1 add def exit } if numericruns i get 4 ge nextiso646only i get 10 ge and { //databarexpanded.lnumeric iso646 encode /mode (numeric) def exit } if alphanumericruns i get 5 ge nextiso646only i get 10 ge and { //databarexpanded.lalphanumeric iso646 encode /mode (alphanumeric) def exit } if gpf i get iso646 encode /i i 1 add def exit } if } loop } loop /gpf gpfenc 0 j getinterval def % % Complete the variable length field and create pad % 1 12 add method length add vlf length add cdf length add gpf length add dup rembits dup array /pad exch def vlf length 0 ne { add 12 idiv dup 2 mod vlf exch 0 exch put 14 le {0} {1} ifelse vlf exch 1 exch put } { pop pop } ifelse pad length 0 gt { 0 5 pad length 1 sub { % Fill with 00100 /i exch def pad i //databarexpanded.fillpat 0 pad length i sub 5 2 copy gt {exch} if pop getinterval putinterval } for mode (numeric) eq { % Prefix shift from numeric to ASCII /pad [ 0 0 0 0 pad aload pop ] 0 pad length getinterval def } if } if % % Concatenate fields % /binval [ linkage {1} {0} ifelse method {48 sub} forall vlf aload pop cdf aload pop gpf aload pop pad aload pop ] def options /debugbits known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugbits binval //raiseerror exec } if /datalen binval length 12 idiv def /ncr { % n r 2 copy sub 2 copy lt {exch} if % n r maxd mind 1 1 5 3 roll % mind j=1 v=1 n maxd 1 add -1 exch { % mind j v n -1 maxd+1 mul % mind j v*i 1 index 3 index le { 1 index idiv exch 1 add exch } if } for { % mind j v 1 index 3 index gt {exit} if 1 index idiv exch 1 add exch } loop exch pop exch pop } def /getRSSwidths { /oe exch def /el exch def /mw exch def /nm exch def /val exch def /out el array def /mask 0 def 0 1 el 2 sub { /bar exch def /ew 1 def /mask mask 1 bar bitshift or def { /sval nm ew sub 1 sub el bar sub 2 sub ncr def oe mask 0 eq and nm ew sub el 2 mul sub bar 2 mul add -2 ge and { /sval sval nm ew sub el sub bar add el bar sub 2 sub ncr sub def } if el bar sub 2 gt { /lval 0 def nm ew sub el sub bar add 2 add -1 mw 1 add { nm exch sub ew sub 1 sub el bar sub 3 sub ncr /lval exch lval add def } for /sval sval lval el bar sub 1 sub mul sub def } { nm ew sub mw gt {/sval sval 1 sub def} if } ifelse /val val sval sub def val 0 lt {exit} if /ew ew 1 add def /mask mask 1 bar bitshift not and def } loop /val val sval add def /nm nm ew sub def out bar ew put } for out el 1 sub nm put out } def /dxw datalen array def 0 1 datalen 1 sub { /x exch def /d binval x 12 mul 12 getinterval def /d 0 0 1 11 {/j exch def 2 11 j sub exp cvi d j get mul add} for def /j 0 def { d //databarexpanded.tab174 j get le { //databarexpanded.tab174 j 1 add 7 getinterval aload pop /dte exch def /dto exch def /dmwe exch def /dmwo exch def /dele exch def /delo exch def /dgs exch def exit } if /j j 8 add def } loop /dwo d dgs sub dte idiv delo dmwo 4 true getRSSwidths def /dwe d dgs sub dte mod dele dmwe 4 false getRSSwidths def /dw 8 array def x 2 mod 0 eq { 0 1 3 { /j exch def dw 7 j 2 mul sub dwo j get put dw 6 j 2 mul sub dwe j get put } for } { 0 1 3 { /j exch def dw j 2 mul dwo j get put dw j 2 mul 1 add dwe j get put } for } ifelse dxw x dw put } for /seq //databarexpanded.finderseq datalen 2 sub 2 idiv get def /fxw seq length array def 0 1 seq length 1 sub { /x exch def fxw x //databarexpanded.finderwidths seq x get 5 mul 5 getinterval put } for /checkweightseq [ seq {16 mul //databarexpanded.checkweights exch 16 getinterval aload pop} forall ] dup length 8 sub 8 exch getinterval def /widths [ dxw {aload pop} forall ] def /checksum 0 def 0 1 widths length 1 sub { /i exch def /checksum checksum widths i get checkweightseq i get mul add def } for /checksum checksum 211 mod datalen 3 sub 211 mul add def /i 0 def { checksum //databarexpanded.tab174 i get le { //databarexpanded.tab174 i 1 add 7 getinterval aload pop /cte exch def /cto exch def /cmwe exch def /cmwo exch def /cele exch def /celo exch def /cgs exch def exit } if /i i 8 add def } loop /cwo checksum cgs sub cte idiv celo cmwo 4 true getRSSwidths def /cwe checksum cgs sub cte mod cele cmwe 4 false getRSSwidths def /cw 8 array def 0 1 3 { /i exch def cw i 2 mul cwo i get put cw i 2 mul 1 add cwe i get put } for 22 array dup dup 0 cw put 1 dxw putinterval 0 datalen 1 add getinterval /dxw exch def /datalen dxw length def % % Encode row runlengths % /rows datalen segments div ceiling cvi array def /numrows rows length def 0 1 numrows 1 sub { /r exch def mark segments 4 mod 0 ne r 2 mod 1 eq and {0} if 1 1 0 1 segments 1 sub { /pos exch r segments mul add def pos datalen lt { dxw pos get aload pop pos 2 mod 0 eq {fxw pos 2 idiv get aload pop} if } if } for 1 1 counttomark array astore rows exch r exch put pop } for format (expandedstacked) ne { % Linear /sbs [ 0 1 1 % 0-width placeholder + left guard (space + bar) 0 1 datalen 1 sub { /i exch def dxw i get aload pop i 2 mod 0 eq {fxw i 2 idiv get aload pop} if } for 1 1 % right guard (bar + space) ] def /height /resolve_height //render exec dup -1 eq { pop 34.0 72 div } if def << /ren /renlinear /sbs sbs /bhs [sbs length 1 add 2 idiv {height} repeat] /bbs [sbs length 1 add 2 idiv {0} repeat] /borderleft 0.0 /borderright 0.0 /bordertop 0.0 /borderbottom 0.0 /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } { % expandedstacked /seps numrows array def 0 1 numrows 1 sub { /r exch def /row rows r get def % % Sample runlengths into bitmap % mark 0 2 row length 1 sub { /i exch def row i get {0} repeat i row length 1 sub lt {row i 1 add get {1} repeat} if } for counttomark array astore /row exch def pop % % Derive the separator pattern % /sep [ row {1 exch sub} forall ] def /finderpos [ % Finder pattern module positions 19 98 row length 13 sub {} for 68 98 row length 13 sub {} for ] def finderpos { dup 14 add 1 exch { /i exch def row i get 0 eq { row 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 } forall sep 0 //databarexpanded.seppad putinterval sep row length 4 sub //databarexpanded.seppad putinterval % % For even segment-pair symbols reverse alternate rows % segments 4 mod 0 eq r 2 mod 1 eq and { rows r get length rows 0 get length ne % Except partial width last row finderpos length 2 mod 1 eq and { % with odd finders /row [ 0 row aload pop ] def /sep [ 0 sep aload pop ] def } { row length 1 sub -1 0 {row exch get} for row astore pop sep length 1 sub -1 0 {sep exch get} for sep astore pop } ifelse } if rows r row put seps r sep put } for % % Extend last row and separator to fill width of symbol % /pixx rows 0 get length def [ pixx {0} repeat ] dup 0 rows numrows 1 sub get putinterval rows exch numrows 1 sub exch put [ pixx {0} repeat ] dup 0 seps numrows 1 sub get putinterval seps exch numrows 1 sub exch put % % Middle separator pattern % /sep [ pixx 2 idiv 1 add { 0 1 } repeat ] 0 pixx getinterval def sep 0 //databarexpanded.seppad putinterval sep pixx 4 sub //databarexpanded.seppad putinterval % % Compose the symbol with one copy of each unique row % /pixs [ 0 1 numrows 1 sub { /r exch def r 0 ne { seps r get aload pop } if rows r get aload pop r numrows 1 sub ne { seps r get aload pop sep aload pop } if } for ] def /rowheights [ 0 1 numrows 1 sub { /r exch def r 0 ne { 1 } if barxmult r numrows 1 sub ne { 1 1 } if } for ] def /pixy 0 rowheights {add} forall def << /ren /renmatrix /pixs pixs /pixx pixx /pixy pixy /rowheights rowheights /height pixy 72 div /width pixx 72 div /borderleft 0.0 /borderright 0.0 /bordertop 0.0 /borderbottom 0.0 /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } ifelse } stopped {end stop} if end } [/barcode] {null def} forall bind def /databarexpanded dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER databarexpanded-- % --BEGIN ENCODER databarexpandedstacked-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput gs1process setanycolor render renlinear renmatrix databarexpanded-- % --DESC: GS1 DataBar Expanded Stacked % --EXAM: (01)09521234543213(3103)000123 % --EXOP: segments=4 % --RNDR: renlinear renmatrix % --FMLY: GS1 DataBar %%BeginResource: uk.co.terryburton.bwipp databarexpandedstacked 0.0 2026052800 81951 78515 %%BeginData: 79 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 5 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /databarexpanded dup /uk.co.terryburton.bwipp findresource put begin /databarexpandedstacked { 4 dict begin { /dontdraw false def /propspec false def /loosespec false def /strictspec false def /width 0 def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Apply AST spec overrides and resolve physical specification % /databarexpandedstacked ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec % % Get the result of encoding with databarexpanded with format=expandedstacked % options (format) (expandedstacked) put options (ast) undef options (mag) undef options (propspec) propspec put options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put options (hnom) hnom put options (modunit) modunit put /uk.co.terryburton.bwipp._dontdraw true def barcode options //databarexpanded exec /args exch def args (opt) options put args _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /databarexpandedstacked dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER databarexpandedstacked-- % --BEGIN ENCODER gs1northamericancoupon-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput gs1process setanycolor render renlinear renmatrix databarexpanded databarexpandedstacked-- % --DESC: GS1 North American Coupon % --EXAM: (8110)106141416543213500110000310123196000 % --EXOP: includetext segments=8 % --RNDR: renmatrix % --FMLY: GS1 DataBar %%BeginResource: uk.co.terryburton.bwipp gs1northamericancoupon 0.0 2026052800 89926 96540 %%BeginData: 140 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 5 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /gs1process dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /databarexpandedstacked dup /uk.co.terryburton.bwipp findresource put begin /gs1northamericancoupon.aliases << (coupontext) /text1 (coupontextsubspace) /text1subspace (coupontextsplit) /text1split (coupontextlinegaps) /text1linegaps (coupontextcolor) /text1color (coupontextxalign) /text1xalign (coupontextyalign) /text1yalign (coupontextdirection) /text1direction (coupontextfont) /text1font (coupontextsize) /text1size (coupontextxoffset) /text1xoffset (coupontextyoffset) /text1yoffset (coupontextgaps) /text1gaps >> readonly def /gs1northamericancoupon { 32 dict begin { /dontdraw false def /includetext false def % Enable/disable coupon text /text1 (unset) def % sentinel: user-supplied label content overrides default /text1font (unset) def /text1size 9.0 def /text1xalign (unset) def /text1yalign (unset) def /text1xoffset null def % sentinel realtype /text1yoffset null def % sentinel realtype /parse false def /dontlint false def /lintreqs true def /strictspec false def /width 0 def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /modunit 1 def //gs1northamericancoupon.aliases /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def barcode /ai //gs1process exec pop /vals exch def /ais exch def % Validate the AI structure ais length 1 ne { /bwipp.gs1northamericancouponBadAIStructure (A GS1 North American Coupon should consist of a single AI (8110)) //raiseerror exec } if ais 0 get (8110) ne { /bwipp.gs1northamericancouponBadAIStructure (A GS1 North American Coupon should consist of a single AI (8110)) //raiseerror exec } if % Parse out the Company Prefix and Offer Code /val vals 0 get def /vli val 0 get 48 sub def vli 0 lt vli 6 gt or { /bwipp.gs1northamericancouponBadVLI (The AI (8110) data should start with a Company Prefix length indicator in the range 0 to 6) //raiseerror exec } if val length vli 13 add lt { /bwipp.gs1northamericancouponTooShort (The AI (8110) data is too short) //raiseerror exec } if /gcp val 1 vli 6 add getinterval def /cod val vli 7 add 6 getinterval def /coupontext gcp length 7 add string def coupontext 0 gcp putinterval coupontext gcp length (-) putinterval coupontext gcp length 1 add cod putinterval % % Apply AST spec overrides and resolve physical specification % /gs1northamericancoupon ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec % Get the result of encoding with databarexpandedstacked options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (ast) undef options (mag) undef options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put options (modunit) modunit put includetext { options (text1) text1 (unset) eq { coupontext } { text1 } ifelse put options (text1font) text1font (unset) eq { /Helvetica } { text1font } ifelse put options (text1size) text1size put options (text1xalign) text1xalign (unset) eq { (left) } { text1xalign } ifelse put options (text1yalign) text1yalign (unset) eq { (above) } { text1yalign } ifelse put text1xoffset null ne { options (text1xoffset) text1xoffset put } if options (text1yoffset) text1yoffset null eq { 3 } { text1yoffset } ifelse put } if /uk.co.terryburton.bwipp._dontdraw true def barcode options //databarexpandedstacked exec /args exch def args (opt) options put args _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /gs1northamericancoupon dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER gs1northamericancoupon-- % --BEGIN ENCODER pharmacode-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear-- % --DESC: Pharmaceutical Binary Code % --EXAM: 117480 % --EXOP: showborder % --RNDR: renlinear % --FMLY: Pharmaceutical Symbols %%BeginResource: uk.co.terryburton.bwipp pharmacode 0.0 2026052800 68990 72198 %%BeginData: 122 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 5 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /pharmacode { 16 dict begin % Confine variables to local scope { /dontdraw false def /height -1.0 def /width 0 def /nwidth 1 def /wwidth 3 def /swidth 2 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Validate the input % barcode length 1 lt barcode length 6 gt or { /bwipp.pharmacodeBadLength (Pharmacode must be 1 to 6 digits) //raiseerror exec } if barcode { dup 48 lt exch 57 gt or { /bwipp.pharmacodeBadCharacter (Pharmacode must contain only digits) //raiseerror exec } if } forall barcode cvi dup 3 lt exch 131070 gt or { /bwipp.pharmacodeBadValue (Pharmacode value must be between 3 and 131070) //raiseerror exec } if % % Apply AST spec overrides and resolve physical specification % /pharmacode ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec % % Create the human readable text % /txt barcode length array def 0 1 barcode length 1 sub { /i exch def txt i [barcode i 1 getinterval 0 0 () 0] put } for % % Convert the integer into the paramacode string % /barcode barcode cvi 1 add 2 17 string cvrs def /barcode barcode 1 barcode length 1 sub getinterval def /barlen barcode length def % Length of the code /sbs barlen 2 mul array def 0 1 barlen 1 sub { /i exch def /enc barcode i 1 getinterval def enc (0) eq { sbs i 2 mul nwidth put } { sbs i 2 mul wwidth put } ifelse sbs i 2 mul 1 add swidth put } for /height /resolve_height //render exec dup -1 eq { pop 1.0 } if def << /ren /renlinear /sbs sbs /bhs [sbs length 1 add 2 idiv {height} repeat] /bbs [sbs length 1 add 2 idiv {0} repeat] /txt txt /text1xalign (center) /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /pharmacode dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER pharmacode-- % --BEGIN ENCODER pharmacode2-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear-- % --DESC: Two-track Pharmacode % --EXAM: 117480 % --EXOP: includetext showborder % --RNDR: renlinear % --FMLY: Pharmaceutical Symbols %%BeginResource: uk.co.terryburton.bwipp pharmacode2 0.0 2026052800 70582 73736 %%BeginData: 136 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /pharmacode2.base3sub [ 3 1 2 ] readonly def /pharmacode2.base3map [ 2 0 1 ] readonly def /pharmacode2.htmult [ 1 1 2 ] readonly def /pharmacode2 { 16 dict begin { /dontdraw false def /includetext false def % Enable/disable text /height -1.0 def % Height of short bars in millimetres /width 0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Validate the input % barcode length 1 lt barcode length 8 gt or { /bwipp.pharmacode2BadLength (Two-track Pharmacode must be 1 to 6 digits) //raiseerror exec } if barcode { dup 48 lt exch 57 gt or { /bwipp.pharmacode2badCharacter (Two-track Pharmacode must contain only digits) //raiseerror exec } if } forall barcode cvi dup 4 lt exch 64570080 gt or { /bwipp.pharmacode2badValue (Two-track Pharmacode value must be between 4 and 64570080) //raiseerror exec } if % % Apply AST spec overrides and resolve physical specification % /pharmacode2 ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec /height /resolve_height //render exec dup -1 eq { pop 4.0 } if def % % Create the human readable text % /txt barcode length array def 0 1 barcode length 1 sub { /i exch def txt i [barcode i 1 getinterval 0 0 () 0] put } for /encstr 16 string def /sbs 32 array def /bar 1 25.4 div height mul def % bar height (mm) /spc 1 25.4 div 72 mul def % bar width & spacing (1mm) % % Convert number into a base3 representation % /i 15 def /val barcode cvi def { % loop val 0 eq {exit} if val 3 mod dup //pharmacode2.base3sub exch get val exch sub 3 idiv /val exch def encstr i //pharmacode2.base3map 4 -1 roll get put /i i 1 sub def } loop /encstr encstr i 1 add 15 i sub getinterval def % % Generate the bar pattern % /bhs encstr length array def /bbs encstr length array def 0 1 encstr length 1 sub { /i exch def encstr i get dup bhs i bar //pharmacode2.htmult 5 -1 roll get mul put bbs i [0 bar 0] 4 -1 roll get put } for << /ren /renlinear /bhs bhs /bbs bbs /sbs [encstr length 2 mul {spc} repeat] /txt txt /text1xalign (center) /text1yoffset -4.0 /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /pharmacode2 dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER pharmacode2-- % --BEGIN ENCODER code2of5-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear-- % --DESC: Code 25 % --EXAM: 01234567 % --EXOP: includetext includecheck includecheckintext % --RNDR: renlinear % --FMLY: Less-used Symbols %%BeginResource: uk.co.terryburton.bwipp code2of5 0.0 2026052800 77867 80990 %%BeginData: 190 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /code2of5.versions << /industrial [ (1111313111) (3111111131) (1131111131) (3131111111) (1111311131) (3111311111) (1131311111) (1111113131) (3111113111) (1131113111) (313111) (31113) ] /iata [ (1111313111) (3111111131) (1131111131) (3131111111) (1111311131) (3111311111) (1131311111) (1111113131) (3111113111) (1131113111) (1111) (311) ] /matrix [ (113311) (311131) (131131) (331111) (113131) (313111) (133111) (111331) (311311) (131311) (311111) (31111) ] /coop [ (331111) (111331) (113131) (113311) (131131) (131311) (133111) (311131) (311311) (313111) (3131) (133) ] /datalogic [ (113311) (311131) (131131) (331111) (113131) (313111) (133111) (111331) (311311) (131311) (1111) (311) ] >> readonly def /code2of5.barchars (0123456789) readonly def /code2of5 { 32 dict begin { /dontdraw false def /includecheck false def /validatecheck false def /includetext false def % Enable/disable text /includecheckintext false def /text1font /Courier def /text1size 10.0 def /text1yoffset -7.0 def /height -1.0 def /width 0 def /version (industrial) def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def barcode () eq { /bwipp.code2of5emptyData (The data must not be empty) //raiseerror exec } if barcode length 500 gt { /bwipp.code2of5inputTooLong (The input data is too long) //raiseerror exec } if % % Validate input % barcode { dup 48 lt exch 57 gt or { /bwipp.code2of5badCharacter (Code 25 must contain only digits) //raiseerror exec } if } forall % % Apply AST spec overrides and resolve physical specification % /code2of5 ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec /barlen barcode length validatecheck {1 sub} if def /checksum 0 def 0 1 barlen 1 sub { /i exch def /checksum checksum barcode i get 48 sub barlen i sub 2 mod 0 ne {3 mul} if add def } for /checksum 10 checksum 10 mod sub 10 mod def validatecheck { barcode barlen get checksum 48 add ne { /bwipp.code2of5badCheckDigit (Incorrect Code 25 check digit provided) //raiseerror exec } if /barcode barcode 0 barlen getinterval def /includecheck true def } if //code2of5.versions version known not { /bwipp.code2of5badVersion (Unrecognised Code 25 version) //raiseerror exec } if /encs //code2of5.versions version get def /cs encs 0 get length def /cw 0 encs 0 get {48 sub add} forall def /ss encs 10 get length def /sw 0 encs 10 get {48 sub add} forall def /es encs 11 get length def /sbs barlen includecheck {1 add} if cs mul ss add es add string def % % Put the start character % sbs 0 encs 10 get putinterval 0 1 barlen 1 sub { /i exch def % Lookup the encoding for the each barcode character barcode i 1 getinterval //code2of5.barchars exch search pop % Discard true leaving pre length /indx exch def % indx is the length of pre pop pop % Discard seek and post /enc encs indx get def % Get the indxth encoding sbs i cs mul ss add enc putinterval % Put encoded digit into sbs } for % % Put the checksum and end characters % includecheck { sbs barlen cs mul ss add encs checksum get putinterval sbs barlen cs mul cs add ss add encs 11 get putinterval } { sbs barlen cs mul ss add encs 11 get putinterval } ifelse /text includecheck includecheckintext and { barlen 1 add string dup 0 barcode putinterval dup barlen //code2of5.barchars checksum 1 getinterval putinterval } { barcode } ifelse def /sbs [sbs {48 sub} forall] def /height /resolve_height //render exec dup -1 eq { pop 1.0 } if def << /ren /renlinear /sbs sbs /bhs [sbs length 1 add 2 idiv {height} repeat] /bbs [sbs length 1 add 2 idiv {0} repeat] includetext { /txt [ [text 0 0 text1font text1size] ] /text1xalign (center) } if /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /code2of5 dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER code2of5-- % --BEGIN ENCODER industrial2of5-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear code2of5-- % --DESC: Industrial 2 of 5 % --EXAM: 01234567 % --EXOP: includetext includecheck includecheckintext % --RNDR: renlinear % --FMLY: Less-used Symbols %%BeginResource: uk.co.terryburton.bwipp industrial2of5 0.0 2026052800 63339 66753 %%BeginData: 47 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 4 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /code2of5 dup /uk.co.terryburton.bwipp findresource put begin /industrial2of5 { 4 dict begin { /dontdraw false def null /apply //processoptions exec /options exch def /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Get the result of encoding with code2of5 with version=industrial % options (version) (industrial) put /uk.co.terryburton.bwipp._dontdraw true def barcode options //code2of5 exec /args exch def args (opt) options put args _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /industrial2of5 dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER industrial2of5-- % --BEGIN ENCODER iata2of5-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear code2of5-- % --DESC: IATA 2 of 5 % --EXAM: 01234567 % --EXOP: includetext includecheck includecheckintext % --RNDR: renlinear % --FMLY: Less-used Symbols %%BeginResource: uk.co.terryburton.bwipp iata2of5 0.0 2026052800 63309 66729 %%BeginData: 47 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 4 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /code2of5 dup /uk.co.terryburton.bwipp findresource put begin /iata2of5 { 4 dict begin { /dontdraw false def null /apply //processoptions exec /options exch def /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Get the result of encoding with code2of5 with version=iata % options (version) (iata) put /uk.co.terryburton.bwipp._dontdraw true def barcode options //code2of5 exec /args exch def args (opt) options put args _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /iata2of5 dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER iata2of5-- % --BEGIN ENCODER matrix2of5-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear code2of5-- % --DESC: Matrix 2 of 5 % --EXAM: 01234567 % --EXOP: includetext includecheck includecheckintext % --RNDR: renlinear % --FMLY: Less-used Symbols %%BeginResource: uk.co.terryburton.bwipp matrix2of5 0.0 2026052800 63319 66737 %%BeginData: 47 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 4 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /code2of5 dup /uk.co.terryburton.bwipp findresource put begin /matrix2of5 { 4 dict begin { /dontdraw false def null /apply //processoptions exec /options exch def /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Get the result of encoding with code2of5 with version=matrix % options (version) (matrix) put /uk.co.terryburton.bwipp._dontdraw true def barcode options //code2of5 exec /args exch def args (opt) options put args _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /matrix2of5 dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER matrix2of5-- % --BEGIN ENCODER coop2of5-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear code2of5-- % --DESC: COOP 2 of 5 % --EXAM: 01234567 % --EXOP: includetext includecheck includecheckintext % --RNDR: renlinear % --FMLY: Less-used Symbols %%BeginResource: uk.co.terryburton.bwipp coop2of5 0.0 2026052800 63309 66729 %%BeginData: 47 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 4 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /code2of5 dup /uk.co.terryburton.bwipp findresource put begin /coop2of5 { 4 dict begin { /dontdraw false def null /apply //processoptions exec /options exch def /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Get the result of encoding with code2of5 with version=coop % options (version) (coop) put /uk.co.terryburton.bwipp._dontdraw true def barcode options //code2of5 exec /args exch def args (opt) options put args _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /coop2of5 dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER coop2of5-- % --BEGIN ENCODER datalogic2of5-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear code2of5-- % --DESC: Datalogic 2 of 5 % --EXAM: 01234567 % --EXOP: includetext includecheck includecheckintext % --RNDR: renlinear % --FMLY: Less-used Symbols %%BeginResource: uk.co.terryburton.bwipp datalogic2of5 0.0 2026052800 63334 66749 %%BeginData: 47 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 4 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /code2of5 dup /uk.co.terryburton.bwipp findresource put begin /datalogic2of5 { 4 dict begin { /dontdraw false def null /apply //processoptions exec /options exch def /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Get the result of encoding with code2of5 with version=datalogic % options (version) (datalogic) put /uk.co.terryburton.bwipp._dontdraw true def barcode options //code2of5 exec /args exch def args (opt) options put args _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /datalogic2of5 dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER datalogic2of5-- % --BEGIN ENCODER code11-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear-- % --DESC: Code 11 % --EXAM: 0123456789 % --EXOP: includetext includecheck includecheckintext % --RNDR: renlinear % --FMLY: Less-used Symbols %%BeginResource: uk.co.terryburton.bwipp code11 0.0 2026052800 87040 86626 %%BeginData: 215 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /code11.encs [ (111131) (311131) (131131) (331111) (113131) (313111) (133111) (111331) (311311) (311111) (113111) (113311) ] readonly def /code11.barchars (0123456789-) readonly def /code11.latevars dup 2 dict def load /init { currentglobal true setglobal //code11.latevars begin /charvals 11 dict def 0 1 10 { charvals exch dup //code11.barchars exch 1 getinterval exch put } for /charvals charvals readonly def /init { //code11.latevars {def} forall } def end //code11.latevars /init get exec setglobal } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//code11.latevars /init get exec} if } {pop} ifelse /code11 { 32 dict begin { /dontdraw false def /includecheck false def /validatecheck false def /includetext false def /includecheckintext false def /text1font /Courier def /text1size 10.0 def /text1yoffset -7.0 def /height -1.0 def /width 0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def //code11.latevars /init get exec barcode () eq { /bwipp.code11emptyData (The data must not be empty) //raiseerror exec } if barcode length 500 gt { /bwipp.code11inputTooLong (The input data is too long) //raiseerror exec } if % % Validate the input % 0 1 barcode length 1 sub { barcode exch 1 getinterval charvals exch known not { /bwipp.code11badCharacter (Code 11 must contain only digits and dashes) //raiseerror exec } if } for % % Apply AST spec overrides and resolve physical specification % /code11 ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec /barlen barcode length def validatecheck { barlen 11 eq { /bwipp.code11badLength (Code 11 cannot be 11 characters using check digits) //raiseerror exec } if /barlen barlen barlen 10 le {1} {2} ifelse sub def } if /numchecks includecheck validatecheck or {barlen 10 ge {2} {1} ifelse} {0} ifelse def /checksum1 0 def /checksum2 0 def 0 1 barlen 1 sub { /i exch def /indx charvals barcode i 1 getinterval get def /checksum1 checksum1 barlen i sub 1 sub 10 mod 1 add indx mul add def /checksum2 checksum2 barlen i sub 9 mod 1 add indx mul add def } for /checksum1 checksum1 11 mod def /checksum2 checksum2 checksum1 add 11 mod def validatecheck { numchecks 1 eq { barcode barlen get //code11.barchars checksum1 get ne { /bwipp.code11badCheckDigit (Incorrect Code 11 check digit provided) //raiseerror exec } if } { barcode barlen get //code11.barchars checksum1 get ne barcode barlen 1 add get //code11.barchars checksum2 get ne or { /bwipp.code11badCheckDigits (Incorrect Code 11 check digits provided) //raiseerror exec } if } ifelse /barcode barcode 0 barlen getinterval def /includecheck true def } if /sbs barlen numchecks add 6 mul 12 add string def % % Put the start character % sbs 0 //code11.encs 11 get putinterval 0 1 barlen 1 sub { /i exch def /indx charvals barcode i 1 getinterval get def /enc //code11.encs indx get def sbs i 6 mul 6 add enc putinterval } for % % Put the checksum and end characters % includecheck { barlen 10 ge { sbs barlen 6 mul 6 add //code11.encs checksum1 get putinterval sbs barlen 6 mul 12 add //code11.encs checksum2 get putinterval sbs barlen 6 mul 18 add //code11.encs 11 get putinterval } { sbs barlen 6 mul 6 add //code11.encs checksum1 get putinterval sbs barlen 6 mul 12 add //code11.encs 11 get putinterval } ifelse } { sbs barlen 6 mul 6 add //code11.encs 11 get putinterval } ifelse /text includecheck includecheckintext and { barlen 10 ge { barlen 2 add string dup 0 barcode putinterval dup barlen //code11.barchars checksum1 1 getinterval putinterval dup barlen 1 add //code11.barchars checksum2 1 getinterval putinterval } { barlen 1 add string dup 0 barcode putinterval dup barlen //code11.barchars checksum1 1 getinterval putinterval } ifelse } { barcode } ifelse def /sbs [sbs {48 sub} forall] def /height /resolve_height //render exec dup -1 eq { pop 1.0 } if def << /ren /renlinear /sbs sbs /bhs [sbs length 1 add 2 idiv {height} repeat] /bbs [sbs length 1 add 2 idiv {0} repeat] includetext { /txt [ [text 0 0 text1font text1size] ] /text1xalign (center) } if /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /code11 dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER code11-- % --BEGIN ENCODER bc412-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear-- % --DESC: BC412 % --EXAM: BC412SEMI % --EXOP: semi includetext includecheckintext % --RNDR: renlinear % --FMLY: Less-used Symbols %%BeginResource: uk.co.terryburton.bwipp bc412 0.0 2026052800 88269 91327 %%BeginData: 252 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /bc412.barchars (0R9GLVHA8EZ4NTS1J2Q6C7DYKBUIX3FWP5M) readonly def /bc412.encs [ (11111115) (13111212) (11131113) (12111213) (12121311) % 0R9GL (13131111) (12111312) (11131212) (11121411) (11151111) % VHA8E (15111111) (11111511) (12131211) (13121112) (13111311) % Z4NTS (11111214) (12121113) (11111313) (13111113) (11121213) % 1J2Q6 (11141112) (11121312) (11141211) (14121111) (12121212) % C7DYK (11131311) (13121211) (12111411) (14111211) (11111412) % BUIX3 (12111114) (14111112) (12141111) (11121114) (12131112) % FWP5M (12) (111) % Start Stop ] readonly def /bc412.latevars dup 2 dict def load /init { currentglobal true setglobal //bc412.latevars begin /charvals 35 dict def 0 1 34 { charvals exch dup //bc412.barchars exch 1 getinterval exch put } for /charvals charvals readonly def /init { //bc412.latevars {def} forall } def end //bc412.latevars /init get exec setglobal } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//bc412.latevars /init get exec} if } {pop} ifelse /bc412 { 32 dict begin { /dontdraw false def /includecheck false def /validatecheck false def /includetext false def /includecheckintext false def /includestartstop false def /semi false def /text1font /Courier def /text1size 10.0 def /text1yoffset -7.0 def /height -1.0 def /width 0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def //bc412.latevars /init get exec barcode () eq { /bwipp.bc412emptyData (The data must not be empty) //raiseerror exec } if barcode length 500 gt { /bwipp.bc412inputTooLong (The input data is too long) //raiseerror exec } if semi { % Implies includecheck and includecheckintext also /includestartstop true def } if % % Validate the input % 0 1 barcode length 1 sub { barcode exch 1 getinterval charvals exch known not { /bwipp.bc412badCharacter (BC412 must contain only digits and capital letters except O) //raiseerror exec } if } for semi { % % Validate length % validatecheck { barcode length 8 lt barcode length 19 gt or { /bwipp.bc412semivalidateBadLength (BC412 semi with check digit must be 8 to 19 characters long) //raiseerror exec } if } { barcode length 7 lt barcode length 18 gt or { /bwipp.bc412semiBadLength (BC412 semi must be 7 to 18 characters long) //raiseerror exec } if } ifelse /barlen barcode length def validatecheck not { % Place dummy (0) in checksum position (1-based 2nd) /barlen barlen 1 add def /sbarcode barlen string def sbarcode 0 barcode 0 get put sbarcode 1 48 put % (0) sbarcode 2 barcode 1 barlen 2 sub getinterval putinterval /barcode sbarcode def } if /sumodd 0 def /sumeven 0 def 0 1 barlen 1 sub { /i exch def barcode i 1 getinterval charvals exch get i 2 mod 0 eq { % 1-based odd sumodd add /sumodd exch def } { sumeven add /sumeven exch def } ifelse } for /checksum sumodd 35 mod sumeven 35 mod 2 mul add 35 mod def % F = Mod35( Mod35( Fodd ) + 2 * Mod35( Feven ) ) validatecheck { checksum 0 ne { /bwipp.bc412semiBadCheckDigit (Incorrect BC412 semi check digit provided) //raiseerror exec } if } { /checksum checksum 17 mul 35 mod def % CD = Mod35( 17 * F ) barcode 1 //bc412.barchars checksum get put } ifelse } { /barlen barcode length validatecheck {1 sub} if def /checksum 0 def 0 1 barlen 1 sub { barcode exch 1 getinterval charvals exch get checksum add /checksum exch def } for /checksum checksum 35 mod def validatecheck { barcode barlen get //bc412.barchars checksum get ne { /bwipp.bc412badCheckDigit (Incorrect BC412 check digit provided) //raiseerror exec } if /barcode barcode 0 barlen getinterval def /includecheck true def } if } ifelse % % Apply AST spec overrides and resolve physical specification % /bc412 ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec /sbs barlen 1 add 8 mul 5 add string def % % Put the start character % includestartstop { sbs 0 //bc412.encs 35 get putinterval /pos 2 def } { /pos 0 def } ifelse 0 1 barlen 1 sub { /i exch def /indx charvals barcode i 1 getinterval get def sbs pos //bc412.encs indx get putinterval /pos pos 8 add def } for % % Put the checksum % includecheck { sbs pos //bc412.encs checksum get putinterval /pos pos 8 add def } if % % Put the stop character % includestartstop { sbs pos //bc412.encs 36 get putinterval /pos pos 3 add def } if /text includecheck includecheckintext and { barlen 1 add string dup 0 barcode putinterval dup barlen //bc412.barchars checksum 1 getinterval putinterval } { barcode } ifelse def /sbs sbs 0 pos getinterval def /height /resolve_height //render exec dup -1 eq { pop 1.0 } if def << /ren /renlinear /sbs [sbs {48 sub} forall] /bhs [sbs length 1 add 2 idiv {height} repeat] /bbs [sbs length 1 add 2 idiv {0} repeat] includetext { /txt [ [text 0 0 text1font text1size] ] /text1xalign (center) } if /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /bc412 dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER bc412-- % --BEGIN ENCODER rationalizedCodabar-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear-- % --DESC: Codabar % --EXAM: A0123456789B % --EXOP: includetext includecheck includecheckintext % --RNDR: renlinear % --FMLY: Less-used Symbols %%BeginResource: uk.co.terryburton.bwipp rationalizedCodabar 0.0 2026052800 80231 83108 %%BeginData: 182 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /rationalizedCodabar.encs [ (11111331) (11113311) (11131131) (33111111) (11311311) (31111311) (13111131) (13113111) (13311111) (31131111) (11133111) (11331111) (31113131) (31311131) (31313111) (11313131) (11331311) (13131131) (11131331) (11133311) ] readonly def /rationalizedCodabar.barchars (0123456789-$:/.+ABCD) readonly def /rationalizedCodabar.barcharsalt (0123456789-$:/.+TN*E) readonly def /rationalizedCodabar { 32 dict begin { /dontdraw false def /altstartstop false def /includecheck false def % Enable/disable checkdigit /validatecheck false def /includetext false def % Enable/disable text /includecheckintext false def /text1font /Courier def /text1size 10.0 def /text1yoffset -7.0 def /height -1.0 def /width 0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def barcode length 500 gt { /bwipp.rationalizedCodabarinputTooLong (The input data is too long) //raiseerror exec } if /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def barcode length 2 lt barcode length 3 lt validatecheck and or { /bwipp.rationalizedCodabarBadLength (Codabar must be at least 2 characters in length excluding any check digit) //raiseerror exec } if /barchars altstartstop {//rationalizedCodabar.barcharsalt} {//rationalizedCodabar.barchars} ifelse def /charvals 20 dict def 0 1 19 {charvals exch dup barchars exch 1 getinterval exch put} for /bodyvals 16 dict def 0 1 15 {bodyvals exch dup barchars exch 1 getinterval exch put} for /ssvals 4 dict def 16 1 19 {ssvals exch dup barchars exch 1 getinterval exch put} for % % Validate the input % barcode 0 1 getinterval ssvals exch known not barcode barcode length 1 sub 1 getinterval ssvals exch known not or { altstartstop { /bwipp.rationalizedCodabarBadAltStartStop (Codabar start and stop characters must be one of E N T or *) //raiseerror exec } { /bwipp.rationalizedCodabarBadStartStop (Codabar start and stop characters must be one of A B C or D) //raiseerror exec } ifelse } if 1 1 barcode length 2 sub { barcode exch 1 getinterval bodyvals exch known not { /bwipp.rationalizedCodabarBadCharacter (Codabar body must contain only digits and symbols - $ : / . +) //raiseerror exec } if } for % % Apply AST spec overrides and resolve physical specification % /rationalizedCodabar ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec /barlen barcode length validatecheck {1 sub} if def /checksum 0 def 0 1 barlen 2 sub { barcode exch 1 getinterval charvals exch get checksum add /checksum exch def } for barcode barcode length 1 sub 1 getinterval charvals exch get checksum add /checksum exch def /checksum 16 checksum 16 mod sub 16 mod def validatecheck { barcode barlen 1 sub get barchars checksum get ne { /bwipp.rationalizedCodabarBadCheckDigit (Incorrect Codabar check digit provided) //raiseerror exec } if barlen string dup 0 barcode 0 barlen 1 sub getinterval putinterval dup barlen 1 sub barcode barlen 1 getinterval putinterval /barcode exch def /includecheck true def } if /sbs barlen includecheck {1 add} if 8 mul string def 0 1 barlen 2 sub { /i exch def /indx charvals barcode i 1 getinterval get def /enc //rationalizedCodabar.encs indx get def sbs i 8 mul enc putinterval % Put encoded digit into sbs } for % % Put the checksum character and stop character % includecheck { sbs barlen 8 mul 8 sub //rationalizedCodabar.encs checksum get putinterval /indx charvals barcode barlen 1 sub 1 getinterval get def /enc //rationalizedCodabar.encs indx get def sbs barlen 8 mul enc putinterval } { /indx charvals barcode barlen 1 sub 1 getinterval get def /enc //rationalizedCodabar.encs indx get def sbs barlen 8 mul 8 sub enc putinterval } ifelse % Build display text: start data [check] stop /text includecheck includecheckintext and { barlen 1 add string dup 0 barcode 0 barlen 1 sub getinterval putinterval dup barlen 1 sub barchars checksum 1 getinterval putinterval dup barlen barcode barlen 1 sub 1 getinterval putinterval } { barcode } ifelse def /height /resolve_height //render exec dup -1 eq { pop 1.0 } if def << /ren /renlinear /sbs [sbs {48 sub} forall] /bhs [sbs length 1 add 2 idiv {height} repeat] /bbs [sbs length 1 add 2 idiv {0} repeat] includetext { /txt [ [text 0 0 text1font text1size] ] /text1xalign (center) } if /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /rationalizedCodabar dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER rationalizedCodabar-- % --BEGIN ENCODER onecode-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear-- % --DESC: USPS Intelligent Mail % --EXAM: 0123456709498765432101234567891 % --EXOP: % --RNDR: renlinear % --FMLY: Postal Symbols %%BeginResource: uk.co.terryburton.bwipp onecode 0.0 2026052800 126504 132931 %%BeginData: 400 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /onecode.startvals << 20 [0] 25 [1] 29 [1 0 0 0 0 1] 31 [1 0 0 0 1 0 0 0 0 1] >> readonly def /onecode.tab513 [ 31 7936 47 7808 55 7552 59 7040 61 6016 62 3968 79 7744 87 7488 91 6976 93 5952 94 3904 103 7360 107 6848 109 5824 110 3776 115 6592 117 5568 118 3520 121 5056 122 3008 124 1984 143 7712 151 7456 155 6944 157 5920 158 3872 167 7328 171 6816 173 5792 174 3744 179 6560 181 5536 182 3488 185 5024 186 2976 188 1952 199 7264 203 6752 205 5728 206 3680 211 6496 213 5472 214 3424 217 4960 218 2912 220 1888 227 6368 229 5344 230 3296 233 4832 234 2784 236 1760 241 4576 242 2528 244 1504 248 992 271 7696 279 7440 283 6928 285 5904 286 3856 295 7312 299 6800 301 5776 302 3728 307 6544 309 5520 310 3472 313 5008 314 2960 316 1936 327 7248 331 6736 333 5712 334 3664 339 6480 341 5456 342 3408 345 4944 346 2896 348 1872 355 6352 357 5328 358 3280 361 4816 362 2768 364 1744 369 4560 370 2512 372 1488 376 976 391 7216 395 6704 397 5680 398 3632 403 6448 405 5424 406 3376 409 4912 410 2864 412 1840 419 6320 421 5296 422 3248 425 4784 426 2736 428 1712 433 4528 434 2480 436 1456 440 944 451 6256 453 5232 454 3184 457 4720 458 2672 460 1648 465 4464 466 2416 468 1392 472 880 481 4336 482 2288 484 1264 488 752 527 7688 535 7432 539 6920 541 5896 542 3848 551 7304 555 6792 557 5768 558 3720 563 6536 565 5512 566 3464 569 5000 570 2952 572 1928 583 7240 587 6728 589 5704 590 3656 595 6472 597 5448 598 3400 601 4936 602 2888 604 1864 611 6344 613 5320 614 3272 617 4808 618 2760 620 1736 625 4552 626 2504 628 1480 632 968 647 7208 651 6696 653 5672 654 3624 659 6440 661 5416 662 3368 665 4904 666 2856 668 1832 675 6312 677 5288 678 3240 681 4776 682 2728 684 1704 689 4520 690 2472 692 1448 696 936 707 6248 709 5224 710 3176 713 4712 714 2664 716 1640 721 4456 722 2408 724 1384 728 872 737 4328 738 2280 740 1256 775 7192 779 6680 781 5656 782 3608 787 6424 789 5400 790 3352 793 4888 794 2840 796 1816 803 6296 805 5272 806 3224 809 4760 810 2712 812 1688 817 4504 818 2456 820 1432 824 920 835 6232 837 5208 838 3160 841 4696 842 2648 844 1624 849 4440 850 2392 852 1368 865 4312 866 2264 868 1240 899 6200 901 5176 902 3128 905 4664 906 2616 908 1592 913 4408 914 2360 916 1336 929 4280 930 2232 932 1208 961 4216 962 2168 964 1144 1039 7684 1047 7428 1051 6916 1053 5892 1054 3844 1063 7300 1067 6788 1069 5764 1070 3716 1075 6532 1077 5508 1078 3460 1081 4996 1082 2948 1084 1924 1095 7236 1099 6724 1101 5700 1102 3652 1107 6468 1109 5444 1110 3396 1113 4932 1114 2884 1116 1860 1123 6340 1125 5316 1126 3268 1129 4804 1130 2756 1132 1732 1137 4548 1138 2500 1140 1476 1159 7204 1163 6692 1165 5668 1166 3620 1171 6436 1173 5412 1174 3364 1177 4900 1178 2852 1180 1828 1187 6308 1189 5284 1190 3236 1193 4772 1194 2724 1196 1700 1201 4516 1202 2468 1204 1444 1219 6244 1221 5220 1222 3172 1225 4708 1226 2660 1228 1636 1233 4452 1234 2404 1236 1380 1249 4324 1250 2276 1287 7188 1291 6676 1293 5652 1294 3604 1299 6420 1301 5396 1302 3348 1305 4884 1306 2836 1308 1812 1315 6292 1317 5268 1318 3220 1321 4756 1322 2708 1324 1684 1329 4500 1330 2452 1332 1428 1347 6228 1349 5204 1350 3156 1353 4692 1354 2644 1356 1620 1361 4436 1362 2388 1377 4308 1378 2260 1411 6196 1413 5172 1414 3124 1417 4660 1418 2612 1420 1588 1425 4404 1426 2356 1441 4276 1442 2228 1473 4212 1474 2164 1543 7180 1547 6668 1549 5644 1550 3596 1555 6412 1557 5388 1558 3340 1561 4876 1562 2828 1564 1804 1571 6284 1573 5260 1574 3212 1577 4748 1578 2700 1580 1676 1585 4492 1586 2444 1603 6220 1605 5196 1606 3148 1609 4684 1610 2636 1617 4428 1618 2380 1633 4300 1634 2252 1667 6188 1669 5164 1670 3116 1673 4652 1674 2604 1681 4396 1682 2348 1697 4268 1698 2220 1729 4204 1730 2156 1795 6172 1797 5148 1798 3100 1801 4636 1802 2588 1809 4380 1810 2332 1825 4252 1826 2204 1857 4188 1858 2140 1921 4156 1922 2108 2063 7682 2071 7426 2075 6914 2077 5890 2078 3842 2087 7298 2091 6786 2093 5762 2094 3714 2099 6530 2101 5506 2102 3458 2105 4994 2106 2946 2119 7234 2123 6722 2125 5698 2126 3650 2131 6466 2133 5442 2134 3394 2137 4930 2138 2882 2147 6338 2149 5314 2150 3266 2153 4802 2154 2754 2161 4546 2162 2498 2183 7202 2187 6690 2189 5666 2190 3618 2195 6434 2197 5410 2198 3362 2201 4898 2202 2850 2211 6306 2213 5282 2214 3234 2217 4770 2218 2722 2225 4514 2226 2466 2243 6242 2245 5218 2246 3170 2249 4706 2250 2658 2257 4450 2258 2402 2273 4322 2311 7186 2315 6674 2317 5650 2318 3602 2323 6418 2325 5394 2326 3346 2329 4882 2330 2834 2339 6290 2341 5266 2342 3218 2345 4754 2346 2706 2353 4498 2354 2450 2371 6226 2373 5202 2374 3154 2377 4690 2378 2642 2385 4434 2401 4306 2435 6194 2437 5170 2438 3122 2441 4658 2442 2610 2449 4402 2465 4274 2497 4210 2567 7178 2571 6666 2573 5642 2574 3594 2579 6410 2581 5386 2582 3338 2585 4874 2586 2826 2595 6282 2597 5258 2598 3210 2601 4746 2602 2698 2609 4490 2627 6218 2629 5194 2630 3146 2633 4682 2641 4426 2657 4298 2691 6186 2693 5162 2694 3114 2697 4650 2705 4394 2721 4266 2753 4202 2819 6170 2821 5146 2822 3098 2825 4634 2833 4378 2849 4250 2881 4186 2945 4154 3079 7174 3083 6662 3085 5638 3086 3590 3091 6406 3093 5382 3094 3334 3097 4870 3107 6278 3109 5254 3110 3206 3113 4742 3121 4486 3139 6214 3141 5190 3145 4678 3153 4422 3169 4294 3203 6182 3205 5158 3209 4646 3217 4390 3233 4262 3265 4198 3331 6166 3333 5142 3337 4630 3345 4374 3361 4246 3393 4182 3457 4150 3587 6158 3589 5134 3593 4622 3601 4366 3617 4238 3649 4174 3713 4142 3841 4126 4111 7681 4119 7425 4123 6913 4125 5889 4135 7297 4139 6785 4141 5761 4147 6529 4149 5505 4153 4993 4167 7233 4171 6721 4173 5697 4179 6465 4181 5441 4185 4929 4195 6337 4197 5313 4201 4801 4209 4545 4231 7201 4235 6689 4237 5665 4243 6433 4245 5409 4249 4897 4259 6305 4261 5281 4265 4769 4273 4513 4291 6241 4293 5217 4297 4705 4305 4449 4359 7185 4363 6673 4365 5649 4371 6417 4373 5393 4377 4881 4387 6289 4389 5265 4393 4753 4401 4497 4419 6225 4421 5201 4425 4689 4483 6193 4485 5169 4489 4657 4615 7177 4619 6665 4621 5641 4627 6409 4629 5385 4633 4873 4643 6281 4645 5257 4649 4745 4675 6217 4677 5193 4739 6185 4741 5161 4867 6169 4869 5145 5127 7173 5131 6661 5133 5637 5139 6405 5141 5381 5155 6277 5157 5253 5187 6213 5251 6181 5379 6165 5635 6157 6151 7171 6155 6659 6163 6403 6179 6275 6211 5189 4681 4433 4321 3142 2634 2386 2274 1612 1364 1252 856 744 496 ] readonly def /onecode.tab213 [ 3 6144 5 5120 6 3072 9 4608 10 2560 12 1536 17 4352 18 2304 20 1280 24 768 33 4224 34 2176 36 1152 40 640 48 384 65 4160 66 2112 68 1088 72 576 80 320 96 192 129 4128 130 2080 132 1056 136 544 144 288 257 4112 258 2064 260 1040 264 528 513 4104 514 2056 516 1032 1025 4100 1026 2052 2049 4098 4097 2050 1028 520 272 160 ] readonly def /onecode.barmap [ 7 2 4 3 1 10 0 0 9 12 2 8 5 5 6 11 8 9 3 1 0 1 5 12 2 5 1 8 4 4 9 11 6 3 8 10 3 9 7 6 5 11 1 4 8 5 2 12 9 10 0 2 7 1 6 7 3 6 4 9 0 3 8 6 6 4 2 7 1 1 9 9 7 10 5 2 4 0 3 8 6 2 0 4 8 11 1 0 9 8 3 12 2 6 7 7 5 1 4 10 1 12 6 9 7 3 8 0 5 8 9 7 4 6 2 10 3 4 0 5 8 4 5 7 7 11 1 9 6 0 9 6 0 6 4 8 2 1 3 2 5 9 8 12 4 11 6 1 9 5 7 4 3 3 1 2 0 7 2 0 1 3 4 1 6 10 3 5 8 7 9 4 2 11 5 6 0 8 7 12 4 2 8 1 5 10 3 0 9 3 0 9 6 5 2 4 7 8 1 7 5 0 4 5 2 3 0 10 6 12 9 2 3 11 1 6 8 8 7 9 5 4 0 11 1 5 2 2 9 1 4 12 8 3 6 6 7 0 3 7 4 7 7 5 0 12 1 11 2 9 9 0 6 8 5 3 3 10 8 2 ] readonly def /onecode { 32 dict begin { /dontdraw false def /height -1.0 def /width 0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def /barlen barcode length def barcode { dup 48 lt exch 57 gt or { /bwipp.onecodeBadCharacter (The data must contain only digits) //raiseerror exec } if } forall barlen 20 ne barlen 25 ne and barlen 29 ne and barlen 31 ne and { /bwipp.onecodeInvalidLength (The data must be 20, 25, 29 or 31 digits) //raiseerror exec } if % % Apply AST spec overrides and resolve physical specification % /onecode ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec % % Create the human readable text % /txtdict << 2 dup 5 dup barcode 5 1 getinterval (9) eq {14} {11} ifelse dup 20 dup 25 dup 29 dup >> def /txt barlen 6 add array def /spacecnt 0 def 0 1 barlen 1 sub { /i exch def txtdict i known { txt i spacecnt add [( ) 0 0 () 0] put /spacecnt spacecnt 1 add def } if txt i spacecnt add [barcode i 1 getinterval 0 0 () 0] put } for /txt txt 0 barcode length spacecnt add getinterval def /normalize { /base exch def /num exch def num length 1 sub -1 1 { /i exch def num i 1 sub 2 copy get num i get base idiv add put num i num i get base mod put } for % % Extend array using stack accumulation % num 0 get base ge { mark num 0 get { % loop dup base lt {exit} if dup base mod exch base idiv } loop % Stack: mark lsb lsb-1 ... msb (msb < base) counttomark 1 sub /extcnt exch def counttomark array astore /extdigits exch def pop % mark % Build num with reversed extension digits prepended to num[1:] /num [ extcnt -1 0 { extdigits exch get } for num 1 num length 1 sub getinterval aload pop ] def } if % % Trim leading zeros and return % 0 { dup num length ge {exit} if num 1 index get 0 ne {exit} if 1 add } loop dup num length ge { pop [0] } { num exch num length 1 index sub getinterval } ifelse } def /bigadd { 2 copy length exch length 2 copy sub abs /offset exch def lt {exch} if /a exch def /b exch def 0 1 b length 1 sub { dup a exch offset add 2 copy get b 5 -1 roll get add put } for a } def % % Conversion of data fields into binary data % /binval //onecode.startvals barlen get [barcode 20 barlen 20 sub getinterval {48 sub} forall] bigadd def /binval [binval aload pop barcode 0 get 48 sub] def /binval [binval {5 mul} forall] [barcode 1 get 48 sub] bigadd 10 normalize def /binval [binval aload pop barcode 2 18 getinterval {48 sub} forall] def % % Conversion of binary data into byte array % /bytes 13 array def /bintmp binval dup length array copy def 12 -1 0 { /i exch def 0 1 bintmp length 2 sub { /j exch def bintmp j 1 add 2 copy get bintmp j get 256 mod 10 mul add put bintmp j bintmp j get 256 idiv put } for bytes i bintmp bintmp length 1 sub get 256 mod put bintmp bintmp length 1 sub 2 copy get 256 idiv put } for % % Generation of 11-bit CRC on byte array % /fcs 2047 def /dat bytes 0 get 5 bitshift def 6 { /fcs fcs 1 bitshift fcs dat xor 1024 and 0 ne {3893 xor} if 2047 and def /dat dat 1 bitshift def } repeat 1 1 12 { bytes exch get 3 bitshift /dat exch def 8 { /fcs fcs 1 bitshift fcs dat xor 1024 and 0 ne {3893 xor} if 2047 and def /dat dat 1 bitshift def } repeat } for % % Conversion from binary data to codewords % /codewords 10 array def 9 -1 0 { /i exch def /b i 9 eq { 636 } { 1365 } ifelse def 0 1 binval length 2 sub { /j exch def binval j 1 add 2 copy get binval j get b mod 10 mul add put binval j binval j get b idiv put } for codewords i binval binval length 1 sub get b mod put binval binval length 1 sub 2 copy get b idiv put } for % % Inserting additional information into codewords % codewords 9 codewords 9 get 2 mul put fcs 1024 and 0 ne { codewords 0 codewords 0 get 659 add put } if options /debugcws known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugcws codewords //raiseerror exec } if % % Conversion from codewords to characters % /chars 10 array def 0 1 9 { /i exch def codewords i get dup 1286 le { //onecode.tab513 exch get } { //onecode.tab213 exch 1287 sub get } ifelse chars i 3 -1 roll put } for 9 -1 0 { /i exch def 2 i exp cvi fcs and 0 ne { chars i chars i get 8191 xor put } if } for /height /resolve_height //render exec dup -1 eq { pop 0.15 } if def % % Conversion from characters to the OneCode encoding % /bbs 65 array def /bhs 65 array def 0 1 64 { /i exch def /dec chars //onecode.barmap i 4 mul get get 2 //onecode.barmap i 4 mul 1 add get exp cvi and 0 ne def /asc chars //onecode.barmap i 4 mul 2 add get get 2 //onecode.barmap i 4 mul 3 add get exp cvi and 0 ne def dec not asc not and { bbs i 3 height mul 8 div put bhs i 2 height mul 8 div put } if dec not asc and { bbs i 3 height mul 8 div put bhs i 5 height mul 8 div put } if dec asc not and { bbs i 0 height mul 8 div put bhs i 5 height mul 8 div put } if dec asc and { bbs i 0 height mul 8 div put bhs i 8 height mul 8 div put } if } for << /ren /renlinear /bbs bbs /bhs bhs /sbs [bhs length 1 sub {1.44 1.872} repeat 1.44] /txt txt /text1xalign (left) /text1font /Helvetica /text1yoffset -1.0 /text1xoffset -0.3 /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /onecode dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER onecode-- % --BEGIN ENCODER postnet-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear-- % --DESC: USPS POSTNET % --EXAM: 01234 % --EXOP: includetext includecheckintext % --RNDR: renlinear % --FMLY: Postal Symbols %%BeginResource: uk.co.terryburton.bwipp postnet 0.0 2026052800 75517 78662 %%BeginData: 169 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /postnet.barchars (0123456789) readonly def /postnet.encs [ (55222) (22255) (22525) (22552) (25225) (25252) (25522) (52225) (52252) (52522) (5) (5) ] readonly def /postnet { 32 dict begin { /dontdraw false def /includetext false def % Enable/disable text /validatecheck false def /includecheckintext false def /text1font /Courier def /text1size 10.0 def /text1yoffset -7.0 def /height -1.0 def /width 0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def /barlen barcode length validatecheck {1 sub} if def % % Validate the input % barlen 5 ne barlen 9 ne and barlen 11 ne and { /bwipp.postnetBadLength (USPS POSTNET must be 5, 9 or 11 digits excluding check digit) //raiseerror exec } if barcode { dup 48 lt exch 57 gt or { /bwipp.postnetBadCharacter (USPS POSTNET must contain only digits) //raiseerror exec } if } forall % % Apply AST spec overrides and resolve physical specification % /postnet ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec /checksum 0 def 0 1 barlen 1 sub { /i exch def /checksum checksum barcode i get 48 sub add def } for /checksum 10 checksum 10 mod sub 10 mod def validatecheck { barcode barlen get //postnet.barchars checksum get ne { /bwipp.postnetBadCheckDigit (Incorrect USPS POSTNET check digit provided) //raiseerror exec } if /barcode barcode 0 barlen getinterval def } if /height /resolve_height //render exec dup -1 eq { pop 0.125 } if def /bhs barlen 5 mul 7 add array def % % Put start character % /enc //postnet.encs 10 get def /heights enc length array def 0 1 enc length 1 sub { /j exch def heights j enc j 1 getinterval cvi height mul 5 div put } for bhs 0 heights putinterval % Put encoded digit into sbs 0 1 barlen 1 sub { /i exch def /enc //postnet.encs barcode i get 48 sub get def /heights enc length array def 0 1 enc length 1 sub { /j exch def heights j enc j 1 getinterval cvi height mul 5 div put } for bhs i 5 mul 1 add heights putinterval % Put encoded digit into sbs } for % % Put the checksum character % /enc //postnet.encs checksum get def /heights enc length array def 0 1 enc length 1 sub { /j exch def heights j enc j 1 getinterval cvi height mul 5 div put } for bhs barlen 5 mul 1 add heights putinterval /text includecheckintext { barlen 1 add string dup 0 barcode putinterval dup barlen //postnet.barchars checksum 1 getinterval putinterval } { barcode } ifelse def % % Put end character % /enc //postnet.encs 11 get def /heights enc length array def 0 1 enc length 1 sub { /j exch def heights j enc j 1 getinterval cvi height mul 5 div put } for bhs barlen 5 mul 6 add heights putinterval << /ren /renlinear /bhs bhs /bbs [bhs length {0} repeat] /sbs [bhs length 1 sub {1.44 1.872} repeat 1.44] includetext { /txt [ [text 0 0 text1font text1size] ] /text1xalign (center) } if /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /postnet dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER postnet-- % --BEGIN ENCODER planet-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear-- % --DESC: USPS PLANET % --EXAM: 01234567890 % --EXOP: includetext includecheckintext % --RNDR: renlinear % --FMLY: Postal Symbols %%BeginResource: uk.co.terryburton.bwipp planet 0.0 2026052800 75327 78478 %%BeginData: 172 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /planet.barchars (0123456789) readonly def /planet.encs [ (22555) (55522) (55252) (55225) (52552) (52525) (52255) (25552) (25525) (25255) (5) (5) ] readonly def /planet { 32 dict begin { /dontdraw false def /includetext false def % Enable/disable text /validatecheck false def /includecheckintext false def /text1font /Courier def /text1size 10.0 def /text1yoffset -7.0 def /height -1.0 def /width 0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def /barlen barcode length validatecheck {1 sub} if def % % Validate the input % barlen 11 ne barlen 13 ne and { /bwipp.planetBadLength (USPS PLANET must be 11 or 13 digits excluding check digit) //raiseerror exec } if barcode { dup 48 lt exch 57 gt or { /bwipp.planetBadCharacter (USPS PLANET must contain only digits) //raiseerror exec } if } forall % % Apply AST spec overrides and resolve physical specification % /planet ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec % % Calculate the checksum % /checksum 0 def 0 1 barlen 1 sub { /i exch def /checksum checksum barcode i get 48 sub add def } for /checksum 10 checksum 10 mod sub 10 mod def validatecheck { barcode barlen get //planet.barchars checksum get ne { /bwipp.planetBadCheckDigit (Incorrect USPS PLANET check digit provided) //raiseerror exec } if /barcode barcode 0 barlen getinterval def } if /height /resolve_height //render exec dup -1 eq { pop 0.125 } if def /bhs barlen 5 mul 7 add array def % % Put start character % /enc //planet.encs 10 get def /heights enc length array def 0 1 enc length 1 sub { /j exch def heights j enc j 1 getinterval cvi height mul 5 div put } for bhs 0 heights putinterval % Put encoded digit into sbs 0 1 barlen 1 sub { /i exch def /enc //planet.encs barcode i get 48 sub get def /heights enc length array def 0 1 enc length 1 sub { /j exch def heights j enc j 1 getinterval cvi height mul 5 div put } for bhs i 5 mul 1 add heights putinterval % Put encoded digit into sbs } for % % Put the checksum character % /enc //planet.encs checksum get def /heights enc length array def 0 1 enc length 1 sub { /j exch def heights j enc j 1 getinterval cvi height mul 5 div put } for bhs barlen 5 mul 1 add heights putinterval /text includecheckintext { barlen 1 add string dup 0 barcode putinterval dup barlen //planet.barchars checksum 1 getinterval putinterval } { barcode } ifelse def % % Put end character % /enc //planet.encs 11 get def /heights enc length array def 0 1 enc length 1 sub { /j exch def heights j enc j 1 getinterval cvi height mul 5 div put } for bhs barlen 5 mul 6 add heights putinterval << /ren /renlinear /bhs bhs /bbs [bhs length {0} repeat] /sbs [bhs length 1 sub {1.44 1.872} repeat 1.44] includetext { /txt [ [text 0 0 text1font text1size] ] /text1xalign (center) } if /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /planet dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER planet-- % --BEGIN ENCODER royalmail-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear-- % --DESC: Royal Mail 4 State Customer Code % --EXAM: LE28HS9Z % --EXOP: includetext % --RNDR: renlinear % --FMLY: Postal Symbols %%BeginResource: uk.co.terryburton.bwipp royalmail 0.0 2026052800 80844 83888 %%BeginData: 209 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /royalmail.barchars (ZUVWXY501234B6789AHCDEFGNIJKLMTOPQRS) readonly def /royalmail.encs [ (3300) (2211) (2301) (2310) (3201) (3210) (1122) (0033) (0123) (0132) (1023) (1032) (1302) (0213) (0303) (0312) (1203) (1212) (1320) (0231) (0321) (0330) (1221) (1230) (3102) (2013) (2103) (2112) (3003) (3012) (3120) (2031) (2121) (2130) (3021) (3030) (2) (3) ] readonly def /royalmail.latevars dup 2 dict def load /init { currentglobal true setglobal //royalmail.latevars begin /charvals 36 dict def 0 1 35 { charvals exch dup //royalmail.barchars exch 1 getinterval exch put } for /charvals charvals readonly def /init { //royalmail.latevars {def} forall } def end //royalmail.latevars /init get exec setglobal } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//royalmail.latevars /init get exec} if } {pop} ifelse /royalmail { 32 dict begin { /dontdraw false def /includetext false def % Enable/disable text /validatecheck false def /includecheckintext false def /text1font /Courier def /text1size 10.0 def /text1yoffset -7.0 def /height -1.0 def /width 0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def //royalmail.latevars /init get exec barcode () eq { /bwipp.royalmailEmptyData (The data must not be empty) //raiseerror exec } if barcode length 500 gt { /bwipp.royalmailInputTooLong (The input data is too long) //raiseerror exec } if % % Apply AST spec overrides and resolve physical specification % /royalmail ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec % % Validate the input % 0 1 barcode length 1 sub { barcode exch 1 getinterval charvals exch known not { /bwipp.royalmailBadCharacter (RM4SCC must contain only capital letters and digits) //raiseerror exec } if } for /barlen barcode length validatecheck {1 sub} if def /checksumrow 0 def /checksumcol 0 def 0 1 barlen 1 sub { /i exch def /indx charvals barcode i 1 getinterval get def /checksumrow checksumrow indx 6 idiv add def /checksumcol checksumcol indx 6 mod add def } for /checksum checksumrow 6 mod 6 mul checksumcol 6 mod add def validatecheck { barcode barlen get //royalmail.barchars checksum get ne { /bwipp.royalmailBadCheckDigit (Incorrect RM4SCC check digit provided) //raiseerror exec } if /barcode barcode 0 barlen getinterval def } if /encstr barlen 4 mul 6 add string def % % Put start character % encstr 0 //royalmail.encs 36 get putinterval 0 1 barlen 1 sub { /i exch def /indx charvals barcode i 1 getinterval get def encstr i 4 mul 1 add //royalmail.encs indx get putinterval } for % % Put the checksum character % encstr barlen 4 mul 1 add //royalmail.encs checksum get putinterval /text includecheckintext { barlen 1 add string dup 0 barcode putinterval dup barlen //royalmail.barchars checksum 1 getinterval putinterval } { barcode } ifelse def % % Put end character % encstr barlen 4 mul 5 add //royalmail.encs 37 get putinterval /height /resolve_height //render exec dup -1 eq { pop 0.175 } if def /bbs encstr length array def /bhs encstr length array def 0 1 encstr length 1 sub { /i exch def /enc encstr i 1 getinterval def enc (0) eq { bbs i 3 height mul 8 div put bhs i 2 height mul 8 div put } if enc (1) eq { bbs i 0 height mul 8 div put bhs i 5 height mul 8 div put } if enc (2) eq { bbs i 3 height mul 8 div put bhs i 5 height mul 8 div put } if enc (3) eq { bbs i 0 height mul 8 div put bhs i 8 height mul 8 div put } if } for << /ren /renlinear /bbs bbs /bhs bhs /sbs [bhs length 1 sub {1.44 1.872} repeat 1.44] includetext { /txt [ [text 0 0 text1font text1size] ] /text1xalign (center) } if /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /royalmail dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER royalmail-- % --BEGIN ENCODER auspost-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear-- % --DESC: AusPost 4 State Customer Code % --EXAM: 5956439111ABA 9 % --EXOP: includetext custinfoenc=character % --RNDR: renlinear % --FMLY: Postal Symbols %%BeginResource: uk.co.terryburton.bwipp auspost 0.0 2026052800 103111 109587 %%BeginData: 328 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 17 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /auspost.encs [ (000) (001) (002) (010) (011) (012) (020) (021) (022) (100) (101) (102) (110) (111) (112) (120) (121) (122) (200) (201) (202) (210) (211) (212) (220) (221) (222) (300) (301) (302) (310) (311) (312) (320) (321) (322) (023) (030) (031) (032) (033) (103) (113) (123) (130) (131) (132) (133) (203) (213) (223) (230) (231) (232) (233) (303) (313) (323) (330) (331) (332) (333) (003) (013) (00) (01) (02) (10) (11) (12) (20) (21) (22) (30) (13) (3) ] readonly def /auspost.barchars (ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz #) readonly def /auspost.fcclen << (11) 37 (45) 37 (59) 52 (62) 67 (87) 37 (92) 37 >> readonly def /auspost.rsprod { 64 mul add rstable exch get } bind def /auspost.latevars dup 8 dict def load /init { currentglobal true setglobal //auspost.latevars begin % % Calculate the Reed-Solomon table for error correction % /rstable 64 64 mul array def rstable 0 [ 64 {0} repeat ] putinterval rstable 64 [ 0 1 63 {} for ] putinterval 1 % ... prev 64 { dup 1 bitshift dup 64 and 0 ne {67 xor} if % ... next 1 index 64 mul % ... prevbase 1 index 64 mul % ... nextbase 0 1 63 { % i rstable 2 index 2 index add rstable 5 index 4 index add get 1 bitshift dup 64 and 0 ne {67 xor} if put pop % i } for pop pop exch pop } repeat pop /rstable rstable readonly def % % Calculate the generator polynomials % /rspoly [ 1 0 0 0 0 ] def 1 1 4 { % i 1 1 index bitshift % t = 2^i exch -1 1 { % j = i -> 1 rspoly 1 index 2 copy 1 sub get % ... rsploy j rsploy[j-1] rspoly 5 -1 roll get % ... rsploy[j] 4 index % ... t //auspost.rsprod exec % p = rsploy[j] * t xor put % rspoly[j] = rsploy[j-1] ^ p } for rspoly 0 2 copy get % ... rspoly 0 rspoly[0] 3 index % ... t //auspost.rsprod exec put % rspoly[0] = rspoly[0] * t pop % t } for /rspoly rspoly readonly def /init { //auspost.latevars {def} forall } def end //auspost.latevars /init get exec setglobal } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//auspost.latevars /init get exec} if } {pop} ifelse /auspost { 32 dict begin { /dontdraw false def /includetext false def /text1font /Courier def /text1size 10.0 def /text1yoffset -7.0 def /height -1.0 def /width 0 def /custinfoenc (character) def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def //auspost.latevars /init get exec custinfoenc (character) ne custinfoenc (numeric) ne and { /bwipp.auspostBadCustinfoEncoding (Customer information encoding must be either character or numeric) //raiseerror exec } if /barlen barcode length def barlen 10 lt { /bwipp.auspostTooShort (The data length must be at least 10) //raiseerror exec } if //auspost.fcclen barlen 2 ge { barcode 0 2 getinterval } { () } ifelse 2 copy known not { pop pop /bwipp.auspostBadFCC (Must begin with an FCC, either 11, 45, 59, 62, 87 or 92) //raiseerror exec } if get /encstr exch string def % % Validate that the message has a complete, numeric DPID % true 1 { barlen 10 lt { pop false exit } if barcode 2 8 getinterval { dup 48 lt exch 57 gt or { pop false exit } if } forall } repeat not { /bwipp.auspostIncompleteDPID (The DPID must be 8 digits) //raiseerror exec } if % % Validate that the message will fit % barlen 10 sub custinfoenc (numeric) eq {2} {3} ifelse mul encstr length 22 sub 14 sub gt { /bwipp.auspostTooLong (The message is too long) //raiseerror exec } if % % Apply AST spec overrides and resolve physical specification % /auspost ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec % % Put start character % encstr 0 //auspost.encs 74 get putinterval % % Encode the FCC % 0 1 1 { /i exch def //auspost.encs barcode i 1 getinterval cvi 64 add get encstr i 2 mul 2 add 3 2 roll putinterval } for % % Encode the DPID % 2 1 9 { /i exch def //auspost.encs barcode i 1 getinterval cvi 64 add get encstr i 2 mul 2 add 3 2 roll putinterval } for % % Encode the customer information % custinfoenc (numeric) eq { 0 1 barlen 11 sub { /i exch def //auspost.encs barcode i 10 add get dup dup 48 lt exch 57 gt or { pop pop /bwipp.auspostInvalidCustinfoDigit (The customer information data contains a non-digit character) //raiseerror exec } if 48 sub 64 add get encstr i 2 mul 22 add 3 2 roll putinterval } for /ciflen barlen 10 sub 2 mul def } { 0 1 barlen 11 sub { /i exch def barcode i 10 add 1 getinterval //auspost.barchars exch search not { pop /bwipp.auspostInvalidCustinfoCharacter (The customer information contains an invalid character) //raiseerror exec } if length /indx exch def pop pop /enc //auspost.encs indx get def encstr i 3 mul 22 add enc putinterval } for /ciflen barlen 10 sub 3 mul def } ifelse % % Add any filler characters % 22 ciflen add 1 encstr length 14 sub { encstr exch //auspost.encs 75 get putinterval } for % % Calculate the Reed-Solomon codes for triples % /rscodes encstr length 16 sub 3 idiv 4 add array def rscodes 0 [ 4 {0} repeat ] putinterval 2 3 encstr length 16 sub { /i exch def rscodes rscodes length i 2 sub 3 idiv sub 1 sub encstr i 1 getinterval cvi 16 mul encstr i 1 add 1 getinterval cvi 4 mul add encstr i 2 add 1 getinterval cvi add put } for rscodes length 5 sub -1 0 { % i 0 1 4 { % j rscodes 2 index 2 index add 2 copy get % ... rscodes i+j rscodes[i+j] rspoly 5 -1 roll get % ... rspoly[j] rscodes 5 index 4 add get % ... rscodes[i+4] //auspost.rsprod exec % p = rspoly[j] * rscodes[i+4] xor put % rscodes[i+j] = rscodes[i+j] ^ p } for pop % i } for /checkcode (000000000000) 12 string copy def 0 1 3 { /i exch def /enc rscodes 3 i sub get 4 3 string cvrs def checkcode i 3 mul 3 enc length sub add enc putinterval } for % % Put checkcode and end characters % encstr encstr length 14 sub checkcode putinterval encstr encstr length 2 sub //auspost.encs 74 get putinterval /height /resolve_height //render exec dup -1 eq { pop 0.175 } if def /bbs encstr length array def /bhs encstr length array def 0 1 encstr length 1 sub { /i exch def /enc encstr i 1 getinterval def enc (0) eq { bbs i 0 height mul 8 div put bhs i 8 height mul 8 div put } if enc (1) eq { bbs i 3 height mul 8 div put bhs i 5 height mul 8 div put } if enc (2) eq { bbs i 0 height mul 8 div put bhs i 5 height mul 8 div put } if enc (3) eq { bbs i 3 height mul 8 div put bhs i 2 height mul 8 div put } if } for << /ren /renlinear /bbs bbs /bhs bhs /sbs [bhs length 1 sub {1.44 1.872} repeat 1.44] includetext { /txt [ [barcode 2 barlen 2 sub getinterval 0 0 text1font text1size] ] /text1xalign (center) } if /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /auspost dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER auspost-- % --BEGIN ENCODER kix-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear-- % --DESC: Royal Dutch TPG Post KIX % --EXAM: 1231FZ13XHS % --EXOP: includetext % --RNDR: renlinear % --FMLY: Postal Symbols %%BeginResource: uk.co.terryburton.bwipp kix 0.0 2026052800 76177 79444 %%BeginData: 173 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /kix.encs [ (0033) (0123) (0132) (1023) (1032) (1122) (0213) (0303) (0312) (1203) (1212) (1302) (0231) (0321) (0330) (1221) (1230) (1320) (2013) (2103) (2112) (3003) (3012) (3102) (2031) (2121) (2130) (3021) (3030) (3120) (2211) (2301) (2310) (3201) (3210) (3300) ] readonly def /kix.barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ) readonly def /kix.latevars dup 2 dict def load /init { currentglobal true setglobal //kix.latevars begin /charvals 36 dict def 0 1 35 { charvals exch dup //kix.barchars exch 1 getinterval exch put } for /charvals charvals readonly def /init { //kix.latevars {def} forall } def end //kix.latevars /init get exec setglobal } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//kix.latevars /init get exec} if } {pop} ifelse /kix { 16 dict begin { /dontdraw false def /includetext false def /text1font /Courier def /text1size 10.0 def /text1yoffset -7.0 def /height -1.0 def /width 0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def //kix.latevars /init get exec barcode () eq { /bwipp.kixEmptyData (The data must not be empty) //raiseerror exec } if barcode length 500 gt { /bwipp.kixInputTooLong (The input data is too long) //raiseerror exec } if % % Validate the input % 0 1 barcode length 1 sub { barcode exch 1 getinterval charvals exch known not { /bwipp.kixBadCharacter (KIX must contain only capital letters and digits) //raiseerror exec } if } for /barlen barcode length def % % Apply AST spec overrides and resolve physical specification % /kix ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec /encstr barlen 4 mul string def 0 1 barlen 1 sub { /i exch def /indx charvals barcode i 1 getinterval get def encstr i 4 mul //kix.encs indx get putinterval } for /height /resolve_height //render exec dup -1 eq { pop 0.175 } if def /bbs encstr length array def /bhs encstr length array def 0 1 encstr length 1 sub { /i exch def /enc encstr i 1 getinterval def enc (0) eq { bbs i 3 height mul 8 div put bhs i 2 height mul 8 div put } if enc (1) eq { bbs i 0 height mul 8 div put bhs i 5 height mul 8 div put } if enc (2) eq { bbs i 3 height mul 8 div put bhs i 5 height mul 8 div put } if enc (3) eq { bbs i 0 height mul 8 div put bhs i 8 height mul 8 div put } if } for << /ren /renlinear /bbs bbs /bhs bhs /sbs [bhs length 1 sub {1.44 1.872} repeat 1.44] includetext { /txt [ [barcode 0 0 text1font text1size] ] /text1xalign (center) } if /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /kix dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER kix-- % --BEGIN ENCODER japanpost-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear-- % --DESC: Japan Post 4 State Customer Code % --EXAM: 6540123789-A-K-Z % --EXOP: includetext includecheckintext % --RNDR: renlinear % --FMLY: Postal Symbols %%BeginResource: uk.co.terryburton.bwipp japanpost 0.0 2026052800 79055 82183 %%BeginData: 209 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /japanpost.encs [ (300) (330) (312) (132) (321) (303) (123) (231) (213) (033) (030) % 0-9 and "-" (120) (102) (210) (012) (201) (021) (003) (333) % C1-C8 (31) (13) % ST EN ] readonly def /japanpost.barchars (0123456789-ABCDEFGHIJKLMNOPQRSTUVWXYZ) readonly def /japanpost { 32 dict begin { /dontdraw false def /includetext false def % Enable/disable text /includecheckintext false def /text1font /Courier def /text1size 10.0 def /text1yoffset -7.0 def /height -1.0 def /width 0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def barcode () eq { /bwipp.japanpostEmptyData (The data must not be empty) //raiseerror exec } if % % Validate the input % barcode { dup dup 48 ge exch 57 le and exch % 0-9 dup dup 65 ge exch 90 le and exch % A-Z 45 eq or or not { % "-" /bwipp.japanpostBadCharacter (Japan Post must contain only digits, capital letters and the dash symbol) //raiseerror exec } if } forall /barlen barcode length def % % Apply AST spec overrides and resolve physical specification % /japanpost ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec /encstr 20 1 add 3 mul 4 add string def /digits 20 array def % % Put start character % encstr 0 //japanpost.encs 19 get putinterval /checksum 0 def /j 0 def /i 0 def true 0 1 barlen 1 sub { /i exch def barcode i 1 getinterval //japanpost.barchars exch search pop % Discard true leaving pre length /indx exch def % indx is the length of pre pop pop % Discard match and post indx 11 ge indx 37 lt and { % Insert escape j 18 gt {pop false exit} if % Should fit in 20 chars % 11-20: C1 (11) % 21-30: C2 (12) % 31-36: C3 (13) /digit indx 1 sub 10 idiv 10 add def encstr j 3 mul 2 add //japanpost.encs digit get putinterval /checksum checksum digit add def digits j digit put /j j 1 add def } if j 19 gt {pop false exit} if % Should fit in 20 chars /digit 0 def indx 37 eq { /digit 14 def % space (C14) } if indx 11 ge indx 37 lt and { /digit indx 1 sub 10 mod def } if indx 11 lt { /digit indx def } if encstr j 3 mul 2 add //japanpost.encs digit get putinterval % space /checksum checksum digit add def digits j digit put /j j 1 add def } for not { /bwipp.japanpostTooLong (The input is too long) //raiseerror exec } if % % Fill spaces (c14) at right end % j 1 20 1 sub { /k exch def encstr k 3 mul 2 add //japanpost.encs 14 get putinterval /checksum checksum 14 add def digits k 14 put } for % % Put the checksum character % /checksum checksum 19 mod 19 exch sub def encstr 2 20 3 mul add //japanpost.encs checksum get putinterval /text includecheckintext { barlen 1 add string dup 0 barcode putinterval dup barlen //japanpost.barchars checksum 1 getinterval putinterval } { barcode } ifelse def % % Put end character % encstr 20 1 add 3 mul 2 add //japanpost.encs 20 get putinterval /height /resolve_height //render exec dup -1 eq { pop 0.175 } if def /bbs 21 3 mul 4 add array def /bhs bbs length array def 0 1 bbs length 1 sub { /i exch def /enc encstr i 1 getinterval def /bunit 0 def /hunit 0 def enc (0) eq { /bunit 3 def /hunit 2 def } if enc (1) eq { /bunit 0 def /hunit 5 def } if enc (2) eq { /bunit 3 def /hunit 5 def } if enc (3) eq { /bunit 0 def /hunit 8 def } if bbs i bunit height mul 8 div put bhs i hunit height mul 8 div put } for << /ren /renlinear /bbs bbs /bhs bhs /sbs [bhs length 1 sub {1.44 1.872} repeat 1.44] includetext { /txt [ [text 0 0 text1font text1size] ] /text1xalign (center) } if /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /japanpost dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER japanpost-- % --BEGIN ENCODER msi-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear-- % --DESC: MSI Modified Plessey % --EXAM: 0123456789 % --EXOP: includetext includecheck includecheckintext % --RNDR: renlinear % --FMLY: Less-used Symbols %%BeginResource: uk.co.terryburton.bwipp msi 0.0 2026052800 102168 108642 %%BeginData: 207 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /msi.encs [ (12121212) (12121221) (12122112) (12122121) (12211212) (12211221) (12212112) (12212121) (21121212) (21121221) (21) (121) ] readonly def /msi.barchars (0123456789) readonly def % % Checksum function lookup dictionary % /msi.checkfunc << /mod10 { mod10 } bind /mod1010 { mod10 mod10 } bind /mod11 { mod11 } bind /ncrmod11 { ncrmod11 } bind /mod1110 { mod11 mod10 } bind /ncrmod1110 { ncrmod11 mod10 } bind >> readonly def /msi { 16 dict begin { /dontdraw false def /includecheck false def % Enable/disable checkdigit /includetext false def % Enable/disable text /includecheckintext false def /checktype (unset) def /badmod11 false def /text1font /Courier def /text1size 10.0 def /text1yoffset -7.0 def /height -1.0 def /width 0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def barcode length 500 gt { /bwipp.msiinputTooLong (The input data is too long) //raiseerror exec } if /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def checktype (unset) ne includecheck not and { /bwipp.msiCheckTypeWithoutCheck (checktype requires includecheck) //raiseerror exec } if badmod11 checktype (mod11) ne checktype (ncrmod11) ne and checktype (mod1110) ne and checktype (ncrmod1110) ne and and { /bwipp.msiBadMod11Mismatch (badmod11 requires checktype with mod11) //raiseerror exec } if checktype (unset) eq { /checktype (mod10) def } if % % Validate the input % barcode { dup 48 lt exch 57 gt or { /bwipp.msiBadCharacter (MSI must contain only digits) //raiseerror exec } if } forall /barlen barcode length def % Length of the code /txtlen barlen def % % Apply AST spec overrides and resolve physical specification % /msi ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec /mod10 { /code exch def 0 0 code {48 sub exch 10 mul add exch} forall pop 2 mul 0 {1 index 10 mod add exch 10 idiv dup 0 eq {pop exit} if exch} loop 0 0 code {48 sub add exch} forall exch pop add 10 mod 10 exch sub 10 mod code length 1 add string dup 0 code putinterval dup code length 4 -1 roll 48 add put } def /mod11 { /code exch def code length 1 sub code {48 sub exch dup 1 sub exch 6 mod 2 add exch} forall pop 0 code length {3 1 roll mul add} repeat 11 mod 11 exch sub 11 mod dup 10 eq { badmod11 { pop code length 2 add string dup 0 code putinterval dup code length (10) putinterval } { pop /bwipp.msiBadMod11NotSpecified (mod11 check digit is 10 but badmod11 not specified) //raiseerror exec } ifelse } { code length 1 add string dup 0 code putinterval dup code length 4 -1 roll 48 add put } ifelse } def /ncrmod11 { /code exch def code length 1 sub code {48 sub exch dup 1 sub exch 8 mod 2 add exch} forall pop 0 code length {3 1 roll mul add} repeat 11 mod 11 exch sub 11 mod dup 10 eq { badmod11 { pop code length 2 add string dup 0 code putinterval dup code length (10) putinterval } { pop /bwipp.msiBadMod11NotSpecified (mod11 check digit is 10 but badmod11 not specified) //raiseerror exec } ifelse } { code length 1 add string dup 0 code putinterval dup code length 4 -1 roll 48 add put } ifelse } def % % Calculate checksum % includecheck { //msi.checkfunc checktype 2 copy known not { pop pop /bwipp.msiBadCharacter (MSI checktype must be mod10, mod1010, mod11, ncrmod11, mod1110 or ncrmod1110) //raiseerror exec } if get barcode exch exec /barcode exch def /barlen barcode length def includecheckintext {/txtlen barlen def} if } if /sbs barlen 8 mul 5 add string def % % Put start character % sbs 0 //msi.encs 10 get putinterval 0 1 barlen 1 sub { /i exch def barcode i 1 getinterval //msi.barchars exch search pop % Discard true leaving pre length /indx exch def % indx is the length of pre pop pop % Discard seek and post /enc //msi.encs indx get def % Get the indxth encoding sbs i 8 mul 2 add enc putinterval % Put encoded digit into sbs } for % % Put the end character % sbs barlen 8 mul 2 add //msi.encs 11 get putinterval /height /resolve_height //render exec dup -1 eq { pop 1.0 } if def << /ren /renlinear /sbs [sbs {48 sub} forall] /bhs [sbs length 1 add 2 idiv {height} repeat] /bbs [sbs length 1 add 2 idiv {0} repeat] includetext { /txt [ [barcode 0 txtlen getinterval 0 0 text1font text1size] ] /text1xalign (center) } if /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /msi dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER msi-- % --BEGIN ENCODER plessey-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear-- % --DESC: Plessey UK % --EXAM: 01234ABCD % --EXOP: includetext includecheckintext % --RNDR: renlinear % --FMLY: Less-used Symbols %%BeginResource: uk.co.terryburton.bwipp plessey 0.0 2026052800 86625 86274 %%BeginData: 219 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 17 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /plessey.barchars (0123456789ABCDEF) readonly def /plessey.encs [ (14141414) (32141414) (14321414) (32321414) (14143214) (32143214) (14323214) (32323214) (14141432) (32141432) (14321432) (32321432) (14143232) (32143232) (14323232) (32323232) (32321432) (541412323) (323) ] readonly def /plessey.checksalt [ 1 1 1 1 0 1 0 0 1 ] readonly def /plessey.checkinit [ 0 0 0 0 0 0 0 0 ] readonly def /plessey.latevars dup 2 dict def load /init { currentglobal true setglobal //plessey.latevars begin /charvals 16 dict def 0 1 15 { charvals exch dup //plessey.barchars exch 1 getinterval exch put } for /charvals charvals readonly def /init { //plessey.latevars {def} forall } def end //plessey.latevars /init get exec setglobal } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//plessey.latevars /init get exec} if } {pop} ifelse /plessey { 32 dict begin { /dontdraw false def /includetext false def % Enable/disable text /validatecheck false def /includecheckintext false def /unidirectional false def /text1font /Courier def /text1size 10.0 def /text1yoffset -7.0 def /height -1.0 def /width 0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def //plessey.latevars /init get exec barcode () eq { /bwipp.plesseyEmptyData (The data must not be empty) //raiseerror exec } if barcode length 500 gt { /bwipp.plesseyInputTooLong (The input data is too long) //raiseerror exec } if % % Validate the input % 0 1 barcode length 1 sub { barcode exch 1 getinterval charvals exch known not { /bwipp.plesseyBadCharacter (Plessey must contain only digits and letters A B C D E F) //raiseerror exec } if } for validatecheck barcode length 2 lt and { /bwipp.plesseyBadLength (Plessey with check digits must be at least 2 characters) //raiseerror exec } if /barlen barcode length validatecheck {2 sub} if def % % Apply AST spec overrides and resolve physical specification % /plessey ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec % % Calculate the checksums % /checkbits barlen 4 mul 8 add array def checkbits barlen 4 mul //plessey.checkinit putinterval 0 1 barlen 1 sub { /i exch def /indx charvals barcode i 1 getinterval get def checkbits i 4 mul [ indx 1 and indx -1 bitshift 1 and indx -2 bitshift 1 and indx -3 bitshift ] putinterval } for 0 1 barlen 4 mul 1 sub { /i exch def checkbits i get 1 eq { 0 1 8 { /j exch def checkbits i j add checkbits i j add get //plessey.checksalt j get xor put } for } if } for /checkval 0 def 0 1 7 { /i exch def /checkval checkval 2 i exp cvi checkbits barlen 4 mul i add get mul add def } for /checksum1 checkval 15 and def /checksum2 checkval -4 bitshift def validatecheck { barcode barlen get //plessey.barchars checksum1 get ne barcode barlen 1 add get //plessey.barchars checksum2 get ne or { /bwipp.plesseyBadCheckDigits (Incorrect Plessey check digits provided) //raiseerror exec } if /barcode barcode 0 barlen getinterval def } if /sbs barlen 8 mul unidirectional {27} {33} ifelse add string def % % Put start character % sbs 0 //plessey.encs 16 get putinterval 0 1 barlen 1 sub { /i exch def /indx charvals barcode i 1 getinterval get def sbs i 8 mul 8 add //plessey.encs indx get putinterval } for % % Put the checksum characters % sbs barlen 8 mul 8 add //plessey.encs checksum1 get putinterval sbs barlen 8 mul 16 add //plessey.encs checksum2 get putinterval /text includecheckintext { barlen 2 add string dup 0 barcode putinterval dup barlen //plessey.barchars checksum1 1 getinterval putinterval dup barlen 1 add //plessey.barchars checksum2 1 getinterval putinterval } { barcode } ifelse def % % Put end character % sbs barlen 8 mul 24 add //plessey.encs unidirectional {18} {17} ifelse get putinterval /height /resolve_height //render exec dup -1 eq { pop 1.0 } if def << /ren /renlinear /sbs [sbs {48 sub} forall] /bhs [sbs length 1 add 2 idiv {height} repeat] /bbs [sbs length 1 add 2 idiv {0} repeat] includetext { /txt [ [text 0 0 text1font text1size] ] /text1xalign (center) } if /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /plessey dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER plessey-- % --BEGIN ENCODER telepen-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor render renlinear-- % --DESC: Telepen % --EXAM: ABCDEF % --EXOP: includetext % --RNDR: renlinear % --FMLY: Less-used Symbols %%BeginResource: uk.co.terryburton.bwipp telepen 0.0 2026052800 89074 82001 %%BeginData: 219 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /telepen.encs [ (31313131) (1131313111) (33313111) (1111313131) (3111313111) (11333131) (13133131) (111111313111) (31333111) (1131113131) (33113131) (1111333111) (3111113131) (1113133111) (1311133111) (111111113131) (3131113111) (11313331) (333331) (111131113111) (31113331) (1133113111) (1313113111) (1111113331) (31131331) (113111113111) (3311113111) (1111131331) (311111113111) (1113111331) (1311111331) (11111111113111) (31313311) (1131311131) (33311131) (1111313311) (3111311131) (11333311) (13133311) (111111311131) (31331131) (1131113311) (33113311) (1111331131) (3111113311) (1113131131) (1311131131) (111111113311) (3131111131) (1131131311) (33131311) (111131111131) (3111131311) (1133111131) (1313111131) (111111131311) (3113111311) (113111111131) (3311111131) (111113111311) (311111111131) (111311111311) (131111111311) (11111111111131) (3131311111) (11313133) (333133) (111131311111) (31113133) (1133311111) (1313311111) (1111113133) (313333) (113111311111) (3311311111) (11113333) (311111311111) (11131333) (13111333) (11111111311111) (31311133) (1131331111) (33331111) (1111311133) (3111331111) (11331133) (13131133) (111111331111) (3113131111) (1131111133) (33111133) (111113131111) (3111111133) (111311131111) (131111131111) (111111111133) (31311313) (113131111111) (3331111111) (1111311313) (311131111111) (11331313) (13131313) (11111131111111) (3133111111) (1131111313) (33111313) (111133111111) (3111111313) (111313111111) (131113111111) (111111111313) (313111111111) (1131131113) (33131113) (11113111111111) (3111131113) (113311111111) (131311111111) (111111131113) (3113111113) (11311111111111) (331111111111) (111113111113) (31111111111111) (111311111113) (131111111113) (1111111111111111) ] readonly def /telepen { 32 dict begin { /numeric false def /dontdraw false def /includetext false def % Enable/disable text /text1font /Courier def /text1size 10.0 def /text1yoffset -7.0 def /height -1.0 def /width 0 def /parse false def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def barcode length 500 gt { /bwipp.telepeninputTooLong (The input data is too long) //raiseerror exec } if /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Parse ordinals of the form ^NNN to ASCII % /fncvals << /parse parse /parseonly true /parsefnc false >> def barcode fncvals //parseinput exec /barcode exch def /barlen barcode length def options (parse) undef numeric barlen 2 mod 0 ne and { /bwipp.telepenNumericOddLength (Telepen Numeric must have an even length) //raiseerror exec } if % % Apply AST spec overrides and resolve physical specification % /telepen ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec /sbs barlen 16 mul 48 add string def % % Put the start character ASCII 95 % /enc //telepen.encs 95 get def sbs 0 enc putinterval /l enc length def /checksum 0 def /i 0 def /j 0 def { % loop i barlen eq {exit} if numeric { barcode i get 16 gt { % 00-99 or 0X-9X /np barcode i 2 getinterval def np 0 get dup 48 lt exch 57 gt or np 1 get dup 48 lt 1 index 57 gt or exch 88 eq not and or { -1 } { np 0 get 48 sub np 1 get 48 sub dup 40 ne { exch 10 mul add 10 add } { pop } ifelse 17 add } ifelse dup -1 eq { pop /bwipp.telepenInvalidNumericCharacter (Telepen Numeric may contain only digits, or X in even positions) //raiseerror exec } if /indx exch def % numeric pair displayed via barcode /i i 2 add def } { % Ordinal values 0-16 /indx barcode i get def /i i 1 add def } ifelse } { % ASCII mode /indx barcode i get def indx 127 gt { /bwipp.telepenInvalidAlphaCharacter (Telepen Alpha characters must have ordinal values 0 to 127) //raiseerror exec } if /i i 1 add def } ifelse /checksum checksum indx add def /enc //telepen.encs indx get def sbs l enc putinterval % Put encoded digit into sbs /l l enc length add def /j j 1 add def } loop % % Put the checksum character % /checksum 127 checksum 127 mod sub 127 mod def /enc //telepen.encs checksum get def sbs l enc putinterval /l l enc length add def % % Put the end character ASCII 122 % /enc //telepen.encs 122 get def sbs l enc putinterval /l l enc length add def % % Shrink sbs to fit exactly % /sbs sbs 0 l getinterval def % Build display text: replace non-printable chars with spaces /text barcode length string def 0 1 barcode length 1 sub { /i exch def /c barcode i get def text i c 32 ge c 126 le and { c } { 32 } ifelse put } for /sbs [sbs {48 sub} forall] def /height /resolve_height //render exec dup -1 eq { pop 1.0 } if def << /ren /renlinear /sbs sbs /bhs [sbs length 1 add 2 idiv {height} repeat] /bbs [sbs length 1 add 2 idiv {0} repeat] includetext { /txt [ [text 0 0 text1font text1size] ] /text1xalign (center) } if /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /telepen dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER telepen-- % --BEGIN ENCODER telepennumeric-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor render renlinear telepen-- % --DESC: Telepen Numeric % --EXAM: 01234567 % --EXOP: includetext % --RNDR: renlinear % --FMLY: Less-used Symbols %%BeginResource: uk.co.terryburton.bwipp telepennumeric 0.0 2026052800 66356 69514 %%BeginData: 47 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 4 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put dup /telepen dup /uk.co.terryburton.bwipp findresource put begin /telepennumeric { 4 dict begin { /dontdraw false def null /apply //processoptions exec /options exch def /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Get the result of encoding with telepen with numeric=true % options (numeric) true put /uk.co.terryburton.bwipp._dontdraw true def barcode options //telepen exec /args exch def args (opt) options put args _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /telepennumeric dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER telepennumeric-- % --BEGIN ENCODER posicode-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor render renlinear-- % --DESC: PosiCode % --EXAM: ABC123 % --EXOP: version=b inkspread=-0.5 parsefnc includetext % --RNDR: renlinear % --FMLY: Less-used Symbols %%BeginResource: uk.co.terryburton.bwipp posicode 0.0 2026052800 135805 128374 %%BeginData: 521 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 17 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin % % Special function characters % /posicode.la0 -1 def /posicode.la1 -2 def /posicode.la2 -3 def /posicode.sf0 -4 def /posicode.sf1 -5 def /posicode.sf2 -6 def /posicode.fn1 -7 def /posicode.fn2 -8 def /posicode.fn3 -9 def /posicode.fn4 -10 def /la0 //posicode.la0 def /la1 //posicode.la1 def /la2 //posicode.la2 def /sf0 //posicode.sf0 def /sf1 //posicode.sf1 def /sf2 //posicode.sf2 def /fn1 //posicode.fn1 def /fn2 //posicode.fn2 def /fn3 //posicode.fn3 def /fn4 //posicode.fn4 def % % Character maps for each state % /posicode.charmapsnormal [ % 0 1 2 0 1 2 0 1 2 [ (0) (^) (') ] [ (1) (;) 27 ] [ (2) (<) 28 ] % 0-2 [ (3) (=) 29 ] [ (4) (>) 30 ] [ (5) (?) 31 ] % 3-5 [ (6) (@) (!) ] [ (7) ([) (") ] [ (8) 92 (#) ] % 6-8 [ (9) (]) (&) ] [ (A) (a) 1 ] [ (B) (b) 2 ] % 9-11 [ (C) (c) 3 ] [ (D) (d) 4 ] [ (E) (e) 5 ] % 12-14 [ (F) (f) 6 ] [ (G) (g) 7 ] [ (H) (h) 8 ] % 15-17 [ (I) (i) 9 ] [ (J) (j) 10 ] [ (K) (k) 11 ] % 18-20 [ (L) (l) 12 ] [ (M) (m) 13 ] [ (N) (n) 14 ] % 21-23 [ (O) (o) 15 ] [ (P) (p) 16 ] [ (Q) (q) 17 ] % 24-26 [ (R) (r) 18 ] [ (S) (s) 19 ] [ (T) (t) 20 ] % 27-29 [ (U) (u) 21 ] [ (V) (v) 22 ] [ (W) (w) 23 ] % 30-32 [ (X) (x) 24 ] [ (Y) (y) 25 ] [ (Z) (z) 26 ] % 33-35 [ (-) (_) 40 ] [ (.) (`) 41 ] [ ( ) 127 0 ] % 36-38 [ ($) ({) (*) ] [ (/) (|) (,) ] [ (+) (}) (:) ] % 39-41 [ (%) (~) fn1 ] [ la1 la0 fn2 ] [ sf1 sf0 fn3 ] % 42-44 [ sf2 sf2 fn4 ] % 45 ] readonly def /posicode.charmapslimited [ [ (0) -98 -98 ] [ (1) -98 -98 ] [ (2) -98 -98 ] % 0-2 [ (3) -98 -98 ] [ (4) -98 -98 ] [ (5) -98 -98 ] % 3-5 [ (6) -98 -98 ] [ (7) -98 -98 ] [ (8) -98 -98 ] % 6-8 [ (9) -98 -98 ] [ (A) -98 -98 ] [ (B) -98 -98 ] % 9-11 [ (C) -98 -98 ] [ (D) -98 -98 ] [ (E) -98 -98 ] % 12-14 [ (F) -98 -98 ] [ (G) -98 -98 ] [ (H) -98 -98 ] % 15-17 [ (I) -98 -98 ] [ (J) -98 -98 ] [ (K) -98 -98 ] % 18-20 [ (L) -98 -98 ] [ (M) -98 -98 ] [ (N) -98 -98 ] % 21-23 [ (O) -98 -98 ] [ (P) -98 -98 ] [ (Q) -98 -98 ] % 24-26 [ (R) -98 -98 ] [ (S) -98 -98 ] [ (T) -98 -98 ] % 27-29 [ (U) -98 -98 ] [ (V) -98 -98 ] [ (W) -98 -98 ] % 30-32 [ (X) -98 -98 ] [ (Y) -98 -98 ] [ (Z) -98 -98 ] % 33-35 [ (-) -98 -98 ] [ (.) -98 -98 ] % 36-37 ] readonly def /posicode.encmaps << % ";"=11, "<"=12 /a [ (141112) (131212) (121312) (111412) (131113) (121213) (111313) (121114) (111214) (111115) (181111) (171211) (161311) (151411) (141511) (131611) (121711) (111811) (171112) (161212) (151312) (141412) (131512) (121612) (111712) (161113) (151213) (141313) (131413) (121513) (111613) (151114) (141214) (131314) (121414) (111514) (141115) (131215) (121315) (111415) (131116) (121216) (111316) (121117) (111217) (111118) (1<111112) (111111111;1) ] /b [ (151213) (141313) (131413) (121513) (141214) (131314) (121414) (131215) (121315) (121216) (191212) (181312) (171412) (161512) (151612) (141712) (131812) (121912) (181213) (171313) (161413) (151513) (141613) (131713) (121813) (171214) (161314) (151414) (141514) (131614) (121714) (161215) (151315) (141415) (131515) (121615) (151216) (141316) (131416) (121516) (141217) (131317) (121417) (131218) (121318) (121219) (1<121312) (121212121<1) ] /limiteda [ (111411) (111312) (111213) (111114) (121311) (121212) (121113) (141111) (131211) (131112) (171111) (161211) (151311) (141411) (131511) (121611) (111711) (161112) (151212) (141312) (131412) (121512) (111612) (151113) (141213) (131313) (121413) (111513) (141114) (131214) (121314) (111414) (131115) (121215) (111315) (121116) (111216) (111117) (151111) (1) ] /limitedb [ (121512) (121413) (121314) (121215) (131412) (131313) (131214) (151212) (141312) (141213) (181212) (171312) (161412) (151512) (141612) (131712) (121812) (171213) (161313) (151413) (141513) (131613) (121713) (161214) (151314) (141414) (131514) (121614) (151215) (141315) (131415) (121515) (141216) (131316) (121416) (131217) (121317) (121218) (141212) (1) ] >> readonly def /posicode.c2w [ [ 495 330 210 126 70 35 15 5 ] [ 165 120 84 56 35 20 10 4 ] [ 45 36 28 21 15 10 6 3 ] [ 9 8 7 6 5 4 3 2 ] [ 1 1 1 1 1 1 1 1 ] ] readonly def /posicode.latevars dup 8 dict def load /init { currentglobal true setglobal //posicode.latevars begin % % Pre-compute charvals for normal charmaps % /charvals_normal [ //posicode.charmapsnormal length dict //posicode.charmapsnormal length dict //posicode.charmapsnormal length dict ] def 0 1 //posicode.charmapsnormal length 1 sub { /i exch def /encs //posicode.charmapsnormal i get def 0 1 2 { /j exch def encs j get dup type /stringtype eq {0 get} if charvals_normal j get exch i put } for } for /charvals_normal charvals_normal readonly def % % Pre-compute charvals for limited charmaps % /charvals_limited [ //posicode.charmapslimited length dict //posicode.charmapslimited length dict //posicode.charmapslimited length dict ] def 0 1 //posicode.charmapslimited length 1 sub { /i exch def /encs //posicode.charmapslimited i get def 0 1 2 { /j exch def encs j get dup type /stringtype eq {0 get} if charvals_limited j get exch i put } for } for /charvals_limited charvals_limited readonly def /init { //posicode.latevars {def} forall } def end //posicode.latevars /init get exec setglobal } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//posicode.latevars /init get exec} if } {pop} ifelse /posicode { 64 dict begin { /dontdraw false def /includetext false def % Enable/disable text /text1font /Courier def /text1size 10.0 def /text1xoffset 0.0 def /text1yoffset -7.0 def /height -1.0 def /width 0 def /encoding (auto) def /version (a) def /checkoffset 0 def /raw false def /parse false def /parsefnc false def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def barcode length 500 gt { /bwipp.posicodeinputTooLong (The input data is too long) //raiseerror exec } if % % Apply AST spec overrides and resolve physical specification % /posicode ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def //posicode.latevars /init get exec version (a) ne version (b) ne and version (limiteda) ne and version (limitedb) ne and { /bwipp.posicodeInvalidVersion (The version must be either a, b, limiteda or limitedb) //raiseerror exec } if /charmaps version (a) eq version (b) eq or {//posicode.charmapsnormal} {//posicode.charmapslimited} ifelse def % % Select the pre-computed charvals for the selected version % /charvals version (a) eq version (b) eq or {charvals_normal} {charvals_limited} ifelse def /set0 charvals 0 get def /set1 charvals 1 get def /set2 charvals 2 get def % % Validate the input if limited % version (limiteda) eq version (limitedb) eq or { 0 1 barcode length 1 sub { barcode exch 1 getinterval 0 get set0 exch known not { /bwipp.posicodeBadCharacter (Posicode limited must contain only digits, capital letters, and the symbols - and .) //raiseerror exec } if } for } if raw {/encoding (raw) def} if encoding (raw) eq { /cws barcode length array def /i 0 def /j 0 def { % loop i barcode length 3 sub ge {exit} if barcode i get 94 ne {exit} if barcode i 1 add 3 getinterval false 1 index { dup 48 lt exch 57 gt or { pop true } if } forall { pop exit } if cvi /cw exch def cw 45 gt { /bwipp.posicodeBadRawCodeword (Raw codewords must be 0 to 45) //raiseerror exec } if cws j cw put /i i 4 add def /j j 1 add def } loop i barcode length ne { /bwipp.posicodeBadRawFormat (Raw codewords must be formatted as ^NNN) //raiseerror exec } if /cws cws 0 j getinterval def /text () def } if encoding (auto) eq { % % Parse the input % /fncvals << /parse parse /parsefnc parsefnc (FNC1) //posicode.fn1 (FNC2) //posicode.fn2 (FNC3) //posicode.fn3 % (FNC4) fn4 Not user accessible as encoded automatically >> def barcode fncvals //parseinput exec /msg exch def /msglen msg length def /text msglen string def 0 1 msglen 1 sub { /i exch def text i msg i get dup 0 lt { pop 32 } if put } for % % Standard and extended ASCII runlength at position % /numSA [ msglen {0} repeat 0 ] def /numEA [ msglen {0} repeat 0 ] def msglen 1 sub -1 0 { /i exch def msg i get 0 ge { msg i get 128 ge { numEA i numEA i 1 add get 1 add put } { numSA i numSA i 1 add get 1 add put } ifelse } if } for % % FNC4 codeword insertion for extended ASCII % /ea false def mark 0 1 msglen 1 sub { /i exch def /c msg i get def ea c 128 lt xor not c 0 ge and { % Other mode required ea {numSA} {numEA} ifelse i get dup % Runlength of other mode i add msglen eq {3} {5} ifelse % Does run terminate symbol lt { % Shift //posicode.fn4 } { % Latch //posicode.fn4 //posicode.fn4 /ea ea not def } ifelse } if c 0 ge {c 127 and} {c} ifelse } for counttomark array astore /msg exch def pop /msglen msg length def % % Convert the input message to codewords % /enc { exch get cws exch j exch put /j j 1 add def } def /cws msglen 2 mul array def /i 0 def /j 0 def /cset (set0) def { i msglen eq {exit} if { % common exit % % Read next two characters % /char1 msg i get def /char2 i 1 add msglen lt {msg i 1 add get} {-99} ifelse def % % If current mode is sufficient then directly encode % cset load char1 known { char1 cset load enc /i i 1 add def exit } if % % If char1 is in set2 then shift encode % set2 char1 known { //posicode.sf2 cset load enc char1 set2 enc /i i 1 add def exit } if % % If char2 is also not in this set then latch else shift encode % cset load char2 known not { cset (set0) eq { //posicode.la1 cset load enc /cset (set1) def } { //posicode.la0 cset load enc /cset (set0) def } ifelse exit } { cset (set0) eq { //posicode.sf1 cset load enc char1 set1 enc } { //posicode.sf0 cset load enc char1 set0 enc } ifelse /i i 1 add def exit } ifelse exit } loop } loop /cws cws 0 j getinterval def } if % auto encoding % % Create an array containing the character mappings % //posicode.encmaps version get /encs exch def /v 0 def cws { /cw exch def 6 { cw v xor 1 and 0 ne { /v v 7682 xor def } if /v v -1 bitshift def /cw cw -1 bitshift def } repeat } forall /v v checkoffset add def version (limiteda) eq version (limitedb) eq or { /v v 1023 and def v 824 gt v 853 lt and { /v v 292 add def } if } { /v v 1023 and 45 add def } ifelse /d [ 2 2 2 2 2 2 ] def /r 0 def /c 0 def /w 0 def /sum 0 def { sum v eq {exit} if /t sum //posicode.c2w r get c get add def t v eq { /w w 1 add def d r w 2 add put /sum t def } if t v gt { d r w 2 add put /r r 1 add def /w 0 def } if t v lt { /c c 1 add def /w w 1 add def /sum t def } if } loop 20 0 1 4 {d exch get sub} for d exch 5 exch put version (b) eq version (limitedb) eq or { /d [ d {1 add} forall ] def } if /cbs (111111111111) 12 string copy def 5 -1 0 { /i exch def cbs 5 i sub 2 mul 1 add d i get 47 add put } for % % Concatenate the space bar successions % /sbs cws length 6 mul 31 add string def encs encs length 2 sub get dup sbs exch 0 exch putinterval length /j exch def 0 1 cws length 1 sub { /i exch def sbs j encs cws i get get putinterval /j j 6 add def } for sbs j cbs putinterval /j j 12 add def encs encs length 1 sub get dup sbs exch j exch putinterval length j add /j exch def /sbs sbs 0 j getinterval def /height /resolve_height //render exec dup -1 eq { pop 1.0 } if def << /ren /renlinear /sbs [sbs {48 sub} forall] /bhs [sbs length 1 add 2 idiv {height} repeat] /bbs [sbs length 1 add 2 idiv {0} repeat] /txt [ [text text1xoffset text1yoffset text1font text1size] ] /text1xalign (center) /borderleft << /a 0.0 /b 0.0 /limiteda 12.0 /limitedb 13.0 >> version get /borderright << /a 0.0 /b 0.0 /limiteda 12.0 /limitedb 13.0 >> version get /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /posicode dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER posicode-- % --BEGIN ENCODER codablockf-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor render renmatrix-- % --DESC: Codablock F % --EXAM: CODABLOCK F 34567890123456789010040digit % --EXOP: columns=8 % --RNDR: renmatrix % --FMLY: Less-used Symbols %%BeginResource: uk.co.terryburton.bwipp codablockf 0.0 2026052800 164740 163950 %%BeginData: 689 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 17 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put begin /codablockf.swa -1 def /codablockf.swb -2 def /codablockf.swc -3 def /codablockf.sft -4 def /codablockf.fn1 -5 def /codablockf.fn2 -6 def /codablockf.fn3 -7 def /codablockf.fn4 -8 def /codablockf.sta -9 def /codablockf.stp -10 def /swa //codablockf.swa def /swb //codablockf.swb def /swc //codablockf.swc def /sft //codablockf.sft def /fn1 //codablockf.fn1 def /fn2 //codablockf.fn2 def /fn3 //codablockf.fn3 def /fn4 //codablockf.fn4 def /sta //codablockf.sta def /stp //codablockf.stp def % % Character maps for each state % /codablockf.charmaps [ % A B C A B C A B C [ 32 32 (00) ] [ (!) (!) (01) ] [ (") (") (02) ] % 0-2 [ (#) (#) (03) ] [ ($) ($) (04) ] [ (%) (%) (05) ] % 3-5 [ (&) (&) (06) ] [ (') (') (07) ] [ 40 40 (08) ] % 6-8 [ 41 41 (09) ] [ (*) (*) (10) ] [ (+) (+) (11) ] % 9-11 [ (,) (,) (12) ] [ (-) (-) (13) ] [ (.) (.) (14) ] % 12-14 [ (/) (/) (15) ] [ (0) (0) (16) ] [ (1) (1) (17) ] % 15-17 [ (2) (2) (18) ] [ (3) (3) (19) ] [ (4) (4) (20) ] % 18-20 [ (5) (5) (21) ] [ (6) (6) (22) ] [ (7) (7) (23) ] % 21-23 [ (8) (8) (24) ] [ (9) (9) (25) ] [ (:) (:) (26) ] % 24-26 [ (;) (;) (27) ] [ (<) (<) (28) ] [ (=) (=) (29) ] % 27-29 [ (>) (>) (30) ] [ (?) (?) (31) ] [ (@) (@) (32) ] % 30-32 [ (A) (A) (33) ] [ (B) (B) (34) ] [ (C) (C) (35) ] % 33-35 [ (D) (D) (36) ] [ (E) (E) (37) ] [ (F) (F) (38) ] % 36-38 [ (G) (G) (39) ] [ (H) (H) (40) ] [ (I) (I) (41) ] % 39-41 [ (J) (J) (42) ] [ (K) (K) (43) ] [ (L) (L) (44) ] % 42-44 [ (M) (M) (45) ] [ (N) (N) (46) ] [ (O) (O) (47) ] % 45-47 [ (P) (P) (48) ] [ (Q) (Q) (49) ] [ (R) (R) (50) ] % 48-50 [ (S) (S) (51) ] [ (T) (T) (52) ] [ (U) (U) (53) ] % 51-53 [ (V) (V) (54) ] [ (W) (W) (55) ] [ (X) (X) (56) ] % 54-56 [ (Y) (Y) (57) ] [ (Z) (Z) (58) ] [ ([) ([) (59) ] % 57-59 [ 92 92 (60) ] [ (]) (]) (61) ] [ (^) (^) (62) ] % 60-62 [ (_) (_) (63) ] [ 0 (`) (64) ] [ 1 (a) (65) ] % 63-65 [ 2 (b) (66) ] [ 3 (c) (67) ] [ 4 (d) (68) ] % 66-68 [ 5 (e) (69) ] [ 6 (f) (70) ] [ 7 (g) (71) ] % 69-71 [ 8 (h) (72) ] [ 9 (i) (73) ] [ 10 (j) (74) ] % 72-74 [ 11 (k) (75) ] [ 12 (l) (76) ] [ 13 (m) (77) ] % 75-77 [ 14 (n) (78) ] [ 15 (o) (79) ] [ 16 (p) (80) ] % 78-80 [ 17 (q) (81) ] [ 18 (r) (82) ] [ 19 (s) (83) ] % 81-83 [ 20 (t) (84) ] [ 21 (u) (85) ] [ 22 (v) (86) ] % 84-86 [ 23 (w) (87) ] [ 24 (x) (88) ] [ 25 (y) (89) ] % 87-89 [ 26 (z) (90) ] [ 27 ({) (91) ] [ 28 (|) (92) ] % 90-92 [ 29 (}) (93) ] [ 30 (~) (94) ] [ 31 127 (95) ] % 93-95 [ fn3 fn3 (96) ] [ fn2 fn2 (97) ] [ sft sft (98) ] % 96-98 [ swc swc (99) ] [ swb fn4 swb ] [ fn4 swa swa ] % 99-101 [ fn1 fn1 fn1 ] [ sta sta sta ] [ stp stp stp ] % 102-104 ] readonly def % % Character encodings % /codablockf.encs [ (212222) (222122) (222221) (121223) (121322) (131222) (122213) (122312) (132212) (221213) (221312) (231212) (112232) (122132) (122231) (113222) (123122) (123221) (223211) (221132) (221231) (213212) (223112) (312131) (311222) (321122) (321221) (312212) (322112) (322211) (212123) (212321) (232121) (111323) (131123) (131321) (112313) (132113) (132311) (211313) (231113) (231311) (112133) (112331) (132131) (113123) (113321) (133121) (313121) (211331) (231131) (213113) (213311) (213131) (311123) (311321) (331121) (312113) (312311) (332111) (314111) (221411) (431111) (111224) (111422) (121124) (121421) (141122) (141221) (112214) (112412) (122114) (122411) (142112) (142211) (241211) (221114) (413111) (241112) (134111) (111242) (121142) (121241) (114212) (124112) (124211) (411212) (421112) (421211) (212141) (214121) (412121) (111143) (111341) (131141) (114113) (114311) (411113) (411311) (113141) (114131) (311141) (411131) (211412) (2331112) ] readonly def /codablockf.latevars dup 8 dict def load /init { currentglobal true setglobal //codablockf.latevars begin % % Invert charmaps to give character to value maps for each state % /charvals [ 105 dict 105 dict 105 dict ] def 0 1 //codablockf.charmaps length 1 sub { /i exch def /encs //codablockf.charmaps i get def 0 1 2 { /j exch def encs j get dup type /stringtype eq {0 get} if % convert string to ASCII if required charvals j get exch i put } for } for /seta charvals 0 get readonly def /setb charvals 1 get readonly def /setc charvals 2 get readonly def /charvals charvals readonly def % % Maps for row indicators and symbol checksums % /abmap [ 64 1 95 {} for 0 1 15 {} for 26 1 63 {} for ] readonly def /cmap [ 0 1 85 {} for ] readonly def /init { //codablockf.latevars {def} forall } def end //codablockf.latevars /init get exec setglobal } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//codablockf.latevars /init get exec} if } {pop} ifelse /codablockf { 64 dict begin { /dontdraw false def /rows -1 def /columns 8 def /rowheight 10 def /sepheight 1 def /parse false def /parsefnc false def /strictspec false def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Apply AST spec overrides and resolve physical specification % /codablockf ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec //codablockf.latevars /init get exec barcode length 25000 gt { /bwipp.codablockfinputTooLong (The input data is too long) //raiseerror exec } if columns 4 lt columns 62 gt or { /bwipp.codablockfBadColumns (Codablock F must have 4 to 62 columns) //raiseerror exec } if rows -1 ne rows 2 lt rows 44 gt or and { /bwipp.codablockfBadRows (Codablock F must have 2 to 44 rows) //raiseerror exec } if rowheight 8 lt rowheight 50 gt or { /bwipp.codablockfBadRowHeight (Codablock F must have rowheight from 8 to 50) //raiseerror exec } if sepheight 1 lt sepheight 5 gt or { /bwipp.codablockfBadSepHeight (Codablock F must have sepheight from 1 to 5) //raiseerror exec } if /c columns 4 ge columns 62 le and {columns} {8} ifelse def /rows rows 2 ge rows 44 le and {rows} {-1} ifelse def % Parse the input /fncvals << /parse parse /parsefnc parsefnc (FNC1) //codablockf.fn1 % (FNC2) fn2 Not permitted for Codablock F (FNC3) //codablockf.fn3 % (FNC4) fn4 Not user accessible as encoded automatically >> def barcode fncvals //parseinput exec /msg exch def /msglen msg length def % % FNC4 codeword insertion for extended ASCII % /kmsg msg def % Keep for k1/k2 check characters calculation mark msg { dup 128 ge {//codablockf.fn4 exch 127 and} if } forall counttomark array astore /msg exch def pop /msglen msg length def % Absolute capacity is 62 columns x 44 rows numeric. msglen 5452 gt { /bwipp.codablockfinputTooLong (The input data is too long) //raiseerror exec } if % % Pre-compute setC digit runlength from each position; two parity % arrays because FNC1 only counts when s is even. Position after an % FNC4 is its second byte, so numsscr exits there. % /numsAtNEven [ msglen 1 add {0} repeat ] def /numsAtSEven [ msglen 1 add {0} repeat ] def /numsAtNOdd [ msglen 1 add {0} repeat ] def /numsAtSOdd [ msglen 1 add {0} repeat ] def msglen 1 sub -1 0 { /i exch def /ch msg i get def i 0 ne { msg i 1 sub get //codablockf.fn4 eq } { false } ifelse { numsAtNEven i 0 put numsAtSEven i 0 put numsAtNOdd i 0 put numsAtSOdd i 0 put } { setc ch known not { numsAtNEven i 0 put numsAtSEven i 0 put numsAtNOdd i 0 put numsAtSOdd i 0 put } { ch //codablockf.fn1 eq { numsAtNEven i 1 numsAtNEven i 1 add get add put numsAtSEven i 2 numsAtSEven i 1 add get add put numsAtNOdd i 0 put numsAtSOdd i 0 put } { numsAtNEven i 1 numsAtNOdd i 1 add get add put numsAtSEven i 1 numsAtSOdd i 1 add get add put numsAtNOdd i 1 numsAtNEven i 1 add get add put numsAtSOdd i 1 numsAtSEven i 1 add get add put } ifelse } ifelse } ifelse } for /numsscr { dup numsAtNEven exch get exch numsAtSEven exch get } bind def % % Encoding for each alphabet % /enca { seta exch get cws exch j exch put /j j 1 add def } def /encb { setb exch get cws exch j exch put /j j 1 add def } def /encc { dup type /arraytype ne { setc exch get } { aload pop 48 sub exch 48 sub 10 mul add } ifelse cws exch j exch put /j j 1 add def } def % % Character exclusively in either alphabet A or B % /anotb {dup seta exch known exch setb exch known not and} def /bnota {dup setb exch known exch seta exch known not and} def % % Pre-compute relative position of next anotb and next bnota characters % /nextanotb [ msg length {0} repeat 9999 ] def /nextbnota [ msg length {0} repeat 9999 ] def msg length 1 sub -1 0 { /i exch def msg i get anotb { nextanotb i 0 put } { nextanotb i nextanotb i 1 add get 1 add put } ifelse msg i get bnota { nextbnota i 0 put } { nextbnota i nextbnota i 1 add get 1 add put } ifelse } for % % Does a-only come before b-only after given position and vice versa % /abeforeb {dup nextanotb exch get exch nextbnota exch get lt} def /bbeforea {dup nextbnota exch get exch nextanotb exch get lt} def % % Add padding to row % /padrow { { { % common exit cset (seta) eq {//codablockf.swc enca /cset (setc) def exit} if cset (setb) eq {//codablockf.swc encb /cset (setc) def exit} if cset (setc) eq {//codablockf.swb encc /cset (setb) def exit} if } loop } repeat } def % % Encode a if fits in row, allowing for fn4 + possible shift, assuming rem ge 1 % /encafitsrow { rem 2 le msg i get //codablockf.fn4 eq and { % If have 2 left and don't need to shift rem 2 eq msg i 1 add get 95 le and dup { % Return false if not //codablockf.fn4 enca msg i 1 add get enca /i i 2 add def } if } { msg i get enca /i i 1 add def true } ifelse } def % % Encode b if fits in row, allowing for fn4 + possible shift, assuming rem ge 1 % /encbfitsrow { rem 2 le msg i get //codablockf.fn4 eq and { % If have 2 left and don't need to shift rem 2 eq msg i 1 add get 32 ge and dup { % Return false if not //codablockf.fn4 encb msg i 1 add get encb /i i 2 add def } if } { msg i get encb /i i 1 add def true } ifelse } def % % Convert message to codewords % /cws c 5 add 44 mul array def /i 0 def /j 0 def /r 1 def /lastrow false def { lastrow {exit} if r 44 gt { /bwipp.codablockfTooBig (Maximum length exceeded) //raiseerror exec } if % % Add start character and code subset selector % //codablockf.sta enca i msglen lt {i numsscr} {-1 -1} ifelse /nums exch def /nchars exch def { % common exit msglen 0 eq { //codablockf.swb enca /cset (setb) def exit } if nums 2 ge { //codablockf.swc enca /cset (setc) def exit } if i abeforeb { //codablockf.sft enca /cset (seta) def exit } if //codablockf.swb enca /cset (setb) def exit } loop /j j 1 add def % Skip row indicator position % % Main encoding loop % /endofrow false def { /rem c 3 add j c 5 add mod sub def % Codewords to end of row i msglen eq endofrow or {exit} if i numsscr /nums exch def /nchars exch def /remnums nums rem 2 mul gt {rem 2 mul} {nums} ifelse def % % Determine switches and shifts % { % common exit cset (seta) eq cset (setb) eq or remnums 4 ge and msg i get //codablockf.fn1 ne and { remnums 2 mod 0 eq rem 3 ge and { //codablockf.swc cset (seta) eq {enca} {encb} ifelse /cset (setc) def 2 { msg i get //codablockf.fn1 eq { //codablockf.fn1 encc /i i 1 add def } { msg i 2 getinterval encc /i i 2 add def } ifelse } repeat exit } if remnums 2 mod 0 ne rem 4 ge and { msg i get cset (seta) eq {enca} {encb} ifelse /i i 1 add def //codablockf.swc cset (seta) eq {enca} {encb} ifelse /cset (setc) def 2 { msg i get //codablockf.fn1 eq { //codablockf.fn1 encc /i i 1 add def } { msg i 2 getinterval encc /i i 2 add def } ifelse } repeat exit } if } if cset (setb) eq msg i get anotb and rem 2 ge and { i msglen 1 sub lt { i 1 add bbeforea { //codablockf.sft encb msg i get enca /i i 1 add def exit } if } if //codablockf.swa encb /cset (seta) def msg i get enca /i i 1 add def exit } if cset (seta) eq msg i get bnota and rem 2 ge and { i msglen 1 sub lt { i 1 add abeforeb { //codablockf.sft enca msg i get encb /i i 1 add def exit } if } if //codablockf.swb enca /cset (setb) def msg i get encb /i i 1 add def exit } if cset (setc) eq remnums 2 lt and rem 2 ge and { /rem rem 1 sub def i abeforeb { //codablockf.swa encc /cset (seta) def encafitsrow { exit } if } { //codablockf.swb encc /cset (setb) def encbfitsrow { exit } if } ifelse } if % No switches or latches so try to encode cset (seta) eq seta msg i get known and rem 1 ge and { encafitsrow { exit } if } if cset (setb) eq setb msg i get known and rem 1 ge and { encbfitsrow { exit } if } if cset (setc) eq remnums 2 ge and rem 1 ge and { msg i get //codablockf.fn1 eq { //codablockf.fn1 encc /i i 1 add def } { msg i 2 getinterval encc /i i 2 add def } ifelse exit } if % Encoding does not fit in the row /endofrow true def exit } loop % common exit } loop % % Determine whether this is the final row % r rows ge rows -1 eq or r 1 gt and i msglen eq and rem 2 ge and { rem 2 sub padrow /j j 3 add def % Skip symbol and row checksum character positions //codablockf.stp enca /lastrow true def } { rem padrow /j j 1 add def % Skip row checksum character positions //codablockf.stp enca /r r 1 add def } ifelse } loop /cws cws 0 j getinterval def % % Add symbol check characters to last row % /chkmsg kmsg length array def % Using kmsg (pre-fn4 insertion) /j 0 def 0 1 kmsg length 1 sub { /i exch def /char kmsg i get def char 0 ge {chkmsg j char put /j j 1 add def} if char //codablockf.fn1 eq i 0 ne and {chkmsg j 29 put /j j 1 add def} if } for /t1 0 def /t2 0 def /k1 0 def /k2 0 def 0 1 j 1 sub { /i exch def /t1 chkmsg i get i mul 86 mod def /t2 t1 chkmsg i get add 86 mod def /k1 k1 t2 add 86 mod def /k2 k2 t1 add 86 mod def } for cws cws length 4 sub cset (setc) ne {abmap} {cmap} ifelse k1 get put cws cws length 3 sub cset (setc) ne {abmap} {cmap} ifelse k2 get put % % Populate row indicators % cws 2 2 copy 1 sub get 99 ne {abmap} {cmap} ifelse r 2 sub get put 1 1 r 1 sub { /i exch def cws i c 5 add mul 2 add 2 copy 1 sub get 99 ne {abmap} {cmap} ifelse i 42 add get put } for % % Calculate row check characters % 0 1 r 1 sub { cws exch c 5 add mul c 4 add getinterval /rcws exch def /csum rcws 0 get def 1 1 rcws length 2 sub { /i exch def /csum csum rcws i get i mul add def } for rcws rcws length 1 sub csum 103 mod put } for options /debugcws known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugcws cws //raiseerror exec } if % % Derive the bits for each row % /rowbits r array def 0 1 r 1 sub { /i exch def /sbs [ cws i c 5 add mul c 5 add getinterval { //codablockf.encs exch get {48 sub} forall } forall ] def mark 0 sbs {1 index 1 eq {{0}} {{1}} ifelse repeat} forall counttomark 1 sub array astore exch pop exch pop rowbits i 3 -1 roll put } for % % Populate the bitmap with one copy of each unique row % /symwid c 11 mul 57 add def /symhgt sepheight r 1 add mul r rowheight mul add def /numcomprows r 2 mul 1 add def symwid numcomprows mul { array } stopped { pop /bwipp.codablockfSymbolTooLarge (The symbol size exceeds the implementation limits) //raiseerror exec } if /pixs exch def % Reusable row templates /allone [ symwid {1} repeat ] def /seprow [ 1 1 0 1 0 0 0 0 1 0 0 symwid 24 sub {1} repeat 1 1 0 0 0 1 1 1 0 1 0 1 1 ] def /rowheights numcomprows array def /pos 0 def /ri 0 def % Top separator pixs pos allone putinterval /pos pos symwid add def rowheights ri sepheight put /ri ri 1 add def % Data rows with separators 0 1 r 2 sub { /i exch def pixs pos rowbits i get putinterval /pos pos symwid add def rowheights ri rowheight put /ri ri 1 add def pixs pos seprow putinterval /pos pos symwid add def rowheights ri sepheight put /ri ri 1 add def } for % Last data row pixs pos rowbits r 1 sub get putinterval /pos pos symwid add def rowheights ri rowheight put /ri ri 1 add def % Bottom separator pixs pos allone putinterval rowheights ri sepheight put << /ren /renmatrix /pixs pixs /pixx symwid /pixy symhgt /rowheights rowheights /height symhgt 72 div /width symwid 72 div /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /codablockf dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER codablockf-- % --BEGIN ENCODER code16k-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor render renmatrix-- % --DESC: Code 16K % --EXAM: Abcd-1234567890-wxyZ % --EXOP: % --RNDR: renmatrix % --FMLY: Less-used Symbols %%BeginResource: uk.co.terryburton.bwipp code16k 0.0 2026052800 193009 192040 %%BeginData: 883 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 33 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put begin /code16k.swa -1 def /code16k.swb -2 def /code16k.swc -3 def /code16k.sa1 -4 def /code16k.sb1 -5 def /code16k.sc1 -6 def /code16k.sa2 -7 def /code16k.sb2 -8 def /code16k.sc2 -9 def /code16k.pad -10 def /code16k.sb3 -11 def /code16k.sc3 -12 def /code16k.fn1 -13 def /code16k.fn2 -14 def /code16k.fn3 -15 def /code16k.fn4 -16 def /swa //code16k.swa def /swb //code16k.swb def /swc //code16k.swc def /sa1 //code16k.sa1 def /sb1 //code16k.sb1 def /sc1 //code16k.sc1 def /sa2 //code16k.sa2 def /sb2 //code16k.sb2 def /sc2 //code16k.sc2 def /pad //code16k.pad def /sb3 //code16k.sb3 def /sc3 //code16k.sc3 def /fn1 //code16k.fn1 def /fn2 //code16k.fn2 def /fn3 //code16k.fn3 def /fn4 //code16k.fn4 def % % Character maps for each state % /code16k.charmaps [ % A B C A B C A B C [ 32 32 (00) ] [ (!) (!) (01) ] [ (") (") (02) ] % 0-2 [ (#) (#) (03) ] [ ($) ($) (04) ] [ (%) (%) (05) ] % 3-5 [ (&) (&) (06) ] [ (') (') (07) ] [ 40 40 (08) ] % 6-8 [ 41 41 (09) ] [ (*) (*) (10) ] [ (+) (+) (11) ] % 9-11 [ (,) (,) (12) ] [ (-) (-) (13) ] [ (.) (.) (14) ] % 12-14 [ (/) (/) (15) ] [ (0) (0) (16) ] [ (1) (1) (17) ] % 15-17 [ (2) (2) (18) ] [ (3) (3) (19) ] [ (4) (4) (20) ] % 18-20 [ (5) (5) (21) ] [ (6) (6) (22) ] [ (7) (7) (23) ] % 21-23 [ (8) (8) (24) ] [ (9) (9) (25) ] [ (:) (:) (26) ] % 24-26 [ (;) (;) (27) ] [ (<) (<) (28) ] [ (=) (=) (29) ] % 27-29 [ (>) (>) (30) ] [ (?) (?) (31) ] [ (@) (@) (32) ] % 30-32 [ (A) (A) (33) ] [ (B) (B) (34) ] [ (C) (C) (35) ] % 33-35 [ (D) (D) (36) ] [ (E) (E) (37) ] [ (F) (F) (38) ] % 36-38 [ (G) (G) (39) ] [ (H) (H) (40) ] [ (I) (I) (41) ] % 39-41 [ (J) (J) (42) ] [ (K) (K) (43) ] [ (L) (L) (44) ] % 42-44 [ (M) (M) (45) ] [ (N) (N) (46) ] [ (O) (O) (47) ] % 45-47 [ (P) (P) (48) ] [ (Q) (Q) (49) ] [ (R) (R) (50) ] % 48-50 [ (S) (S) (51) ] [ (T) (T) (52) ] [ (U) (U) (53) ] % 51-53 [ (V) (V) (54) ] [ (W) (W) (55) ] [ (X) (X) (56) ] % 54-56 [ (Y) (Y) (57) ] [ (Z) (Z) (58) ] [ ([) ([) (59) ] % 57-59 [ 92 92 (60) ] [ (]) (]) (61) ] [ (^) (^) (62) ] % 60-62 [ (_) (_) (63) ] [ 0 (`) (64) ] [ 1 (a) (65) ] % 63-65 [ 2 (b) (66) ] [ 3 (c) (67) ] [ 4 (d) (68) ] % 66-68 [ 5 (e) (69) ] [ 6 (f) (70) ] [ 7 (g) (71) ] % 69-71 [ 8 (h) (72) ] [ 9 (i) (73) ] [ 10 (j) (74) ] % 72-74 [ 11 (k) (75) ] [ 12 (l) (76) ] [ 13 (m) (77) ] % 75-77 [ 14 (n) (78) ] [ 15 (o) (79) ] [ 16 (p) (80) ] % 78-80 [ 17 (q) (81) ] [ 18 (r) (82) ] [ 19 (s) (83) ] % 81-83 [ 20 (t) (84) ] [ 21 (u) (85) ] [ 22 (v) (86) ] % 84-86 [ 23 (w) (87) ] [ 24 (x) (88) ] [ 25 (y) (89) ] % 87-89 [ 26 (z) (90) ] [ 27 ({) (91) ] [ 28 (|) (92) ] % 90-92 [ 29 (}) (93) ] [ 30 (~) (94) ] [ 31 127 (95) ] % 93-95 [ fn3 fn3 (96) ] [ fn2 fn2 (97) ] [ sb1 sa1 (98) ] % 96-98 [ swc swc (99) ] [ swb fn4 swb ] [ fn4 swa swa ] % 99-101 [ fn1 fn1 fn1 ] [ pad pad pad ] [ sb2 sa2 sb1 ] % 102-104 [ sc2 sc2 sb2 ] [ sc3 sc3 sb3 ] % 105-106 ] readonly def % % Basic metrics for the each symbol % % r dcws /code16k.metrics [ [ 2 7 ] [ 3 12 ] [ 4 17 ] [ 5 22 ] [ 6 27 ] [ 7 32 ] [ 8 37 ] [ 9 42 ] [ 10 47 ] [ 11 52 ] [ 12 57 ] [ 13 62 ] [ 14 67 ] [ 15 72 ] [ 16 77 ] ] readonly def % % Character mappings % /code16k.encs [ (212222) (222122) (222221) (121223) (121322) (131222) (122213) (122312) (132212) (221213) (221312) (231212) (112232) (122132) (122231) (113222) (123122) (123221) (223211) (221132) (221231) (213212) (223112) (312131) (311222) (321122) (321221) (312212) (322112) (322211) (212123) (212321) (232121) (111323) (131123) (131321) (112313) (132113) (132311) (211313) (231113) (231311) (112133) (112331) (132131) (113123) (113321) (133121) (313121) (211331) (231131) (213113) (213311) (213131) (311123) (311321) (331121) (312113) (312311) (332111) (314111) (221411) (431111) (111224) (111422) (121124) (121421) (141122) (141221) (112214) (112412) (122114) (122411) (142112) (142211) (241211) (221114) (413111) (241112) (134111) (111242) (121142) (121241) (114212) (124112) (124211) (411212) (421112) (421211) (212141) (214121) (412121) (111143) (111341) (131141) (114113) (114311) (411113) (411311) (113141) (114131) (311141) (411131) (211412) (211214) (211232) (211133) ] readonly def % % Start/stop character encodings % /code16k.startencs [ (3211) (2221) (2122) (1411) (1132) (1231) (1114) (3112) (3211) (2221) (2122) (1411) (1132) (1231) (1114) (3112) ] readonly def /code16k.stopencsodd [ (3211) (2221) (2122) (1411) (1132) (1231) (1114) (3112) (1132) (1231) (1114) (3112) (3211) (2221) (2122) (1411) ] readonly def /code16k.stopencseven [ (2122) (1411) (1132) (1231) (1114) (3112) (1132) (1231) (1114) (3112) (3211) (2221) (2122) (1411) (3211) (2221) ] readonly def /code16k.latevars dup 8 dict def load /init { currentglobal true setglobal //code16k.latevars begin % % Invert charmaps to give character to value maps for each state % /charvals [ 109 dict 109 dict 109 dict ] def 0 1 //code16k.charmaps length 1 sub { /i exch def /encs //code16k.charmaps i get def 0 1 2 { /j exch def encs j get dup type /stringtype eq {0 get} if % convert string to ASCII if required charvals j get exch i put } for } for /charvals charvals readonly def /seta charvals 0 get readonly def /setb charvals 1 get readonly def /setc charvals 2 get readonly def /init { //code16k.latevars {def} forall } def end //code16k.latevars /init get exec setglobal } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//code16k.latevars /init get exec} if } {pop} ifelse /code16k { 64 dict begin { /dontdraw false def /sam -1 def /rows 0 def /rowheight 8 def /sepheight 1 def /raw false def /parse false def /parsefnc false def /strictspec false def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def barcode length 500 gt { /bwipp.code16kinputTooLong (The input data is too long) //raiseerror exec } if /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Apply AST spec overrides and resolve physical specification % /code16k ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec //code16k.latevars /init get exec rows 0 ne rows 2 lt rows 16 gt or and { /bwipp.code16kBadRows (Code 16K must have 2 to 16 rows) //raiseerror exec } if rowheight 8 lt rowheight 50 gt or { /bwipp.code16kBadRowHeight (Code 16K must have rowheight from 8 to 50) //raiseerror exec } if sepheight 1 lt sepheight 5 gt or { /bwipp.code16kBadSepHeight (Code 16K must have sepheight from 1 to 5) //raiseerror exec } if sam -1 ne { true 1 { sam dup 12 lt exch 99 gt or { pop false exit } if sam 10 mod 2 lt { pop false exit } if sam 10 idiv sam 10 mod gt { pop false exit } if } repeat not { /bwipp.code16kBadSAM (SAM must be formatted as "NM" for Nth of M symbols, from 2 to 9 symbols) //raiseerror exec } if } if sam -1 ne {/rows 16 def} if raw { /mode 0 def /cws barcode length array def /i 0 def /j 0 def { % loop i barcode length 3 sub ge {exit} if barcode i get 94 ne {exit} if barcode i 1 add 3 getinterval false 1 index { dup 48 lt exch 57 gt or { pop true } if } forall { pop exit } if cvi /cw exch def cw 106 gt { /bwipp.code16kBadRawCodeword (Raw codewords must be 0 to 106) //raiseerror exec } if cws j cw put /i i 4 add def /j j 1 add def } loop i barcode length ne { /bwipp.code16kBadRawFormat (Raw codewords must be formatted as ^NNN) //raiseerror exec } if /cws cws 0 j getinterval def } { % % Parse the input % /fncvals << /parse parse /parsefnc parsefnc (FNC1) //code16k.fn1 (FNC2) //code16k.fn2 (FNC3) //code16k.fn3 % (FNC4) fn4 Not user accessible as encoded automatically >> def barcode fncvals //parseinput exec /msg exch def /msglen msg length def % % Standard and extended ASCII runlength at position % /numSA [ msglen {0} repeat 0 ] def /numEA [ msglen {0} repeat 0 ] def msglen 1 sub -1 0 { /i exch def msg i get 0 ge { msg i get 128 ge { numEA i numEA i 1 add get 1 add put } { numSA i numSA i 1 add get 1 add put } ifelse } if } for % % FNC4 codeword insertion for extended ASCII % /ea false def mark 0 1 msglen 1 sub { /i exch def /c msg i get def ea c 128 lt xor not c 0 ge and { % Other mode required ea {numSA} {numEA} ifelse i get dup % Runlength of other mode i add msglen eq {3} {5} ifelse % Does run terminate symbol lt { % Shift //code16k.fn4 } { % Latch //code16k.fn4 //code16k.fn4 /ea ea not def } ifelse } if c 0 ge {c 127 and} {c} ifelse } for counttomark array astore /msg exch def pop /msglen msg length def % % Pre-compute setC digit runlength from each position; two parity % arrays because FNC1 only counts when s is even. % /numsAtNEven [ msglen 1 add {0} repeat ] def /numsAtSEven [ msglen 1 add {0} repeat ] def /numsAtNOdd [ msglen 1 add {0} repeat ] def /numsAtSOdd [ msglen 1 add {0} repeat ] def msglen 1 sub -1 0 { /i exch def /ch msg i get def setc ch known not { numsAtNEven i 0 put numsAtSEven i 0 put numsAtNOdd i 0 put numsAtSOdd i 0 put } { ch //code16k.fn1 eq { numsAtNEven i 1 numsAtNEven i 1 add get add put numsAtSEven i 2 numsAtSEven i 1 add get add put numsAtNOdd i 0 put numsAtSOdd i 0 put } { numsAtNEven i 1 numsAtNOdd i 1 add get add put numsAtSEven i 1 numsAtSOdd i 1 add get add put numsAtNOdd i 1 numsAtNEven i 1 add get add put numsAtSOdd i 1 numsAtSEven i 1 add get add put } ifelse } ifelse } for /numsscr { dup numsAtNEven exch get exch numsAtSEven exch get } bind def % % Encoding for each alphabet % /enca { seta exch get cws exch j exch put /j j 1 add def } def /encb { setb exch get cws exch j exch put /j j 1 add def } def /encc { dup type /arraytype ne { setc exch get } { aload pop 48 sub exch 48 sub 10 mul add } ifelse cws exch j exch put /j j 1 add def } def % % Character exclusively in either alphabet A or B % /anotb {dup seta exch known exch setb exch known not and} def /bnota {dup setb exch known exch seta exch known not and} def % % Pre-compute relative position of next anotb and next bnota characters % /nextanotb [ msg length {0} repeat 9999 ] def /nextbnota [ msg length {0} repeat 9999 ] def msg length 1 sub -1 0 { /i exch def msg i get anotb { nextanotb i 0 put } { nextanotb i nextanotb i 1 add get 1 add put } ifelse msg i get bnota { nextbnota i 0 put } { nextbnota i nextbnota i 1 add get 1 add put } ifelse } for % % Does a-only come before b-only after given position and vice versa % /abeforeb {dup nextanotb exch get exch nextbnota exch get lt} def /bbeforea {dup nextbnota exch get exch nextanotb exch get lt} def /cws barcode length 2 mul 3 add array def % Select mode and encode first characters /i 0 def /j 0 def { % common exit % extended data length sam -1 ne { % encode one and two cws 0 sam 10 idiv 1 sub put cws 1 sam 10 mod 1 sub put /j 2 def /cset (setb) def /mode 7 def exit } if % empty => b msglen 0 eq { /cset (setb) def /mode 1 def exit } if % FNC1 . 2+ nums => c fnc1 msglen 2 ge { msg 0 get //code16k.fn1 eq 1 numsscr exch pop 2 ge and { /cset (setc) def /mode 4 def /i 1 def exit } if } if % FNC1 => b fnc1 msg 0 get //code16k.fn1 eq { /cset (setb) def /mode 3 def /i 1 def exit } if msglen 2 ge { % 2+ even nums => c 0 numsscr exch pop dup 2 ge exch 2 mod 0 eq and { /cset (setc) def /mode 2 def exit } if % 3+ odd nums => c sb1 encode 0 numsscr exch pop dup 3 ge exch 2 mod 1 eq and { msg 0 get encb /cset (setc) def /mode 5 def /i 1 def exit } if % b . 2+ even nums => c sb1 encode setb msg 0 get known 1 numsscr exch pop dup 2 ge exch 2 mod 0 eq and and { msg 0 get encb /cset (setc) def /mode 5 def /i 1 def exit } if % b . 3+ odd nums => c sb2 encode setb msg 0 get known 1 numsscr exch pop dup 3 ge exch 2 mod 1 eq and and { msg 0 get encb msg 1 get encb /cset (setc) def /mode 6 def /i 2 def exit } if % b . b . 2+ even nums => c sb2 encode setb msg 0 get known setb msg 1 get known and 2 numsscr exch pop dup 2 ge exch 2 mod 0 eq and and { msg 0 get encb msg 1 get encb /cset (setc) def /mode 6 def /i 2 def exit } if } if % anotb before bnota => a 0 abeforeb { /cset (seta) def /mode 0 def exit } if % otherwise => b /cset (setb) def /mode 1 def exit } loop { % Encode remainder i msglen eq {exit} if i numsscr /nums exch def /nchars exch def % % Determine switches and shifts % { % common exit cset (seta) eq { % bnota . anotb before bnota => sb1 encode i msglen 1 sub lt { msg i get bnota i 1 add abeforeb and { //code16k.sb1 enca msg i get encb /i i 1 add def exit } if } if % bnota . bnota . anotb before bnota => sb2 encode i msglen 2 sub lt { msg i get bnota msg i 1 add get bnota and i 2 add abeforeb and { //code16k.sb2 enca msg i get encb msg i 1 add get encb /i i 2 add def exit } if } if % bnota => swb msg i get bnota { //code16k.swb enca /cset (setb) def exit } if % 4 nums . a => sc2 encode i msglen 4 sub lt { nums 4 eq seta msg i 4 add get known and { //code16k.sc2 enca 2 { msg i get //code16k.fn1 eq { //code16k.fn1 encc /i i 1 add def } { msg i 2 getinterval encc /i i 2 add def } ifelse } repeat exit } if } if % 6 nums . a => sc3 encode i msglen 6 sub lt { nums 6 eq seta msg i 6 add get known and { //code16k.sc3 enca 3 { msg i get //code16k.fn1 eq { //code16k.fn1 encc /i i 1 add def } { msg i 2 getinterval encc /i i 2 add def } ifelse } repeat exit } if } if % 4+ even nums => swc nums 4 ge nums 2 mod 0 eq and { //code16k.swc enca /cset (setc) def exit } if % otherwise => encode msg i get enca /i i 1 add def exit } if cset (setb) eq { % anotb . bnota before anotb => sa1 encode i msglen 1 sub lt { msg i get anotb i 1 add bbeforea and { //code16k.sa1 encb msg i get enca /i i 1 add def exit } if } if % anotb . anotb . bnota before anotb => sa2 encode i msglen 2 sub lt { msg i get anotb msg i 1 add get anotb and i 2 add bbeforea and { //code16k.sa2 encb msg i get enca msg i 1 add get enca /i i 2 add def exit } if } if % anotb => swa msg i get anotb { //code16k.swa encb /cset (seta) def exit } if % 4 nums . b => sc2 encode i msglen 4 sub lt { nums 4 eq setb msg i 4 add get known and { //code16k.sc2 encb 2 { msg i get //code16k.fn1 eq { //code16k.fn1 encc /i i 1 add def } { msg i 2 getinterval encc /i i 2 add def } ifelse } repeat exit } if } if % 6 nums . b => sc3 encode i msglen 6 sub lt { nums 6 eq setb msg i 6 add get known and { //code16k.sc3 encb 3 { msg i get //code16k.fn1 eq { //code16k.fn1 encc /i i 1 add def } { msg i 2 getinterval encc /i i 2 add def } ifelse } repeat exit } if } if % 4+ even nums => swc nums 4 ge nums 2 mod 0 eq and { //code16k.swc encb /cset (setc) def exit } if % otherwise => encode msg i get encb /i i 1 add def exit } if cset (setc) eq { % 2+ nums => encode nums 2 ge { msg i get //code16k.fn1 eq { //code16k.fn1 encc /i i 1 add def } { msg i 2 getinterval encc /i i 2 add def } ifelse exit } if % b . 2+ even nums => sb1 encode i msglen 1 sub lt { setb msg i get known i 1 add numsscr exch pop dup 2 ge exch 2 mod 0 eq and and { //code16k.sb1 encc msg i get encb /i i 1 add def exit } if } if % b . 3+ odd nums => sb2 encode i msglen 1 sub lt { setb msg i get known i 1 add numsscr exch pop dup 3 ge exch 2 mod 1 eq and and { //code16k.sb2 encc msg i get encb msg i 1 add get encb /i i 2 add def exit } if } if % b . b . 2+ even nums => sb2 encode i msglen 2 sub lt { setb msg i get known setb msg i 1 add get known and i 2 add numsscr exch pop dup 2 ge exch 2 mod 0 eq and and { //code16k.sb2 encc msg i get encb msg i 1 add get encb /i i 2 add def exit } if } if % b . b . 3+ odd nums => sb3 encode i msglen 3 sub lt { setb msg i get known setb msg i 1 add get known and i 2 add numsscr exch pop dup 3 ge exch 2 mod 1 eq and and { //code16k.sb3 encc msg i get encb msg i 1 add get encb msg i 2 add get encb /i i 3 add def exit } if } if % b . b . b . 2+ even nums => sb3 encode i msglen 3 sub lt { setb msg i get known setb msg i 1 add get known and setb msg i 2 add get known and i 3 add numsscr exch pop dup 2 ge exch 2 mod 0 eq and and { //code16k.sb3 encc msg i get encb msg i 1 add get encb msg i 2 add get encb /i i 3 add def exit } if } if % anotb before bnota => swa i abeforeb { //code16k.swa encc /cset (seta) def exit } if % otherwise => swb //code16k.swb encc /cset (setb) def exit } if exit } loop } loop /cws cws 0 j getinterval def } ifelse % % Select metrics of an appropriate symbol % /urows rows def //code16k.metrics { /m exch def /r m 0 get def % Columns in symbol /dcws m 1 get def % Data codewords in symbol /okay true def urows 0 ne urows r ne and {/okay false def} if cws length dcws gt {/okay false def} if okay {exit} if } forall okay not { /bwipp.code16kNoValidSymbol (Maximum length exceeded or data too large for given options) //raiseerror exec } if % % Extend cws to ncws codewords by addition of pad characters % /cws [ cws aload pop dcws cws length sub {103} repeat ] def % % Add the start character % /cws [ r 2 sub 7 mul mode add cws aload pop ] def % % Calculate the check characters % 0 0 1 dcws {dup 2 add exch cws exch get mul add} for 107 mod /c1 exch def 0 0 1 dcws {dup 1 add exch cws exch get mul add} for c1 dcws 2 add mul add 107 mod /c2 exch def /cws [ cws aload pop c1 c2 ] def options /debugcws known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugcws cws //raiseerror exec } if sam -1 eq sam 10 idiv 2 mod 1 eq or { /stopencs //code16k.stopencsodd def } { /stopencs //code16k.stopencseven def } ifelse % % Derive the bits for each row % /rowbits r array def 0 1 r 1 sub { /i exch def /sbs [ 10 //code16k.startencs i get {48 sub} forall 1 cws i 5 mul 5 getinterval { //code16k.encs exch get {48 sub} forall } forall stopencs i get {48 sub} forall 1 ] def mark 1 sbs {1 index 0 eq {{1}} {{0}} ifelse repeat} forall counttomark 1 sub array astore exch pop exch pop rowbits i 3 -1 roll put } for % % Populate the bitmap with one copy of each unique row % /symhgt sepheight r 1 add mul r rowheight mul add def /numcomprows r 2 mul 1 add def 81 numcomprows mul { array } stopped { pop /bwipp.code16kSymbolTooLarge (The symbol size exceeds the implementation limits) //raiseerror exec } if /pixs exch def % Reusable row templates /allone [ 81 {1} repeat ] def /seprow [ 10 {0} repeat 70 {1} repeat 0 ] def /rowheights numcomprows array def /pos 0 def /ri 0 def % Top separator pixs pos allone putinterval /pos pos 81 add def rowheights ri sepheight put /ri ri 1 add def % Data rows with separators 0 1 r 2 sub { /i exch def pixs pos rowbits i get putinterval /pos pos 81 add def rowheights ri rowheight put /ri ri 1 add def pixs pos seprow putinterval /pos pos 81 add def rowheights ri sepheight put /ri ri 1 add def } for % Last data row pixs pos rowbits r 1 sub get putinterval /pos pos 81 add def rowheights ri rowheight put /ri ri 1 add def % Bottom separator pixs pos allone putinterval rowheights ri sepheight put << /ren /renmatrix /pixs pixs /pixx 81 /pixy symhgt /rowheights rowheights /height symhgt 72 div /width 81 72 div /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /code16k dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER code16k-- % --BEGIN ENCODER code49-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor render renmatrix-- % --DESC: Code 49 % --EXAM: MULTIPLE ROWS IN CODE 49 % --EXOP: % --RNDR: renmatrix % --FMLY: Less-used Symbols %%BeginResource: uk.co.terryburton.bwipp code49 0.0 2026052800 260316 259747 %%BeginData: 1200 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 17 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put begin /code49.s1 -1 def /code49.s2 -2 def /code49.fn1 -3 def /code49.fn2 -4 def /code49.fn3 -5 def /code49.ns -6 def % % Character encodings % /code49.charmap [ (0) (1) (2) (3) (4) (5) (6) (7) (8) (9) (A) (B) (C) (D) (E) (F) (G) (H) (I) (J) (K) (L) (M) (N) (O) (P) (Q) (R) (S) (T) (U) (V) (W) (X) (Y) (Z) (-) (.) ( ) ($) (/) (+) (%) //code49.s1 //code49.s2 //code49.fn1 //code49.fn2 //code49.fn3 //code49.ns ] readonly def % % Shifted character encodings % /code49.combos [ (1 ) (1A) (1B) (1C) (1D) (1E) (1F) (1G) (1H) (1I) (1J) (1K) (1L) (1M) (1N) (1O) (1P) (1Q) (1R) (1S) (1T) (1U) (1V) (1W) (1X) (1Y) (1Z) (11) (12) (13) (14) (15) ( ) (16) (17) (18) ( $) ( %) (19) (10) (1-) (1.) (1$) ( +) (1/) ( -) ( .) ( /) ( 0) ( 1) ( 2) ( 3) ( 4) ( 5) ( 6) ( 7) ( 8) ( 9) (1+) (21) (22) (23) (24) (25) (26) ( A) ( B) ( C) ( D) ( E) ( F) ( G) ( H) ( I) ( J) ( K) ( L) ( M) ( N) ( O) ( P) ( Q) ( R) ( S) ( T) ( U) ( V) ( W) ( X) ( Y) ( Z) (27) (28) (29) (20) (2-) (2.) (2A) (2B) (2C) (2D) (2E) (2F) (2G) (2H) (2I) (2J) (2K) (2L) (2M) (2N) (2O) (2P) (2Q) (2R) (2S) (2T) (2U) (2V) (2W) (2X) (2Y) (2Z) (2$) (2/) (2+) (2%) (2 ) ] readonly def /code49.samval [ 12 22 13 23 33 14 24 34 44 15 25 35 45 55 16 26 36 46 56 66 17 27 37 47 57 67 77 18 28 38 48 58 68 78 88 19 29 39 49 59 69 79 89 99 ] readonly def % % Basic metrics for the each symbol % /code49.metrics [ % r dcws [ 2 9 ] [ 3 16 ] [ 4 23 ] [ 5 30 ] [ 6 37 ] [ 7 42 ] [ 8 49 ] ] readonly def [ 1 9 31 26 2 12 17 23 37 18 22 6 27 44 15 43 39 11 13 5 41 33 36 8 4 32 3 19 40 25 29 10 24 30 ] dup [ exch 20 exch 0 32 getinterval aload pop ] /code49.weightx exch readonly def dup [ exch 16 exch 1 32 getinterval aload pop ] /code49.weighty exch readonly def [ exch 38 exch 2 32 getinterval aload pop ] /code49.weightz exch readonly def /code49.patterns [ [ % Even parity (11521132) (25112131) (14212132) (25121221) (14221222) (12412132) (23321221) (12421222) (21521221) (15112222) (15121312) (13312222) (24221311) (13321312) (11512222) (22421311) (11521312) (25112311) (14212312) (23312311) (12412312) (21512311) (16121131) (14321131) (12521131) (15212131) (15221221) (13412131) (13421221) (11612131) (16112221) (16121311) (14312221) (14321311) (12512221) (12521311) (15212311) (13412311) (11612311) (11131135) (31131133) (51131131) (21122134) (41122132) (21131224) (41131222) (11113135) (31113133) (51113131) (11122225) (31122223) (51122221) (11131315) (31131313) (51131311) (21113224) (41113222) (21122314) (41122312) (11113315) (31113313) (51113311) (12131134) (32131132) (21231133) (41231131) (22122133) (42122131) (11222134) (22131223) (42131221) (11231224) (31231222) (12113134) (32113132) (12122224) (32122222) (12131314) (32131312) (21231313) (41231311) (22113223) (42113221) (11213224) (22122313) (42122311) (11222314) (31222312) (12113314) (32113312) (21213313) (41213311) (13131133) (33131131) (22231132) (11331133) (31331131) (23122132) (12222133) (23131222) (12231223) (32231221) (21331222) (13113133) (33113131) (13122223) (33122221) (11313133) (13131313) (33131311) (11322223) (22231312) (11331313) (31331311) (23113222) (12213223) (23122312) (12222313) (32222311) (21322312) (13113313) (33113311) (22213312) (11313313) (31313311) (14131132) (23231131) (12331132) (21431131) (24122131) (13222132) (24131221) (13231222) (11422132) (22331221) (11431222) (14113132) (14122222) (12313132) (14131312) (12322222) (23231311) (12331312) (21431311) (24113221) (13213222) (24122311) (13222312) (11413222) (22322311) (11422312) (14113312) (23213311) (12313312) (21413311) (15131131) (13331131) (14222131) (14231221) (12422131) (12431221) (15113131) (15122221) (13313131) (15131311) (13322221) (11513131) (13331311) (11522221) (14213221) (14222311) (12413221) (12422311) (15113311) (13313311) (11513311) (11141134) (31141132) (21132133) (41132131) (21141223) (41141221) (11123134) (31123132) (11132224) (31132222) (11141314) (31141312) (21114133) (41114131) (21123223) (41123221) (21132313) (41132311) (11114224) (31114222) (11123314) (31123312) (21114313) (41114311) (12141133) (32141131) (21241132) (22132132) (11232133) (22141222) (11241223) (31241221) (12123133) (32123131) (12132223) (32132221) (12141313) (32141311) (21241312) (22114132) (11214133) (22123222) (11223223) (22132312) (11232313) (31232311) (12114223) (32114221) (12123313) (32123311) (21223312) (22114312) (11214313) (31214311) (13141132) (22241131) (11341132) (23132131) (12232132) (23141221) (12241222) (21341221) (13123132) (13132222) (11323132) (13141312) (11332222) (22241311) (11341312) (23114131) (12214132) (23123221) (12223222) (23132311) (12232312) (21332311) (13114222) (13123312) (11314222) (22223311) (11323312) (23114311) (12214312) (21314311) (14141131) (12341131) (13232131) (13241221) (11432131) (14123131) (14132221) (12323131) (14141311) (12332221) (12341311) (13214131) (13223221) (11414131) (13232311) (11423221) (11432311) (14114221) (14123311) (12314221) (12323311) (13214311) (11414311) (11151133) (31151131) (21142132) (21151222) (11133133) (31133131) (11142223) (31142221) (11151313) (31151311) (21124132) (21133222) (21142312) (11115133) (31115131) (11124223) (31124221) (11133313) (31133311) (21115222) (21124312) (12151132) (21251131) (22142131) (11242132) (22151221) (11251222) (12133132) (12142222) (12151312) (21251311) (22124131) (11224132) (22133221) (11233222) (22142311) (11242312) (12115132) (12124222) (12133312) (21233311) (22115221) (11215222) (22124311) (11224312) (13151131) (12242131) (12251221) (13133131) (13142221) (11333131) (13151311) (11342221) (12224131) (12233221) (12242311) (13115131) (13124221) (11315131) (13133311) (11324221) (11333311) (12215221) (12224311) (11161132) (21152131) (21161221) (11143132) (11152222) (11161312) (21134131) (21143221) (21152311) (11125132) (11134222) (11143312) (21116131) (21125221) (21134311) (12161131) (11252131) (12143131) (12152221) (12161311) (11234131) (11243221) (11252311) (12125131) (12134221) (12143311) (11216131) (11225221) (11234311) (11111236) (31111234) (51111232) (21111325) (41111323) (61111321) (11111416) (31111414) (51111412) (31211143) (51211141) (12111235) (32111233) (52111231) (21211234) (41211232) (22111324) (42111322) (11211325) (31211323) (51211321) (12111415) (32111413) (52111411) (21211414) (41211412) (12211144) (32211142) (21311143) (41311141) (13111234) (33111232) (22211233) (42211231) (11311234) (31311232) (23111323) (43111321) (12211324) (32211322) (21311323) (41311321) (13111414) (33111412) (22211413) (42211411) (11311414) (31311412) (13211143) (33211141) (22311142) (11411143) (31411141) (14111233) (34111231) (23211232) (12311233) (32311231) (21411232) (24111322) (13211323) (33211321) (22311322) (11411323) (31411321) (14111413) (34111411) (23211412) (12311413) (32311411) (21411412) (14211142) (23311141) (12411142) (21511141) (15111232) (24211231) (13311232) (22411231) (11511232) (25111321) (14211322) (23311321) (12411322) (21511321) (15111412) (24211411) (13311412) (22411411) (11511412) (15211141) (13411141) (11611141) (16111231) (14311231) (12511231) (15211321) (13411321) (11611321) (16111411) (14311411) (12511411) (21121144) (41121142) (11112145) (31112143) (51112141) (11121235) (31121233) (51121231) (21112234) (41112232) (21121324) (41121322) (11112325) (31112323) (51112321) (11121415) (31121413) (51121411) (21112414) (41112412) (22121143) (42121141) (11221144) (31221142) (12112144) (32112142) (12121234) (32121232) (21221233) (41221231) (22112233) (42112231) (11212234) (22121323) (42121321) (11221324) (31221322) (12112324) (32112322) (12121414) (32121412) (21221413) (41221411) (22112413) (42112411) (11212414) (31212412) (23121142) (12221143) (32221141) (21321142) (13112143) (33112141) (13121233) (33121231) (11312143) (22221232) (11321233) (31321231) (23112232) (12212233) (23121322) (12221323) (32221321) (21321322) (13112323) (33112321) (13121413) (33121411) (11312323) (22221412) (11321413) (31321411) (23112412) (12212413) (32212411) (21312412) (24121141) (13221142) (22321141) (11421142) (14112142) (14121232) (12312142) (23221231) (12321232) (21421231) (24112231) (13212232) (24121321) (13221322) (11412232) (22321321) (11421322) (14112322) (14121412) (12312322) (23221411) (12321412) (21421411) (24112411) (13212412) (22312411) (11412412) (14221141) (12421141) (15112141) (15121231) (13312141) (13321231) (11512141) (11521231) (14212231) (14221321) (12412231) (12421321) (15112321) (15121411) (13312321) (13321411) (11512321) (11521411) (14212411) (12412411) (21131143) (41131141) (11122144) (31122142) (11131234) (31131232) (21113143) (41113141) (21122233) (41122231) (21131323) (41131321) (11113234) (31113232) (11122324) (31122322) (11131414) (31131412) (21113323) (41113321) (21122413) (41122411) (11113414) (31113412) (22131142) (11231143) (31231141) (12122143) (32122141) (12131233) (32131231) (21231232) (22113142) (11213143) (22122232) (11222233) (22131322) (11231323) (31231321) (12113233) (32113231) (12122323) (32122321) (12131413) (32131411) (21231412) (22113322) (11213323) (22122412) (11222413) (31222411) (12113413) (32113411) (21213412) (23131141) (12231142) (21331141) (13122142) (13131232) (11322142) (22231231) (11331232) (23113141) (12213142) (23122231) (12222232) (23131321) (12231322) (21331321) (13113232) (13122322) (11313232) (13131412) (11322322) (22231411) (11331412) (23113321) (12213322) (23122411) (12222412) (21322411) (13113412) (22213411) (11313412) (13231141) (11431141) (14122141) (14131231) (12322141) (12331231) (13213141) (13222231) (11413141) (13231321) (11422231) (11431321) (14113231) (14122321) (12313231) (14131411) (12322321) (12331411) (13213321) (13222411) (11413321) (11422411) (14113411) (12313411) (21141142) (11132143) (31132141) (11141233) (31141231) (21123142) (21132232) (21141322) (11114143) (31114141) (11123233) (31123231) (11132323) (31132321) (11141413) (31141411) (21114232) (21123322) (21132412) (11114323) (31114321) (11123413) (31123411) (22141141) (11241142) (12132142) (12141232) (21241231) (22123141) (11223142) (22132231) (11232232) (22141321) (11241322) (12114142) (12123232) (12132322) (12141412) (21241411) (22114231) (11214232) (22123321) (11223322) (22132411) (11232412) (12114322) (12123412) (21223411) (12241141) (13132141) (13141231) (11332141) (11341231) (12223141) (12232231) (12241321) (13114141) (13123231) (11314141) (13132321) (11323231) (13141411) (11332321) (11341411) (12214231) (12223321) (12232411) (13114321) (13123411) (11314321) (11323411) (21151141) (11142142) (11151232) (21133141) (21142231) (21151321) (11124142) (11133232) (11142322) (11151412) (21115141) (21124231) (21133321) (21142411) (11115232) (11124322) (11133412) (11251141) (12142141) (12151231) (11233141) (11242231) (11251321) (12124141) (12133231) (12142321) (12151411) (11215141) (11224231) (11233321) (11242411) (12115231) (12124321) (12133411) (11152141) (11161231) (11134141) (11143231) (11152321) (11161411) (11116141) (11125231) (11134321) (11143411) (21111244) (41111242) (11111335) (31111333) (51111331) (21111424) (41111422) (11111515) (31111513) (51111511) (21211153) (41211151) (22111243) (42111241) (11211244) (31211242) (12111334) (32111332) (21211333) (41211331) (22111423) (42111421) (11211424) (31211422) (12111514) (32111512) (21211513) (41211511) (22211152) (11311153) (31311151) (23111242) (12211243) (32211241) (21311242) (13111333) (33111331) (22211332) (11311333) (31311331) (23111422) (12211423) (32211421) (21311422) (13111513) (33111511) (22211512) (11311513) (31311511) (23211151) (12311152) (21411151) (24111241) (13211242) (22311241) (11411242) (14111332) (23211331) (12311332) (21411331) (24111421) (13211422) (22311421) (11411422) (14111512) (23211511) (12311512) (21411511) (13311151) (11511151) (14211241) (12411241) (15111331) (13311331) (11511331) (14211421) (12411421) (15111511) (13311511) (11511511) (31121152) (21112153) (41112151) (21121243) (41121241) (11112244) (31112242) (11121334) (31121332) (21112333) (41112331) (21121423) (41121421) (11112424) (31112422) (11121514) (31121512) (21112513) (41112511) (12121153) (32121151) (21221152) (22112152) (11212153) (22121242) (11221243) (31221241) (12112243) (32112241) (12121333) (32121331) (21221332) (22112332) (11212333) (22121422) (11221423) (31221421) (12112423) (32112421) (12121513) (32121511) (21221512) (22112512) (11212513) (31212511) (13121152) (22221151) (11321152) (23112151) (12212152) (23121241) (12221242) (21321241) (13112242) (13121332) (11312242) (22221331) (11321332) (23112331) (12212332) (23121421) (12221422) (21321421) (13112422) (13121512) (11312422) (22221511) (11321512) (23112511) (12212512) (21312511) (14121151) (12321151) (13212151) (13221241) (11412151) (11421241) (14112241) (14121331) (12312241) (12321331) (13212331) (13221421) (11412331) (11421421) (14112421) (14121511) (12312421) (12321511) (13212511) (11412511) (11131153) (31131151) (21122152) (21131242) (11113153) (31113151) (11122243) (31122241) (11131333) (31131331) (21113242) (21122332) (21131422) (11113333) (31113331) (11122423) (31122421) (11131513) (31131511) (21113422) (21122512) (12131152) (21231151) (22122151) (11222152) (22131241) (11231242) (12113152) (12122242) (12131332) (21231331) (22113241) (11213242) (22122331) (11222332) (22131421) (11231422) (12113332) (12122422) (12131512) (21231511) (22113421) (11213422) (22122511) (11222512) (13131151) (11331151) (12222151) (12231241) (13113151) (13122241) (11313151) (13131331) (11322241) (11331331) (12213241) (12222331) (12231421) (13113331) (13122421) (11313331) (13131511) (11322421) (11331511) (12213421) (12222511) (11141152) (21132151) (21141241) (11123152) (11132242) (11141332) (21114151) (21123241) (21132331) (21141421) (11114242) (11123332) (11132422) (11141512) (21114331) (21123421) (21132511) (12141151) (11232151) (11241241) (12123151) (12132241) (12141331) (11214151) (11223241) (11232331) (11241421) (12114241) (12123331) (12132421) (12141511) (11214331) (11223421) (11232511) (11151151) (11133151) (11142241) (11151331) (11115151) (11124241) (11133331) (11142421) (11151511) (11111254) (31111252) (21111343) (41111341) (11111434) (31111432) (21111523) (41111521) (11111614) (31111612) (31211161) (12111253) (32111251) (21211252) (22111342) (11211343) (31211341) (12111433) (32111431) (21211432) (22111522) (11211523) (31211521) (12111613) (32111611) (21211612) (12211162) (21311161) (13111252) (22211251) (11311252) (23111341) (12211342) (21311341) (13111432) (22211431) (11311432) (23111521) (12211522) (21311521) (13111612) (22211611) (11311612) (13211161) (11411161) (14111251) (12311251) (13211341) (11411341) (14111431) (12311431) (13211521) (11411521) (14111611) (12311611) (21121162) (11112163) (31112161) (11121253) (31121251) (21112252) (21121342) (11112343) (31112341) (11121433) (31121431) (21112432) (21121522) (11112523) (31112521) (11121613) (31121611) (22121161) (11221162) (12112162) (12121252) (21221251) (22112251) (11212252) (22121341) (11221342) (12112342) (12121432) (21221431) (22112431) (11212432) (22121521) (11221522) (12112522) (12121612) (21221611) (12221161) (13112161) (13121251) (11312161) (11321251) (32121115) (52121113) (21221116) (41221114) (61221112) (22112116) (42112114) (31212115) (51212113) (13121116) (33121114) (22221115) (42221113) (11321116) (31321114) (51321112) (23112115) (43112113) (12212116) (32212114) (52212112) (21312115) (41312113) (61312111) (14121115) (34121113) (23221114) (43221112) (12321115) (32321113) (52321111) (21421114) (41421112) (24112114) (13212115) (33212113) (22312114) (42312112) (11412115) (31412113) (51412111) (15121114) (24221113) (13321114) (33321112) (22421113) (42421111) (11521114) (31521112) (25112113) (14212114) (34212112) (23312113) (43312111) (12412114) (32412112) (21512113) (41512111) (16121113) (25221112) (14321113) (34321111) (23421112) (12521113) (32521111) (15212113) (24312112) (13412113) (33412111) (22512112) (11612113) (31612111) (31131115) (51131113) (21122116) (41122114) (61122112) (31113115) (51113113) (12131116) (32131114) (52131112) (21231115) (41231113) (61231111) (22122115) (42122113) (11222116) (31222114) (51222112) (12113116) (32113114) (52113112) (21213115) (41213113) (61213111) (13131115) (33131113) (22231114) (42231112) (11331115) (31331113) (51331111) (23122114) (43122112) (12222115) (32222113) (52222111) (21322114) (41322112) (13113115) (33113113) (22213114) (42213112) (11313115) (31313113) (51313111) (14131114) (34131112) (23231113) (43231111) (12331114) (32331112) (21431113) (41431111) (24122113) (13222114) (33222112) (22322113) (42322111) (11422114) (31422112) (14113114) (34113112) (23213113) (43213111) (12313114) (32313112) (21413113) (41413111) (15131113) (24231112) (13331113) (33331111) (22431112) (25122112) (14222113) (34222111) (23322112) (12422113) (32422111) (21522112) (15113113) (24213112) (13313113) (33313111) (22413112) (11513113) (31513111) (16131112) (25231111) (14331112) (23431111) (15222112) (24322111) (13422112) (22522111) (16113112) (25213111) (14313112) (23413111) (12513112) (21613111) (11141116) (31141114) (51141112) (21132115) (41132113) (61132111) (11123116) (31123114) (51123112) (21114115) (41114113) (61114111) (12141115) (32141113) (52141111) (21241114) (41241112) (22132114) (42132112) (11232115) (31232113) (51232111) (12123115) (32123113) (52123111) (21223114) (41223112) (22114114) (42114112) (11214115) (31214113) (51214111) (13141114) (33141112) (22241113) (42241111) (11341114) (31341112) (23132113) (43132111) (12232114) (32232112) (21332113) (41332111) (13123114) (33123112) (22223113) (42223111) (11323114) (31323112) (23114113) (43114111) (12214114) (32214112) (21314113) (41314111) (14141113) (34141111) (23241112) (12341113) (32341111) (24132112) (13232113) (33232111) (22332112) (11432113) (31432111) (14123113) (34123111) (23223112) (12323113) (32323111) (21423112) (24114112) (13214113) (33214111) (22314112) (11414113) (31414111) (15141112) (24241111) (13341112) (25132111) (14232112) (23332111) (12432112) (15123112) (24223111) (13323112) (22423111) (11523112) (25114111) (14214112) (23314111) (12414112) (21514111) (16141111) (14341111) (15232111) (13432111) (16123111) (14323111) (12523111) (15214111) (13414111) (11614111) (11151115) (31151113) (51151111) (21142114) (41142112) (11133115) (31133113) (51133111) (21124114) (41124112) (11115115) (31115113) (51115111) (12151114) (32151112) (21251113) (41251111) (22142113) (42142111) (11242114) (31242112) (12133114) (32133112) (21233113) (41233111) (22124113) (42124111) (11224114) (31224112) (12115114) (32115112) (21215113) (41215111) (13151113) (33151111) (22251112) (23142112) (12242113) (32242111) (21342112) (13133113) (33133111) (22233112) (11333113) (31333111) (23124112) (12224113) (32224111) (21324112) (13115113) (33115111) (22215112) (11315113) (31315111) (14151112) (23251111) (24142111) (13242112) (22342111) (14133112) (23233111) (12333112) (21433111) (24124111) (13224112) (22324111) (11424112) (14115112) (23215111) (12315112) (21415111) (15151111) (14242111) (15133111) (13333111) (14224111) (12424111) (15115111) (13315111) (11515111) (11161114) (31161112) (21152113) (41152111) (11143114) (31143112) (21134113) (41134111) (11125114) (31125112) (21116113) (41116111) (12161113) (32161111) (22152112) (11252113) (31252111) (12143113) (32143111) (21243112) (22134112) (11234113) (31234111) (12125113) (32125111) (21225112) (22116112) (11216113) (31216111) (13161112) (23152111) (12252112) (13143112) (22243111) (11343112) (23134111) (12234112) (21334111) (13125112) (22225111) (11325112) (23116111) (12216112) (21316111) (14161111) (13252111) (14143111) (12343111) (13234111) (11434111) (14125111) (12325111) (13216111) (11416111) (31111216) (51111214) (31211125) (51211123) (32111215) (52111213) (21211216) (41211214) (61211212) (12211126) (32211124) (52211122) (21311125) (41311123) (61311121) (13111216) (33111214) (22211215) (42211213) (11311216) (31311214) (51311212) (13211125) (33211123) (22311124) (42311122) (11411125) (31411123) (51411121) (14111215) (34111213) (23211214) (43211212) (12311215) (32311213) (52311211) (21411214) (41411212) (14211124) (34211122) (23311123) (43311121) (12411124) (32411122) (21511123) (41511121) (15111214) (24211213) (13311214) (33311212) (22411213) (42411211) (11511214) (31511212) (15211123) (24311122) (13411123) (33411121) (22511122) (11611123) (31611121) (16111213) (25211212) (14311213) (34311211) (23411212) (12511213) (32511211) (21611212) (21121126) (41121124) (61121122) (31112125) (51112123) (31121215) (51121213) (21112216) (41112214) (61112212) (22121125) (42121123) (11221126) (31221124) (51221122) (12112126) (32112124) (52112122) (12121216) (32121214) (52121212) (21221215) (41221213) (61221211) (22112215) (42112213) (11212216) (31212214) (51212212) (23121124) (43121122) (12221125) (32221123) (52221121) (21321124) (41321122) (13112125) (33112123) (13121215) (33121213) (11312125) (22221214) (42221212) (11321215) (31321213) (51321211) (23112214) (43112212) (12212215) (32212213) (52212211) (21312214) (41312212) (24121123) (13221124) (33221122) (22321123) (42321121) (11421124) (31421122) (14112124) (34112122) (14121214) (34121212) (12312124) (23221213) (43221211) (12321214) (32321212) (21421213) (41421211) (24112213) (13212214) (33212212) (22312213) (42312211) (11412214) (31412212) (25121122) (14221123) (34221121) (23321122) (12421123) (32421121) (21521122) (15112123) (15121213) (13312123) (24221212) (13321213) (33321211) (11512123) (22421212) (11521213) (31521211) (25112212) (14212213) (34212211) (23312212) (12412213) (32412211) (21512212) (15221122) (24321121) (13421122) (22521121) (16112122) (16121212) (14312122) (25221211) (14321212) (12512122) (23421211) (12521212) (15212212) (24312211) (13412212) (22512211) (11612212) (21131125) (41131123) (61131121) (11122126) (31122124) (51122122) (11131216) (31131214) (51131212) (21113125) (41113123) (61113121) (21122215) (41122213) (61122211) (11113216) (31113214) (51113212) (22131124) (42131122) (11231125) (31231123) (51231121) (12122125) (32122123) (52122121) (12131215) (32131213) (52131211) (21231214) (41231212) (22113124) (42113122) (11213125) (22122214) (42122212) (11222215) (31222213) (51222211) (12113215) (32113213) (52113211) (21213214) (41213212) (23131123) (43131121) (12231124) (32231122) (21331123) (41331121) (13122124) (33122122) (13131214) (33131212) (11322124) (22231213) (42231211) (11331214) (31331212) (23113123) (43113121) (12213124) (23122213) (43122211) (12222214) (32222212) (21322213) (41322211) (13113214) (33113212) (22213213) (42213211) (11313214) (31313212) (24131122) (13231123) (33231121) (22331122) (11431123) (31431121) (14122123) (34122121) (14131213) (34131211) (12322123) (23231212) (12331213) (32331211) (21431212) (24113122) (13213123) (24122212) (13222213) (33222211) (11413123) (22322212) (11422213) (31422211) (14113213) (34113211) (23213212) (12313213) (32313211) (21413212) (25131121) (14231122) (23331121) (12431122) (15122122) (15131212) (13322122) (24231211) (13331212) (11522122) (22431211) (25113121) (14213122) (25122211) (14222212) (12413122) (23322211) (12422212) (21522211) (15113212) (24213211) (13313212) (22413211) (11513212) (15231121) (13431121) (16122121) (16131211) (14322121) (14331211) (12522121) (15213121) (15222211) (13413121) (13422211) (11613121) (16113211) (14313211) (12513211) (21141124) (41141122) (11132125) (31132123) (51132121) (11141215) (31141213) (51141211) (21123124) (41123122) (21132214) (41132212) (11114125) (31114123) (51114121) (11123215) (31123213) (51123211) (21114214) (41114212) (22141123) (42141121) (11241124) (31241122) (12132124) (32132122) (12141214) (32141212) (21241213) (41241211) (22123123) (42123121) (11223124) (22132213) (42132211) (11232214) (31232212) (12114124) (32114122) (12123214) (32123212) (21223213) (41223211) (22114213) (42114211) (11214214) (31214212) (23141122) (12241123) (32241121) (21341122) (13132123) (33132121) (13141213) (33141211) (11332123) (22241212) (11341213) (31341211) (23123122) (12223123) (23132212) (12232213) (32232211) (21332212) (13114123) (33114121) (13123213) (33123211) (11314123) (22223212) (11323213) (31323211) (23114212) (12214213) (32214211) (21314212) (24141121) (13241122) (22341121) (14132122) (14141212) (12332122) (23241211) (12341212) (24123121) (13223122) (24132211) (13232212) (11423122) (22332211) (11432212) (14114122) (14123212) (12314122) (23223211) (12323212) (21423211) (24114211) (13214212) (22314211) (11414212) (14241121) (15132121) (15141211) (13332121) (13341211) (14223121) (14232211) (12423121) (12432211) (15114121) (15123211) (13314121) (13323211) (11514121) (11523211) (14214211) (12414211) (21151123) (41151121) (11142124) (31142122) (11151214) (31151212) (21133123) (41133121) (21142213) (41142211) (11124124) (31124122) (11133214) (31133212) (21115123) (41115121) (21124213) (41124211) (11115214) (31115212) (22151122) (11251123) (31251121) (12142123) (32142121) (12151213) (32151211) (21251212) (22133122) (11233123) (22142212) (11242213) (31242211) (12124123) (32124121) (12133213) (32133211) (21233212) (22115122) (11215123) (22124212) (11224213) (31224211) (12115213) (32115211) (21215212) (23151121) (12251122) (13142122) (13151212) (11342122) (22251211) (23133121) (12233122) (23142211) (12242212) (21342211) (13124122) (13133212) (11324122) (22233211) (11333212) (23115121) (12215122) (23124211) (12224212) (21324211) (13115212) (22215211) (11315212) (13251121) (14142121) (14151211) (12342121) (13233121) (13242211) (11433121) (14124121) (14133211) (12324121) (12333211) (13215121) (13224211) (11415121) (11424211) (14115211) (12315211) (21161122) (11152123) (31152121) (11161213) (31161211) (21143122) (21152212) (11134123) (31134121) (11143213) (31143211) (21125122) (21134212) (11116123) (31116121) (11125213) (31125211) (22161121) (12152122) (12161212) (22143121) (11243122) (22152211) (11252212) (12134122) (12143212) (21243211) (22125121) (11225122) (22134211) (11234212) (12116122) (12125212) (21225211) (13152121) (13161211) (12243121) (12252211) (13134121) (13143211) (11334121) (11343211) (12225121) (12234211) (13116121) (13125211) (11316121) (11325211) (21111226) (41111224) (61111222) (31111315) (51111313) (21211135) (41211133) (61211131) (22111225) (42111223) (11211226) (31211224) (51211222) (12111316) (32111314) (52111312) (21211315) (41211313) (61211311) (22211134) (42211132) (11311135) (31311133) (51311131) (23111224) (43111222) (12211225) (32211223) (52211221) (21311224) (41311222) (13111315) (33111313) (22211314) (42211312) (11311315) (31311313) (51311311) (23211133) (43211131) (12311134) (32311132) (21411133) (41411131) (24111223) (13211224) (33211222) (22311223) (42311221) (11411224) (31411222) (14111314) (34111312) (23211313) (43211311) (12311314) (32311312) (21411313) (41411311) (24211132) (13311133) (33311131) (22411132) (11511133) (31511131) (25111222) (14211223) (34211221) (23311222) (12411223) (32411221) (21511222) (15111313) (24211312) (13311313) (33311311) (22411312) (11511313) (31511311) (25211131) (14311132) (23411131) (12511132) (21611131) (15211222) (24311221) (13411222) (22511221) (11611222) (16111312) (25211311) (14311312) (23411311) (12511312) (21611311) (31121134) (51121132) (21112135) (41112133) (61112131) (21121225) (41121223) (61121221) (11112226) (31112224) (51112222) (11121316) (31121314) (51121312) (21112315) (41112313) (61112311) (12121135) (32121133) (52121131) (21221134) (41221132) (22112134) (42112132) (11212135) (22121224) (42121222) (11221225) (31221223) (51221221) (12112225) (32112223) (52112221) (12121315) (32121313) (52121311) (21221314) (41221312) (22112314) (42112312) (11212315) (31212313) (51212311) (13121134) (33121132) (22221133) (42221131) (11321134) (31321132) (23112133) (43112131) (12212134) (23121223) (43121221) (12221224) (32221222) (21321223) (41321221) (13112224) (33112222) (13121314) (33121312) (11312224) (22221313) (42221311) (11321314) (31321312) (23112313) (43112311) (12212314) (32212312) (21312313) (41312311) (14121133) (34121131) (23221132) (12321133) (32321131) (21421132) (24112132) (13212133) (24121222) (13221223) (33221221) (11412133) (22321222) (11421223) (31421221) (14112223) (34112221) (14121313) (34121311) (12312223) (23221312) (12321313) (32321311) (21421312) (24112312) (13212313) (33212311) (22312312) (11412313) (31412311) (15121132) (24221131) (13321132) (22421131) ] [ % Odd parity (22121116) (42121114) (31221115) (51221113) (32112115) (52112113) (21212116) (41212114) (61212112) (23121115) (43121113) (12221116) (32221114) (52221112) (21321115) (41321113) (61321111) (13112116) (33112114) (22212115) (42212113) (11312116) (31312114) (51312112) (24121114) (13221115) (33221113) (22321114) (42321112) (11421115) (31421113) (51421111) (14112115) (34112113) (23212114) (43212112) (12312115) (32312113) (52312111) (21412114) (41412112) (25121113) (14221114) (34221112) (23321113) (43321111) (12421114) (32421112) (21521113) (41521111) (15112114) (24212113) (13312114) (33312112) (22412113) (42412111) (11512114) (31512112) (15221113) (24321112) (13421113) (33421111) (22521112) (16112113) (25212112) (14312113) (34312111) (23412112) (12512113) (32512111) (21612112) (21131116) (41131114) (61131112) (31122115) (51122113) (21113116) (41113114) (61113112) (22131115) (42131113) (11231116) (31231114) (51231112) (12122116) (32122114) (52122112) (21222115) (41222113) (61222111) (22113115) (42113113) (11213116) (31213114) (51213112) (23131114) (43131112) (12231115) (32231113) (52231111) (21331114) (41331112) (13122115) (33122113) (22222114) (42222112) (11322115) (31322113) (51322111) (23113114) (43113112) (12213115) (32213113) (52213111) (21313114) (41313112) (24131113) (13231114) (33231112) (22331113) (42331111) (11431114) (31431112) (14122114) (34122112) (23222113) (43222111) (12322114) (32322112) (21422113) (41422111) (24113113) (13213114) (33213112) (22313113) (42313111) (11413114) (31413112) (25131112) (14231113) (34231111) (23331112) (12431113) (32431111) (15122113) (24222112) (13322113) (33322111) (22422112) (11522113) (31522111) (25113112) (14213113) (34213111) (23313112) (12413113) (32413111) (21513112) (15231112) (24331111) (13431112) (16122112) (25222111) (14322112) (23422111) (12522112) (15213112) (24313111) (13413112) (22513111) (11613112) (21141115) (41141113) (61141111) (11132116) (31132114) (51132112) (21123115) (41123113) (61123111) (11114116) (31114114) (51114112) (22141114) (42141112) (11241115) (31241113) (51241111) (12132115) (32132113) (52132111) (21232114) (41232112) (22123114) (42123112) (11223115) (31223113) (51223111) (12114115) (32114113) (52114111) (21214114) (41214112) (23141113) (43141111) (12241114) (32241112) (21341113) (41341111) (13132114) (33132112) (22232113) (42232111) (11332114) (31332112) (23123113) (43123111) (12223114) (32223112) (21323113) (41323111) (13114114) (33114112) (22214113) (42214111) (11314114) (31314112) (24141112) (13241113) (33241111) (22341112) (14132113) (34132111) (23232112) (12332113) (32332111) (21432112) (24123112) (13223113) (33223111) (22323112) (11423113) (31423111) (14114113) (34114111) (23214112) (12314113) (32314111) (21414112) (25141111) (14241112) (23341111) (15132112) (24232111) (13332112) (22432111) (25123111) (14223112) (23323111) (12423112) (21523111) (15114112) (24214111) (13314112) (22414111) (11514112) (15241111) (16132111) (14332111) (15223111) (13423111) (16114111) (14314111) (12514111) (21151114) (41151112) (11142115) (31142113) (51142111) (21133114) (41133112) (11124115) (31124113) (51124111) (21115114) (41115112) (22151113) (42151111) (11251114) (31251112) (12142114) (32142112) (21242113) (41242111) (22133113) (42133111) (11233114) (31233112) (12124114) (32124112) (21224113) (41224111) (22115113) (42115111) (11215114) (31215112) (23151112) (12251113) (32251111) (13142113) (33142111) (22242112) (11342113) (31342111) (23133112) (12233113) (32233111) (21333112) (13124113) (33124111) (22224112) (11324113) (31324111) (23115112) (12215113) (32215111) (21315112) (24151111) (13251112) (14142112) (23242111) (12342112) (24133111) (13233112) (22333111) (11433112) (14124112) (23224111) (12324112) (21424111) (24115111) (13215112) (22315111) (11415112) (14251111) (15142111) (13342111) (14233111) (12433111) (15124111) (13324111) (11524111) (14215111) (12415111) (21161113) (41161111) (11152114) (31152112) (21143113) (41143111) (11134114) (31134112) (21125113) (41125111) (11116114) (31116112) (22161112) (12152113) (32152111) (21252112) (22143112) (11243113) (31243111) (12134113) (32134111) (21234112) (22125112) (11225113) (31225111) (12116113) (32116111) (21216112) (23161111) (13152112) (22252111) (23143111) (12243112) (21343111) (13134112) (22234111) (11334112) (23125111) (12225112) (21325111) (13116112) (22216111) (11316112) (14152111) (13243111) (14134111) (12334111) (13225111) (11425111) (14116111) (12316111) (41111215) (61111213) (21211126) (41211124) (61211122) (22111216) (42111214) (31211215) (51211213) (22211125) (42211123) (11311126) (31311124) (51311122) (23111215) (43111213) (12211216) (32211214) (52211212) (21311215) (41311213) (61311211) (23211124) (43211122) (12311125) (32311123) (52311121) (21411124) (41411122) (24111214) (13211215) (33211213) (22311214) (42311212) (11411215) (31411213) (51411211) (24211123) (13311124) (33311122) (22411123) (42411121) (11511124) (31511122) (25111213) (14211214) (34211212) (23311213) (43311211) (12411214) (32411212) (21511213) (41511211) (25211122) (14311123) (34311121) (23411122) (12511123) (32511121) (21611122) (15211213) (24311212) (13411213) (33411211) (22511212) (11611213) (31611211) (31121125) (51121123) (21112126) (41112124) (61112122) (21121216) (41121214) (61121212) (31112215) (51112213) (12121126) (32121124) (52121122) (21221125) (41221123) (61221121) (22112125) (42112123) (11212126) (22121215) (42121213) (11221216) (31221214) (51221212) (12112216) (32112214) (52112212) (21212215) (41212213) (61212211) (13121125) (33121123) (22221124) (42221122) (11321125) (31321123) (51321121) (23112124) (43112122) (12212125) (23121214) (43121212) (12221215) (32221213) (52221211) (21321214) (41321212) (13112215) (33112213) (22212214) (42212212) (11312215) (31312213) (51312211) (14121124) (34121122) (23221123) (43221121) (12321124) (32321122) (21421123) (41421121) (24112123) (13212124) (24121213) (13221214) (33221212) (11412124) (22321213) (42321211) (11421214) (31421212) (14112214) (34112212) (23212213) (43212211) (12312214) (32312212) (21412213) (41412211) (15121123) (24221122) (13321123) (33321121) (22421122) (11521123) (31521121) (25112122) (14212123) (25121212) (14221213) (34221211) (12412123) (23321212) (12421213) (32421211) (21521212) (15112213) (24212212) (13312213) (33312211) (22412212) (11512213) (31512211) (16121122) (25221121) (14321122) (23421121) (12521122) (15212122) (15221212) (13412122) (24321211) (13421212) (11612122) (22521211) (16112212) (25212211) (14312212) (23412211) (12512212) (21612211) (11131126) (31131124) (51131122) (21122125) (41122123) (61122121) (21131215) (41131213) (61131211) (11113126) (31113124) (51113122) (11122216) (31122214) (51122212) (21113215) (41113213) (61113211) (12131125) (32131123) (52131121) (21231124) (41231122) (22122124) (42122122) (11222125) (22131214) (42131212) (11231215) (31231213) (51231211) (12113125) (32113123) (52113121) (12122215) (32122213) (52122211) (21222214) (41222212) (22113214) (42113212) (11213215) (31213213) (51213211) (13131124) (33131122) (22231123) (42231121) (11331124) (31331122) (23122123) (43122121) (12222124) (23131213) (43131211) (12231214) (32231212) (21331213) (41331211) (13113124) (33113122) (13122214) (33122212) (11313124) (22222213) (42222211) (11322214) (31322212) (23113213) (43113211) (12213214) (32213212) (21313213) (41313211) (14131123) (34131121) (23231122) (12331123) (32331121) (21431122) (24122122) (13222123) (24131212) (13231213) (33231211) (11422123) (22331212) (11431213) (31431211) (14113123) (34113121) (14122213) (34122211) (12313123) (23222212) (12322213) (32322211) (21422212) (24113212) (13213213) (33213211) (22313212) (11413213) (31413211) (15131122) (24231121) (13331122) (22431121) (25122121) (14222122) (25131211) (14231212) (12422122) (23331211) (12431212) (15113122) (15122212) (13313122) (24222211) (13322212) (11513122) (22422211) (11522212) (25113211) (14213212) (23313211) (12413212) (21513211) (16131121) (14331121) (15222121) (15231211) (13422121) (13431211) (16113121) (16122211) (14313121) (14322211) (12513121) (12522211) (15213211) (13413211) (11613211) (11141125) (31141123) (51141121) (21132124) (41132122) (21141214) (41141212) (11123125) (31123123) (51123121) (11132215) (31132213) (51132211) (21114124) (41114122) (21123214) (41123212) (11114215) (31114213) (51114211) (12141124) (32141122) (21241123) (41241121) (22132123) (42132121) (11232124) (22141213) (42141211) (11241214) (31241212) (12123124) (32123122) (12132214) (32132212) (21232213) (41232211) (22114123) (42114121) (11214124) (22123213) (42123211) (11223214) (31223212) (12114214) (32114212) (21214213) (41214211) (13141123) (33141121) (22241122) (11341123) (31341121) (23132122) (12232123) (23141212) (12241213) (32241211) (21341212) (13123123) (33123121) (13132213) (33132211) (11323123) (22232212) (11332213) (31332211) (23114122) (12214123) (23123212) (12223213) (32223211) (21323212) (13114213) (33114211) (22214212) (11314213) (31314211) (14141122) (23241121) (12341122) (24132121) (13232122) (24141211) (13241212) (11432122) (22341211) (14123122) (14132212) (12323122) (23232211) (12332212) (21432211) (24114121) (13214122) (24123211) (13223212) (11414122) (22323211) (11423212) (14114212) (23214211) (12314212) (21414211) (15141121) (13341121) (14232121) (14241211) (12432121) (15123121) (15132211) (13323121) (13332211) (11523121) (14214121) (14223211) (12414121) (12423211) (15114211) (13314211) (11514211) (11151124) (31151122) (21142123) (41142121) (21151213) (41151211) (11133124) (31133122) (11142214) (31142212) (21124123) (41124121) (21133213) (41133211) (11115124) (31115122) (11124214) (31124212) (21115213) (41115211) (12151123) (32151121) (21251122) (22142122) (11242123) (22151212) (11251213) (31251211) (12133123) (32133121) (12142213) (32142211) (21242212) (22124122) (11224123) (22133212) (11233213) (31233211) (12115123) (32115121) (12124213) (32124211) (21224212) (22115212) (11215213) (31215211) (13151122) (22251121) (23142121) (12242122) (23151211) (12251212) (13133122) (13142212) (11333122) (22242211) (11342212) (23124121) (12224122) (23133211) (12233212) (21333211) (13115122) (13124212) (11315122) (22224211) (11324212) (23115211) (12215212) (21315211) (14151121) (13242121) (13251211) (14133121) (14142211) (12333121) (12342211) (13224121) (13233211) (11424121) (11433211) (14115121) (14124211) (12315121) (12324211) (13215211) (11415211) (11161123) (31161121) (21152122) (21161212) (11143123) (31143121) (11152213) (31152211) (21134122) (21143212) (11125123) (31125121) (11134213) (31134211) (21116122) (21125212) (12161122) (22152121) (11252122) (22161211) (12143122) (12152212) (21252211) (22134121) (11234122) (22143211) (11243212) (12125122) (12134212) (21234211) (22116121) (11216122) (22125211) (11225212) (13161121) (12252121) (13143121) (13152211) (11343121) (12234121) (12243211) (13125121) (13134211) (11325121) (11334211) (12216121) (12225211) (31111225) (51111223) (21111316) (41111314) (61111312) (31211134) (51211132) (12111226) (32111224) (52111222) (21211225) (41211223) (61211221) (22111315) (42111313) (11211316) (31211314) (51211312) (12211135) (32211133) (52211131) (21311134) (41311132) (13111225) (33111223) (22211224) (42211222) (11311225) (31311223) (51311221) (23111314) (43111312) (12211315) (32211313) (52211311) (21311314) (41311312) (13211134) (33211132) (22311133) (42311131) (11411134) (31411132) (14111224) (34111222) (23211223) (43211221) (12311224) (32311222) (21411223) (41411221) (24111313) (13211314) (33211312) (22311313) (42311311) (11411314) (31411312) (14211133) (34211131) (23311132) (12411133) (32411131) (21511132) (15111223) (24211222) (13311223) (33311221) (22411222) (11511223) (31511221) (25111312) (14211313) (34211311) (23311312) (12411313) (32411311) (21511312) (15211132) (24311131) (13411132) (22511131) (11611132) (16111222) (25211221) (14311222) (23411221) (12511222) (21611221) (15211312) (24311311) (13411312) (22511311) (11611312) (21121135) (41121133) (61121131) (11112136) (31112134) (51112132) (11121226) (31121224) (51121222) (21112225) (41112223) (61112221) (21121315) (41121313) (61121311) (11112316) (31112314) (51112312) (22121134) (42121132) (11221135) (31221133) (51221131) (12112135) (32112133) (52112131) (12121225) (32121223) (52121221) (21221224) (41221222) (22112224) (42112222) (11212225) (22121314) (42121312) (11221315) (31221313) (51221311) (12112315) (32112313) (52112311) (21212314) (41212312) (23121133) (43121131) (12221134) (32221132) (21321133) (41321131) (13112134) (33112132) (13121224) (33121222) (11312134) (22221223) (42221221) (11321224) (31321222) (23112223) (43112221) (12212224) (23121313) (43121311) (12221314) (32221312) (21321313) (41321311) (13112314) (33112312) (22212313) (42212311) (11312314) (31312312) (24121132) (13221133) (33221131) (22321132) (11421133) (31421131) (14112133) (34112131) (14121223) (34121221) (12312133) (23221222) (12321223) (32321221) (21421222) (24112222) (13212223) (24121312) (13221313) (33221311) (11412223) (22321312) (11421313) (31421311) (14112313) (34112311) (23212312) (12312313) (32312311) (21412312) (25121131) (14221132) (23321131) (12421132) (21521131) (15112132) (15121222) (13312132) (24221221) (13321222) (11512132) (22421221) (11521222) (25112221) (14212222) (25121311) (14221312) (12412222) (23321311) (12421312) (21521311) (15112312) (24212311) (13312312) (22412311) (11512312) (15221131) (13421131) (16112131) (16121221) (14312131) (14321221) (12512131) (12521221) (15212221) (15221311) (13412221) (13421311) (11612221) (16112311) (14312311) (12512311) (21131134) (41131132) (11122135) (31122133) (51122131) (11131225) (31131223) (51131221) (21113134) (41113132) (21122224) (41122222) (21131314) (41131312) (11113225) (31113223) (51113221) (11122315) (31122313) (51122311) (21113314) (41113312) (22131133) (42131131) (11231134) (31231132) (12122134) (32122132) (12131224) (32131222) (21231223) (41231221) (22113133) (42113131) (11213134) (22122223) (42122221) (11222224) (22131313) (42131311) (11231314) (31231312) (12113224) (32113222) (12122314) (32122312) (21222313) (41222311) (22113313) (42113311) (11213314) (31213312) (23131132) (12231133) (32231131) (21331132) (13122133) (33122131) (13131223) (33131221) (11322133) (22231222) (11331223) (31331221) (23113132) (12213133) (23122222) (12222223) (23131312) (12231313) (32231311) (21331312) (13113223) (33113221) (13122313) (33122311) (11313223) (22222312) (11322313) (31322311) (23113312) (12213313) (32213311) (21313312) (24131131) (13231132) (22331131) (11431132) (14122132) (14131222) (12322132) (23231221) (12331222) (21431221) (24113131) (13213132) (24122221) (13222222) (24131311) (11413132) (13231312) (11422222) (22331311) (11431312) (14113222) (14122312) (12313222) (23222311) (12322312) (21422311) (24113311) (13213312) (22313311) (11413312) (14231131) (12431131) (15122131) (15131221) (13322131) (13331221) (11522131) (14213131) (14222221) (12413131) (14231311) (12422221) (12431311) (15113221) (15122311) (13313221) (13322311) (11513221) (11522311) (14213311) (12413311) (21141133) (41141131) (11132134) (31132132) (11141224) (31141222) (21123133) (41123131) (21132223) (41132221) (21141313) (41141311) (11114134) (31114132) (11123224) (31123222) (11132314) (31132312) (21114223) (41114221) (21123313) (41123311) (11114314) (31114312) (22141132) (11241133) (31241131) (12132133) (32132131) (12141223) (32141221) (21241222) (22123132) (11223133) (22132222) (11232223) (22141312) (11241313) (31241311) (12114133) (32114131) (12123223) (32123221) (12132313) (32132311) (21232312) (22114222) (11214223) (22123312) (11223313) (31223311) (12114313) (32114311) (21214312) (23141131) (12241132) (21341131) (13132132) (13141222) (11332132) (22241221) (11341222) (23123131) (12223132) (23132221) (12232222) (23141311) (12241312) (21341311) (13114132) (13123222) (11314132) (13132312) (11323222) (22232311) (11332312) (23114221) (12214222) (23123311) (12223312) (21323311) (13114312) (22214311) (11314312) (13241131) (14132131) (14141221) (12332131) (12341221) (13223131) (13232221) (11423131) (13241311) (11432221) (14114131) (14123221) (12314131) (14132311) (12323221) (12332311) (13214221) (13223311) (11414221) (11423311) (14114311) (12314311) (21151132) (11142133) (31142131) (11151223) (31151221) (21133132) (21142222) (21151312) (11124133) (31124131) (11133223) (31133221) (11142313) (31142311) (21115132) (21124222) (21133312) (11115223) (31115221) (11124313) (31124311) (22151131) (11251132) (12142132) (12151222) (21251221) (22133131) (11233132) (22142221) (11242222) (22151311) (11251312) (12124132) (12133222) (12142312) (21242311) (22115131) (11215132) (22124221) (11224222) (22133311) (11233312) (12115222) (12124312) (21224311) (12251131) (13142131) (13151221) (11342131) (12233131) (12242221) (12251311) (13124131) (13133221) (11324131) (13142311) (11333221) (11342311) (12215131) (12224221) (12233311) (13115221) (13124311) (11315221) (11324311) (21161131) (11152132) (11161222) (21143131) (21152221) (21161311) (11134132) (11143222) (11152312) (21125131) (21134221) (21143311) (11116132) (11125222) (11134312) (12152131) (12161221) (11243131) (11252221) (12134131) (12143221) (12152311) (11225131) (11234221) (11243311) (12116131) (12125221) (12134311) (21111235) (41111233) (61111231) (11111326) (31111324) (51111322) (21111415) (41111413) (61111411) (21211144) (41211142) (22111234) (42111232) (11211235) (31211233) (51211231) (12111325) (32111323) (52111321) (21211324) (41211322) (22111414) (42111412) (11211415) (31211413) (51211411) (22211143) (42211141) (11311144) (31311142) (23111233) (43111231) (12211234) (32211232) (21311233) (41311231) (13111324) (33111322) (22211323) (42211321) (11311324) (31311322) (23111413) (43111411) (12211414) (32211412) (21311413) (41311411) (23211142) (12311143) (32311141) (21411142) (24111232) (13211233) (33211231) (22311232) (11411233) (31411231) (14111323) (34111321) (23211322) (12311323) (32311321) (21411322) (24111412) (13211413) (33211411) (22311412) (11411413) (31411411) (24211141) (13311142) (22411141) (11511142) (25111231) (14211232) (23311231) (12411232) (21511231) (15111322) (24211321) (13311322) (22411321) (11511322) (25111411) (14211412) (23311411) (12411412) (21511411) (14311141) (12511141) (15211231) (13411231) (11611231) (16111321) (14311321) (12511321) (15211411) (13411411) (11611411) (31121143) (51121141) (21112144) (41112142) (21121234) (41121232) (11112235) (31112233) (51112231) (11121325) (31121323) (51121321) (21112324) (41112322) (21121414) (41121412) (11112415) (31112413) (51112411) (12121144) (32121142) (21221143) (41221141) (22112143) (42112141) (11212144) (22121233) (42121231) (11221234) (31221232) (12112234) (32112232) (12121324) (32121322) (21221323) (41221321) (22112323) (42112321) (11212324) (22121413) (42121411) (11221414) (31221412) (12112414) (32112412) (21212413) (41212411) (13121143) (33121141) (22221142) (11321143) (31321141) (23112142) (12212143) (23121232) (12221233) (32221231) (21321232) (13112233) (33112231) (13121323) (33121321) (11312233) (22221322) (11321323) (31321321) (23112322) (12212323) (23121412) (12221413) (32221411) (21321412) (13112413) (33112411) (22212412) (11312413) (31312411) (14121142) (23221141) (12321142) (21421141) (24112141) (13212142) (24121231) (13221232) (11412142) (22321231) (11421232) (14112232) (14121322) (12312232) (23221321) (12321322) (21421321) (24112321) (13212322) (24121411) (13221412) (11412322) (22321411) (11421412) (14112412) (23212411) (12312412) (21412411) (15121141) (13321141) (11521141) (14212141) (14221231) (12412141) (12421231) (15112231) (15121321) (13312231) (13321321) (11512231) (11521321) (14212321) (14221411) (12412321) (12421411) (15112411) (13312411) (11512411) (11131144) (31131142) (21122143) (41122141) (21131233) (41131231) (11113144) (31113142) (11122234) (31122232) (11131324) (31131322) (21113233) (41113231) (21122323) (41122321) (21131413) (41131411) (11113324) (31113322) (11122414) (31122412) (21113413) (41113411) (12131143) (32131141) (21231142) (22122142) (11222143) (22131232) (11231233) (31231231) (12113143) (32113141) (12122233) (32122231) (12131323) (32131321) (21231322) (22113232) (11213233) (22122322) (11222323) (22131412) (11231413) (31231411) (12113323) (32113321) (12122413) (32122411) (21222412) (22113412) (11213413) (31213411) (13131142) (22231141) (11331142) (23122141) (12222142) (23131231) (12231232) (21331231) (13113142) (13122232) (11313142) (13131322) (11322232) (22231321) (11331322) (23113231) (12213232) (23122321) (12222322) (23131411) (12231412) (21331411) (13113322) (13122412) (11313322) (22222411) (11322412) (23113411) (12213412) (21313411) (14131141) (12331141) (13222141) (13231231) (11422141) (11431231) (14113141) (14122231) (12313141) (14131321) (12322231) (12331321) (13213231) (13222321) (11413231) (13231411) (11422321) (11431411) (14113321) (14122411) (12313321) (12322411) (13213411) (11413411) (11141143) (31141141) (21132142) (21141232) (11123143) (31123141) (11132233) (31132231) (11141323) (31141321) (21114142) (21123232) (21132322) (21141412) (11114233) (31114231) (11123323) (31123321) (11132413) (31132411) (21114322) (21123412) (12141142) (21241141) (22132141) (11232142) (22141231) (11241232) (12123142) (12132232) (12141322) (21241321) (22114141) (11214142) (22123231) (11223232) (22132321) (11232322) (22141411) (11241412) (12114232) (12123322) (12132412) (21232411) (22114321) (11214322) (22123411) (11223412) (13141141) (11341141) (12232141) (12241231) (13123141) (13132231) (11323141) (13141321) (11332231) (11341321) (12214141) (12223231) (12232321) (12241411) (13114231) (13123321) (11314231) (13132411) (11323321) (11332411) (12214321) (12223411) (11151142) (21142141) (21151231) (11133142) (11142232) (11151322) (21124141) (21133231) (21142321) (21151411) (11115142) (11124232) (11133322) (11142412) (21115231) (21124321) (21133411) (12151141) (11242141) (11251231) (12133141) (12142231) (12151321) (11224141) (11233231) (11242321) (11251411) (12115141) (12124231) (12133321) (12142411) (11215231) (11224321) (11233411) (11161141) (11143141) (11152231) (11161321) (11125141) (11134231) (11143321) (11152411) (11111245) (31111243) (51111241) (21111334) (41111332) (11111425) (31111423) (51111421) (21111514) (41111512) (31211152) (12111244) (32111242) (21211243) (41211241) (22111333) (42111331) (11211334) (31211332) (12111424) (32111422) (21211423) (41211421) (22111513) (42111511) (11211514) (31211512) (12211153) (32211151) (21311152) (13111243) (33111241) (22211242) (11311243) (31311241) (23111332) (12211333) (32211331) (21311332) (13111423) (33111421) (22211422) (11311423) (31311421) (23111512) (12211513) (32211511) (21311512) (13211152) (22311151) (11411152) (14111242) (23211241) (12311242) (21411241) (24111331) (13211332) (22311331) (11411332) (14111422) (23211421) (12311422) (21411421) (24111511) (13211512) (22311511) (11411512) (14211151) (12411151) (15111241) (13311241) (11511241) (14211331) (12411331) (15111421) (13311421) (11511421) (14211511) (12411511) (21121153) (41121151) (11112154) (31112152) (11121244) (31121242) (21112243) (41112241) (21121333) (41121331) (11112334) (31112332) (11121424) (31121422) (21112423) (41112421) (21121513) (41121511) (11112514) (31112512) (22121152) (11221153) (31221151) (12112153) (32112151) (12121243) (32121241) (21221242) (22112242) (11212243) (22121332) (11221333) (31221331) (12112333) (32112331) (12121423) (32121421) (21221422) (22112422) (11212423) (22121512) (11221513) (31221511) (12112513) (32112511) (21212512) (23121151) (12221152) (21321151) (13112152) (13121242) (11312152) (22221241) (11321242) (23112241) (12212242) (23121331) (12221332) (21321331) (13112332) (13121422) (11312332) (22221421) (11321422) (23112421) (12212422) (23121511) (12221512) (21321511) (13112512) (22212511) (11312512) (13221151) (11421151) (14112151) (14121241) (12312151) (12321241) (13212241) (13221331) (11412241) (11421331) (14112331) (14121421) (12312331) (12321421) (13212421) (13221511) (11412421) (11421511) (14112511) (12312511) (21131152) (11122153) (31122151) (11131243) (31131241) (21113152) (21122242) (21131332) (11113243) (31113241) (11122333) (31122331) (11131423) (31131421) (21113332) (21122422) (21131512) (11113423) (31113421) (11122513) (31122511) (22131151) (11231152) (12122152) (12131242) (21231241) (22113151) (11213152) (22122241) (11222242) (22131331) (11231332) (12113242) (12122332) (12131422) (21231421) (22113331) (11213332) (22122421) (11222422) (22131511) (11231512) (12113422) (12122512) (21222511) (12231151) (13122151) (13131241) (11322151) (11331241) (12213151) (12222241) (12231331) (13113241) (13122331) (11313241) (13131421) (11322331) (11331421) (12213331) (12222421) (12231511) (13113421) (13122511) (11313421) (11322511) (21141151) (11132152) (11141242) (21123151) (21132241) (21141331) (11114152) (11123242) (11132332) (11141422) (21114241) (21123331) (21132421) (21141511) (11114332) (11123422) (11132512) (11241151) (12132151) (12141241) (11223151) (11232241) (11241331) (12114151) (12123241) (12132331) (12141421) (11214241) (11223331) (11232421) (11241511) (12114331) (12123421) (12132511) (11142151) (11151241) (11124151) (11133241) (11142331) (11151421) (11115241) (11124331) (11133421) (11142511) (21111253) (41111251) (11111344) (31111342) (21111433) (41111431) (11111524) (31111522) (21111613) (41111611) (21211162) (22111252) (11211253) (31211251) (12111343) (32111341) (21211342) (22111432) (11211433) (31211431) (12111523) (32111521) (21211522) (22111612) (11211613) (31211611) (22211161) (11311162) (23111251) (12211252) (21311251) (13111342) (22211341) (11311342) (23111431) (12211432) (21311431) (13111522) (22211521) (11311522) (23111611) (12211612) (21311611) (12311161) (13211251) (11411251) (14111341) (12311341) (13211431) (11411431) (14111521) (12311521) (13211611) (11411611) (31121161) (21112162) (21121252) (11112253) (31112251) (11121343) (31121341) (21112342) (21121432) (11112433) (31112431) (11121523) (31121521) (21112522) (21121612) (12121162) (21221161) (22112161) (11212162) (22121251) (11221252) (12112252) (12121342) (21221341) (22112341) (11212342) (22121431) (11221432) (12112432) (12121522) (21221521) (22112521) (11212522) (22121611) (11221612) (13121161) (11321161) (12212161) (12221251) (13112251) (13121341) (11312251) (11321341) (12212341) (12221431) (13112431) (13121521) (11312431) (11321521) (12212521) (12221611) (11131162) (21122161) (21131251) (11113162) ] ] readonly def /code49.parity [ (1001) (0101) (1100) (0011) (1010) (0110) (1111) (0000) ] readonly def /code49.latevars dup 4 dict def load /init { currentglobal true setglobal //code49.latevars begin % % Invert charmap to give character to value map % /charvals 49 dict def 0 1 48 { /i exch def //code49.charmap i get dup type /stringtype eq {0 get} if % Convert string to ASCII if required charvals exch i put } for % % Build shifted character encodings % 0 1 127 { /i exch def //code49.combos i get dup 0 get /c1 exch def 1 get /c2 exch def c1 49 eq { % s1 char charvals i [ charvals //code49.s1 get charvals c2 get ] put } if c1 50 eq { % s2 char charvals i [ charvals //code49.s2 get charvals c2 get ] put } if } for /charvals charvals readonly def /init { //code49.latevars {def} forall } def end //code49.latevars /init get exec setglobal } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//code49.latevars /init get exec} if } {pop} ifelse /code49 { 64 dict begin { /dontdraw false def /sam -1 def /append false def /rows 0 def /rowheight 8 def /sepheight 1 def /parse false def /parsefnc false def /strictspec false def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def barcode () eq { /bwipp.code49emptyData (The data must not be empty) //raiseerror exec } if barcode length 500 gt { /bwipp.code49inputTooLong (The input data is too long) //raiseerror exec } if /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Apply AST spec overrides and resolve physical specification % /code49 ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec //code49.latevars /init get exec rows 0 ne rows 2 lt rows 8 gt or and { /bwipp.code49badRows (Code 49 must have 2 to 8 rows) //raiseerror exec } if rowheight 8 lt rowheight 50 gt or { /bwipp.code49badRowHeight (Code 49 must have rowheight from 8 to 50) //raiseerror exec } if sepheight 1 lt sepheight 5 gt or { /bwipp.code49badSepHeight (Code 49 must have sepheight from 1 to 5) //raiseerror exec } if append sam -1 ne and { /bwipp.code49samAndAppend (sam and append cannot be specified together) //raiseerror exec } if sam -1 ne { true 1 { sam dup 12 lt exch 99 gt or { pop false exit } if sam 10 mod 2 lt { pop false exit } if sam 10 idiv sam 10 mod gt { pop false exit } if } repeat not { /bwipp.code49badSAM (SAM must be formatted as "NM" for Nth of M symbols, from 2 to 9 symbols) //raiseerror exec } if } if % % Parse the input % /fncvals << /parse parse /parsefnc parsefnc (FNC1) //code49.fn1 (FNC2) //code49.fn2 (FNC3) //code49.fn3 >> def barcode fncvals //parseinput exec /msg exch def /msglen msg length def msg { 127 gt { /bwipp.code49badCharacter (Code 49 can only support ASCII characters with values 0 to 127) //raiseerror exec } if } forall /encodealpha { charvals exch get dup type /arraytype ne {1 array astore} if dup cws exch j exch putinterval length j add /j exch def } def /base48 { 0 exch {48 sub exch 10 mul add} forall [ 3 1 roll exch 1 sub {dup 48 mod exch 48 idiv} repeat ] [ exch dup length 1 sub -1 0 {1 index exch get exch} for pop ] dup cws exch j exch putinterval length j add /j exch def } def /encodenumeric { /nums exch def /pre nums length dup 5 mod dup 2 ne {sub} {sub 5 sub} ifelse def 0 5 pre 1 sub {nums exch 5 getinterval 3 exch base48} for /nums nums pre nums length pre sub getinterval def nums length dup 1 eq {nums i get encodealpha} if dup 3 eq {2 nums base48} if dup 4 eq {3 [49 48 nums aload pop] base48} if 7 eq { 3 [49 48 nums 0 4 getinterval aload pop] base48 2 nums 4 3 getinterval base48 } if } def % % Pre-compute alphanumeric and numeric runlengths % /numericruns [ msglen {0} repeat 0 ] def msglen 1 sub -1 0 { /i exch def msg i get dup 48 ge exch 57 le and { numericruns i numericruns i 1 add get 1 add put } { numericruns i 0 put } ifelse } for /cws msglen 2 mul 1 add array def % % Autoselect and encode the starting mode % { % common exit append { % Concatenate alphanumeric mode /mode 1 def /method (alpha) def /i 0 def /j 0 def exit } if sam -1 ne { % Group alphanumeric mode /mode 3 def cws 0 0 1 43 { dup //code49.samval exch get sam ne {pop} if } for 1 add put /method (alpha) def /i 0 def /j 1 def exit } if numericruns 0 get 5 ge { % Numeric mode /mode 2 def /method (numeric) def /i 0 def /j 0 def exit } if charvals msg 0 get get dup type /arraytype ne { % Regular alphanumeric mode pop /mode 0 def /method (alpha) def /i 0 def /j 0 def exit } if % Alphanumeric mode starting shift 1 (mode=4) or shift 2 (mode=5) 0 get 43 eq {4} {5} ifelse /mode exch def cws 0 charvals msg 0 get get 1 get put /method (alpha) def /i 1 def /j 1 def exit } loop % % Encode remainder % { i msglen eq {exit} if { % not a loop but common exit point method (alpha) eq { numericruns i get 5 ge { //code49.ns encodealpha /method (numeric) def exit } if msg i get encodealpha /i i 1 add def exit } if method (numeric) eq { numericruns i get 5 lt { //code49.ns encodealpha /method (alpha) def exit } if msg i numericruns i get getinterval encodenumeric /i i numericruns i get add def exit } if } loop } loop /cws cws 0 j getinterval def % % Select metrics of an appropriate symbol % /urows rows def //code49.metrics { /m exch def /r m 0 get def % Columns in symbol /dcws m 1 get def % Data codewords in symbol /okay true def urows 0 ne urows r ne and {/okay false def} if cws length dcws gt {/okay false def} if okay {exit} if } forall okay not { /bwipp.code49noValidSymbol (Maximum length exceeded) //raiseerror exec } if % % Extend cws to ncws codewords by addition of pad characters % /cws [ cws aload pop dcws cws length sub {48} repeat ] def % % Populate code character array and add row check characters % /ccs r 8 mul array def /j 0 def 0 1 r 2 sub { /i exch def /cc cws j 7 getinterval def ccs i 8 mul cc putinterval ccs i 8 mul 7 add 0 cc {add} forall 49 mod put /j j 7 add def } for j dcws lt { ccs ccs length 8 sub cws j dcws j sub getinterval putinterval } if % % Place row count character % /cr7 r 2 sub 7 mul mode add def ccs ccs length 2 sub cr7 put % % Calculate the symbol check characters % /calccheck { /weights exch def /score 0 def 0 1 r 1 sub 8 mul 2 idiv 1 sub { /i exch def ccs i 2 mul get 49 mul ccs i 2 mul 1 add get add weights i 1 add get mul /score exch score add def } for score } def /lastrow ccs ccs length 8 sub 8 getinterval def % % wr1 check character % r 7 ge { cr7 //code49.weightz 0 get mul //code49.weightz calccheck add 2401 mod dup 49 idiv exch 49 mod 2 array astore lastrow 0 3 -1 roll putinterval } if /wr1 lastrow 0 get 49 mul lastrow 1 get add def % % wr2 check character % cr7 //code49.weighty 0 get mul //code49.weighty calccheck add wr1 //code49.weighty r 4 mul 3 sub get mul add 2401 mod dup /wr2 exch def dup 49 idiv exch 49 mod 2 array astore lastrow 2 3 -1 roll putinterval % % wr3 check character % cr7 //code49.weightx 0 get mul //code49.weightx calccheck add wr1 //code49.weightx r 4 mul 3 sub get mul add wr2 //code49.weightx r 4 mul 2 sub get mul add 2401 mod dup 49 idiv exch 49 mod 2 array astore lastrow 4 3 -1 roll putinterval % % Place last row check character % ccs ccs length 8 sub 7 getinterval 0 exch {add} forall 49 mod ccs ccs length 1 sub 3 -1 roll put options /debugcws known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugcws ccs //raiseerror exec } if % % Derive the bits for each row % /rowbits r array def 0 1 r 1 sub { /i exch def /p i r 1 sub ne {//code49.parity i get} {(0000)} ifelse def /ccrow ccs i 8 mul 8 getinterval def /scrow [ 0 2 7 {ccrow exch 2 getinterval aload pop exch 49 mul add} for ] def /sbs [ 10 1 1 0 1 3 { /j exch def //code49.patterns p j get 48 sub get scrow j get get {48 sub} forall } for 4 1 ] def mark 1 sbs {1 index 0 eq {{1}} {{0}} ifelse repeat} forall counttomark 1 sub array astore exch pop exch pop rowbits i 3 -1 roll put } for % % Populate the bitmap with one copy of each unique row % /numcomprows r 2 mul 1 add def /pixs [ 81 {1} repeat 0 1 r 2 sub { /i exch def rowbits i get aload pop 10 {0} repeat 70 {1} repeat 0 } for rowbits r 1 sub get aload pop 81 {1} repeat ] def /symhgt sepheight r 1 add mul r rowheight mul add def /rowheights [ sepheight 0 1 r 2 sub { pop rowheight sepheight } for rowheight sepheight ] def << /ren /renmatrix /pixs pixs /pixx 81 /pixy symhgt /rowheights rowheights /height symhgt 72 div /width 81 72 div /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /code49 dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER code49-- % --BEGIN ENCODER channelcode-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear-- % --DESC: Channel Code % --EXAM: 3493 % --EXOP: height=0.5 includetext % --RNDR: renlinear % --FMLY: Less-used Symbols %%BeginResource: uk.co.terryburton.bwipp channelcode 0.0 2026052800 146184 151779 %%BeginData: 303 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin % % Accelerate generation of bar patterns % /channelcode.memo [ [ % CH3 [ 0 [1 1 1 1 1 2 1 2] [1 1 1 1 1 1 1 3] [1 1 1 1 1 3 2] [1 1 1 1 1 3 3] ] ] [ % CH4 [ 0 [1 1 1 1 2 1 1 3] [1 1 1 1 1 1 1 4] [1 1 1 1 4 3 3] [1 1 1 1 4 4 4] ] ] [ % CH5 [ 0 [1 1 1 2 1 1 2 3] [1 1 1 1 1 1 1 5] [1 1 1 5 4 4 4] [1 1 1 5 5 5 5] ] ] [ % CH6 [ 0 [1 1 2 1 1 2 1 4] [1 1 1 1 1 1 1 6] [1 1 6 5 5 5 4] [1 1 6 6 6 6 6] ] ] [ % CH7 [ 0 [1 2 1 1 2 1 1 5] [1 1 1 1 1 1 1 7] [1 7 6 6 6 5 5] [1 7 7 7 7 7 7] ] [ 150000 [1 3 1 1 2 4 1 1] [1 1 3 1 2 3 2 1] [1 7 5 5 5 4 1] [1 7 7 5 5 4 2] ] [ 300000 [1 1 4 2 1 1 1 3] [1 2 4 1 1 1 2 2] [1 7 7 4 3 3 3] [1 7 6 3 3 3 3] ] [ 450000 [1 1 4 1 1 4 1 1] [1 3 2 1 2 1 2 2] [1 7 7 4 4 4 1] [1 7 5 4 4 3 3] ] ] [ % CH8 [ 0 [2 1 1 2 1 1 2 5] [1 1 1 1 1 1 1 8] [8 7 7 7 6 6 6] [8 8 8 8 8 8 8] ] [ 150000 [2 1 1 2 1 1 5 2] [1 1 2 1 5 2 1 2] [8 7 7 7 6 6 6] [8 8 8 7 7 3 2] ] [ 300000 [2 1 1 4 2 2 2 1] [1 1 4 2 1 2 1 3] [8 7 7 7 4 3 2] [8 8 8 5 4 4 3] ] [ 450000 [2 2 2 1 1 3 1 3] [1 1 2 1 1 2 4 3] [8 7 6 5 5 5 3] [8 8 8 7 7 7 6] ] [ 600000 [2 3 1 1 4 2 1 1] [1 1 3 1 3 1 2 3] [8 7 5 5 5 2 1] [8 8 8 6 6 4 4] ] [ 750000 [2 1 3 1 2 3 2 1] [1 2 1 1 3 4 1 2] [8 7 7 5 5 4 2] [8 8 7 7 7 5 2] ] [ 900000 [2 2 1 4 1 2 2 1] [1 2 1 2 1 5 1 2] [8 7 6 6 3 3 2] [8 8 7 7 6 6 2] ] [ 1050000 [2 4 1 1 1 2 2 2] [1 2 1 2 1 3 1 4] [8 7 4 4 4 4 3] [8 8 7 7 6 6 4] ] [ 1200000 [2 2 1 5 2 1 1 1] [1 3 1 3 2 1 1 3] [8 7 6 6 2 1 1] [8 8 6 6 4 3 3] ] [ 1350000 [2 2 1 3 3 1 1 2] [1 4 1 2 1 1 4 1] [8 7 6 6 4 2 2] [8 8 5 5 4 4 4] ] [ 1500000 [3 1 2 2 2 1 1 3] [1 1 1 1 2 2 4 3] [8 6 6 5 4 3 3] [8 8 8 8 8 7 6] ] [ 1650000 [3 2 1 2 3 1 2 1] [1 1 1 1 3 2 4 2] [8 6 5 5 4 2 2] [8 8 8 8 8 6 5] ] [ 1800000 [3 1 1 3 2 3 1 1] [1 2 1 1 3 4 2 1] [8 6 6 6 4 3 1] [8 8 7 7 7 5 2] ] [ 1950000 [3 2 1 2 1 2 2 2] [1 2 4 1 2 2 1 2] [8 6 5 5 4 4 3] [8 8 7 4 4 3 2] ] [ 2100000 [3 1 2 1 4 2 1 1] [1 4 1 2 1 1 2 3] [8 6 6 5 5 2 1] [8 8 5 5 4 4 4] ] [ 2250000 [4 1 1 4 1 1 2 1] [1 1 4 2 1 1 1 4] [8 5 5 5 2 2 2] [8 8 8 5 4 4 4] ] [ 2400000 [4 3 1 2 1 2 1 1] [1 2 4 2 2 2 1 1] [8 5 3 3 2 2 1] [8 8 7 4 3 2 1] ] [ 2550000 [5 1 1 1 1 1 3 2] [1 2 2 4 3 1 1 1] [8 4 4 4 4 4 4] [8 8 7 6 3 1 1] ] [ 2700000 [1 1 3 6 1 1 1 1] [2 1 1 2 1 1 6 1] [8 8 8 6 1 1 1] [8 7 7 7 6 6 6] ] [ 2850000 [1 1 1 2 2 3 2 3] [2 1 3 3 2 1 1 2] [8 8 8 8 7 6 4] [8 7 7 5 3 2 2] ] [ 3000000 [1 2 3 3 3 1 1 1] [2 1 1 1 5 1 2 2] [8 8 7 5 3 1 1] [8 7 7 7 7 3 3] ] [ 3150000 [1 3 1 2 2 2 3 1] [2 1 1 3 2 1 3 2] [8 8 6 6 5 4 3] [8 7 7 7 5 4 4] ] [ 3300000 [1 5 1 1 3 1 1 2] [2 1 1 4 3 2 1 1] [8 8 4 4 4 2 2] [8 7 7 7 4 2 1] ] [ 3450000 [1 1 2 2 2 5 1 1] [2 2 2 2 3 1 1 2] [8 8 8 7 6 5 1] [8 7 6 5 4 2 2] ] [ 3600000 [1 2 1 1 3 4 2 1] [2 2 3 1 1 1 2 3] [8 8 7 7 7 5 2] [8 7 6 4 4 4 4] ] [ 3750000 [1 1 2 1 1 5 3 1] [2 3 1 1 4 1 2 1] [8 8 8 7 7 7 3] [8 7 5 5 5 2 2] ] [ 3900000 [1 3 1 2 4 2 1 1] [2 3 3 1 1 1 2 2] [8 8 6 6 5 2 1] [8 7 5 3 3 3 3] ] [ 4050000 [1 3 1 2 3 1 2 2] [2 6 2 1 1 1 1 1] [8 8 6 6 5 3 3] [8 7 2 1 1 1 1] ] [ 4200000 [2 1 1 2 1 2 2 4] [2 1 3 1 3 3 1 1] [8 7 7 7 6 6 5] [8 7 7 5 5 3 1] ] [ 4350000 [2 2 1 4 1 2 2 1] [2 1 4 1 3 1 2 1] [8 7 6 6 3 3 2] [8 7 7 4 4 2 2] ] [ 4500000 [2 1 1 1 2 1 3 4] [2 2 2 1 2 1 3 2] [8 7 7 7 7 6 6] [8 7 6 5 5 4 4] ] [ 4650000 [2 4 2 1 2 2 1 1] [2 2 2 1 2 1 2 3] [8 7 4 3 3 2 1] [8 7 6 5 5 4 4] ] [ 4800000 [2 3 2 1 1 2 2 2] [2 4 1 2 1 1 3 1] [8 7 5 4 4 4 3] [8 7 4 4 3 3 3] ] [ 4950000 [3 2 2 1 2 1 1 3] [2 1 1 2 1 1 1 6] [8 6 5 4 4 3 3] [8 7 7 7 6 6 6] ] [ 5100000 [3 2 1 1 1 3 3 1] [2 2 3 2 1 1 3 1] [8 6 5 5 5 5 3] [8 7 6 4 3 3 3] ] [ 5250000 [4 1 2 1 2 2 1 2] [2 1 4 1 2 1 1 3] [8 5 5 4 4 3 2] [8 7 7 4 4 3 3] ] [ 5400000 [5 1 2 1 2 1 1 2] [2 2 1 1 4 1 3 1] [8 4 4 3 3 2 2] [8 7 6 6 6 3 3] ] [ 5550000 [1 1 4 4 1 2 1 1] [3 1 2 1 1 3 2 2] [8 8 8 5 2 2 1] [8 6 6 5 5 5 3] ] [ 5700000 [1 2 1 1 2 1 3 4] [3 1 4 1 2 2 1 1] [8 8 7 7 7 6 6] [8 6 6 3 3 2 1] ] [ 5850000 [1 1 3 3 2 2 2 1] [3 2 1 1 2 1 4 1] [8 8 8 6 4 3 2] [8 6 5 5 5 4 4] ] [ 6000000 [1 4 3 1 1 2 1 2] [3 2 2 1 2 2 1 2] [8 8 5 3 3 3 2] [8 6 5 4 4 3 2] ] [ 6150000 [2 1 1 4 1 2 1 3] [3 1 1 2 1 2 1 4] [8 7 7 7 4 4 3] [8 6 6 6 5 5 4] ] [ 6300000 [2 2 2 1 3 2 2 1] [3 1 4 1 3 1 1 1] [8 7 6 5 5 3 2] [8 6 6 3 3 1 1] ] [ 6450000 [2 5 1 3 1 1 1 1] [3 2 1 1 2 3 1 2] [8 7 3 3 1 1 1] [8 6 5 5 5 4 2] ] [ 6600000 [3 2 3 1 2 1 2 1] [3 1 3 2 2 1 1 2] [8 6 5 3 3 2 2] [8 6 6 4 3 2 2] ] [ 6750000 [4 1 2 2 1 1 3 1] [3 2 1 3 1 1 3 1] [8 5 5 4 3 3 3] [8 6 5 5 3 3 3] ] [ 6900000 [1 2 1 4 2 2 2 1] [4 1 1 2 2 2 2 1] [8 8 7 7 4 3 2] [8 5 5 5 4 3 2] ] [ 7050000 [1 2 5 2 1 2 1 1] [4 2 1 3 2 1 1 1] [8 8 7 3 2 2 1] [8 5 4 4 2 1 1] ] [ 7200000 [2 2 2 1 3 1 3 1] [4 1 3 1 3 1 1 1] [8 7 6 5 5 3 3] [8 5 5 3 3 1 1] ] [ 7350000 [3 1 4 2 1 1 1 2] [4 2 2 1 1 1 2 2] [8 6 6 3 2 2 2] [8 5 4 3 3 3 3] ] [ 7500000 [1 1 1 4 1 1 3 3] [5 2 1 2 2 1 1 1] [8 8 8 8 5 5 5] [8 4 3 3 2 1 1] ] [ 7650000 [5 2 1 2 1 2 1 1] [5 2 2 1 1 2 1 1] [8 4 3 3 2 2 1] [8 4 3 2 2 2 1] ] ] ] readonly def /channelcode.mod23map [ [] [] [ 13 12 4 9 3 1 ] [ 8 2 12 3 18 16 4 1 ] [ 11 16 17 8 20 4 10 2 5 1 ] [ 1 4 16 18 3 12 2 8 9 13 6 1 ] [ 20 16 22 13 15 12 5 4 17 9 21 3 7 1 ] [ 2 6 18 8 1 3 9 4 12 13 16 2 6 18 8 1 ] ] readonly def /channelcode.maxvals [ 26 292 3493 44072 576688 7742862 ] readonly def /channelcode.shortfinder [ 1 1 1 1 1 ] readonly def /channelcode.longfinder [ 1 1 1 1 1 1 1 1 1 ] readonly def /channelcode { 64 dict begin { /dontdraw false def /shortfinder false def /includetext false def /includecheck false def /height -1.0 def /width 0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def /barlen barcode length def % % Validate the input % barlen 2 lt barlen 7 gt or { /bwipp.channelcodeBadLength (Channel Code must be 2 to 7 digits) //raiseerror exec } if barcode { dup 48 lt exch 57 gt or { /bwipp.channelcodeBadCharacter (Channel Code must contain only digits) //raiseerror exec } if } forall barcode cvi //channelcode.maxvals barlen 2 sub get gt { /bwipp.channelcodeTooBig (The Channel Code value is too big for the number of channels) //raiseerror exec } if % % Apply AST spec overrides and resolve physical specification % /channelcode ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec % % Tail-call optimisation FTW! % /loops1 { /s2max s1max 1 add s1 sub def /b1 1 def s1 1 eq {nextb1} {loopb1} ifelse } def /loopb1 { /b2max b1max 1 add b1 sub def /s2 1 def loops2 } def /loops2 { /s3max s2max 1 add s2 sub def /b2 1 def s1 b1 add s2 add 3 eq {nextb2} {loopb2} ifelse } def /loopb2 { /b3max b2max 1 add b2 sub def /s3 1 def loops3 } def /loops3 { /s4max s3max 1 add s3 sub def /b3 1 def b1 s2 add b2 add s3 add 4 eq {nextb3} {loopb3} ifelse } def /loopb3 { /b4max b3max 1 add b3 sub def /s4 1 def loops4 } def /loops4 { /s5max s4max 1 add s4 sub def /b4 1 def b2 s3 add b3 add s4 add 4 eq {nextb4} {loopb4} ifelse } def /loopb4 { /b5max b4max 1 add b4 sub def /s5 1 def loops5 } def /loops5 { /s6max s5max 1 add s5 sub def /b5 1 def b3 s4 add b4 add s5 add 4 eq {nextb5} {loopb5} ifelse } def /loopb5 { /b6max b5max 1 add b5 sub def /s6 1 def loops6 } def /loops6 { /s7max s6max 1 add s6 sub def /b6 1 def b4 s5 add b5 add s6 add 4 eq {nextb6} {loopb6} ifelse } def /loopb6 { /b7max b6max 1 add b6 sub def /s7 1 def loops7 } def /loops7 { /s8 s7max 1 add s7 sub def /b7 1 def b5 s6 add b6 add s7 add 4 eq {nextb7} {loopb7} ifelse } def /loopb7 { /b8 b7max 1 add b7 sub def b6 s7 add b7 add s8 add b8 add 5 eq {nextb7} {chkchr} ifelse } def /chkchr { value target eq { [s1 b1 s2 b2 s3 b3 s4 b4 s5 b5 s6 b6 s7 b7 s8 b8] exit } if /value value 1 add def nextb7 } def /nextb7 { /b7 b7 1 add def b7 b7max le {loopb7} {nexts7} ifelse } def /nexts7 { /s7 s7 1 add def s7 s7max le {loops7} {nextb6} ifelse } def /nextb6 { /b6 b6 1 add def b6 b6max le {loopb6} {nexts6} ifelse } def /nexts6 { /s6 s6 1 add def s6 s6max le {loops6} {nextb5} ifelse } def /nextb5 { /b5 b5 1 add def b5 b5max le {loopb5} {nexts5} ifelse } def /nexts5 { /s5 s5 1 add def s5 s5max le {loops5} {nextb4} ifelse } def /nextb4 { /b4 b4 1 add def b4 b4max le {loopb4} {nexts4} ifelse } def /nexts4 { /s4 s4 1 add def s4 s4max le {loops4} {nextb3} ifelse } def /nextb3 { /b3 b3 1 add def b3 b3max le {loopb3} {nexts3} ifelse } def /nexts3 { /s3 s3 1 add def s3 s3max le {loops3} {nextb2} ifelse } def /nextb2 { /b2 b2 1 add def b2 b2max le {loopb2} {nexts2} ifelse } def /nexts2 { /s2 s2 1 add def s2 s2max le {loops2} {nextb1} ifelse } def /nextb1 { /b1 b1 1 add def b1 b1max le {loopb1} {nexts1} ifelse } def /nexts1 { /s1 s1 1 add def s1 s1max le {loops1} if } def /encode { /chan exch def /target exch def % % Lookup memoized starting value close to the target % //channelcode.memo chan 3 sub get { /m exch def m 0 get target gt {exit} if /mv m 0 get def /mb m 1 get def /ms m 2 get def /mbmax m 3 get def /msmax m 4 get def } forall /value mv def mb aload pop [/b8 /b7 /b6 /b5 /b4 /b3 /b2 /b1] {exch def} forall ms aload pop [/s8 /s7 /s6 /s5 /s4 /s3 /s2 /s1] {exch def} forall mbmax aload pop [/b7max /b6max /b5max /b4max /b3max /b2max /b1max] {exch def} forall msmax aload pop [/s7max /s6max /s5max /s4max /s3max /s2max /s1max] {exch def} forall 1 {chkchr} repeat 8 chan sub 2 mul dup 16 exch sub getinterval } def % % Determine finder % /finder shortfinder { //channelcode.shortfinder } { //channelcode.longfinder } ifelse def % % Encode the main data % /data barcode cvi barlen 1 add encode def % % Determine check data % /check [] def includecheck { /mod23 //channelcode.mod23map barlen get def 0 0 1 data length 1 sub { dup data exch get 1 sub exch mod23 exch get mul add } for 23 mod 3 encode /check exch def } if % % Construct the symbol % /sbs [ finder aload pop data aload pop check aload pop ] def /height /resolve_height //render exec dup -1 eq { pop 1.0 } if def % % Create the human readable text % /txt barlen array def 0 1 barlen 1 sub { /i exch def txt i [barcode i 1 getinterval 0 0 () 0] put } for << /ren /renlinear /sbs sbs /bhs [sbs length 1 add 2 idiv {height} repeat] /bbs [sbs length 1 add 2 idiv {0} repeat] /txt txt /text1xalign (center) /borderleft 1.0 /borderright 2.0 /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /channelcode dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER channelcode-- % --BEGIN ENCODER flattermarken-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear-- % --DESC: Flattermarken % --EXAM: 11099 % --EXOP: inkspread=-0.25 showborder borderleft=0 borderright=0 % --RNDR: renlinear %%BeginResource: uk.co.terryburton.bwipp flattermarken 0.0 2026052800 67624 70896 %%BeginData: 114 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /flattermarken.encs [ (0018) (0117) (0216) (0315) (0414) (0513) (0612) (0711) (0810) (0900) ] readonly def /flattermarken.barchars (1234567890) readonly def /flattermarken { 16 dict begin { /dontdraw false def /includetext false def % Enable/disable text /text1font /Courier def /text1size 10.0 def /text1yoffset -7.0 def /height -1.0 def /width 0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def barcode length 500 gt { /bwipp.flattermarkeninputTooLong (The input data is too long) //raiseerror exec } if /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Validate the input % barcode { dup 48 lt exch 57 gt or { /bwipp.flattermarkenBadCharacter (Flattermarken must contain only digits) //raiseerror exec } if } forall /barlen barcode length def % % Apply AST spec overrides and resolve physical specification % /flattermarken ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec /sbs barlen 4 mul string def 0 1 barlen 1 sub { /i exch def barcode i 1 getinterval //flattermarken.barchars exch search pop length /indx exch def pop pop /enc //flattermarken.encs indx get def sbs i 4 mul enc putinterval } for /height /resolve_height //render exec dup -1 eq { pop 0.3 } if def << /ren /renlinear /sbs [sbs {48 sub} forall] /bhs [sbs length 1 add 2 idiv {height} repeat] /bbs [sbs length 1 add 2 idiv {0} repeat] /txt [ [barcode 0 0 text1font text1size] ] /text1xalign (center) /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /flattermarken dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER flattermarken-- % --BEGIN ENCODER raw-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear-- % --DESC: Custom 1D symbology % --EXAM: 331132131313411122131311333213114131131221323 % --EXOP: height=0.5 % --RNDR: renlinear %%BeginResource: uk.co.terryburton.bwipp raw 0.0 2026052800 65012 64935 %%BeginData: 86 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 5 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /raw { 16 dict begin { /dontdraw false def /height -1.0 def /width 0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Validate input % barcode length 2500 gt { /bwipp.rawinputTooLong (The input data is too long) //raiseerror exec } if barcode { dup 49 lt exch 57 gt or { /bwipp.rawBadCharacter (Raw must contain only digits 1 to 9) //raiseerror exec } if } forall % % Apply AST spec overrides and resolve physical specification % /raw ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec /height /resolve_height //render exec dup -1 eq { pop 1.0 } if def << /ren /renlinear /sbs [barcode {48 sub} forall] /bhs [barcode length 1 add 2 idiv {height} repeat] /bbs [barcode length 1 add 2 idiv {0} repeat] /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /raw dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER raw-- % --BEGIN ENCODER daft-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear-- % --DESC: Custom 4 state symbology % --EXAM: FATDAFTDAD % --EXOP: % --RNDR: renlinear %%BeginResource: uk.co.terryburton.bwipp daft 0.0 2026052800 68832 72068 %%BeginData: 112 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 5 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renlinear dup /uk.co.terryburton.bwipp findresource put begin /daft { 16 dict begin { /dontdraw false def /height -1.0 def /width 0 def /propspec false def /loosespec false def /strictspec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def barcode () eq { /bwipp.daftEmptyData (The data must not be empty) //raiseerror exec } if barcode length 2500 gt { /bwipp.daftinputTooLong (The input data is too long) //raiseerror exec } if barcode { dup 68 ne exch dup 65 ne exch dup 70 ne exch 84 ne and and and { /bwipp.daftBadCharacter (DAFT must contain only characters D, A, F and T) //raiseerror exec } if } forall /barlen barcode length def % % Apply AST spec overrides and resolve physical specification % /daft ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec /height /resolve_height //render exec dup -1 eq { pop 0.175 } if def /bbs barlen array def /bhs barlen array def 0 1 barlen 1 sub { /i exch def /enc barcode i 1 getinterval def enc (D) eq { bbs i 0 height mul 8 div put bhs i 5 height mul 8 div put } if enc (A) eq { bbs i 3 height mul 8 div put bhs i 5 height mul 8 div put } if enc (F) eq { bbs i 0 height mul 8 div put bhs i 8 height mul 8 div put } if enc (T) eq { bbs i 3 height mul 8 div put bhs i 2 height mul 8 div put } if } for << /ren /renlinear /bbs bbs /bhs bhs /sbs [bhs length 1 sub {1.44 1.872} repeat 1.44] /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renlinear if } stopped {end stop} if end } [/barcode] {null def} forall bind def /daft dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER daft-- % --BEGIN ENCODER symbol-- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render renlinear renmatrix-- % --DESC: Miscellaneous symbols % --EXAM: fima % --EXOP: % --RNDR: renlinear renmatrix % --FMLY: Postal Symbols %%BeginResource: uk.co.terryburton.bwipp symbol 0.0 2026052800 739725 742830 %%BeginData: 120 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 33 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render 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 /symbol.fimasbs [ 2.25 2.25 2.25 11.25 2.25 11.25 2.25 2.25 2.25 ] readonly def /symbol.fimabhs [ //symbol.fimasbs length 2 idiv 1 add {.625} repeat ] readonly def /symbol.fimabbs [ //symbol.fimasbs length 2 idiv 1 add {0 } repeat ] readonly def /symbol.fimbsbs [ 2.25 6.75 2.25 2.25 2.25 6.25 2.25 2.25 2.25 6.75 2.25 ] readonly def /symbol.fimbbhs [ //symbol.fimbsbs length 2 idiv 1 add {.625} repeat ] readonly def /symbol.fimbbbs [ //symbol.fimbsbs length 2 idiv 1 add {0 } repeat ] readonly def /symbol.fimcsbs [ 2.25 2.25 2.25 6.75 2.25 6.75 2.25 6.75 2.25 2.25 2.25 ] readonly def /symbol.fimcbhs [ //symbol.fimcsbs length 2 idiv 1 add {.625} repeat ] readonly def /symbol.fimcbbs [ //symbol.fimcsbs length 2 idiv 1 add {0 } repeat ] readonly def /symbol.fimdsbs [ 2.25 2.25 2.25 2.25 2.25 6.75 2.25 6.75 2.25 2.25 2.25 2.25 2.25 ] readonly def /symbol.fimdbhs [ //symbol.fimdsbs length 2 idiv 1 add {.625} repeat ] readonly def /symbol.fimdbbs [ //symbol.fimdsbs length 2 idiv 1 add {0 } repeat ] readonly def /symbol.fimesbs [ 2.25 6.75 2.25 15.75 2.25 6.75 2.25 ] readonly def /symbol.fimebhs [ //symbol.fimesbs length 2 idiv 1 add {.625} repeat ] readonly def /symbol.fimebbs [ //symbol.fimesbs length 2 idiv 1 add {0 } repeat ] readonly def /symbol.zebrasbs [ 100 { 1 1 } repeat 1 ] readonly def /symbol.zebrabhs [ //symbol.zebrasbs length 2 idiv 1 add {1} repeat ] readonly def /symbol.zebrabbs [ //symbol.zebrasbs length 2 idiv 1 add {0} repeat ] readonly def /symbol.checksize 199 def /symbol.checkpixs [ //symbol.checksize dup mul 2 idiv {1 0} repeat 1 ] readonly def /symbol.symbols << /fima { << /ren /renlinear /sbs //symbol.fimasbs /bhs //symbol.fimabhs /bbs //symbol.fimabbs >> } bind /fimb { << /ren /renlinear /sbs //symbol.fimbsbs /bhs //symbol.fimbbhs /bbs //symbol.fimbbbs >> } bind /fimc { << /ren /renlinear /sbs //symbol.fimcsbs /bhs //symbol.fimcbhs /bbs //symbol.fimcbbs >> } bind /fimd { << /ren /renlinear /sbs //symbol.fimdsbs /bhs //symbol.fimdbhs /bbs //symbol.fimdbbs >> } bind /fime { << /ren /renlinear /sbs //symbol.fimesbs /bhs //symbol.fimebhs /bbs //symbol.fimebbs >> } bind /zebra { << /ren /renlinear /sbs //symbol.zebrasbs /bhs //symbol.zebrabhs /bbs //symbol.zebrabbs >> } bind /check { << /ren /renmatrix /pixs //symbol.checkpixs /pixx //symbol.checksize /pixy //symbol.checksize /height //symbol.checksize 72 div /width //symbol.checksize 72 div >> } bind >> readonly def /symbol.renmap << /renlinear //renlinear /renmatrix //renmatrix >> readonly def /symbol { 4 dict begin { /dontdraw false def /propspec false def /loosespec false def /strictspec false def /width 0 def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xmin -1.0 def /xnom -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Validate input % barcode length 50 gt { /bwipp.symbolinputTooLong (The input data is too long) //raiseerror exec } if //symbol.symbols barcode known not { /bwipp.symbolUnknownSymbol (Unknown symbol name provided) //raiseerror exec } if % % Apply AST spec overrides and resolve physical specification % /symbol ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec //symbol.symbols barcode get exec dup /strictspec strictspec put dup /loosespec loosespec put dup /xdim xdim put dup /xmin xmin put dup /xmax xmax put dup /modunit modunit put dup /opt options put _render { dup /ren get //symbol.renmap exch get exec } if } stopped {end stop} if end } [/barcode] {null def} forall bind def /symbol dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER symbol-- % --BEGIN ENCODER pdf417-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor fifocache rsecprime render renmatrix-- % --DESC: PDF417 % --EXAM: This is PDF417 % --EXOP: columns=2 % --RNDR: renmatrix % --FMLY: Two-dimensional symbols %%BeginResource: uk.co.terryburton.bwipp pdf417 0.0 2026052800 272470 274414 %%BeginData: 1221 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 33 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /fifocache dup /uk.co.terryburton.bwipp findresource put dup /rsecprime dup /uk.co.terryburton.bwipp findresource put dup /setuphooks dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put begin /pdf417 [/before /after] //setuphooks exec (setup.define) //pdf417.before exec % % Modes and text submodes % /pdf417.t 0 def /pdf417.n 1 def /pdf417.b 2 def /pdf417.a 0 def /pdf417.l 1 def /pdf417.m 2 def /pdf417.p 3 def % % Special function characters for mode switching % /pdf417.tl -1 def /pdf417.nl -2 def /pdf417.bl -3 def /pdf417.bl6 -4 def /pdf417.bs -5 def % % Special function characters for text mode % /pdf417.al -6 def /pdf417.ll -7 def /pdf417.ml -8 def /pdf417.pl -9 def /pdf417.as -10 def /pdf417.ps -11 def /al //pdf417.al def /ll //pdf417.ll def /ml //pdf417.ml def /pl //pdf417.pl def /as //pdf417.as def /ps //pdf417.ps def % % States % /pdf417.textsubmodes [ pdf417.a pdf417.l pdf417.m pdf417.p ] readonly def % % Character maps for each state % /pdf417.charmaps [ % A L M P [ (A) (a) (0) (;) ] % 0 [ (B) (b) (1) (<) ] % 1 [ (C) (c) (2) (>) ] % 2 [ (D) (d) (3) (@) ] % 3 [ (E) (e) (4) ([) ] % 4 [ (F) (f) (5) 92 ] % 5 [ (G) (g) (6) (]) ] % 6 [ (H) (h) (7) (_) ] % 7 [ (I) (i) (8) (`) ] % 8 [ (J) (j) (9) (~) ] % 9 [ (K) (k) (&) (!) ] % 10 [ (L) (l) 13 13 ] % 11 [ (M) (m) 9 9 ] % 12 [ (N) (n) (,) (,) ] % 13 [ (O) (o) (:) (:) ] % 14 [ (P) (p) (#) 10 ] % 15 [ (Q) (q) (-) (-) ] % 16 [ (R) (r) (.) (.) ] % 17 [ (S) (s) ($) ($) ] % 18 [ (T) (t) (/) (/) ] % 19 [ (U) (u) (+) (") ] % 20 [ (V) (v) (%) (|) ] % 21 [ (W) (w) (*) (*) ] % 22 [ (X) (x) (=) 40 ] % 23 [ (Y) (y) (^) 41 ] % 24 [ (Z) (z) pl (?) ] % 25 [ ( ) ( ) ( ) ({) ] % 26 [ ll as ll (}) ] % 27 [ ml ml al (') ] % 28 [ ps ps ps al ] % 29 ] readonly def /pdf417.e 40000 def % "Empty" - must exceed max cost: 12500*3+4 /e //pdf417.e def % % Bit length of latch between submodes % /pdf417.latlen [ % To: A L M P From [ 0 1 1 2 ] % A [ 2 0 1 2 ] % L [ 1 1 0 1 ] % M [ 1 2 2 0 ] % P ] readonly def % % Latch sequences between submodes % /pdf417.latseq [ % To: A L M P From [ [] [ll] [ml] [ml pl] ] % A [ [ml al] [] [ml] [ml pl] ] % L [ [al] [ll] [] [pl] ] % M [ [al] [al ll] [al ml] [] ] % P ] readonly def % % Bit length of shift to submode % /pdf417.shftlen [ % To: A L M P From [ e e e 1 ] % A [ 1 e e 1 ] % L [ e e e 1 ] % M [ e e e e ] % P ] readonly def /pdf417.latchcws << //pdf417.tl 900 //pdf417.bl 901 //pdf417.bl6 924 //pdf417.nl 902 //pdf417.bs 913 >> readonly def /pdf417.textencfuncs [ /enca /encl /encm /encp ] readonly def /pdf417.encfuncs [ /enct /encn /encb ] readonly def % % Base 10 encoding of the bar space successions for the codewords in each cluster % /pdf417.clusters [ [ 120256 125680 128380 120032 125560 128318 108736 119920 108640 86080 108592 86048 110016 120560 125820 109792 120440 125758 88256 109680 88160 89536 110320 120700 89312 110200 120638 89200 110140 89840 110460 89720 110398 89980 128506 119520 125304 128190 107712 119408 125244 107616 119352 84032 107568 119324 84000 107544 83984 108256 119672 125374 85184 108144 119612 85088 108088 119582 85040 108060 85728 108408 119742 85616 108348 85560 108318 85880 108478 85820 85790 107200 119152 125116 107104 119096 125086 83008 107056 119068 82976 107032 82960 82952 83648 107376 119228 83552 107320 119198 83504 107292 83480 83468 83824 107452 83768 107422 83740 83900 106848 118968 125022 82496 106800 118940 82464 106776 118926 82448 106764 82440 106758 82784 106936 119006 82736 106908 82712 106894 82700 82694 106974 82830 82240 106672 118876 82208 106648 118862 82192 106636 82184 106630 82180 82352 82328 82316 82080 118830 106572 106566 82050 117472 124280 127678 103616 117360 124220 103520 117304 124190 75840 103472 75808 104160 117624 124350 76992 104048 117564 76896 103992 76848 76824 77536 104312 117694 77424 104252 77368 77340 77688 104382 77628 77758 121536 126320 128700 121440 126264 128670 111680 121392 126236 111648 121368 126222 111632 121356 103104 117104 124092 112320 103008 117048 124062 112224 121656 126366 93248 74784 102936 117006 93216 112152 93200 75456 103280 117180 93888 75360 103224 117150 93792 112440 121758 93744 75288 93720 75632 103356 94064 75576 103326 94008 112542 93980 75708 94140 75678 94110 121184 126136 128606 111168 121136 126108 111136 121112 126094 111120 121100 111112 111108 102752 116920 123998 111456 102704 116892 91712 74272 121244 116878 91680 74256 102668 91664 111372 102662 74244 74592 102840 116958 92000 74544 102812 91952 111516 102798 91928 74508 74502 74680 102878 92088 74652 92060 74638 92046 92126 110912 121008 126044 110880 120984 126030 110864 120972 110856 120966 110852 110850 74048 102576 116828 90944 74016 102552 116814 90912 111000 121038 90896 73992 102534 90888 110982 90884 74160 102620 91056 74136 102606 91032 111054 91020 74118 91014 91100 91086 110752 120920 125998 110736 120908 110728 120902 110724 110722 73888 102488 116782 90528 73872 102476 90512 110796 102470 90504 73860 90500 73858 73944 90584 90572 90566 120876 120870 110658 102444 73800 90312 90308 90306 101056 116080 123580 100960 116024 70720 100912 115996 70688 100888 70672 70664 71360 101232 116156 71264 101176 116126 71216 101148 71192 71180 71536 101308 71480 101278 71452 71612 71582 118112 124600 127838 105024 118064 124572 104992 118040 124558 104976 118028 104968 118022 100704 115896 123486 105312 100656 115868 79424 70176 118172 115854 79392 105240 100620 79376 70152 79368 70496 100792 115934 79712 70448 118238 79664 105372 100750 79640 70412 79628 70584 100830 79800 70556 79772 70542 70622 79838 122176 126640 128860 122144 126616 128846 122128 126604 122120 126598 122116 104768 117936 124508 113472 104736 126684 124494 113440 122264 126670 113424 104712 117894 113416 122246 104706 69952 100528 115804 78656 69920 100504 115790 96064 78624 104856 117966 96032 113560 122318 100486 96016 78600 104838 96008 69890 70064 100572 78768 70040 100558 96176 78744 104910 96152 113614 70022 78726 70108 78812 70094 96220 78798 122016 126552 128814 122000 126540 121992 126534 121988 121986 104608 117848 124462 113056 104592 126574 113040 122060 117830 113032 104580 113028 104578 113026 69792 100440 115758 78240 69776 100428 95136 78224 104652 100422 95120 113100 69764 95112 78212 69762 78210 69848 100462 78296 69836 95192 78284 69830 95180 78278 69870 95214 121936 126508 121928 126502 121924 121922 104528 117804 112848 104520 117798 112840 121958 112836 104514 112834 69712 100396 78032 69704 100390 94672 78024 104550 94664 112870 69698 94660 78018 94658 78060 94700 94694 126486 121890 117782 104484 104482 69672 77928 94440 69666 77922 99680 68160 99632 68128 99608 115342 68112 99596 68104 99590 68448 99768 115422 68400 99740 68376 99726 68364 68358 68536 99806 68508 68494 68574 101696 116400 123740 101664 116376 101648 116364 101640 116358 101636 67904 99504 115292 72512 67872 116444 115278 72480 101784 116430 72464 67848 99462 72456 101766 67842 68016 99548 72624 67992 99534 72600 101838 72588 67974 68060 72668 68046 72654 118432 124760 127918 118416 124748 118408 124742 118404 118402 101536 116312 105888 101520 116300 105872 118476 116294 105864 101508 105860 101506 105858 67744 99416 72096 67728 116334 80800 72080 101580 99398 80784 105932 67716 80776 72068 67714 72066 67800 99438 72152 67788 80856 72140 67782 80844 72134 67822 72174 80878 126800 128940 126792 128934 126788 126786 118352 124716 122576 126828 124710 122568 126822 122564 118338 122562 101456 116268 105680 101448 116262 114128 105672 118374 114120 122598 101442 114116 105666 114114 67664 99372 71888 67656 99366 80336 71880 101478 97232 80328 105702 67650 97224 114150 71874 97220 67692 71916 67686 80364 71910 97260 80358 97254 126760 128918 126756 126754 118312 124694 122472 126774 122468 118306 122466 101416 116246 105576 101412 113896 105572 101410 113892 105570 113890 67624 99350 71784 101430 80104 71780 67618 96744 80100 71778 96740 80098 96738 71798 96758 126738 122420 122418 105524 113780 113778 71732 79988 96500 96498 66880 66848 98968 66832 66824 66820 66992 66968 66956 66950 67036 67022 100000 99984 115532 99976 115526 99972 99970 66720 98904 69024 100056 98892 69008 100044 69000 100038 68996 66690 68994 66776 98926 69080 100078 69068 66758 69062 66798 69102 116560 116552 116548 116546 99920 102096 116588 115494 102088 116582 102084 99906 102082 66640 68816 66632 98854 73168 68808 66628 73160 68804 66626 73156 68802 66668 68844 66662 73196 68838 73190 124840 124836 124834 116520 118632 124854 118628 116514 118626 99880 115478 101992 116534 106216 101988 99874 106212 101986 106210 66600 98838 68712 99894 72936 68708 66594 81384 72932 68706 81380 72930 66614 68726 72950 81398 128980 128978 124820 126900 124818 126898 116500 118580 116498 122740 118578 122738 99860 101940 99858 106100 101938 114420 ] [ 128352 129720 125504 128304 129692 125472 128280 129678 125456 128268 125448 128262 125444 125792 128440 129758 120384 125744 128412 120352 125720 128398 120336 125708 120328 125702 120324 120672 125880 128478 110144 120624 125852 110112 120600 125838 110096 120588 110088 120582 110084 110432 120760 125918 89664 110384 120732 89632 110360 120718 89616 110348 89608 110342 89952 110520 120798 89904 110492 89880 110478 89868 90040 110558 90012 89998 125248 128176 129628 125216 128152 129614 125200 128140 125192 128134 125188 125186 119616 125360 128220 119584 125336 128206 119568 125324 119560 125318 119556 119554 108352 119728 125404 108320 119704 125390 108304 119692 108296 119686 108292 108290 85824 108464 119772 85792 108440 119758 85776 108428 85768 108422 85764 85936 108508 85912 108494 85900 85894 85980 85966 125088 128088 129582 125072 128076 125064 128070 125060 125058 119200 125144 128110 119184 125132 119176 125126 119172 119170 107424 119256 125166 107408 119244 107400 119238 107396 107394 83872 107480 119278 83856 107468 83848 107462 83844 83842 83928 107502 83916 83910 83950 125008 128044 125000 128038 124996 124994 118992 125036 118984 125030 118980 118978 106960 119020 106952 119014 106948 106946 82896 106988 82888 106982 82884 82882 82924 82918 124968 128022 124964 124962 118888 124982 118884 118882 106728 118902 106724 106722 82408 106742 82404 82402 124948 124946 118836 118834 106612 106610 124224 127664 129372 124192 127640 129358 124176 127628 124168 127622 124164 124162 117568 124336 127708 117536 124312 127694 117520 124300 117512 124294 117508 117506 104256 117680 124380 104224 117656 124366 104208 117644 104200 117638 104196 104194 77632 104368 117724 77600 104344 117710 77584 104332 77576 104326 77572 77744 104412 77720 104398 77708 77702 77788 77774 128672 129880 93168 128656 129868 92664 128648 129862 92412 128644 128642 124064 127576 129326 126368 124048 129902 126352 128716 127558 126344 124036 126340 124034 126338 117152 124120 127598 121760 117136 124108 121744 126412 124102 121736 117124 121732 117122 121730 103328 117208 124142 112544 103312 117196 112528 121804 117190 112520 103300 112516 103298 112514 75680 103384 117230 94112 75664 103372 94096 112588 103366 94088 75652 94084 75650 75736 103406 94168 75724 94156 75718 94150 75758 128592 129836 91640 128584 129830 91388 128580 91262 128578 123984 127532 126160 123976 127526 126152 128614 126148 123970 126146 116944 124012 121296 116936 124006 121288 126182 121284 116930 121282 102864 116972 111568 102856 116966 111560 121318 111556 102850 111554 74704 102892 92112 74696 102886 92104 111590 92100 74690 92098 74732 92140 74726 92134 128552 129814 90876 128548 90750 128546 123944 127510 126056 128566 126052 123938 126050 116840 123958 121064 116836 121060 116834 121058 102632 116854 111080 121078 111076 102626 111074 74216 102646 91112 74212 91108 74210 91106 74230 91126 128532 90494 128530 123924 126004 123922 126002 116788 120948 116786 120946 102516 110836 102514 110834 73972 90612 73970 90610 128522 123914 125978 116762 120890 102458 110714 123552 127320 129198 123536 127308 123528 127302 123524 123522 116128 123608 127342 116112 123596 116104 123590 116100 116098 101280 116184 123630 101264 116172 101256 116166 101252 101250 71584 101336 116206 71568 101324 71560 101318 71556 71554 71640 101358 71628 71622 71662 127824 129452 79352 127816 129446 79100 127812 78974 127810 123472 127276 124624 123464 127270 124616 127846 124612 123458 124610 115920 123500 118224 115912 123494 118216 124646 118212 115906 118210 100816 115948 105424 100808 115942 105416 118246 105412 100802 105410 70608 100844 79824 70600 100838 79816 105446 79812 70594 79810 70636 79852 70630 79846 129960 95728 113404 129956 95480 113278 129954 95356 95294 127784 129430 78588 128872 129974 95996 78462 128868 127778 95870 128866 123432 127254 124520 123428 126696 128886 123426 126692 124514 126690 115816 123446 117992 115812 122344 117988 115810 122340 117986 122338 100584 115830 104936 100580 113640 104932 100578 113636 104930 113634 70120 100598 78824 70116 96232 78820 70114 96228 78818 96226 70134 78838 129940 94968 113022 129938 94844 94782 127764 78206 128820 127762 95102 128818 123412 124468 123410 126580 124466 126578 115764 117876 115762 122100 117874 122098 100468 104692 100466 113140 104690 113138 69876 78324 69874 95220 78322 95218 129930 94588 94526 127754 128794 123402 124442 126522 115738 117818 121978 100410 104570 112890 69754 78074 94714 94398 123216 127148 123208 127142 123204 123202 115408 123244 115400 123238 115396 115394 99792 115436 99784 115430 99780 99778 68560 99820 68552 99814 68548 68546 68588 68582 127400 129238 72444 127396 72318 127394 123176 127126 123752 123172 123748 123170 123746 115304 123190 116456 115300 116452 115298 116450 99560 115318 101864 99556 101860 99554 101858 68072 99574 72680 68068 72676 68066 72674 68086 72694 129492 80632 105854 129490 80508 80446 127380 72062 127924 127378 80766 127922 123156 123700 123154 124788 123698 124786 115252 116340 115250 118516 116338 118514 99444 101620 99442 105972 101618 105970 67828 72180 67826 80884 72178 80882 97008 114044 96888 113982 96828 96798 129482 80252 130010 97148 80190 97086 127370 127898 128954 123146 123674 124730 126842 115226 116282 118394 122618 99386 101498 105722 114170 67706 71930 80378 96632 113854 96572 96542 80062 96702 96444 96414 96350 123048 123044 123042 115048 123062 115044 115042 99048 115062 99044 99042 67048 99062 67044 67042 67062 127188 68990 127186 123028 123316 123026 123314 114996 115572 114994 115570 98932 100084 98930 100082 66804 69108 66802 69106 129258 73084 73022 127178 127450 123018 123290 123834 114970 115514 116602 98874 99962 102138 66682 68858 73210 81272 106174 81212 81182 72894 81342 97648 114364 97592 114334 97564 97550 81084 97724 81054 97694 97464 114270 97436 97422 80990 97502 97372 97358 97326 114868 114866 98676 98674 66292 66290 123098 114842 115130 98618 99194 66170 67322 69310 73404 73374 81592 106334 81564 81550 73310 81630 97968 114524 97944 114510 97932 97926 81500 98012 81486 97998 97880 114478 97868 97862 81454 97902 97836 97830 69470 73564 73550 81752 106414 81740 81734 73518 81774 81708 81702 ] [ 109536 120312 86976 109040 120060 86496 108792 119934 86256 108668 86136 129744 89056 110072 129736 88560 109820 129732 88312 109694 129730 88188 128464 129772 89592 128456 129766 89340 128452 89214 128450 125904 128492 125896 128486 125892 125890 120784 125932 120776 125926 120772 120770 110544 120812 110536 120806 110532 84928 108016 119548 84448 107768 119422 84208 107644 84088 107582 84028 129640 85488 108284 129636 85240 108158 129634 85116 85054 128232 129654 85756 128228 85630 128226 125416 128246 125412 125410 119784 125430 119780 119778 108520 119798 108516 108514 83424 107256 119166 83184 107132 83064 107070 83004 82974 129588 83704 107390 129586 83580 83518 128116 83838 128114 125172 125170 119284 119282 107508 107506 82672 106876 82552 106814 82492 82462 129562 82812 82750 128058 125050 119034 82296 106686 82236 82206 82366 82108 82078 76736 103920 117500 76256 103672 117374 76016 103548 75896 103486 75836 129384 77296 104188 129380 77048 104062 129378 76924 76862 127720 129398 77564 127716 77438 127714 124392 127734 124388 124386 117736 124406 117732 117730 104424 117750 104420 104418 112096 121592 126334 92608 111856 121468 92384 111736 121406 92272 111676 92216 111646 92188 75232 103160 117118 93664 74992 103036 93424 112252 102974 93304 74812 93244 74782 93214 129332 75512 103294 129908 129330 93944 75388 129906 93820 75326 93758 127604 75646 128756 127602 94078 128754 124148 126452 124146 126450 117236 121844 117234 121842 103412 103410 91584 111344 121212 91360 111224 121150 91248 111164 91192 111134 91164 91150 74480 102780 91888 74360 102718 91768 111422 91708 74270 91678 129306 74620 129850 92028 74558 91966 127546 128634 124026 126202 116986 121338 102906 90848 110968 121022 90736 110908 90680 110878 90652 90638 74104 102590 91000 74044 90940 74014 90910 74174 91070 90480 110780 90424 110750 90396 90382 73916 90556 73886 90526 90296 110686 90268 90254 73822 90334 90204 90190 71136 101112 116094 70896 100988 70776 100926 70716 70686 129204 71416 101246 129202 71292 71230 127348 71550 127346 123636 123634 116212 116210 101364 101362 79296 105200 118140 79072 105080 118078 78960 105020 78904 104990 78876 78862 70384 100732 79600 70264 100670 79480 105278 79420 70174 79390 129178 70524 129466 79740 70462 79678 127290 127866 123514 124666 115962 118266 100858 113376 122232 126654 95424 113264 122172 95328 113208 122142 95280 113180 95256 113166 95244 78560 104824 117950 95968 78448 104764 95856 113468 104734 95800 78364 95772 78350 95758 70008 100542 78712 69948 96120 78652 69918 96060 78622 96030 70078 78782 96190 94912 113008 122044 94816 112952 122014 94768 112924 94744 112910 94732 94726 78192 104636 95088 78136 104606 95032 113054 95004 78094 94990 69820 78268 69790 95164 78238 95134 94560 112824 121950 94512 112796 94488 112782 94476 94470 78008 104542 94648 77980 94620 77966 94606 69726 78046 94686 94384 112732 94360 112718 94348 94342 77916 94428 77902 94414 94296 112686 94284 94278 77870 94318 94252 94246 68336 99708 68216 99646 68156 68126 68476 68414 127162 123258 115450 99834 72416 101752 116414 72304 101692 72248 101662 72220 72206 67960 99518 72568 67900 72508 67870 72478 68030 72638 80576 105840 118460 80480 105784 118430 80432 105756 80408 105742 80396 80390 72048 101564 80752 71992 101534 80696 71964 80668 71950 80654 67772 72124 67742 80828 72094 80798 114016 122552 126814 96832 113968 122524 96800 113944 122510 96784 113932 96776 113926 96772 80224 105656 118366 97120 80176 105628 97072 114076 105614 97048 80140 97036 80134 97030 71864 101470 80312 71836 97208 80284 71822 97180 80270 97166 67678 71902 80350 97246 96576 113840 122460 96544 113816 122446 96528 113804 96520 113798 96516 96514 80048 105564 96688 80024 105550 96664 113870 96652 80006 96646 71772 80092 71758 96732 80078 96718 96416 113752 122414 96400 113740 96392 113734 96388 96386 79960 105518 96472 79948 96460 79942 96454 71726 79982 96494 96336 113708 96328 113702 96324 96322 79916 96364 79910 96358 96296 113686 96292 96290 79894 96310 66936 99006 66876 66846 67006 68976 100028 68920 99998 68892 68878 66748 69052 66718 69022 73056 102072 116574 73008 102044 72984 102030 72972 72966 68792 99934 73144 68764 73116 68750 73102 66654 68830 73182 81216 106160 118620 81184 106136 118606 81168 106124 81160 106118 81156 81154 72880 101980 81328 72856 101966 81304 106190 81292 72838 81286 68700 72924 68686 81372 72910 81358 114336 122712 126894 114320 122700 114312 122694 114308 114306 81056 106072 118574 97696 81040 106060 97680 114380 106054 97672 81028 97668 81026 97666 72792 101934 81112 72780 97752 81100 72774 97740 81094 97734 68654 72814 81134 97774 114256 122668 114248 122662 114244 114242 80976 106028 97488 80968 106022 97480 114278 97476 80962 97474 72748 81004 72742 97516 80998 97510 114216 122646 114212 114210 80936 106006 97384 80932 97380 80930 97378 72726 80950 97398 114196 114194 80916 97332 80914 97330 66236 66206 67256 99166 67228 67214 66142 67294 69296 100188 69272 100174 69260 69254 67164 69340 67150 69326 73376 102232 116654 73360 102220 73352 102214 73348 73346 69208 100142 73432 102254 73420 69190 73414 67118 69230 73454 106320 118700 106312 118694 106308 106306 73296 102188 81616 106348 102182 81608 73284 81604 73282 81602 69164 73324 69158 81644 73318 81638 122792 126934 122788 122786 106280 118678 114536 106276 114532 106274 114530 73256 102166 81512 73252 98024 81508 73250 98020 81506 98018 69142 73270 81526 98038 122772 122770 106260 114484 106258 114482 73236 81460 73234 97908 81458 97906 122762 106250 114458 73226 81434 97850 66396 66382 67416 99246 67404 67398 66350 67438 69456 100268 69448 100262 69444 69442 67372 69484 67366 69478 102312 116694 102308 102306 69416 100246 73576 102326 73572 69410 73570 67350 69430 73590 118740 118738 102292 106420 102290 106418 69396 73524 69394 81780 73522 81778 118730 102282 106394 69386 73498 81722 66476 66470 67496 99286 67492 67490 66454 67510 100308 100306 67476 69556 67474 69554 116714 ] ] readonly def % % Function to calculate the product in the field % /pdf417.rsprod { 2 copy 0 ne exch 0 ne and { rslog exch get exch rslog exch get add 928 mod rsalog exch get } { pop pop 0 } ifelse } bind def % % Generate Reed-Solomon coefficients for a given k % /pdf417.gencoeffs { /coeffs [ 1 k {0} repeat ] def 1 1 k { % i coeffs 1 index 2 copy 1 sub get put % coeffs[i] = coeffs[i-1] rsalog 1 index get % ai = rsalog[i] exch 1 sub -1 1 { % j coeffs exch 2 copy get % ... coeffs j coeffs[j] 3 index % ... ai //pdf417.rsprod exec % p = coeffs[j] * ai coeffs 2 index 1 sub get % ... coeffs[j-1] add 929 mod put % coeffs[j] = (p + coeffs[j-1]) mod 929 } for coeffs 0 2 copy get 3 index //pdf417.rsprod exec put % coeffs[0] = coeffs[0] * ai pop % ai } for /coeffs coeffs 0 k getinterval def k 1 sub -2 0 { coeffs exch 2 copy get 929 exch sub put } for coeffs } bind def % % FIFO cache for ECC polynomials % % 9 unique keys: eclevel 0-8 gives 2,4,8,16,32,64,128,256,512 coefficients % /pdf417.coeffscachemax 9 def % Override with global_ctx.pdf417.coeffscachemax /pdf417.coeffscachelimit 1022 def % Override with global_ctx.pdf417.coeffscachelimit /uk.co.terryburton.bwipp.global_ctx dup where { exch get dup /pdf417.coeffscachemax 2 copy known {get /pdf417.coeffscachemax exch def} {pop pop} ifelse /pdf417.coeffscachelimit 2 copy known {get /pdf417.coeffscachelimit exch def} {pop pop} ifelse } {pop} ifelse /pdf417.coeffscache pdf417.coeffscachemax pdf417.coeffscachelimit //fifocache exec def /pdf417.coeffscachefetch { /k exch def k { //pdf417.gencoeffs exec } { length } //pdf417.coeffscache /fetch get exec } bind def /pdf417.latevars dup 8 dict def load /init { (setup.latevars) //pdf417.before exec currentglobal true setglobal //pdf417.latevars begin % % Invert charmaps to give character to value maps for each state % /charvals [ 30 dict 30 dict 30 dict 30 dict ] def /alltext 104 dict def 0 1 //pdf417.charmaps length 1 sub { /i exch def /encs //pdf417.charmaps i get def 0 1 3 { /j exch def encs j get dup type /stringtype eq {0 get} if dup charvals j get exch i put alltext exch -1 put } for } for /charvals charvals readonly def /alltext alltext readonly def % % Calculate the Reed-Solomon log and anti-log tables % /rsalog [ 1 928 {dup 3 mul 929 mod} repeat ] readonly def /rslog 929 array def 1 1 928 {dup rsalog exch get exch rslog 3 1 roll put} for /rslog rslog readonly def /init { //pdf417.latevars {def} forall } def end //pdf417.latevars /init get exec setglobal (setup.latevars) //pdf417.after exec } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//pdf417.latevars /init get exec} if } {pop} ifelse /pdf417 { 128 dict begin { (input.processoptions) //pdf417.before exec /dontdraw false def /compact false def /eclevel -1 def /fixedeclevel false def /columns 0 def /rows 0 def /rowmult 3 def /ccc false def /raw false def /parse false def /parsefnc false def /strictspec false def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Apply AST spec overrides and resolve physical specification % /pdf417 ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec (input.processoptions) //pdf417.after exec //pdf417.latevars /init get exec (input.validate) //pdf417.before exec barcode () eq { /bwipp.pdf417emptyData (The data must not be empty) //raiseerror exec } if barcode length 12500 gt { /bwipp.pdf417inputTooLong (The input data is too long) //raiseerror exec } if eclevel -1 ne eclevel 0 lt eclevel 8 gt or and { /bwipp.pdf417invalidErrorCorrectionLevel (Valid error correction levels are 0 to 8) //raiseerror exec } if ccc raw and { /bwipp.pdf417cccAndRaw (Cannot combine ccc and raw) //raiseerror exec } if ccc compact and { /bwipp.pdf417cccAndCompact (Cannot combine ccc and compact) //raiseerror exec } if rows 0 ne rows 3 lt rows 90 gt or and { /bwipp.pdf417invalidRows (There must be between 3 and 90 rows) //raiseerror exec } if columns 0 ne columns 1 lt columns 30 gt or and { /bwipp.pdf417invalidColumns (There must be between 1 and 30 columns) //raiseerror exec } if rowmult 0 le rowmult 50 gt or { /bwipp.pdf417badRowMult (The row multiplier must be greater than 0 and at most 50) //raiseerror exec } if (input.validate) //pdf417.after exec % % Convert input into array of codewords % raw { /datcws barcode length array def /i 0 def /j 0 def { % loop i barcode length 3 sub ge {exit} if barcode i get 94 ne {exit} if barcode i 1 add 3 getinterval false 1 index { dup 48 lt exch 57 gt or { pop true } if } forall { pop exit } if cvi /cw exch def cw 928 gt { /bwipp.pdf417badRawCodeword (Raw codewords must be 0 to 928) //raiseerror exec } if datcws j cw put /i i 4 add def /j j 1 add def } loop i barcode length ne { /bwipp.pdf417badRawFormat (Raw codewords must be formatted as ^NNN) //raiseerror exec } if /datcws datcws 0 j getinterval def } if /encb { /in exch def /inlen in length def /out inlen 6 idiv 5 mul inlen 6 mod add array def 0 1 inlen 6 idiv 1 sub { /k exch def /msbs [ in k 6 mul 3 getinterval aload pop ] def /mscs [ msbs aload pop exch 256 mul add exch 65536 mul add 3 {dup 900 mod exch 900 idiv} repeat ] def /lsbs [ in k 6 mul 3 add 3 getinterval aload pop ] def /lscs [ lsbs aload pop exch 256 mul add exch 65536 mul add 3 {dup 900 mod exch 900 idiv} repeat ] def lscs 0 get mscs 0 get 316 mul add out k 5 mul 4 add 2 index 900 mod put 900 idiv lscs 1 get add mscs 0 get 641 mul add mscs 1 get 316 mul add out k 5 mul 3 add 2 index 900 mod put 900 idiv lscs 2 get add mscs 0 get 20 mul add mscs 1 get 641 mul add mscs 2 get 316 mul add out k 5 mul 2 add 2 index 900 mod put 900 idiv lscs 3 get add mscs 1 get 20 mul add mscs 2 get 641 mul add out k 5 mul 1 add 2 index 900 mod put 900 idiv mscs 2 get 20 mul add out k 5 mul 3 -1 roll 900 mod put } for /rem inlen 6 mod def rem 0 ne { out out length rem sub [ in inlen rem sub rem getinterval aload pop ] putinterval } if out } def ccc { /barlen barcode length def /datcws barlen 6 idiv 5 mul barlen 6 mod add 2 add array def datcws 0 920 put datcws 1 barlen 6 mod 0 eq {924} {901} ifelse put datcws 2 [ barcode {} forall ] encb putinterval } if raw not ccc not and { % % Parse the input % (input.preprocess) //pdf417.before exec /fncvals << /parse parse /parsefnc parsefnc /eci true % Predates FNC non-data codewords, but supports ECI >> def barcode fncvals //parseinput exec /msg exch def /msglen msg length def % Absolute capacity is 30x90 numeric at eclevel=0. msglen 2713 gt { /bwipp.pdf417inputTooLong (The input data is too long) //raiseerror exec } if (input.preprocess) //pdf417.after exec (input.encoding) //pdf417.before exec % % Determine runlengths of digits % /numdigits [ msglen {0} repeat 0 ] def /numtext [ msglen {0} repeat 0 ] def /numbytes [ msglen {0} repeat 0 ] def /iseci [ msglen {0} repeat 0 ] def msglen 1 sub -1 0 { /i exch def msg i get dup 48 ge exch 57 le and { numdigits i numdigits i 1 add get 1 add put } if alltext msg i get known numdigits i get 13 lt and { numtext i numtext i 1 add get 1 add put } if msg i get 0 ge numtext i get 5 lt and numdigits i get 13 lt and { numbytes i numbytes i 1 add get 1 add put } if iseci i msg i get -1000000 le put } for /numdigits numdigits 0 msglen getinterval def /numtext numtext 0 msglen getinterval def /numbytes numbytes 0 msglen getinterval def mark /seqlen 0 def /state //pdf417.t def /p 0 def { % loop p msglen eq {exit} if iseci p get { /eci msg p get def [ eci ] /p p 1 add def /seqlen seqlen eci -1810900 le {2} {eci -1000900 le {3} {2} ifelse} ifelse add def } { /n numdigits p get def n 13 ge n msglen eq n 8 ge and or { % 13+ digits or all-numeric and 8+ digits //pdf417.nl [ msg p n getinterval aload pop ] /state //pdf417.n def /p p n add def /seqlen seqlen 1 add n add def } { % next /t numtext p get def t 5 ge { state //pdf417.t ne { //pdf417.tl } if [ msg p t getinterval aload pop ] /state //pdf417.t def /p p t add def /seqlen seqlen 1 add t add def % ish } { % next /b numbytes p get def b 1 eq state //pdf417.t eq and { //pdf417.bs [ msg p get ] /p p b add def /seqlen seqlen 2 add def } { % next b 6 mod 0 ne {//pdf417.bl} {//pdf417.bl6} ifelse [ msg p b getinterval aload pop ] /state //pdf417.b def /p p b add def /seqlen seqlen 1 add b add def } ifelse } ifelse } ifelse } ifelse } loop counttomark array astore exch pop /seq exch def % % Submode encoding functions % /enca {charvals //pdf417.a get exch get} def /encl {charvals //pdf417.l get exch get} def /encm {charvals //pdf417.m get exch get} def /encp {charvals //pdf417.p get exch get} def /textencfuncs //pdf417.textencfuncs def /addtotext { text exch l exch put /l l 1 add def } def /enct { /in exch def % % Each char adds 1 codeword, latches add up to 2 % /maxseqlen in length 3 mul 4 add def /seq0 [ 4 { maxseqlen array } repeat ] def /seq1 [ 4 { maxseqlen array } repeat ] def /len0 4 array def len0 0 0 put len0 1 0 put len0 2 0 put len0 3 0 put /len1 4 array def /curseq seq0 def /curseqlen len0 def /nxtseq seq1 def /nxtseqlen len1 def /curlen [ //pdf417.e //pdf417.e //pdf417.e //pdf417.e ] def curlen submode 0 put % % Derive the optimal sequences ending in each submode % in { /char exch def % % Check for optimisations in the current sequences by latching from x to y % { % loop /imp false def //pdf417.textsubmodes { /x exch def //pdf417.textsubmodes { /y exch def /cost curlen x get //pdf417.latlen x get y get add def cost curlen y get lt { curlen y cost put % Copy curseq[x] to curseq[y] and append latseq codes /srclen curseqlen x get def srclen 0 gt { curseq y get 0 curseq x get 0 srclen getinterval putinterval } if //pdf417.latseq x get y get { curseq y get srclen 3 -1 roll put /srclen srclen 1 add def } forall curseqlen y srclen put /imp true def } if } forall } forall imp not {exit} if % Repeat unless no improvement } loop % % Determine optimal next sequences for each valid encoding % /nxtlen [ //pdf417.e //pdf417.e //pdf417.e //pdf417.e ] def nxtseqlen 0 0 put nxtseqlen 1 0 put nxtseqlen 2 0 put nxtseqlen 3 0 put //pdf417.textsubmodes { /x exch def { % loop for common exit charvals x get char known not {exit} if % % Extend directly: copy curseq[x] + char to nxtseq[x] % /cost curlen x get 1 add def cost nxtlen x get lt { nxtlen x cost put /srclen curseqlen x get def srclen 0 gt { nxtseq x get 0 curseq x get 0 srclen getinterval putinterval } if nxtseq x get srclen char put nxtseqlen x srclen 1 add put } if % % Optimise for direct shifts from y to x % //pdf417.textsubmodes { /y exch def x y ne { /cost curlen y get //pdf417.shftlen y get x get add 1 add def cost nxtlen y get lt { nxtlen y cost put % Copy curseq[y] + shift + char to nxtseq[y] /srclen curseqlen y get def srclen 0 gt { nxtseq y get 0 curseq y get 0 srclen getinterval putinterval } if nxtseq y get srclen x //pdf417.a eq {//pdf417.as} {//pdf417.ps} ifelse put nxtseq y get srclen 1 add char put nxtseqlen y srclen 2 add put } if } if } forall exit } loop } forall /curlen nxtlen def % Swap cur and nxt buffers curseq nxtseq /curseq exch def /nxtseq exch def curseqlen nxtseqlen /curseqlen exch def /nxtseqlen exch def } forall % % Select the optimal sequence % /minseq //pdf417.e def //pdf417.textsubmodes { /k exch def curlen k get minseq lt { /minseq curlen k get def /txtseq curseq k get 0 curseqlen k get getinterval def } if } forall % % Encode the sequence % /text minseq array def /k 0 def /l 0 def { k txtseq length ge {exit} if /char txtseq k get def % % Encode character % char textencfuncs submode get load exec addtotext /k k 1 add def % % Encode shifted next character % char //pdf417.as eq char //pdf417.ps eq or { txtseq k get char //pdf417.as eq {enca} {encp} ifelse addtotext /k k 1 add def } if % % Latches to new submode % char //pdf417.al eq {/submode //pdf417.a def} if char //pdf417.ll eq {/submode //pdf417.l def} if char //pdf417.ml eq {/submode //pdf417.m def} if char //pdf417.pl eq {/submode //pdf417.p def} if } loop text length 2 mod 1 eq { submode //pdf417.p eq { /pad //pdf417.al encp def /submode //pdf417.a def } { % % Need to check whether a ps shift can be used to pad % /nextecitext false def % % If have one or more ECIs next followed by text sequence (array)... % i 1 add 1 seq length 1 sub { /ti exch def seq ti get type /arraytype ne { /nextecitext false def exit } if seq ti get 0 get -1000000 gt { exit } if /nextecitext true def } for nextecitext { % ... then don't use ps as it would affect first char of text sequence submode //pdf417.a eq { charvals //pdf417.l get seq ti get 0 get known { % Check whether to use ll or ml latch /pad //pdf417.ll enca def /submode //pdf417.l def } { /pad //pdf417.ml enca def /submode //pdf417.m def } ifelse } { submode //pdf417.m eq { charvals //pdf417.l get seq ti get 0 get known { % Check whether to use ll, pl or al latch /pad //pdf417.ll encm def /submode //pdf417.l def } { charvals //pdf417.p get seq ti get 0 get known { /pad //pdf417.pl encm def /submode //pdf417.p def } { /pad //pdf417.al encm def /submode //pdf417.a def } ifelse } ifelse } { % L /pad //pdf417.ml encl def % Only latch available /submode //pdf417.m def } ifelse } ifelse } { % Otherwise use standard ps shift pad /pad //pdf417.ps textencfuncs submode get load exec def } ifelse } ifelse /text [ text aload pop pad ] def } if /out text length 2 idiv array def 0 1 out length 1 sub { /k exch def out k text k 2 mul get 30 mul text k 2 mul 1 add get add put } for out } def /encn { /in exch def mark 0 44 in length 1 sub { /k exch def /gmod [ 1 in k in length k sub dup 44 gt {pop 44} if getinterval {48 sub} forall ] def /cwn 15 array def /cwi 15 def { % Pre-allocate, fill from end /dv 900 def /val 0 def /gmulstart true def mark % Start collecting gmul digits { gmod length 0 eq {exit} if /val val 10 mul gmod 0 get add def /gmod gmod 1 gmod length 1 sub getinterval def val dv lt { gmulstart not { 0 } if % Push 0 if not at start } { val dv idiv % Push quotient digit /gmulstart false def } ifelse /val val dv mod def } loop counttomark array astore exch pop % Build gmul /cwi cwi 1 sub def cwn cwi val put % Store codeword from end /gmod exch def gmod length 0 eq {exit} if } loop cwn cwi 15 cwi sub getinterval aload pop % Push codewords } for counttomark array astore exch pop } def /ence { 0 get neg 1000000 sub dup 000899 le { % ECI 000000 - 000899 927 exch 2 array astore } { dup 810899 le { % ECI 000900 - 810899 926 exch dup 900 idiv 1 sub exch 900 mod 3 array astore } { dup 811799 le { % ECI 810900 - 811799 925 exch 810900 sub 2 array astore } { pop /bwipp.pdf417badECI (PDF417 supports ECIs 000000 to 811799) //raiseerror exec } ifelse } ifelse } ifelse } def /encfuncs //pdf417.encfuncs def /addtocws { dup datcws j 3 -1 roll putinterval length j add /j exch def } def % % Encode the sequence % /state //pdf417.t def /submode //pdf417.a def /datcws seqlen array def /i 0 def /j 0 def { i seq length ge {exit} if /chars seq i get def chars type /arraytype eq { chars 0 get -1000000 le { % ECI chars ence addtocws } { % Encode data according to mode chars encfuncs state get load exec addtocws } ifelse } { % Encode the latch to new state or byte shift [ //pdf417.latchcws chars get ] addtocws chars //pdf417.tl eq {/state //pdf417.t def /submode //pdf417.a def} if chars //pdf417.nl eq {/state //pdf417.n def} if chars //pdf417.bl eq chars //pdf417.bl6 eq or {/state //pdf417.b def} if chars //pdf417.bs eq { /i i 1 add def seq i get encb addtocws } if } ifelse /i i 1 add def } loop /datcws datcws 0 j getinterval def (input.encoding) //pdf417.after exec } if /m datcws length def m 926 gt { /bwipp.pdf417dataTooLong (The data is too long) //raiseerror exec } if % % Determine the error correction level if unspecified % eclevel -1 eq { m 40 le {/eclevel 2 def} if m 41 ge m 160 le and {/eclevel 3 def} if m 161 ge m 320 le and {/eclevel 4 def} if m 321 ge {/eclevel 5 def} if } if % % Reduce the error level so that it does not cause an excessive number of codewords % fixedeclevel not { /maxeclevel 928 1 sub m sub ln 2 ln div cvi 1 sub def eclevel maxeclevel gt {/eclevel maxeclevel def} if } if % % To determine size of matrix, number of columns if given by user... % /k 2 eclevel 1 add exp cvi def columns 0 eq {/columns m k add 3 div sqrt round cvi def} if /c columns 1 ge {columns} {1} ifelse def % % ... and rows is greater of those required and that given by user within limits % /r m k add 1 add columns div ceiling cvi def % Required r rows lt rows 90 le and {/r rows def} if r 3 lt {/r 3 def} if % % Symbol cannot exceed 90 rows % r 90 gt { /bwipp.pdf417insufficientCapacity (Insufficient capacity in the symbol) //raiseerror exec } if % % Opportunistically raise the error level if a better fit to the matrix is possible % fixedeclevel not { /maxeclevel c r mul 1 sub m sub ln 2 ln div cvi 1 sub 8 2 copy gt {exch} if pop def maxeclevel eclevel gt { /eclevel maxeclevel def /k 2 eclevel 1 add exp cvi def } if } if % % Fetch the coefficients % (ecc.coeffs) //pdf417.before exec /coeffs k //pdf417.coeffscachefetch exec def (ecc.coeffs) //pdf417.after exec (ecc.cws) //pdf417.before exec % % Create codewords array sized for data + ECC, and add padding % /n c r mul k sub def n 928 gt { /bwipp.pdf417insufficientCapacity (Insufficient capacity in the symbol) //raiseerror exec } if /cws c r mul array def cws 0 n put cws 1 datcws putinterval cws m 1 add [ n m sub 1 sub {900} repeat ] putinterval options /debugcws known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugcws cws 0 n getinterval //raiseerror exec } if % % Derive the error codewords directly into cws[n..n+k) % {cws exch get} n coeffs k cws n k getinterval 929 //rsecprime exec options /debugecc known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugecc cws n k getinterval //raiseerror exec } if (ecc.cws) //pdf417.after exec (matrix.layout) //pdf417.before exec % % Return the 17 bits for a codeword in a given cluster % /cwtobits { //pdf417.clusters exch get exch get /v exch def [ 17 {0} repeat v 2 17 string cvrs {48 sub} forall ] dup length 17 sub 17 getinterval } def % % Populate bitmap for the image % compact { /rwid 17 c mul 17 add 17 add 1 add def } { /rwid 17 c mul 17 add 17 add 17 add 18 add def } ifelse rwid r mul { array } stopped { pop /bwipp.pdf417PixsTooLarge (The resulting symbol exceeds the implementation maximum array size) //raiseerror exec } if /pixs exch def 0 1 r 1 sub { /i exch def i 3 mod 0 eq { /lcw i 3 idiv 30 mul r 1 sub 3 idiv add def /rcw i 3 idiv 30 mul c add 1 sub def } if i 3 mod 1 eq { /lcw i 3 idiv 30 mul eclevel 3 mul add r 1 sub 3 mod add def /rcw i 3 idiv 30 mul r 1 sub 3 idiv add def } if i 3 mod 2 eq { /lcw i 3 idiv 30 mul c add 1 sub def /rcw i 3 idiv 30 mul eclevel 3 mul add r 1 sub 3 mod add def } if pixs i rwid mul [ 1 1 1 1 1 1 1 1 0 1 0 1 0 1 0 0 0 lcw i 3 mod cwtobits aload pop cws c i mul c getinterval { i 3 mod cwtobits aload pop } forall compact { 1 } { rcw i 3 mod cwtobits aload pop 1 1 1 1 1 1 1 0 1 0 0 0 1 0 1 0 0 1 } ifelse ] putinterval } for (matrix.layout) //pdf417.after exec << /ren /renmatrix /pixs pixs /pixx rwid /pixy r rowmult mul /rowheights [ r { rowmult } repeat ] /height r rowmult mul 72 div /width rwid 72 div /borderleft 2.0 /borderright 2.0 /bordertop 2.0 /borderbottom 2.0 /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /pdf417 dup load /uk.co.terryburton.bwipp defineresource pop (setup.define) //pdf417.after exec end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER pdf417-- % --BEGIN ENCODER pdf417compact-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor fifocache rsecprime render renmatrix pdf417-- % --DESC: Compact PDF417 % --EXAM: This is compact PDF417 % --EXOP: columns=2 % --RNDR: renmatrix % --FMLY: Two-dimensional symbols %%BeginResource: uk.co.terryburton.bwipp pdf417compact 0.0 2026052800 78612 71731 %%BeginData: 47 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 4 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /pdf417 dup /uk.co.terryburton.bwipp findresource put begin /pdf417compact { 4 dict begin { /dontdraw false def null /apply //processoptions exec /options exch def /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Get the result of encoding with pdf417 with compact option % options (compact) true put /uk.co.terryburton.bwipp._dontdraw true def barcode options //pdf417 exec /args exch def args (opt) options put args _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /pdf417compact dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER pdf417compact-- % --BEGIN ENCODER micropdf417-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor fifocache rsecprime render renmatrix-- % --DESC: MicroPDF417 % --EXAM: MicroPDF417 % --EXOP: % --RNDR: renmatrix % --FMLY: Two-dimensional symbols %%BeginResource: uk.co.terryburton.bwipp micropdf417 0.0 2026052800 295279 300470 %%BeginData: 1339 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 33 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /fifocache dup /uk.co.terryburton.bwipp findresource put dup /rsecprime dup /uk.co.terryburton.bwipp findresource put dup /setuphooks dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put begin /micropdf417 [/before /after] //setuphooks exec (setup.define) //micropdf417.before exec % % Modes and text submodes % /micropdf417.t 0 def /micropdf417.n 1 def /micropdf417.b 2 def /micropdf417.a 0 def /micropdf417.l 1 def /micropdf417.m 2 def /micropdf417.p 3 def % % Special function characters for mode switching % /micropdf417.tl -1 def /micropdf417.nl -2 def /micropdf417.bl -3 def /micropdf417.bl6 -4 def /micropdf417.bs -5 def % % Special function characters for text mode % /micropdf417.al -6 def /micropdf417.ll -7 def /micropdf417.ml -8 def /micropdf417.pl -9 def /micropdf417.as -10 def /micropdf417.ps -11 def /al //micropdf417.al def /ll //micropdf417.ll def /ml //micropdf417.ml def /pl //micropdf417.pl def /as //micropdf417.as def /ps //micropdf417.ps def % % Special function characters for 05/06 macros % /micropdf417.m05 -12 def /micropdf417.m06 -13 def /micropdf417.textsubmodes [ micropdf417.a micropdf417.l micropdf417.m micropdf417.p ] readonly def % % Character maps for each state % /micropdf417.charmaps [ % A L M P [ (A) (a) (0) (;) ] % 0 [ (B) (b) (1) (<) ] % 1 [ (C) (c) (2) (>) ] % 2 [ (D) (d) (3) (@) ] % 3 [ (E) (e) (4) ([) ] % 4 [ (F) (f) (5) 92 ] % 5 [ (G) (g) (6) (]) ] % 6 [ (H) (h) (7) (_) ] % 7 [ (I) (i) (8) (`) ] % 8 [ (J) (j) (9) (~) ] % 9 [ (K) (k) (&) (!) ] % 10 [ (L) (l) 13 13 ] % 11 [ (M) (m) 9 9 ] % 12 [ (N) (n) (,) (,) ] % 13 [ (O) (o) (:) (:) ] % 14 [ (P) (p) (#) 10 ] % 15 [ (Q) (q) (-) (-) ] % 16 [ (R) (r) (.) (.) ] % 17 [ (S) (s) ($) ($) ] % 18 [ (T) (t) (/) (/) ] % 19 [ (U) (u) (+) (") ] % 20 [ (V) (v) (%) (|) ] % 21 [ (W) (w) (*) (*) ] % 22 [ (X) (x) (=) 40 ] % 23 [ (Y) (y) (^) 41 ] % 24 [ (Z) (z) pl (?) ] % 25 [ ( ) ( ) ( ) ({) ] % 26 [ ll as ll (}) ] % 27 [ ml ml al (') ] % 28 [ ps ps ps al ] % 29 ] readonly def /micropdf417.e 20000 def % "Empty" - must exceed max cost: 5000*3+4 /e //micropdf417.e def % % Bit length of latch between submodes % /micropdf417.latlen [ % To: A L M P From [ 0 1 1 2 ] % A [ 2 0 1 2 ] % L [ 1 1 0 1 ] % M [ 1 2 2 0 ] % P ] readonly def % % Latch sequences between submodes % /micropdf417.latseq [ % To: A L M P From [ [] [ll] [ml] [ml pl] ] % A [ [ml al] [] [ml] [ml pl] ] % L [ [al] [ll] [] [pl] ] % M [ [al] [al ll] [al ml] [] ] % P ] readonly def % % Bit length of shift to submode % /micropdf417.shftlen [ % To: A L M P From [ e e e 1 ] % A [ 1 e e 1 ] % L [ e e e 1 ] % M [ e e e e ] % P ] readonly def % % Basic symbol metrics % % c r ecw rl rc rr /micropdf417.ccametrics [ [ 2 5 4 39 0 19 ] [ 2 6 4 1 0 33 ] [ 2 7 5 32 0 12 ] [ 2 8 5 8 0 40 ] [ 2 9 6 14 0 46 ] [ 2 10 6 43 0 23 ] [ 2 12 7 20 0 52 ] [ 3 4 4 11 43 23 ] [ 3 5 5 1 33 13 ] [ 3 6 6 5 37 17 ] [ 3 7 7 15 47 27 ] [ 3 8 7 21 1 33 ] [ 4 3 4 40 20 52 ] [ 4 4 5 43 23 3 ] [ 4 5 6 46 26 6 ] [ 4 6 7 34 14 46 ] [ 4 7 8 29 9 41 ] ] readonly def % c r ecw rl rc rr /micropdf417.nonccametrics [ [ 1 11 7 1 0 9 ] [ 1 14 7 8 0 8 ] [ 1 17 7 36 0 36 ] [ 1 20 8 19 0 19 ] [ 1 24 8 9 0 17 ] [ 1 28 8 25 0 33 ] [ 2 8 8 1 0 1 ] [ 2 11 9 1 0 9 ] [ 2 14 9 8 0 8 ] [ 2 17 10 36 0 36 ] [ 2 20 11 19 0 19 ] [ 2 23 13 9 0 17 ] [ 2 26 15 27 0 35 ] [ 3 6 12 1 1 1 ] [ 3 8 14 7 7 7 ] [ 3 10 16 15 15 15 ] [ 3 12 18 25 25 25 ] [ 3 15 21 37 37 37 ] [ 3 20 26 1 17 33 ] [ 3 26 32 1 9 17 ] [ 3 32 38 21 29 37 ] [ 3 38 44 15 31 47 ] [ 3 44 50 1 25 49 ] [ 4 4 8 47 19 43 ] [ 4 6 12 1 1 1 ] [ 4 8 14 7 7 7 ] [ 4 10 16 15 15 15 ] [ 4 12 18 25 25 25 ] [ 4 15 21 37 37 37 ] [ 4 20 26 1 17 33 ] [ 4 26 32 1 9 17 ] [ 4 32 38 21 29 37 ] [ 4 38 44 15 31 47 ] [ 4 44 50 1 25 49 ] ] readonly def % % Base 10 encoding of the bar space successions for the codewords in each cluster % /micropdf417.clusters [ [ 120256 125680 128380 120032 125560 128318 108736 119920 108640 86080 108592 86048 110016 120560 125820 109792 120440 125758 88256 109680 88160 89536 110320 120700 89312 110200 120638 89200 110140 89840 110460 89720 110398 89980 128506 119520 125304 128190 107712 119408 125244 107616 119352 84032 107568 119324 84000 107544 83984 108256 119672 125374 85184 108144 119612 85088 108088 119582 85040 108060 85728 108408 119742 85616 108348 85560 108318 85880 108478 85820 85790 107200 119152 125116 107104 119096 125086 83008 107056 119068 82976 107032 82960 82952 83648 107376 119228 83552 107320 119198 83504 107292 83480 83468 83824 107452 83768 107422 83740 83900 106848 118968 125022 82496 106800 118940 82464 106776 118926 82448 106764 82440 106758 82784 106936 119006 82736 106908 82712 106894 82700 82694 106974 82830 82240 106672 118876 82208 106648 118862 82192 106636 82184 106630 82180 82352 82328 82316 82080 118830 106572 106566 82050 117472 124280 127678 103616 117360 124220 103520 117304 124190 75840 103472 75808 104160 117624 124350 76992 104048 117564 76896 103992 76848 76824 77536 104312 117694 77424 104252 77368 77340 77688 104382 77628 77758 121536 126320 128700 121440 126264 128670 111680 121392 126236 111648 121368 126222 111632 121356 103104 117104 124092 112320 103008 117048 124062 112224 121656 126366 93248 74784 102936 117006 93216 112152 93200 75456 103280 117180 93888 75360 103224 117150 93792 112440 121758 93744 75288 93720 75632 103356 94064 75576 103326 94008 112542 93980 75708 94140 75678 94110 121184 126136 128606 111168 121136 126108 111136 121112 126094 111120 121100 111112 111108 102752 116920 123998 111456 102704 116892 91712 74272 121244 116878 91680 74256 102668 91664 111372 102662 74244 74592 102840 116958 92000 74544 102812 91952 111516 102798 91928 74508 74502 74680 102878 92088 74652 92060 74638 92046 92126 110912 121008 126044 110880 120984 126030 110864 120972 110856 120966 110852 110850 74048 102576 116828 90944 74016 102552 116814 90912 111000 121038 90896 73992 102534 90888 110982 90884 74160 102620 91056 74136 102606 91032 111054 91020 74118 91014 91100 91086 110752 120920 125998 110736 120908 110728 120902 110724 110722 73888 102488 116782 90528 73872 102476 90512 110796 102470 90504 73860 90500 73858 73944 90584 90572 90566 120876 120870 110658 102444 73800 90312 90308 90306 101056 116080 123580 100960 116024 70720 100912 115996 70688 100888 70672 70664 71360 101232 116156 71264 101176 116126 71216 101148 71192 71180 71536 101308 71480 101278 71452 71612 71582 118112 124600 127838 105024 118064 124572 104992 118040 124558 104976 118028 104968 118022 100704 115896 123486 105312 100656 115868 79424 70176 118172 115854 79392 105240 100620 79376 70152 79368 70496 100792 115934 79712 70448 118238 79664 105372 100750 79640 70412 79628 70584 100830 79800 70556 79772 70542 70622 79838 122176 126640 128860 122144 126616 128846 122128 126604 122120 126598 122116 104768 117936 124508 113472 104736 126684 124494 113440 122264 126670 113424 104712 117894 113416 122246 104706 69952 100528 115804 78656 69920 100504 115790 96064 78624 104856 117966 96032 113560 122318 100486 96016 78600 104838 96008 69890 70064 100572 78768 70040 100558 96176 78744 104910 96152 113614 70022 78726 70108 78812 70094 96220 78798 122016 126552 128814 122000 126540 121992 126534 121988 121986 104608 117848 124462 113056 104592 126574 113040 122060 117830 113032 104580 113028 104578 113026 69792 100440 115758 78240 69776 100428 95136 78224 104652 100422 95120 113100 69764 95112 78212 69762 78210 69848 100462 78296 69836 95192 78284 69830 95180 78278 69870 95214 121936 126508 121928 126502 121924 121922 104528 117804 112848 104520 117798 112840 121958 112836 104514 112834 69712 100396 78032 69704 100390 94672 78024 104550 94664 112870 69698 94660 78018 94658 78060 94700 94694 126486 121890 117782 104484 104482 69672 77928 94440 69666 77922 99680 68160 99632 68128 99608 115342 68112 99596 68104 99590 68448 99768 115422 68400 99740 68376 99726 68364 68358 68536 99806 68508 68494 68574 101696 116400 123740 101664 116376 101648 116364 101640 116358 101636 67904 99504 115292 72512 67872 116444 115278 72480 101784 116430 72464 67848 99462 72456 101766 67842 68016 99548 72624 67992 99534 72600 101838 72588 67974 68060 72668 68046 72654 118432 124760 127918 118416 124748 118408 124742 118404 118402 101536 116312 105888 101520 116300 105872 118476 116294 105864 101508 105860 101506 105858 67744 99416 72096 67728 116334 80800 72080 101580 99398 80784 105932 67716 80776 72068 67714 72066 67800 99438 72152 67788 80856 72140 67782 80844 72134 67822 72174 80878 126800 128940 126792 128934 126788 126786 118352 124716 122576 126828 124710 122568 126822 122564 118338 122562 101456 116268 105680 101448 116262 114128 105672 118374 114120 122598 101442 114116 105666 114114 67664 99372 71888 67656 99366 80336 71880 101478 97232 80328 105702 67650 97224 114150 71874 97220 67692 71916 67686 80364 71910 97260 80358 97254 126760 128918 126756 126754 118312 124694 122472 126774 122468 118306 122466 101416 116246 105576 101412 113896 105572 101410 113892 105570 113890 67624 99350 71784 101430 80104 71780 67618 96744 80100 71778 96740 80098 96738 71798 96758 126738 122420 122418 105524 113780 113778 71732 79988 96500 96498 66880 66848 98968 66832 66824 66820 66992 66968 66956 66950 67036 67022 100000 99984 115532 99976 115526 99972 99970 66720 98904 69024 100056 98892 69008 100044 69000 100038 68996 66690 68994 66776 98926 69080 100078 69068 66758 69062 66798 69102 116560 116552 116548 116546 99920 102096 116588 115494 102088 116582 102084 99906 102082 66640 68816 66632 98854 73168 68808 66628 73160 68804 66626 73156 68802 66668 68844 66662 73196 68838 73190 124840 124836 124834 116520 118632 124854 118628 116514 118626 99880 115478 101992 116534 106216 101988 99874 106212 101986 106210 66600 98838 68712 99894 72936 68708 66594 81384 72932 68706 81380 72930 66614 68726 72950 81398 128980 128978 124820 126900 124818 126898 116500 118580 116498 122740 118578 122738 99860 101940 99858 106100 101938 114420 ] [ 128352 129720 125504 128304 129692 125472 128280 129678 125456 128268 125448 128262 125444 125792 128440 129758 120384 125744 128412 120352 125720 128398 120336 125708 120328 125702 120324 120672 125880 128478 110144 120624 125852 110112 120600 125838 110096 120588 110088 120582 110084 110432 120760 125918 89664 110384 120732 89632 110360 120718 89616 110348 89608 110342 89952 110520 120798 89904 110492 89880 110478 89868 90040 110558 90012 89998 125248 128176 129628 125216 128152 129614 125200 128140 125192 128134 125188 125186 119616 125360 128220 119584 125336 128206 119568 125324 119560 125318 119556 119554 108352 119728 125404 108320 119704 125390 108304 119692 108296 119686 108292 108290 85824 108464 119772 85792 108440 119758 85776 108428 85768 108422 85764 85936 108508 85912 108494 85900 85894 85980 85966 125088 128088 129582 125072 128076 125064 128070 125060 125058 119200 125144 128110 119184 125132 119176 125126 119172 119170 107424 119256 125166 107408 119244 107400 119238 107396 107394 83872 107480 119278 83856 107468 83848 107462 83844 83842 83928 107502 83916 83910 83950 125008 128044 125000 128038 124996 124994 118992 125036 118984 125030 118980 118978 106960 119020 106952 119014 106948 106946 82896 106988 82888 106982 82884 82882 82924 82918 124968 128022 124964 124962 118888 124982 118884 118882 106728 118902 106724 106722 82408 106742 82404 82402 124948 124946 118836 118834 106612 106610 124224 127664 129372 124192 127640 129358 124176 127628 124168 127622 124164 124162 117568 124336 127708 117536 124312 127694 117520 124300 117512 124294 117508 117506 104256 117680 124380 104224 117656 124366 104208 117644 104200 117638 104196 104194 77632 104368 117724 77600 104344 117710 77584 104332 77576 104326 77572 77744 104412 77720 104398 77708 77702 77788 77774 128672 129880 93168 128656 129868 92664 128648 129862 92412 128644 128642 124064 127576 129326 126368 124048 129902 126352 128716 127558 126344 124036 126340 124034 126338 117152 124120 127598 121760 117136 124108 121744 126412 124102 121736 117124 121732 117122 121730 103328 117208 124142 112544 103312 117196 112528 121804 117190 112520 103300 112516 103298 112514 75680 103384 117230 94112 75664 103372 94096 112588 103366 94088 75652 94084 75650 75736 103406 94168 75724 94156 75718 94150 75758 128592 129836 91640 128584 129830 91388 128580 91262 128578 123984 127532 126160 123976 127526 126152 128614 126148 123970 126146 116944 124012 121296 116936 124006 121288 126182 121284 116930 121282 102864 116972 111568 102856 116966 111560 121318 111556 102850 111554 74704 102892 92112 74696 102886 92104 111590 92100 74690 92098 74732 92140 74726 92134 128552 129814 90876 128548 90750 128546 123944 127510 126056 128566 126052 123938 126050 116840 123958 121064 116836 121060 116834 121058 102632 116854 111080 121078 111076 102626 111074 74216 102646 91112 74212 91108 74210 91106 74230 91126 128532 90494 128530 123924 126004 123922 126002 116788 120948 116786 120946 102516 110836 102514 110834 73972 90612 73970 90610 128522 123914 125978 116762 120890 102458 110714 123552 127320 129198 123536 127308 123528 127302 123524 123522 116128 123608 127342 116112 123596 116104 123590 116100 116098 101280 116184 123630 101264 116172 101256 116166 101252 101250 71584 101336 116206 71568 101324 71560 101318 71556 71554 71640 101358 71628 71622 71662 127824 129452 79352 127816 129446 79100 127812 78974 127810 123472 127276 124624 123464 127270 124616 127846 124612 123458 124610 115920 123500 118224 115912 123494 118216 124646 118212 115906 118210 100816 115948 105424 100808 115942 105416 118246 105412 100802 105410 70608 100844 79824 70600 100838 79816 105446 79812 70594 79810 70636 79852 70630 79846 129960 95728 113404 129956 95480 113278 129954 95356 95294 127784 129430 78588 128872 129974 95996 78462 128868 127778 95870 128866 123432 127254 124520 123428 126696 128886 123426 126692 124514 126690 115816 123446 117992 115812 122344 117988 115810 122340 117986 122338 100584 115830 104936 100580 113640 104932 100578 113636 104930 113634 70120 100598 78824 70116 96232 78820 70114 96228 78818 96226 70134 78838 129940 94968 113022 129938 94844 94782 127764 78206 128820 127762 95102 128818 123412 124468 123410 126580 124466 126578 115764 117876 115762 122100 117874 122098 100468 104692 100466 113140 104690 113138 69876 78324 69874 95220 78322 95218 129930 94588 94526 127754 128794 123402 124442 126522 115738 117818 121978 100410 104570 112890 69754 78074 94714 94398 123216 127148 123208 127142 123204 123202 115408 123244 115400 123238 115396 115394 99792 115436 99784 115430 99780 99778 68560 99820 68552 99814 68548 68546 68588 68582 127400 129238 72444 127396 72318 127394 123176 127126 123752 123172 123748 123170 123746 115304 123190 116456 115300 116452 115298 116450 99560 115318 101864 99556 101860 99554 101858 68072 99574 72680 68068 72676 68066 72674 68086 72694 129492 80632 105854 129490 80508 80446 127380 72062 127924 127378 80766 127922 123156 123700 123154 124788 123698 124786 115252 116340 115250 118516 116338 118514 99444 101620 99442 105972 101618 105970 67828 72180 67826 80884 72178 80882 97008 114044 96888 113982 96828 96798 129482 80252 130010 97148 80190 97086 127370 127898 128954 123146 123674 124730 126842 115226 116282 118394 122618 99386 101498 105722 114170 67706 71930 80378 96632 113854 96572 96542 80062 96702 96444 96414 96350 123048 123044 123042 115048 123062 115044 115042 99048 115062 99044 99042 67048 99062 67044 67042 67062 127188 68990 127186 123028 123316 123026 123314 114996 115572 114994 115570 98932 100084 98930 100082 66804 69108 66802 69106 129258 73084 73022 127178 127450 123018 123290 123834 114970 115514 116602 98874 99962 102138 66682 68858 73210 81272 106174 81212 81182 72894 81342 97648 114364 97592 114334 97564 97550 81084 97724 81054 97694 97464 114270 97436 97422 80990 97502 97372 97358 97326 114868 114866 98676 98674 66292 66290 123098 114842 115130 98618 99194 66170 67322 69310 73404 73374 81592 106334 81564 81550 73310 81630 97968 114524 97944 114510 97932 97926 81500 98012 81486 97998 97880 114478 97868 97862 81454 97902 97836 97830 69470 73564 73550 81752 106414 81740 81734 73518 81774 81708 81702 ] [ 109536 120312 86976 109040 120060 86496 108792 119934 86256 108668 86136 129744 89056 110072 129736 88560 109820 129732 88312 109694 129730 88188 128464 129772 89592 128456 129766 89340 128452 89214 128450 125904 128492 125896 128486 125892 125890 120784 125932 120776 125926 120772 120770 110544 120812 110536 120806 110532 84928 108016 119548 84448 107768 119422 84208 107644 84088 107582 84028 129640 85488 108284 129636 85240 108158 129634 85116 85054 128232 129654 85756 128228 85630 128226 125416 128246 125412 125410 119784 125430 119780 119778 108520 119798 108516 108514 83424 107256 119166 83184 107132 83064 107070 83004 82974 129588 83704 107390 129586 83580 83518 128116 83838 128114 125172 125170 119284 119282 107508 107506 82672 106876 82552 106814 82492 82462 129562 82812 82750 128058 125050 119034 82296 106686 82236 82206 82366 82108 82078 76736 103920 117500 76256 103672 117374 76016 103548 75896 103486 75836 129384 77296 104188 129380 77048 104062 129378 76924 76862 127720 129398 77564 127716 77438 127714 124392 127734 124388 124386 117736 124406 117732 117730 104424 117750 104420 104418 112096 121592 126334 92608 111856 121468 92384 111736 121406 92272 111676 92216 111646 92188 75232 103160 117118 93664 74992 103036 93424 112252 102974 93304 74812 93244 74782 93214 129332 75512 103294 129908 129330 93944 75388 129906 93820 75326 93758 127604 75646 128756 127602 94078 128754 124148 126452 124146 126450 117236 121844 117234 121842 103412 103410 91584 111344 121212 91360 111224 121150 91248 111164 91192 111134 91164 91150 74480 102780 91888 74360 102718 91768 111422 91708 74270 91678 129306 74620 129850 92028 74558 91966 127546 128634 124026 126202 116986 121338 102906 90848 110968 121022 90736 110908 90680 110878 90652 90638 74104 102590 91000 74044 90940 74014 90910 74174 91070 90480 110780 90424 110750 90396 90382 73916 90556 73886 90526 90296 110686 90268 90254 73822 90334 90204 90190 71136 101112 116094 70896 100988 70776 100926 70716 70686 129204 71416 101246 129202 71292 71230 127348 71550 127346 123636 123634 116212 116210 101364 101362 79296 105200 118140 79072 105080 118078 78960 105020 78904 104990 78876 78862 70384 100732 79600 70264 100670 79480 105278 79420 70174 79390 129178 70524 129466 79740 70462 79678 127290 127866 123514 124666 115962 118266 100858 113376 122232 126654 95424 113264 122172 95328 113208 122142 95280 113180 95256 113166 95244 78560 104824 117950 95968 78448 104764 95856 113468 104734 95800 78364 95772 78350 95758 70008 100542 78712 69948 96120 78652 69918 96060 78622 96030 70078 78782 96190 94912 113008 122044 94816 112952 122014 94768 112924 94744 112910 94732 94726 78192 104636 95088 78136 104606 95032 113054 95004 78094 94990 69820 78268 69790 95164 78238 95134 94560 112824 121950 94512 112796 94488 112782 94476 94470 78008 104542 94648 77980 94620 77966 94606 69726 78046 94686 94384 112732 94360 112718 94348 94342 77916 94428 77902 94414 94296 112686 94284 94278 77870 94318 94252 94246 68336 99708 68216 99646 68156 68126 68476 68414 127162 123258 115450 99834 72416 101752 116414 72304 101692 72248 101662 72220 72206 67960 99518 72568 67900 72508 67870 72478 68030 72638 80576 105840 118460 80480 105784 118430 80432 105756 80408 105742 80396 80390 72048 101564 80752 71992 101534 80696 71964 80668 71950 80654 67772 72124 67742 80828 72094 80798 114016 122552 126814 96832 113968 122524 96800 113944 122510 96784 113932 96776 113926 96772 80224 105656 118366 97120 80176 105628 97072 114076 105614 97048 80140 97036 80134 97030 71864 101470 80312 71836 97208 80284 71822 97180 80270 97166 67678 71902 80350 97246 96576 113840 122460 96544 113816 122446 96528 113804 96520 113798 96516 96514 80048 105564 96688 80024 105550 96664 113870 96652 80006 96646 71772 80092 71758 96732 80078 96718 96416 113752 122414 96400 113740 96392 113734 96388 96386 79960 105518 96472 79948 96460 79942 96454 71726 79982 96494 96336 113708 96328 113702 96324 96322 79916 96364 79910 96358 96296 113686 96292 96290 79894 96310 66936 99006 66876 66846 67006 68976 100028 68920 99998 68892 68878 66748 69052 66718 69022 73056 102072 116574 73008 102044 72984 102030 72972 72966 68792 99934 73144 68764 73116 68750 73102 66654 68830 73182 81216 106160 118620 81184 106136 118606 81168 106124 81160 106118 81156 81154 72880 101980 81328 72856 101966 81304 106190 81292 72838 81286 68700 72924 68686 81372 72910 81358 114336 122712 126894 114320 122700 114312 122694 114308 114306 81056 106072 118574 97696 81040 106060 97680 114380 106054 97672 81028 97668 81026 97666 72792 101934 81112 72780 97752 81100 72774 97740 81094 97734 68654 72814 81134 97774 114256 122668 114248 122662 114244 114242 80976 106028 97488 80968 106022 97480 114278 97476 80962 97474 72748 81004 72742 97516 80998 97510 114216 122646 114212 114210 80936 106006 97384 80932 97380 80930 97378 72726 80950 97398 114196 114194 80916 97332 80914 97330 66236 66206 67256 99166 67228 67214 66142 67294 69296 100188 69272 100174 69260 69254 67164 69340 67150 69326 73376 102232 116654 73360 102220 73352 102214 73348 73346 69208 100142 73432 102254 73420 69190 73414 67118 69230 73454 106320 118700 106312 118694 106308 106306 73296 102188 81616 106348 102182 81608 73284 81604 73282 81602 69164 73324 69158 81644 73318 81638 122792 126934 122788 122786 106280 118678 114536 106276 114532 106274 114530 73256 102166 81512 73252 98024 81508 73250 98020 81506 98018 69142 73270 81526 98038 122772 122770 106260 114484 106258 114482 73236 81460 73234 97908 81458 97906 122762 106250 114458 73226 81434 97850 66396 66382 67416 99246 67404 67398 66350 67438 69456 100268 69448 100262 69444 69442 67372 69484 67366 69478 102312 116694 102308 102306 69416 100246 73576 102326 73572 69410 73570 67350 69430 73590 118740 118738 102292 106420 102290 106418 69396 73524 69394 81780 73522 81778 118730 102282 106394 69386 73498 81722 66476 66470 67496 99286 67492 67490 66454 67510 100308 100306 67476 69556 67474 69554 116714 ] ] readonly def % % Row address patterns % /micropdf417.raps [ [ % Left and right 802 930 946 818 882 890 826 954 922 986 970 906 778 794 786 914 978 982 980 916 948 932 934 942 940 936 808 812 814 806 822 950 918 790 788 820 884 868 870 878 876 872 840 856 860 862 846 844 836 838 834 866 ] [ % Centre 718 590 622 558 550 566 534 530 538 570 562 546 610 626 634 762 754 758 630 628 612 614 582 578 706 738 742 740 748 620 556 552 616 744 712 716 708 710 646 654 652 668 664 696 688 656 720 592 600 604 732 734 ] ] readonly def /micropdf417.rwids [ 38 55 82 99 ] readonly def /micropdf417.textencfuncs [ /enca /encl /encm /encp ] readonly def /micropdf417.encfuncs [ /enct /encn /encb ] readonly def /micropdf417.latevars dup 8 dict def load /init { (setup.latevars) //micropdf417.before exec currentglobal true setglobal //micropdf417.latevars begin % % Invert charmaps to give character to value maps for each state % /charvals [ 30 dict 30 dict 30 dict 30 dict ] def /alltext 104 dict def 0 1 //micropdf417.charmaps length 1 sub { /i exch def /encs //micropdf417.charmaps i get def 0 1 3 { /j exch def encs j get dup type /stringtype eq {0 get} if dup charvals j get exch i put alltext exch -1 put } for } for /charvals charvals readonly def /alltext alltext readonly def % % Calculate the Reed-Solomon log and anti-log tables % /rsalog [ 1 928 {dup 3 mul 929 mod} repeat ] readonly def /rslog 929 array def 1 1 928 {dup rsalog exch get exch rslog 3 1 roll put} for /rslog rslog readonly def /init { //micropdf417.latevars {def} forall } def end //micropdf417.latevars /init get exec setglobal (setup.latevars) //micropdf417.after exec } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//micropdf417.latevars /init get exec} if } {pop} ifelse % % Function to calculate the product in the field % /micropdf417.rsprod { dup 0 ne { 1 index 0 ne { rslog exch get exch rslog exch get add 928 mod rsalog exch get } { pop pop 0 } ifelse } { pop pop 0 } ifelse } bind def % % Generate Reed-Solomon coefficients for a given k % /micropdf417.gencoeffs { /coeffs [ 1 k {0} repeat ] def 1 1 k { % i coeffs 1 index 2 copy 1 sub get put % coeffs[i] = coeffs[i-1] rsalog 1 index get % ai = rsalog[i] exch 1 sub -1 1 { % j coeffs exch 2 copy get % ... coeffs j coeffs[j] 3 index % ... ai //micropdf417.rsprod exec % p = coeffs[j] * ai coeffs 2 index 1 sub get % ... coeffs[j-1] add 929 mod put % coeffs[j] = (p + coeffs[j-1]) mod 929 } for coeffs 0 2 copy get % ... coeffs 0 coeffs[0] 3 index % ... ai //micropdf417.rsprod exec put % coeffs[0] = coeffs[0] * ai pop % ai } for /coeffs coeffs 0 coeffs length 1 sub getinterval def coeffs length 1 sub -2 0 { coeffs exch 2 copy get 929 exch sub put } for coeffs } bind def % % FIFO cache for ECC polynomials % % 20 unique keys: 4-50 coefficients from symbol metrics % /micropdf417.coeffscachemax 20 def % Override with global_ctx.micropdf417.coeffscachemax /micropdf417.coeffscachelimit 359 def % Override with global_ctx.micropdf417.coeffscachelimit /uk.co.terryburton.bwipp.global_ctx dup where { exch get dup /micropdf417.coeffscachemax 2 copy known {get /micropdf417.coeffscachemax exch def} {pop pop} ifelse /micropdf417.coeffscachelimit 2 copy known {get /micropdf417.coeffscachelimit exch def} {pop pop} ifelse } {pop} ifelse /micropdf417.coeffscache micropdf417.coeffscachemax micropdf417.coeffscachelimit //fifocache exec def /micropdf417.coeffscachefetch { /k exch def k { //micropdf417.gencoeffs exec } { length } //micropdf417.coeffscache /fetch get exec } bind def /micropdf417 { 128 dict begin { (input.processoptions) //micropdf417.before exec /dontdraw false def /version (unset) def /columns 0 def /rows 0 def /rowmult 2 def /cca false def /ccb false def /raw false def /parse false def /parsefnc false def /strictspec false def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Apply AST spec overrides and resolve physical specification % /micropdf417 ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec (input.processoptions) //micropdf417.after exec //micropdf417.latevars /init get exec (input.validate) //micropdf417.before exec barcode () eq { /bwipp.micropdf417emptyData (The data must not be empty) //raiseerror exec } if barcode length 5000 gt { /bwipp.micropdf417inputTooLong (The input data is too long) //raiseerror exec } if rowmult 0 le rowmult 50 gt or { /bwipp.micropdf417badRowMult (The row multiplier must be greater than 0 and at most 50) //raiseerror exec } if cca ccb and cca raw and ccb raw and or or { /bwipp.micropdf417ccaAndCcb (Cannot combine cca, ccb and raw) //raiseerror exec } if % % Parse version=RxC into rows and columns % version (unset) ne { version (x) search { exch pop 2 copy 2 array astore { true 1 index length 0 eq { pop false } if exch { dup 48 lt exch 57 gt or { pop false } if } forall not { pop pop /bwipp.micropdf417BadVersionBadRowOrColumn (version must be formatted as RxC) //raiseerror exec } if } forall /rows exch cvi def /columns exch cvi def } { pop /bwipp.micropdf417badVersionFormat (version must be formatted as RxC) //raiseerror exec } ifelse } if (input.validate) //micropdf417.after exec % % Convert input into array of codewords % raw cca or { /datcws barcode length array def /i 0 def /j 0 def { % loop i barcode length 3 sub ge {exit} if barcode i get 94 ne {exit} if barcode i 1 add 3 getinterval false 1 index { dup 48 lt exch 57 gt or { pop true } if } forall { pop exit } if cvi /cw exch def cw 928 gt { /bwipp.micropdf417badRawCodeword (Raw codewords must be 0 to 928) //raiseerror exec } if datcws j cw put /i i 4 add def /j j 1 add def } loop i barcode length ne { /bwipp.micropdf417badCcaRawFormat (Raw codewords must be formatted as ^NNN) //raiseerror exec } if /datcws datcws 0 j getinterval def } if /encb { /in exch def /inlen in length def /out inlen 6 idiv 5 mul inlen 6 mod add array def 0 1 inlen 6 idiv 1 sub { /k exch def /msbs [ in k 6 mul 3 getinterval aload pop ] def /mscs [ msbs aload pop exch 256 mul add exch 65536 mul add 3 {dup 900 mod exch 900 idiv} repeat ] def /lsbs [ in k 6 mul 3 add 3 getinterval aload pop ] def /lscs [ lsbs aload pop exch 256 mul add exch 65536 mul add 3 {dup 900 mod exch 900 idiv} repeat ] def lscs 0 get mscs 0 get 316 mul add out k 5 mul 4 add 2 index 900 mod put 900 idiv lscs 1 get add mscs 0 get 641 mul add mscs 1 get 316 mul add out k 5 mul 3 add 2 index 900 mod put 900 idiv lscs 2 get add mscs 0 get 20 mul add mscs 1 get 641 mul add mscs 2 get 316 mul add out k 5 mul 2 add 2 index 900 mod put 900 idiv lscs 3 get add mscs 1 get 20 mul add mscs 2 get 641 mul add out k 5 mul 1 add 2 index 900 mod put 900 idiv mscs 2 get 20 mul add out k 5 mul 3 -1 roll 900 mod put } for /rem inlen 6 mod def rem 0 ne { out out length rem sub [ in inlen rem sub rem getinterval aload pop ] putinterval } if out } def ccb { /barlen barcode length def /datcws barlen 6 idiv 5 mul barlen 6 mod add 2 add array def datcws 0 920 put datcws 1 barlen 6 mod 0 eq {924} {901} ifelse put datcws 2 [ barcode {} forall ] encb putinterval } if raw not cca not and ccb not and { % % Parse the input % (input.preprocess) //micropdf417.before exec /fncvals << /parse parse /parsefnc parsefnc % (MAC5) m05 Encoded automatically % (MAC6) m06 Encoded automatically % Predates FNC non-data codewords, but supports ECI /eci true >> def barcode fncvals //parseinput exec /msg exch def /msglen msg length def % % Macro 05/06 compression of [)>{RS}05/06{GS}...{RS}{EOT} structured data % msglen 9 ge { msg 0 7 getinterval aload pop 29 eq exch pop exch 48 eq and exch % [)>{RS}0*{GS}... 30 eq and exch 62 eq and exch 41 eq and exch 91 eq and { msg msglen 2 sub 2 getinterval aload pop 4 eq exch 30 eq and { % ...{RS}{EOT} msg 5 get 53 eq { % ...5... /msg [ //micropdf417.m05 msg 7 msg length 9 sub getinterval aload pop ] def } { msg 5 get 54 eq { % ...6... /msg [ //micropdf417.m06 msg 7 msg length 9 sub getinterval aload pop ] def } if } ifelse } if } if } if /msglen msg length def % Absolute capacity is 4x44 numeric. msglen 366 gt { /bwipp.micropdf417inputTooLong (The input data is too long) //raiseerror exec } if (input.preprocess) //micropdf417.after exec (input.encoding) //micropdf417.before exec % % Determine runlengths of digits % /numdigits [ msglen {0} repeat 0 ] def /numtext [ msglen {0} repeat 0 ] def /numbytes [ msglen {0} repeat 0 ] def /iseci [ msglen {0} repeat ] def msglen 1 sub -1 0 { /i exch def msg i get dup 48 ge exch 57 le and { numdigits i numdigits i 1 add get 1 add put } if alltext msg i get known numdigits i get 13 lt and { numtext i numtext i 1 add get 1 add put } if msg i get 0 ge numtext i get 5 lt and numdigits i get 13 lt and { numbytes i numbytes i 1 add get 1 add put } if iseci i msg i get -1000000 le put } for /numdigits numdigits 0 msglen getinterval def /numtext numtext 0 msglen getinterval def /numbytes numbytes 0 msglen getinterval def mark /seqlen 0 def /state //micropdf417.b def /p 0 def { % loop p msglen eq {exit} if p 0 eq msg p get dup //micropdf417.m05 eq exch //micropdf417.m06 eq or and { msg p get //micropdf417.m05 eq { //micropdf417.m05 } { //micropdf417.m06 } ifelse /p p 1 add def /seqlen seqlen 1 add def } { iseci p get { /eci msg p get def [ eci ] /p p 1 add def /seqlen seqlen eci -1810900 le {2} {eci -1000900 le {3} {2} ifelse} ifelse add def } { /n numdigits p get def n 13 ge n msglen eq n 8 ge and or { % 13+ digits or all-numeric and 8+ digits //micropdf417.nl [ msg p n getinterval aload pop ] /state //micropdf417.n def /p p n add def /seqlen seqlen 1 add n add def } { % next /t numtext p get def t 5 ge { state //micropdf417.t ne { //micropdf417.tl } if [ msg p t getinterval aload pop ] /state //micropdf417.t def /p p t add def /seqlen seqlen 1 add t add def % ish } { % next /b numbytes p get def b 1 eq state //micropdf417.t eq and { //micropdf417.bs [ msg p get ] /p p b add def /seqlen seqlen 2 add def } { % next b 6 mod 0 ne {//micropdf417.bl} {//micropdf417.bl6} ifelse [ msg p b getinterval aload pop ] /state //micropdf417.b def /p p b add def /seqlen seqlen 1 add b add def } ifelse } ifelse } ifelse } ifelse } ifelse } loop counttomark array astore exch pop /seq exch def /latchcws << //micropdf417.tl 900 //micropdf417.bl 901 //micropdf417.bl6 924 //micropdf417.nl 902 //micropdf417.bs 913 //micropdf417.m05 916 //micropdf417.m06 917 >> def % % Submode encoding functions % /enca {charvals //micropdf417.a get exch get} def /encl {charvals //micropdf417.l get exch get} def /encm {charvals //micropdf417.m get exch get} def /encp {charvals //micropdf417.p get exch get} def /textencfuncs //micropdf417.textencfuncs def /addtotext { text exch l exch put /l l 1 add def } def /enct { /in exch def % % Each char adds 1 codeword, latches add up to 2 % /maxseqlen in length 3 mul 4 add def /seq0 [ 4 { maxseqlen array } repeat ] def /seq1 [ 4 { maxseqlen array } repeat ] def /len0 4 array def len0 0 0 put len0 1 0 put len0 2 0 put len0 3 0 put /len1 4 array def /curseq seq0 def /curseqlen len0 def /nxtseq seq1 def /nxtseqlen len1 def /curlen [ //micropdf417.e //micropdf417.e //micropdf417.e //micropdf417.e ] def curlen submode 0 put % Derive the optimal sequences ending in each submode in { /char exch def % Check for optimisations in the current sequences by latching from x to y { % loop /imp false def //micropdf417.textsubmodes { /x exch def //micropdf417.textsubmodes { /y exch def /cost curlen x get //micropdf417.latlen x get y get add def cost curlen y get lt { curlen y cost put % Copy curseq[x] to curseq[y] and append latseq codes /srclen curseqlen x get def srclen 0 gt { curseq y get 0 curseq x get 0 srclen getinterval putinterval } if //micropdf417.latseq x get y get { curseq y get srclen 3 -1 roll put /srclen srclen 1 add def } forall curseqlen y srclen put /imp true def } if } forall } forall imp not {exit} if % Repeat unless no improvement } loop % % Determine optimal next sequences for each valid encoding % /nxtlen [ //micropdf417.e //micropdf417.e //micropdf417.e //micropdf417.e ] def nxtseqlen 0 0 put nxtseqlen 1 0 put nxtseqlen 2 0 put nxtseqlen 3 0 put //micropdf417.textsubmodes { /x exch def { % loop for common exit charvals x get char known not {exit} if % % Extend directly: copy curseq[x] + char to nxtseq[x] % /cost curlen x get 1 add def cost nxtlen x get lt { nxtlen x cost put /srclen curseqlen x get def srclen 0 gt { nxtseq x get 0 curseq x get 0 srclen getinterval putinterval } if nxtseq x get srclen char put nxtseqlen x srclen 1 add put } if % % Optimise for direct shifts from y to x % //micropdf417.textsubmodes { /y exch def x y ne { /cost curlen y get //micropdf417.shftlen y get x get add 1 add def cost nxtlen y get lt { nxtlen y cost put % Copy curseq[y] + shift + char to nxtseq[y] /srclen curseqlen y get def srclen 0 gt { nxtseq y get 0 curseq y get 0 srclen getinterval putinterval } if nxtseq y get srclen x //micropdf417.a eq {//micropdf417.as} {//micropdf417.ps} ifelse put nxtseq y get srclen 1 add char put nxtseqlen y srclen 2 add put } if } if } forall exit } loop } forall /curlen nxtlen def % Swap cur and nxt buffers curseq nxtseq /curseq exch def /nxtseq exch def curseqlen nxtseqlen /curseqlen exch def /nxtseqlen exch def } forall % % Select the optimal sequence % /minseq //micropdf417.e def //micropdf417.textsubmodes { /k exch def curlen k get minseq lt { /minseq curlen k get def /txtseq curseq k get 0 curseqlen k get getinterval def } if } forall % % Encode the sequence % /text minseq array def /k 0 def /l 0 def { k txtseq length ge {exit} if /char txtseq k get def % % Encode character % char textencfuncs submode get load exec addtotext /k k 1 add def % % Encode shifted next character % char //micropdf417.as eq char //micropdf417.ps eq or { txtseq k get char //micropdf417.as eq {enca} {encp} ifelse addtotext /k k 1 add def } if % % Latches to new submode % char //micropdf417.al eq {/submode //micropdf417.a def} if char //micropdf417.ll eq {/submode //micropdf417.l def} if char //micropdf417.ml eq {/submode //micropdf417.m def} if char //micropdf417.pl eq {/submode //micropdf417.p def} if } loop text length 2 mod 1 eq { submode //micropdf417.p eq { /pad //micropdf417.al encp def /submode //micropdf417.a def } { % % Need to check whether a ps shift can be used to pad % /nextecitext false def % If have one or more ECIs next followed by text sequence (array) i 1 add 1 seq length 1 sub { /ti exch def seq ti get type /arraytype ne { /nextecitext false def exit } if seq ti get 0 get -1000000 gt { exit } if /nextecitext true def } for nextecitext { % Then don't use ps as it would affect first char of text sequence submode //micropdf417.a eq { charvals //micropdf417.l get seq ti get 0 get known { % Check whether to use ll or ml latch /pad //micropdf417.ll enca def /submode //micropdf417.l def } { /pad //micropdf417.ml enca def /submode //micropdf417.m def } ifelse } { submode //micropdf417.m eq { charvals //micropdf417.l get seq ti get 0 get known { % Check whether to use ll, pl or al latch /pad //micropdf417.ll encm def /submode //micropdf417.l def } { charvals //micropdf417.p get seq ti get 0 get known { /pad //micropdf417.pl encm def /submode //micropdf417.p def } { /pad //micropdf417.al encm def /submode //micropdf417.a def } ifelse } ifelse } { % L /pad //micropdf417.ml encl def % Only latch available /submode //micropdf417.m def } ifelse } ifelse } { % Otherwise use standard ps shift pad /pad //micropdf417.ps textencfuncs submode get load exec def } ifelse } ifelse /text [ text aload pop pad ] def } if /out text length 2 idiv array def 0 1 out length 1 sub { /k exch def out k text k 2 mul get 30 mul text k 2 mul 1 add get add put } for out } def /encn { /in exch def mark 0 44 in length 1 sub { /k exch def /gmod [ 1 in k in length k sub dup 44 gt {pop 44} if getinterval {48 sub} forall ] def /cwn 15 array def /cwi 15 def { % Pre-allocate, fill from end /dv 900 def /val 0 def /gmulstart true def mark % Start collecting gmul digits { gmod length 0 eq {exit} if /val val 10 mul gmod 0 get add def /gmod gmod 1 gmod length 1 sub getinterval def val dv lt { gmulstart not { 0 } if % Push 0 if not at start } { val dv idiv % Push quotient digit /gmulstart false def } ifelse /val val dv mod def } loop counttomark array astore exch pop % Build gmul /dv val def /cwi cwi 1 sub def cwn cwi dv put % Store codeword from end /gmod exch def gmod length 0 eq {exit} if } loop cwn cwi 15 cwi sub getinterval aload pop % Push codewords } for counttomark array astore exch pop } def /ence { 0 get neg 1000000 sub dup 000899 le { % ECI 000000 - 000899 927 exch 2 array astore } { dup 810899 le { % ECI 000900 - 810899 926 exch dup 900 idiv 1 sub exch 900 mod 3 array astore } { dup 811799 le { % ECI 810900 - 811799 925 exch 810900 sub 2 array astore } { pop /bwipp.pdf417badECI (PDF417 supports ECIs 000000 to 811799) //raiseerror exec } ifelse } ifelse } ifelse } def /encfuncs //micropdf417.encfuncs def /addtocws { dup datcws j 3 -1 roll putinterval length j add /j exch def } def % % Encode the sequence % % No need to set state as seq will always begin with a latch, unlike for pdf417 % /datcws seqlen array def /i 0 def /j 0 def { i seq length ge {exit} if /chars seq i get def chars type /arraytype eq { % Encode data according to mode chars 0 get -1000000 le { % ECI chars ence addtocws } { % Encode data according to mode chars encfuncs state get load exec addtocws } ifelse } { % Encode the latch to new state, byte shift or macro [ latchcws chars get ] addtocws chars //micropdf417.tl eq {/state //micropdf417.t def /submode //micropdf417.a def} if chars //micropdf417.nl eq {/state //micropdf417.n def} if chars //micropdf417.bl eq chars //micropdf417.bl6 eq or {/state //micropdf417.b def} if chars //micropdf417.bs eq { /i i 1 add def seq i get encb addtocws } if chars //micropdf417.m05 eq { i 1 add seq length lt { seq i 1 add get //micropdf417.nl eq { % Latch to numeric mode is implied /i i 1 add def } if } if /state //micropdf417.n def } if chars //micropdf417.m06 eq { i 1 add seq length lt { seq i 1 add get //micropdf417.tl eq { % Latch to mixed text submode is implied /i i 1 add def } if } if /state //micropdf417.t def /submode //micropdf417.m def } if } ifelse /i i 1 add def } loop /datcws datcws 0 j getinterval def (input.encoding) //micropdf417.after exec } if % % Select metrics of an appropriate symbol % (metrics.selection) //micropdf417.before exec /urows rows def /ucols columns def /metrics cca {//micropdf417.ccametrics} {//micropdf417.nonccametrics} ifelse def metrics { /m exch def /c m 0 get def % Columns in symbol /r m 1 get def % Rows in symbol /k m 2 get def % Error correction codewords /rapl m 3 get def % Left row address pattern /rapc m 4 get def % Centre row address pattern /rapr m 5 get def % Right row address pattern /ncws r c mul k sub def % Data codewords /okay true def datcws length ncws gt {/okay false def} if urows 0 ne urows r ne and {/okay false def} if ucols 0 ne ucols c ne and {/okay false def} if okay {exit} if } forall okay not { /bwipp.micropdf417noValidSymbol (Maximum length exceeded or invalid size) //raiseerror exec } if (metrics.selection) //micropdf417.after exec % % Fetch the coefficients % (ecc.coeffs) //micropdf417.before exec /coeffs k //micropdf417.coeffscachefetch exec def (ecc.coeffs) //micropdf417.after exec (ecc.cws) //micropdf417.before exec % % Create codewords array sized for data + ECC, and add padding % /m datcws length def /n c r mul k sub def /cws c r mul array def cws 0 datcws putinterval cws m [ n m sub {900} repeat ] putinterval options /debugcws known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugcws cws 0 n getinterval //raiseerror exec } if % % Derive the error codewords directly into cws[n..n+k) % {cws exch get} n coeffs k cws n k getinterval 929 //rsecprime exec options /debugecc known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugecc cws n k getinterval //raiseerror exec } if (ecc.cws) //micropdf417.after exec (matrix.layout) //micropdf417.before exec % % Return the 17 bits for a codeword in a given cluster % /cwtobits { //micropdf417.clusters exch get exch get /v exch def [ 17 {0} repeat v 2 17 string cvrs {48 sub} forall ] dup length 17 sub 17 getinterval } def % % Return the 10 bits for a row address pattern % /raptobits { //micropdf417.raps exch get exch get /v exch def [ 10 {0} repeat v 2 10 string cvrs {48 sub} forall ] dup length 10 sub 10 getinterval } def % % Populate bitmap for the image % /rwid //micropdf417.rwids c 1 sub get def c 3 eq cca and {/rwid 72 def} if rwid r mul { array } stopped { pop /bwipp.micropdf417PixsTooLarge (The resulting symbol exceeds the implementation maximum array size) //raiseerror exec } if /pixs exch def 0 1 r 1 sub { /i exch def /clst i rapl add 1 sub 3 mod def pixs i rwid mul [ c 1 eq { i rapl add 1 sub 52 mod 0 raptobits aload pop cws i get clst cwtobits aload pop i rapr add 1 sub 52 mod 0 raptobits aload pop } if c 2 eq { i rapl add 1 sub 52 mod 0 raptobits aload pop cws i 2 mul get clst cwtobits aload pop cws i 2 mul 1 add get clst cwtobits aload pop i rapr add 1 sub 52 mod 0 raptobits aload pop } if c 3 eq { cca not { i rapl add 1 sub 52 mod 0 raptobits aload pop } if cws i 3 mul get clst cwtobits aload pop i rapc add 1 sub 52 mod 1 raptobits aload pop cws i 3 mul 1 add get clst cwtobits aload pop cws i 3 mul 2 add get clst cwtobits aload pop i rapr add 1 sub 52 mod 0 raptobits aload pop } if c 4 eq { i rapl add 1 sub 52 mod 0 raptobits aload pop cws i 4 mul get clst cwtobits aload pop cws i 4 mul 1 add get clst cwtobits aload pop i rapc add 1 sub 52 mod 1 raptobits aload pop cws i 4 mul 2 add get clst cwtobits aload pop cws i 4 mul 3 add get clst cwtobits aload pop i rapr add 1 sub 52 mod 0 raptobits aload pop } if 1 ] putinterval } for (matrix.layout) //micropdf417.after exec << /ren /renmatrix /pixs pixs /pixx rwid /pixy r rowmult mul /rowheights [ r { rowmult } repeat ] /height r rowmult mul 72 div /width rwid 72 div /borderleft 1.0 /borderright 1.0 /bordertop 1.0 /borderbottom 1.0 /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /micropdf417 dup load /uk.co.terryburton.bwipp defineresource pop (setup.define) //micropdf417.after exec end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER micropdf417-- % --BEGIN ENCODER datamatrix-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor fifocache rsecbinary render renmatrix-- % --DESC: Data Matrix % --EXAM: This is Data Matrix! % --EXOP: % --RNDR: renmatrix % --FMLY: Two-dimensional symbols %%BeginResource: uk.co.terryburton.bwipp datamatrix 0.0 2026052800 425944 431482 %%BeginData: 1183 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 33 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /fifocache dup /uk.co.terryburton.bwipp findresource put dup /rsecbinary dup /uk.co.terryburton.bwipp findresource put dup /setuphooks dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put begin /datamatrix [/before /after] //setuphooks exec (setup.define) //datamatrix.before exec % % Basic metrics for each symbol % /datamatrix.metrics [ % Standard square symbols [ 10 10 1 1 5 1 0 ] [ 12 12 1 1 7 1 0 ] [ 14 14 1 1 10 1 0 ] [ 16 16 1 1 12 1 0 ] [ 18 18 1 1 14 1 0 ] [ 20 20 1 1 18 1 0 ] [ 22 22 1 1 20 1 0 ] [ 24 24 1 1 24 1 0 ] [ 26 26 1 1 28 1 0 ] [ 32 32 2 2 36 1 0 ] [ 36 36 2 2 42 1 0 ] [ 40 40 2 2 48 1 0 ] [ 44 44 2 2 56 1 0 ] [ 48 48 2 2 68 1 0 ] [ 52 52 2 2 84 2 0 ] [ 64 64 4 4 112 2 0 ] [ 72 72 4 4 144 4 0 ] [ 80 80 4 4 192 4 0 ] [ 88 88 4 4 224 4 0 ] [ 96 96 4 4 272 4 0 ] [ 104 104 4 4 336 6 0 ] [ 120 120 6 6 408 6 0 ] [ 132 132 6 6 496 8 0 ] [ 144 144 6 6 620 10 0 ] % Optional rectangular symbols [ 8 18 1 1 7 1 0 ] [ 8 32 1 2 11 1 0 ] [ 8 48 1 2 15 1 1 ] [ 8 64 1 4 18 1 1 ] [ 8 80 1 4 22 1 1 ] [ 8 96 1 4 28 1 1 ] [ 8 120 1 6 32 1 1 ] [ 8 144 1 6 36 1 1 ] [ 12 26 1 1 14 1 0 ] [ 12 36 1 2 18 1 0 ] [ 12 64 1 4 27 1 1 ] [ 12 88 1 4 36 1 1 ] [ 16 36 1 2 24 1 0 ] [ 16 48 1 2 28 1 0 ] [ 16 64 1 4 36 1 1 ] [ 20 36 1 2 28 1 1 ] [ 20 44 1 2 34 1 1 ] [ 20 64 1 4 42 1 1 ] [ 22 48 1 2 38 1 1 ] [ 24 48 1 2 41 1 1 ] [ 24 64 1 4 46 1 1 ] [ 26 40 1 2 38 1 1 ] [ 26 48 1 2 42 1 1 ] [ 26 64 1 4 50 1 1 ] ] readonly def % % Special characters and encoding values % /datamatrix.fnc1 -1 def /datamatrix.prog -2 def /datamatrix.m05 -3 def /datamatrix.m06 -4 def /datamatrix.lC -5 def /datamatrix.lB -6 def /datamatrix.lX -7 def /datamatrix.lT -8 def /datamatrix.lE -9 def /datamatrix.unl -10 def /datamatrix.sapp -11 def /datamatrix.usft -12 def /datamatrix.sft1 -13 def /datamatrix.sft2 -14 def /datamatrix.sft3 -15 def /datamatrix.eci -16 def /datamatrix.pad -17 def /datamatrix.unlcw 254 def /datamatrix.A 0 def /datamatrix.C 1 def /datamatrix.T 2 def /datamatrix.X 3 def /datamatrix.E 4 def /datamatrix.B 5 def /datamatrix.encfuncs [ /encA /encCTX /encCTX /encCTX /encE /encB ] readonly def % % Codeword placement patterns % /datamatrix.dmn [ { 2 copy 2 sub exch 2 sub exch } bind { 2 copy 1 sub exch 2 sub exch } bind { 2 copy 2 sub exch 1 sub exch } bind { 2 copy 1 sub exch 1 sub exch } bind { 2 copy exch 1 sub exch } bind { 2 copy 2 sub } bind { 2 copy 1 sub } bind { 2 copy } bind ] readonly def /datamatrix.dmc1 [ { mrows 1 sub 0 } bind { mrows 1 sub 1 } bind { mrows 1 sub 2 } bind { 0 mcols 2 sub } bind { 0 mcols 1 sub } bind { 1 mcols 1 sub } bind { 2 mcols 1 sub } bind { 3 mcols 1 sub } bind ] readonly def /datamatrix.dmc2 [ { mrows 3 sub 0 } bind { mrows 2 sub 0 } bind { mrows 1 sub 0 } bind { 0 mcols 4 sub } bind { 0 mcols 3 sub } bind { 0 mcols 2 sub } bind { 0 mcols 1 sub } bind { 1 mcols 1 sub } bind ] readonly def /datamatrix.dmc3 [ { mrows 3 sub 0 } bind { mrows 2 sub 0 } bind { mrows 1 sub 0 } bind { 0 mcols 2 sub } bind { 0 mcols 1 sub } bind { 1 mcols 1 sub } bind { 2 mcols 1 sub } bind { 3 mcols 1 sub } bind ] readonly def /datamatrix.dmc4 [ { mrows 1 sub 0 } bind { mrows 1 sub mcols 1 sub } bind { 0 mcols 3 sub } bind { 0 mcols 2 sub } bind { 0 mcols 1 sub } bind { 1 mcols 3 sub } bind { 1 mcols 2 sub } bind { 1 mcols 1 sub } bind ] readonly def /datamatrix.latevars dup 16 dict def load /init { (setup.latevars) //datamatrix.before exec currentglobal true setglobal //datamatrix.latevars begin % % Character mapping dictionaries % /Avals << 0 1 128 {dup 1 add} for //datamatrix.pad 129 0 1 99 { % Double digits dup 10 2 string cvrs (00) 2 string copy dup 2 3 index length sub 4 -1 roll putinterval exch 130 add } for 229 [ //datamatrix.lC //datamatrix.lB //datamatrix.fnc1 //datamatrix.sapp //datamatrix.prog //datamatrix.usft //datamatrix.m05 //datamatrix.m06 //datamatrix.lX //datamatrix.lT //datamatrix.lE //datamatrix.eci ] {exch 1 add dup} forall pop >> def /Avals << Avals {[exch]} forall >> def /CNvals << //datamatrix.sft1 0 //datamatrix.sft2 1 //datamatrix.sft3 2 32 3 48 1 57 {dup 44 sub} for % 0-9 65 1 90 {dup 51 sub} for % A-Z >> readonly def /C1vals << 0 1 31 {dup} for >> readonly def /C2vals << 33 1 47 {dup 33 sub} for 58 1 64 {dup 43 sub} for 91 1 95 {dup 69 sub} for //datamatrix.fnc1 27 //datamatrix.usft 30 >> readonly def /C3vals << 96 1 127 {dup 96 sub} for >> readonly def /Cvals << CNvals {[exch]} forall C1vals {[exch CNvals //datamatrix.sft1 get exch]} forall C2vals {[exch CNvals //datamatrix.sft2 get exch]} forall C3vals {[exch CNvals //datamatrix.sft3 get exch]} forall >> def /TNvals << //datamatrix.sft1 0 //datamatrix.sft2 1 //datamatrix.sft3 2 32 3 48 1 57 {dup 44 sub} for % 0-9 97 1 122 {dup 83 sub} for % a-z >> readonly def /T1vals << 0 1 31 {dup} for >> readonly def /T2vals << 33 1 47 {dup 33 sub} for 58 1 64 {dup 43 sub} for 91 1 95 {dup 69 sub} for //datamatrix.fnc1 27 //datamatrix.usft 30 >> readonly def /T3vals << 96 0 65 1 90 {dup 64 sub} for 123 1 127 {dup 96 sub} for >> readonly def /Tvals << TNvals {[exch]} forall T1vals {[exch TNvals //datamatrix.sft1 get exch]} forall T2vals {[exch TNvals //datamatrix.sft2 get exch]} forall T3vals {[exch TNvals //datamatrix.sft3 get exch]} forall >> def % % Extended ASCII mappings % 128 1 255 { /i exch def Avals i [ Avals //datamatrix.usft get aload pop Avals i 128 sub get aload pop ] put Cvals i [ Cvals //datamatrix.usft get aload pop Cvals i 128 sub get aload pop ] put Tvals i [ Tvals //datamatrix.usft get aload pop Tvals i 128 sub get aload pop ] put } for /Avals Avals readonly def /Cvals Cvals readonly def /Tvals Tvals readonly def /Xvals << 13 0 42 1 62 2 32 3 48 1 57 {dup 44 sub} for 65 1 90 {dup 51 sub} for >> readonly def /Xvals << Xvals {[exch]} forall >> readonly def /Evals << 64 1 94 {dup 64 sub} for //datamatrix.unl 31 32 1 63 {dup} for >> readonly def /Evals << Evals {[exch]} forall >> readonly def /Bvals << 0 1 255 {dup} for >> readonly def /Bvals << Bvals {[exch]} forall >> readonly def /encvals [ Avals Cvals Tvals Xvals Evals Bvals ] readonly def % % Calculate the Reed-Solomon log and anti-log tables for GF(256) with prime polynomial 301 % /rsalog [ 1 255 { dup 2 mul dup 256 ge {301 xor} if } repeat ] readonly def /rslog 256 array def 1 1 255 {dup rsalog exch get exch rslog 3 1 roll put} for /rslog rslog readonly def /init { //datamatrix.latevars {def} forall } def end //datamatrix.latevars /init get exec setglobal (setup.latevars) //datamatrix.after exec } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//datamatrix.latevars /init get exec} if } {pop} ifelse % % Function to calculate the product in the field % /datamatrix.rsprod { dup 0 ne { 1 index 0 ne { rslog exch get exch rslog exch get add 255 mod rsalog exch get } { pop pop 0 } ifelse } { pop pop 0 } ifelse } bind def % % Generate Reed-Solomon coefficients for a given k % /datamatrix.gencoeffs { /coeffs [ 1 k {0} repeat ] def 1 1 k { % i coeffs 1 index 2 copy 1 sub get put % coeffs[i] = coeffs[i-1] rsalog 1 index get % ai = rsalog[i] exch 1 sub -1 1 { % j coeffs exch 2 copy get % ... coeffs j coeffs[j] 3 index % ... ai //datamatrix.rsprod exec % p = coeffs[j] * ai coeffs 2 index 1 sub get % ... coeffs[j-1] xor put % coeffs[j] = p ^ coeffs[j-1] } for coeffs 0 2 copy get % ... coeffs 0 coeffs[0] 3 index % ... ai //datamatrix.rsprod exec put % coeffs[0] = coeffs[0] * ai pop % ai } for coeffs 0 coeffs length 1 sub getinterval } bind def % % FIFO cache for ECC polynomials % % 25 unique keys: per-block 5-68 from symbol configurations % /datamatrix.coeffscachemax 25 def % Override with global_ctx.datamatrix.coeffscachemax /datamatrix.coeffscachelimit 766 def % Override with global_ctx.datamatrix.coeffscachelimit /uk.co.terryburton.bwipp.global_ctx dup where { exch get dup /datamatrix.coeffscachemax 2 copy known {get /datamatrix.coeffscachemax exch def} {pop pop} ifelse /datamatrix.coeffscachelimit 2 copy known {get /datamatrix.coeffscachelimit exch def} {pop pop} ifelse } {pop} ifelse /datamatrix.coeffscache datamatrix.coeffscachemax datamatrix.coeffscachelimit //fifocache exec def /datamatrix.coeffscachefetch { /k exch def k { //datamatrix.gencoeffs exec } { length } //datamatrix.coeffscache /fetch get exec } bind def /datamatrix { 64 dict begin { (input.processoptions) //datamatrix.before exec /dontdraw false def /columns 0 def /rows 0 def /format (unset) def % square or rectangle /version (unset) def /parse false def /parsefnc false def /c40headerlength -1 def /raw false def /dmre false def /strictspec false def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def /modunit 2 def /uk.co.terryburton.bwipp.global_ctx dup where { exch get /default_modunit 2 copy known {get /modunit exch def} {pop pop} ifelse } {pop} ifelse % % Apply AST spec overrides and resolve physical specification % /datamatrix ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec (input.processoptions) //datamatrix.after exec //datamatrix.latevars /init get exec % % Input validation % (input.validate) //datamatrix.before exec barcode () eq { /bwipp.datamatrixEmptyData (The data must not be empty) //raiseerror exec } if barcode length 15000 gt { /bwipp.datamatrixInputTooLong (The input data is too long) //raiseerror exec } if version (unset) ne rows 0 ne columns 0 ne or and { /bwipp.datamatrixVersionRowsCols (rows and columns must not be given if version is specified) //raiseerror exec } if % % Parse version=RxC into rows and columns % version (unset) ne { version (x) search { exch pop 2 copy 2 array astore { true 1 index length 0 eq { pop false } if exch { dup 48 lt exch 57 gt or { pop false } if } forall not { pop pop /bwipp.datamatrixVersionBadRowOrColumn (version must be formatted as RxC) //raiseerror exec } if } forall /rows exch cvi def /columns exch cvi def /format rows columns eq { (square) } { (rectangle) } ifelse def } { pop /bwipp.datamatrixVersionFormat (version must be formatted as RxC) //raiseerror exec } ifelse } { format (unset) eq { /format dmre { (rectangle) } { (square) } ifelse def } if } ifelse format (square) ne format (rectangle) ne and { /bwipp.datamatrixInvalidFormat (The format must be either square or rectangle) //raiseerror exec } if (input.validate) //datamatrix.after exec % % Create array of codewords remaining to make a full symbol using stack-based accumulation % /urows rows def /ucols columns def mark //datamatrix.metrics { /m exch def /rows m 0 get def % Rows in symbol /cols m 1 get def % Columns in symbol /regh m 2 get def % Horizontal regions /regv m 3 get def % Vertical regions /rscw m 4 get def % Error correction codewords /rsbl m 5 get def % Error correction blocks /doly m 6 get def % DMRE-only model /mrows rows 2 regh mul sub def % Rows in the mapping matrix /mcols cols 2 regv mul sub def % Columns in the mapping matrix /ncws mrows mcols mul 8 idiv rscw sub def % Data codewords /okay true def urows 0 ne urows rows ne and {/okay false def} if ucols 0 ne ucols cols ne and {/okay false def} if format (square) eq rows cols ne and {/okay false def} if format (rectangle) eq rows cols eq and {/okay false def} if dmre not doly 1 eq and {/okay false def} if okay { ncws } if % Push ncws } forall counttomark array astore /fullcws exch def pop /numremcws [ 1558 {10000} repeat ] def fullcws {numremcws exch 1 sub 1 put} forall 1556 -1 0 { /i exch def numremcws i get 1 ne { numremcws i numremcws i 1 add get 1 add put } if } for /getnumremcws { dup numremcws length ge { pop /bwipp.datamatrixTooMuchData (The input data exceeds the symbol capacity) //raiseerror exec } if numremcws exch get } def raw { /cws barcode length array def /i 0 def /j 0 def { % loop i barcode length 3 sub ge {exit} if barcode i get 94 ne {exit} if barcode i 1 add 3 getinterval false 1 index { dup 48 lt exch 57 gt or { pop true } if } forall { pop exit } if cvi /cw exch def cw 255 gt { /bwipp.datamatrixBadRawCodeword (Raw codewords must be 0 to 255) //raiseerror exec } if cws j cw put /i i 4 add def /j j 1 add def } loop i barcode length ne { /bwipp.datamatrixBadRawFormat (Raw codewords must be formatted as ^NNN) //raiseerror exec } if /cws cws 0 j getinterval def } { % % Parse the input % (input.preprocess) //datamatrix.before exec /fncvals << /parse parse /parsefnc parsefnc /eci true (FNC1) //datamatrix.fnc1 (PROG) //datamatrix.prog % (MAC5) //datamatrix.m05 Encoded automatically % (MAC6) //datamatrix.m06 Encoded automatically >> def barcode fncvals //parseinput exec /msg exch def /msglen msg length def % % Macro 05/06 compression of [)>{RS}05/06{GS}...{RS}{EOT} structured data % msglen 9 ge { msg 0 7 getinterval aload pop 29 eq exch pop exch 48 eq and exch % [)>{RS}0*{GS}... 30 eq and exch 62 eq and exch 41 eq and exch 91 eq and { msg msglen 2 sub 2 getinterval aload pop 4 eq exch 30 eq and { % ...{RS}{EOT} msg 5 get 53 eq { % ...5... /msg [ //datamatrix.m05 msg 7 msg length 9 sub getinterval aload pop ] def } { msg 5 get 54 eq { % ...6... /msg [ //datamatrix.m06 msg 7 msg length 9 sub getinterval aload pop ] def } if } ifelse } if } if } if /msglen msg length def % Absolute capacity is 144x144 numeric. msglen 3116 gt { /bwipp.datamatrixInputTooLong (The input data is too long) //raiseerror exec } if (input.preprocess) //datamatrix.after exec % % Input encoding % (input.encoding) //datamatrix.before exec c40headerlength msglen gt { /c40headerlength msglen def } if % Make sure it's bounded as may increment /numD [ msglen {0} repeat 0 ] def /nextXterm [ msglen {0} repeat 9999 ] def /nextNonX [ msglen {0} repeat 9999 ] def /isECI [ msglen {false} repeat false ] def msglen 1 sub -1 0 { /i exch def /barchar msg i get def barchar 48 ge barchar 57 le and { numD i numD i 1 add get 1 add put } if barchar 13 eq barchar 42 eq or barchar 62 eq or { nextXterm i 0 put } { nextXterm i nextXterm i 1 add get 1 add put } ifelse Xvals barchar known not { nextNonX i 0 put } { nextNonX i nextNonX i 1 add get 1 add put } ifelse isECI i barchar -1000000 le put } for /nextXterm [nextXterm {dup 10000 gt {pop 10000} if} forall] def /nextNonX [nextNonX {dup 10000 gt {pop 10000} if} forall] def /isD {char 48 ge char 57 le and} def /isC {CNvals char known} def /isT {TNvals char known} def /isX {Xvals char known} def /isE {Evals char known} def /isEA {char 127 gt} def /isFN {char 0 lt} def /XtermFirst {dup nextXterm exch get exch nextNonX exch get lt} def % % TODO To avoid roundoff, consider increasing the scores by a scale factor of 12 to convert to integers % /lookup { /ac 1.0 def /cc 2.0 def /tc 2.0 def /xc 2.0 def /ec 2.0 def /bc 2.25 def mode //datamatrix.A eq {/ac 0.0 def /cc 1.0 def /tc 1.0 def /xc 1.0 def /ec 1.0 def /bc 1.25 def} if mode //datamatrix.C eq {/cc 0.0 def} if mode //datamatrix.T eq {/tc 0.0 def} if mode //datamatrix.X eq {/xc 0.0 def} if mode //datamatrix.E eq {/ec 0.0 def} if mode //datamatrix.B eq {/bc 0.0 def} if 1 { % common exit isECI i get {//datamatrix.A exit} if % ECI only in ASCII i c40headerlength lt {//datamatrix.C exit} if % C40 only for c40headerlength characters /isfnc1 msg i get //datamatrix.fnc1 eq def /k 0 def { % loop i k add msglen eq { [/ac /cc /tc /xc /ec /bc] {dup load ceiling def} forall true [ cc tc xc ec bc] {ac exch le and} forall {//datamatrix.A exit} if true [ac cc tc xc ec ] {bc exch lt and} forall {isfnc1 {//datamatrix.A} {//datamatrix.B} ifelse exit} if true [ac cc tc xc bc] {ec exch lt and} forall {//datamatrix.E exit} if true [ac cc xc ec bc] {tc exch lt and} forall {//datamatrix.T exit} if true [ac cc tc ec bc] {xc exch lt and} forall {//datamatrix.X exit} if //datamatrix.C exit } if /char msg i k add get def /ac ac isD {1 2 div add} {isEA {ceiling 2 add} {ceiling 1 add} ifelse} ifelse def /cc cc isC {2 3 div add} {isEA { 8 3 div add } { 4 3 div add } ifelse} ifelse def /tc tc isT {2 3 div add} {isEA { 8 3 div add } { 4 3 div add } ifelse} ifelse def /xc xc isX {2 3 div add} {isEA {13 3 div add } {10 3 div add } ifelse} ifelse def /ec ec isE {3 4 div add} {isEA {17 4 div add } {13 4 div add } ifelse} ifelse def /bc bc isFN {4 add} {1 add} ifelse def k 4 ge { true [ cc tc xc ec bc] {ac 1 add exch le and} forall {//datamatrix.A exit} if bc 1 add ac le {isfnc1 {//datamatrix.A} {//datamatrix.B} ifelse exit} if true [ cc tc xc ec ] {bc 1 add exch lt and} forall {isfnc1 {//datamatrix.A} {//datamatrix.B} ifelse exit} if true [ac cc tc xc bc] {ec 1 add exch lt and} forall {//datamatrix.E exit} if true [ac cc xc ec bc] {tc 1 add exch lt and} forall {//datamatrix.T exit} if true [ac cc tc ec bc] {xc 1 add exch lt and} forall {//datamatrix.X exit} if true [ac tc ec bc] {cc 1 add exch lt and} forall { cc xc lt {//datamatrix.C exit} if cc xc eq {i k add 1 add XtermFirst {//datamatrix.X exit} {//datamatrix.C exit} ifelse} if } if } if /k k 1 add def } loop } repeat } def /addtocws { dup length j add cws length gt { pop /bwipp.datamatrixTooMuchData (The input data exceeds the symbol capacity) //raiseerror exec } if dup cws exch j exch putinterval /j exch length j add def } def /ECItocws { neg 1000000 sub dup 000126 le { % ECI 000000 - 000126 1 add 1 array astore } { dup 016382 le { % ECI 000127 - 016382 127 sub dup 254 idiv 128 add exch 254 mod 1 add 2 array astore } { % ECI 016383 - 999999 16383 sub dup 64516 idiv 192 add exch dup 254 idiv 254 mod 1 add exch 254 mod 1 add 3 array astore } ifelse } ifelse } def /encA { 1 { % Common exit isECI i get { Avals //datamatrix.eci get addtocws msg i get ECItocws addtocws /i i 1 add def exit } if i c40headerlength ge numD i get 2 ge and { 2 string dup 0 msg i get put dup 1 msg i 1 add get put Avals exch get addtocws /i i 2 add def exit } if /newmode lookup def newmode mode ne { Avals [-1 //datamatrix.lC //datamatrix.lT //datamatrix.lX //datamatrix.lE //datamatrix.lB] newmode get get addtocws /mode newmode def exit } if Avals msg i get get addtocws /i i 1 add def exit } repeat } def /CTXvalstocws { /in exch def mark 0 3 in length 1 sub { in exch 3 getinterval 0 exch {add 40 mul} forall 40 idiv 1 add dup 256 idiv exch 256 mod } for counttomark array astore exch pop } def /encCTX { /p 0 def /ctxvals 2500 array def /done false def % Lookup the values for each character { i msglen eq {exit} if encvals mode get msg i get known not {exit} if p 3 mod 0 eq { p 0 gt { /newmode lookup def newmode mode ne { ctxvals 0 p getinterval CTXvalstocws addtocws [//datamatrix.unlcw] addtocws newmode //datamatrix.A ne { Avals [-1 //datamatrix.lC //datamatrix.lT //datamatrix.lX //datamatrix.lE //datamatrix.lB] newmode get get addtocws } if /mode newmode def /done true def exit } if } if msglen i sub 3 le { % Check end of data conditions j p 3 idiv 2 mul add getnumremcws /remcws exch def /remvals [ msg i msglen i sub getinterval { dup encvals mode get exch known { encvals mode get exch get aload pop } { % Unencodable X12 characters pop -1 -1 -1 -1 } ifelse } forall ] def remcws 2 eq remvals length 3 eq and { % Encode and omit unlatch [ ctxvals 0 p getinterval aload pop remvals aload pop ] CTXvalstocws addtocws /mode //datamatrix.A def /i msglen def /done true def exit } if % Encode with sft1 as third value, omit unlatch remcws 2 eq remvals length 2 eq and mode //datamatrix.X ne and { [ ctxvals 0 p getinterval aload pop remvals aload pop encvals mode get //datamatrix.sft1 get aload pop ] CTXvalstocws addtocws /mode //datamatrix.A def /i msglen def /done true def exit } if remcws 2 eq remvals length 1 eq and { % Unlatch to ASCII ctxvals 0 p getinterval CTXvalstocws addtocws [//datamatrix.unlcw] addtocws Avals msg i get get addtocws /mode //datamatrix.A def /i msglen def /done true def exit } if remcws 1 eq remvals length 1 eq and { % Implied unlatch to ASCII ctxvals 0 p getinterval CTXvalstocws addtocws Avals msg i get get addtocws /mode //datamatrix.A def /i msglen def /done true def exit } if } if } if encvals mode get msg i get get dup length p add ctxvals length gt { pop /bwipp.datamatrixTooMuchData (The input data exceeds the symbol capacity) //raiseerror exec } if dup ctxvals exch p exch putinterval /p exch length p add def /i i 1 add def } loop % % Backtrack to a boundary and return to ASCII % done not { { p 3 mod 0 eq {exit} if /i i 1 sub def /p p encvals mode get msg i get get length sub def } loop [ ctxvals 0 p getinterval aload pop ] CTXvalstocws addtocws [//datamatrix.unlcw] addtocws /mode //datamatrix.A def /c40headerlength -1 def % Disable when backtracking % Encode something to avoid latching immediately back i msglen ne isECI i get not and { numD i get 2 ge { 2 string dup 0 msg i get put dup 1 msg i 1 add get put Avals exch get addtocws /i i 2 add def } { Avals msg i get get addtocws /i i 1 add def } ifelse } if } if } def /Evalstocws { /in exch def /inlen in length def /outlen in length 4 div 3 mul ceiling cvi def /in [ in aload pop 0 0 0 ] def mark 0 4 inlen 1 sub { in exch 4 getinterval 0 exch {or 6 bitshift} forall -6 bitshift dup -16 bitshift 255 and exch dup -8 bitshift 255 and exch 255 and } for counttomark array astore exch pop 0 outlen getinterval } def /encE { /p 0 def /edifactvals 2100 array def % % Lookup the values for each character % { i msglen eq {exit} if Evals msg i get known not {exit} if p edifactvals length ge { /bwipp.datamatrixTooMuchData (The input data exceeds the symbol capacity) //raiseerror exec } if p 4 mod 0 eq { msglen i sub 2 le { % Check end of data condition j p 4 idiv 3 mul add getnumremcws /remcws exch def /remvals [ msg i msglen i sub getinterval { Avals exch get aload pop } forall ] def remcws 1 eq remcws 2 eq or remvals length remcws le and { % Implied unlatch to ASCII edifactvals 0 p getinterval Evalstocws addtocws remvals addtocws /mode //datamatrix.A def /i msglen def exit } if } if lookup mode ne {exit} if } if Evals msg i get get dup edifactvals exch p exch putinterval /p exch length p add def /i i 1 add def } loop % % Unlatch and pad with zeros until boundary % mode //datamatrix.A ne { j p 4 idiv 3 mul add 1 sub getnumremcws 1 sub /remcws exch def p 4 mod 0 ne i msglen ne or remcws 3 ge or { % Unlatch unless less than 3 codewords remain Evals //datamatrix.unl get dup edifactvals exch p exch putinterval /p exch length p add def } if edifactvals 0 p getinterval Evalstocws addtocws /mode //datamatrix.A def /c40headerlength -1 def % Disable when backtracking % Encode something to avoid latching immediately back i msglen ne isECI i get not and { numD i get 2 ge { 2 string dup 0 msg i get put dup 1 msg i 1 add get put Avals exch get addtocws /i i 2 add def } { Avals msg i get get addtocws /i i 1 add def } ifelse } if } if } def /encB { /p 0 def /bvals 1558 array def { i msglen eq {exit} if lookup mode ne {exit} if p bvals length ge { /bwipp.datamatrixTooMuchData (The input data exceeds the symbol capacity) //raiseerror exec } if bvals p msg i get put /p p 1 add def /i i 1 add def } loop j p add getnumremcws 1 sub /remcws exch def /bvals [ remcws 0 eq i msglen eq and { % Terminates symbol 0 } { p 250 lt {p} {p 250 idiv 249 add p 250 mod} ifelse } ifelse bvals 0 p getinterval aload pop ] def 0 1 bvals length 1 sub { % Pseudo-randomise based on codeword position /p exch def j p add 1 add 149 mul 255 mod 1 add bvals p get add dup 256 ge {256 sub} if bvals exch p exch put } for bvals addtocws /mode //datamatrix.A def } def % % Derive the codewords % /cws 1558 array def /mode //datamatrix.A def /i 0 def /j 0 def % FNC1 in 1st position must be in ASCII to be GS1 msg 0 get //datamatrix.fnc1 eq { Avals //datamatrix.fnc1 get addtocws /i 1 def % Compensate c40headerlength if any c40headerlength 0 gt { /c40headerlength c40headerlength 1 add def } if } if { i msglen ge {exit} if //datamatrix.encfuncs mode get load exec } loop /cws cws 0 j getinterval def } ifelse % % Extend codewords to fill symbol with pseudo-randomised pad characters % /datlen cws length def j 1 sub getnumremcws 1 sub /remcws exch def remcws 0 gt { /cws [ cws aload pop remcws {129} repeat ] def datlen 1 add 1 datlen remcws add 1 sub { /i exch def i 1 add 149 mul 253 mod 1 add 129 add dup 254 gt {254 sub} if cws exch i exch put } for } if options /debugcws known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugcws cws //raiseerror exec } if (input.encoding) //datamatrix.after exec % % Lookup symbol metrics based on number of codewords and user specification % //datamatrix.metrics { /m exch def /rows m 0 get def % Rows in symbol /cols m 1 get def % Columns in symbol /regh m 2 get def % Horizontal regions /regv m 3 get def % Vertical regions /rscw m 4 get def % Error correction codewords /rsbl m 5 get def % Error correction blocks /doly m 6 get def % DMRE-only model /mrows rows 2 regh mul sub def % Rows in the mapping matrix /mcols cols 2 regv mul sub def % Columns in the mapping matrix /rrows mrows regh idiv def % Rows per region /rcols mcols regv idiv def % Columns per region /ncws mrows mcols mul 8 idiv rscw sub def % Data codewords /okay true def cws length ncws ne {/okay false def} if urows 0 ne urows rows ne and {/okay false def} if ucols 0 ne ucols cols ne and {/okay false def} if format (square) eq rows cols ne and {/okay false def} if format (rectangle) eq rows cols eq and {/okay false def} if dmre not doly 1 eq and {/okay false def} if okay {exit} if } forall okay not { /bwipp.datamatrixNoValidSymbol (Maximum length exceeded or invalid size) //raiseerror exec } if % % Fetch the coefficients % (ecc.coeffs) //datamatrix.before exec /coeffs rscw rsbl idiv //datamatrix.coeffscachefetch exec def (ecc.coeffs) //datamatrix.after exec (ecc.cws) //datamatrix.before exec % % Calculate the error correction codewords for each block. Data is read % directly from cws via interleaved indexing. % /ecbs rsbl array def /ecpb rscw rsbl idiv def 0 1 rsbl 1 sub { /blk exch def cws length 1558 ne { /cwbsize cws length rsbl idiv def } { blk 7 le {/cwbsize 156 def} {/cwbsize 155 def} ifelse } ifelse ecbs blk /lfsr ecpb array def {cws exch rsbl mul blk add get} cwbsize coeffs ecpb lfsr //datamatrix.rsprod //rsecbinary exec lfsr put } for % % Strange fixup for 144x144 symbols % ncws 1558 eq { /ecbs [ ecbs 8 2 getinterval aload pop ecbs 0 8 getinterval aload pop ] def } if options /debugecc known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugecc [ ecbs {aload pop} forall ] //raiseerror exec } if % % Extend codewords with the interleaved error correction codes % /cws cws length rscw add array dup 0 cws putinterval def 0 1 rscw 1 sub { /i exch def cws ncws i add ecbs i rsbl mod get i rsbl idiv get put } for (ecc.cws) //datamatrix.after exec % % Place codeword bits into matrix % (matrix.layout) //datamatrix.before exec /module { % cw row col shape 4 -1 roll (00000000) 8 string copy dup 3 -1 roll 2 8 string cvrs dup length 8 exch sub exch putinterval 7 -1 0 {1 index exch get 48 sub exch} for pop 11 -3 roll % 1 2 4 8 16 32 64 128 row col shape { % Place each bit of the codeword in the shape, MSB first exec 1 index 0 lt { exch mrows add exch 4 mrows 4 add 8 mod sub add } if dup 0 lt { mcols add exch 4 mcols 4 add 8 mod sub add exch } if 1 index mrows ge { exch mrows sub exch } if exch mcols mul add mmat exch 5 -1 roll put } forall } def /mmat [ mrows mcols mul {-1} repeat ] def cws length 1 sub -1 0 {cws exch get} for % Reverse cws onto stack 4 0 % Starting row and column { % loop 2 copy 0 eq exch mrows eq and { //datamatrix.dmc1 module exec } if 2 copy 0 eq exch mrows 2 sub eq and mcols 4 mod 0 ne and { //datamatrix.dmc2 module exec } if 2 copy 0 eq exch mrows 2 sub eq and mcols 8 mod 4 eq and { //datamatrix.dmc3 module exec } if 2 copy 2 eq exch mrows 4 add eq and mcols 8 mod 0 eq and { //datamatrix.dmc4 module exec } if { % loop for sweeping upwards 2 copy 0 ge exch mrows lt and { 2 copy exch mcols mul add mmat exch get -1 eq { //datamatrix.dmn module exec } if } if 2 add exch 2 sub exch 2 copy mcols lt exch 0 ge and not {exit} if } loop 3 add exch 1 add exch { % loop for sweeping downwards 2 copy mcols lt exch 0 ge and { 2 copy exch mcols mul add mmat exch get -1 eq { //datamatrix.dmn module exec } if } if 2 sub exch 2 add exch 2 copy 0 ge exch mrows lt and not {exit} if } loop 1 add exch 3 add exch 2 copy mcols lt exch mrows lt or not {pop pop exit} if } loop % % Set checker pattern if required % mmat mrows mcols mul 1 sub get -1 eq { mmat mrows mcols 1 sub mul 2 sub [1 0] putinterval mmat mrows mcols mul 2 sub [0 1] putinterval } if % % Place the modules onto a pixel map between alignment patterns % /pixs rows cols mul array def /cwpos 0 def 0 1 rows 1 sub { /i exch def i rrows 2 add mod 0 eq { pixs i cols mul [ cols 2 idiv {1 0} repeat ] putinterval } if i rrows 2 add mod rrows 1 add eq { pixs i cols mul [ cols {1} repeat ] putinterval } if i rrows 2 add mod 0 ne i rrows 2 add mod rrows 1 add ne and { 0 1 cols 1 sub { /j exch def j rcols 2 add mod 0 eq { pixs i cols mul j add 1 put } if j rcols 2 add mod rcols 1 add eq { pixs i cols mul j add i 2 mod put } if j rcols 2 add mod 0 ne j rcols 2 add mod rcols 1 add ne and { pixs i cols mul j add mmat cwpos get put /cwpos cwpos 1 add def } if } for } if } for (matrix.layout) //datamatrix.after exec << /ren /renmatrix /pixs pixs /pixx cols /pixy rows /height rows modunit mul 72 div /width cols modunit mul 72 div /borderleft 1.0 /borderright 1.0 /bordertop 1.0 /borderbottom 1.0 /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /datamatrix dup load /uk.co.terryburton.bwipp defineresource pop (setup.define) //datamatrix.after exec end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER datamatrix-- % --BEGIN ENCODER datamatrixrectangular-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor fifocache rsecbinary render renmatrix datamatrix-- % --DESC: Data Matrix Rectangular % --EXAM: 1234 % --EXOP: % --RNDR: renmatrix % --FMLY: Two-dimensional symbols %%BeginResource: uk.co.terryburton.bwipp datamatrixrectangular 0.0 2026052800 78662 71773 %%BeginData: 47 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 4 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /datamatrix dup /uk.co.terryburton.bwipp findresource put begin /datamatrixrectangular { 4 dict begin { /dontdraw false def null /apply //processoptions exec /options exch def /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Get the result of encoding with datamatrix with format=rectangle % options (format) (rectangle) put /uk.co.terryburton.bwipp._dontdraw true def barcode options //datamatrix exec /args exch def args (opt) options put args _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /datamatrixrectangular dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER datamatrixrectangular-- % --BEGIN ENCODER datamatrixrectangularextension-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor fifocache rsecbinary render renmatrix datamatrix-- % --DESC: Data Matrix Rectangular Extension % --EXAM: 1234 % --EXOP: version=8x96 % --RNDR: renmatrix % --FMLY: Two-dimensional symbols %%BeginResource: uk.co.terryburton.bwipp datamatrixrectangularextension 0.0 2026052800 78687 71789 %%BeginData: 47 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 4 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /datamatrix dup /uk.co.terryburton.bwipp findresource put begin /datamatrixrectangularextension { 4 dict begin { /dontdraw false def null /apply //processoptions exec /options exch def /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Get the result of encoding with datamatrix % options (dmre) true put /uk.co.terryburton.bwipp._dontdraw true def barcode options //datamatrix exec /args exch def args (opt) options put args _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /datamatrixrectangularextension dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER datamatrixrectangularextension-- % --BEGIN ENCODER mailmark-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor fifocache rsecbinary render renmatrix datamatrix-- % --DESC: Royal Mail Mailmark % --EXAM: JGB 012100123412345678AB19XY1A 0 www.xyz.com % --EXOP: type=29 % --RNDR: renmatrix % --FMLY: Postal Symbols %%BeginResource: uk.co.terryburton.bwipp mailmark 0.0 2026052800 83590 80025 %%BeginData: 96 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 8 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /datamatrix dup /uk.co.terryburton.bwipp findresource put begin /mailmark.typetoversion << (7) (24x24) (9) (32x32) (29) (16x48) >> readonly def /mailmark.typetoformat << (7) (square) (9) (square) (29) (rectangle) >> readonly def /mailmark { 8 dict begin { /type (unset) def % 7, 9 or 29 /parse false def /dontdraw false def null /apply //processoptions exec /options exch def /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Parse ordinals of the form ^NNN to ASCII % /fncvals << /parse parse /parseonly true /parsefnc false >> def barcode fncvals //parseinput exec /barcode exch def /barlen barcode length def options (parse) undef % % Map the given type to a format and version of Data Matrix % /type load dup (7) ne exch dup (9) ne exch (29) ne and and { /bwipp.mailmarkBadType (Royal Mail Mailmark type must be 7, 9 or 29) //raiseerror exec } if //mailmark.typetoversion /type load get /version exch def //mailmark.typetoformat /type load get /format exch def % % Validate the input % barcode length 45 lt { /bwipp.mailmarkBadLength (Royal Mail Mailmark must contain at least 45 characters of Mailmark formatted data, including any required space padding) //raiseerror exec } if barcode 0 4 getinterval (JGB ) ne { /bwipp.mailmarkBadIndicator (Royal Mail Mailmark must begin with JGB identifier) //raiseerror exec } if % % Get the result of encoding with datamatrix % options (version) version put options (format) format put options (c40headerlength) 45 put /uk.co.terryburton.bwipp._dontdraw true def barcode options //datamatrix exec /args exch def args (opt) options put args _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /mailmark dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER mailmark-- % --BEGIN ENCODER qrcode-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor fifocache rsecbinary render renmatrix-- % --DESC: QR Code % --EXAM: http://goo.gl/0bis % --EXOP: eclevel=M % --RNDR: renmatrix % --FMLY: Two-dimensional symbols %%BeginResource: uk.co.terryburton.bwipp qrcode 0.0 2026052800 845485 845581 %%BeginData: 1842 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 64 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /fifocache dup /uk.co.terryburton.bwipp findresource put dup /rsecbinary dup /uk.co.terryburton.bwipp findresource put dup /setuphooks dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put begin /qrcode [/before /after] //setuphooks exec (setup.define) //qrcode.before exec % % Version groups % /qrcode.v1to9 0 def /qrcode.v10to26 1 def /qrcode.v27to40 2 def /qrcode.vM1 3 def /qrcode.vM2 4 def /qrcode.vM3 5 def /qrcode.vM4 6 def /qrcode.vR7x43 7 def /qrcode.vR7x59 8 def /qrcode.vR7x77 9 def /qrcode.vR7x99 10 def /qrcode.vR7x139 11 def /qrcode.vR9x43 12 def /qrcode.vR9x59 13 def /qrcode.vR9x77 14 def /qrcode.vR9x99 15 def /qrcode.vR9x139 16 def /qrcode.vR11x27 17 def /qrcode.vR11x43 18 def /qrcode.vR11x59 19 def /qrcode.vR11x77 20 def /qrcode.vR11x99 21 def /qrcode.vR11x139 22 def /qrcode.vR13x27 23 def /qrcode.vR13x43 24 def /qrcode.vR13x59 25 def /qrcode.vR13x77 26 def /qrcode.vR13x99 27 def /qrcode.vR13x139 28 def /qrcode.vR15x43 29 def /qrcode.vR15x59 30 def /qrcode.vR15x77 31 def /qrcode.vR15x99 32 def /qrcode.vR15x139 33 def /qrcode.vR17x43 34 def /qrcode.vR17x59 35 def /qrcode.vR17x77 36 def /qrcode.vR17x99 37 def /qrcode.vR17x139 38 def % % Encoding modes: (N)umeric, (A)lphanumeric, (B)yte, (K)anji, (E)CI % /qrcode.N 0 def /qrcode.A 1 def /qrcode.B 2 def /qrcode.K 3 def /qrcode.E 4 def % % Encoding function names % /qrcode.encfuncs [ /encN /encA /encB /encK /encE ] readonly def /qrcode.fn1 -1 def % % Characters exclusive to each encoding mode % /qrcode.Nexcl << [ 16#30 1 16#39 {} for ] {-1} forall >> readonly def /qrcode.Aexcl << [ 16#20 16#24 16#25 16#2A 16#2B 16#2D 16#2E 16#2F 16#3A 16#41 1 16#5A {} for //qrcode.fn1 ] {-1} forall >> readonly def /qrcode.Kexcl << [ 16#81 1 16#9F {} for 16#E0 1 16#EB {} for ] {-1} forall >> readonly def % Note: Binary exclusives are calculated from "not others" % % Mode identifiers % /qrcode.mids [ % N A B K E [ (0001) (0010) (0100) (1000) (0111) ] % v1to9 dup % [ (0001) (0010) (0100) (1000) (0111) ] % v10to26 dup % [ (0001) (0010) (0100) (1000) (0111) ] % v27to40 [ () -1 -1 -1 -1 ] % vM1 [ (0) (1) -1 -1 -1 ] % vM2 [ (00) (01) (10) (11) -1 ] % vM3 [ (000) (001) (010) (011) -1 ] % vM4 [ (001) (010) (011) (100) (111) ] % vR7x43 ... 31 { dup } repeat % ... vR17x139 ] readonly def % % Character counts for each mode for each version % /qrcode.cclens [ % N A B K [ 10 9 8 8 ] % v1to9 [ 12 11 16 10 ] % v10to26 [ 14 13 16 12 ] % v27to40 [ 3 -1 -1 -1 ] % vM1 [ 4 3 -1 -1 ] % vM2 [ 5 4 4 3 ] % vM3 [ 6 5 5 4 ] % vM4 [ 4 3 3 2 ] % vR7x43 [ 5 5 4 3 ] % vR7x59 [ 6 5 5 4 ] % vR7x77 [ 7 6 5 5 ] % vR7x99 [ 7 6 6 5 ] % vR7x139 [ 5 5 4 3 ] % vR9x43 [ 6 5 5 4 ] % vR9x59 [ 7 6 5 5 ] % vR9x77 [ 7 6 6 5 ] % vR9x99 [ 8 7 6 6 ] % vR9x139 [ 4 4 3 2 ] % vR11x27 [ 6 5 5 4 ] % vR11x43 [ 7 6 5 5 ] % vR11x59 [ 7 6 6 5 ] % vR11x77 [ 8 7 6 6 ] % vR11x99 [ 8 7 7 6 ] % vR11x139 [ 5 5 4 3 ] % vR13x27 [ 6 6 5 5 ] % vR13x43 [ 7 6 6 5 ] % vR13x59 [ 7 7 6 6 ] % vR13x77 [ 8 7 7 6 ] % vR13x99 [ 8 8 7 7 ] % vR13x139 [ 7 6 6 5 ] % vR15x43 [ 7 7 6 5 ] % vR15x59 [ 8 7 7 6 ] % vR15x77 [ 8 7 7 6 ] % vR15x99 [ 9 8 7 7 ] % vR15x139 [ 7 6 6 5 ] % vR17x43 [ 8 7 6 6 ] % vR17x59 [ 8 7 7 6 ] % vR17x77 [ 8 8 7 6 ] % vR17x99 [ 9 8 8 7 ] % vR17x139 ] readonly def % % Terminator length for each version % /qrcode.termlens [ 3 { 4 % v1to9 ... v27to40 } repeat 3 % vM1 5 % vM2 7 % vM3 9 % vM4 32 { 3 % vR7x43 ... vR17x139 } repeat ] readonly def % % Padding sequences % /qrcode.padstrs [ (11101100) (00010001) ] readonly def % % Alphanumeric character to value map % /qrcode.charmap (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:) def % % Version group mapping for each symbol size % /qrcode.versetmap << (full) << 0 1 9 { 10 2 string cvrs //qrcode.v1to9 } bind for 10 1 26 { 10 2 string cvrs //qrcode.v10to26 } bind for 27 1 40 { 10 2 string cvrs //qrcode.v27to40 } bind for >> (micro) << (M1) //qrcode.vM1 (M2) //qrcode.vM2 (M3) //qrcode.vM3 (M4) //qrcode.vM4 >> (rmqr) << (R7x43) //qrcode.vR7x43 (R7x59) //qrcode.vR7x59 (R7x77) //qrcode.vR7x77 (R7x99) //qrcode.vR7x99 (R7x139) //qrcode.vR7x139 (R9x43) //qrcode.vR9x43 (R9x59) //qrcode.vR9x59 (R9x77) //qrcode.vR9x77 (R9x99) //qrcode.vR9x99 (R9x139) //qrcode.vR9x139 (R11x27) //qrcode.vR11x27 (R11x43) //qrcode.vR11x43 (R11x59) //qrcode.vR11x59 (R11x77) //qrcode.vR11x77 (R11x99) //qrcode.vR11x99 (R11x139) //qrcode.vR11x139 (R13x27) //qrcode.vR13x27 (R13x43) //qrcode.vR13x43 (R13x59) //qrcode.vR13x59 (R13x77) //qrcode.vR13x77 (R13x99) //qrcode.vR13x99 (R13x139) //qrcode.vR13x139 (R15x43) //qrcode.vR15x43 (R15x59) //qrcode.vR15x59 (R15x77) //qrcode.vR15x77 (R15x99) //qrcode.vR15x99 (R15x139) //qrcode.vR15x139 (R17x43) //qrcode.vR17x43 (R17x59) //qrcode.vR17x59 (R17x77) //qrcode.vR17x77 (R17x99) //qrcode.vR17x99 (R17x139) //qrcode.vR17x139 >> >> readonly def /qrcode.versetfull [ //qrcode.v1to9 //qrcode.v10to26 //qrcode.v27to40 ] readonly def /qrcode.versetmicro [ //qrcode.vM1 //qrcode.vM2 //qrcode.vM3 //qrcode.vM4 ] readonly def % % Symbol specification table % /qrcode.metrics [ % format vers vergrp rows cols align modules error codewords error correction blocks % L M Q H L1 L2 M1 M2 Q1 Q2 H1 H2 [ (micro) (M1) //qrcode.vM1 11 11 98 99 36 [ 2 99 99 99 ] [ 1 0 -1 -1 -1 -1 -1 -1 ] ] [ (micro) (M2) //qrcode.vM2 13 13 98 99 80 [ 5 6 99 99 ] [ 1 0 1 0 -1 -1 -1 -1 ] ] [ (micro) (M3) //qrcode.vM3 15 15 98 99 132 [ 6 8 99 99 ] [ 1 0 1 0 -1 -1 -1 -1 ] ] [ (micro) (M4) //qrcode.vM4 17 17 98 99 192 [ 8 10 14 99 ] [ 1 0 1 0 1 0 -1 -1 ] ] [ (full) (1) //qrcode.v1to9 21 21 98 99 208 [ 7 10 13 17 ] [ 1 0 1 0 1 0 1 0 ] ] [ (full) (2) //qrcode.v1to9 25 25 18 99 359 [ 10 16 22 28 ] [ 1 0 1 0 1 0 1 0 ] ] [ (full) (3) //qrcode.v1to9 29 29 22 99 567 [ 15 26 36 44 ] [ 1 0 1 0 2 0 2 0 ] ] [ (full) (4) //qrcode.v1to9 33 33 26 99 807 [ 20 36 52 64 ] [ 1 0 2 0 2 0 4 0 ] ] [ (full) (5) //qrcode.v1to9 37 37 30 99 1079 [ 26 48 72 88 ] [ 1 0 2 0 2 2 2 2 ] ] [ (full) (6) //qrcode.v1to9 41 41 34 99 1383 [ 36 64 96 112 ] [ 2 0 4 0 4 0 4 0 ] ] [ (full) (7) //qrcode.v1to9 45 45 22 38 1568 [ 40 72 108 130 ] [ 2 0 4 0 2 4 4 1 ] ] [ (full) (8) //qrcode.v1to9 49 49 24 42 1936 [ 48 88 132 156 ] [ 2 0 2 2 4 2 4 2 ] ] [ (full) (9) //qrcode.v1to9 53 53 26 46 2336 [ 60 110 160 192 ] [ 2 0 3 2 4 4 4 4 ] ] [ (full) (10) //qrcode.v10to26 57 57 28 50 2768 [ 72 130 192 224 ] [ 2 2 4 1 6 2 6 2 ] ] [ (full) (11) //qrcode.v10to26 61 61 30 54 3232 [ 80 150 224 264 ] [ 4 0 1 4 4 4 3 8 ] ] [ (full) (12) //qrcode.v10to26 65 65 32 58 3728 [ 96 176 260 308 ] [ 2 2 6 2 4 6 7 4 ] ] [ (full) (13) //qrcode.v10to26 69 69 34 62 4256 [ 104 198 288 352 ] [ 4 0 8 1 8 4 12 4 ] ] [ (full) (14) //qrcode.v10to26 73 73 26 46 4651 [ 120 216 320 384 ] [ 3 1 4 5 11 5 11 5 ] ] [ (full) (15) //qrcode.v10to26 77 77 26 48 5243 [ 132 240 360 432 ] [ 5 1 5 5 5 7 11 7 ] ] [ (full) (16) //qrcode.v10to26 81 81 26 50 5867 [ 144 280 408 480 ] [ 5 1 7 3 15 2 3 13 ] ] [ (full) (17) //qrcode.v10to26 85 85 30 54 6523 [ 168 308 448 532 ] [ 1 5 10 1 1 15 2 17 ] ] [ (full) (18) //qrcode.v10to26 89 89 30 56 7211 [ 180 338 504 588 ] [ 5 1 9 4 17 1 2 19 ] ] [ (full) (19) //qrcode.v10to26 93 93 30 58 7931 [ 196 364 546 650 ] [ 3 4 3 11 17 4 9 16 ] ] [ (full) (20) //qrcode.v10to26 97 97 34 62 8683 [ 224 416 600 700 ] [ 3 5 3 13 15 5 15 10 ] ] [ (full) (21) //qrcode.v10to26 101 101 28 50 9252 [ 224 442 644 750 ] [ 4 4 17 0 17 6 19 6 ] ] [ (full) (22) //qrcode.v10to26 105 105 26 50 10068 [ 252 476 690 816 ] [ 2 7 17 0 7 16 34 0 ] ] [ (full) (23) //qrcode.v10to26 109 109 30 54 10916 [ 270 504 750 900 ] [ 4 5 4 14 11 14 16 14 ] ] [ (full) (24) //qrcode.v10to26 113 113 28 54 11796 [ 300 560 810 960 ] [ 6 4 6 14 11 16 30 2 ] ] [ (full) (25) //qrcode.v10to26 117 117 32 58 12708 [ 312 588 870 1050 ] [ 8 4 8 13 7 22 22 13 ] ] [ (full) (26) //qrcode.v10to26 121 121 30 58 13652 [ 336 644 952 1110 ] [ 10 2 19 4 28 6 33 4 ] ] [ (full) (27) //qrcode.v27to40 125 125 34 62 14628 [ 360 700 1020 1200 ] [ 8 4 22 3 8 26 12 28 ] ] [ (full) (28) //qrcode.v27to40 129 129 26 50 15371 [ 390 728 1050 1260 ] [ 3 10 3 23 4 31 11 31 ] ] [ (full) (29) //qrcode.v27to40 133 133 30 54 16411 [ 420 784 1140 1350 ] [ 7 7 21 7 1 37 19 26 ] ] [ (full) (30) //qrcode.v27to40 137 137 26 52 17483 [ 450 812 1200 1440 ] [ 5 10 19 10 15 25 23 25 ] ] [ (full) (31) //qrcode.v27to40 141 141 30 56 18587 [ 480 868 1290 1530 ] [ 13 3 2 29 42 1 23 28 ] ] [ (full) (32) //qrcode.v27to40 145 145 34 60 19723 [ 510 924 1350 1620 ] [ 17 0 10 23 10 35 19 35 ] ] [ (full) (33) //qrcode.v27to40 149 149 30 58 20891 [ 540 980 1440 1710 ] [ 17 1 14 21 29 19 11 46 ] ] [ (full) (34) //qrcode.v27to40 153 153 34 62 22091 [ 570 1036 1530 1800 ] [ 13 6 14 23 44 7 59 1 ] ] [ (full) (35) //qrcode.v27to40 157 157 30 54 23008 [ 570 1064 1590 1890 ] [ 12 7 12 26 39 14 22 41 ] ] [ (full) (36) //qrcode.v27to40 161 161 24 50 24272 [ 600 1120 1680 1980 ] [ 6 14 6 34 46 10 2 64 ] ] [ (full) (37) //qrcode.v27to40 165 165 28 54 25568 [ 630 1204 1770 2100 ] [ 17 4 29 14 49 10 24 46 ] ] [ (full) (38) //qrcode.v27to40 169 169 32 58 26896 [ 660 1260 1860 2220 ] [ 4 18 13 32 48 14 42 32 ] ] [ (full) (39) //qrcode.v27to40 173 173 26 54 28256 [ 720 1316 1950 2310 ] [ 20 4 40 7 43 22 10 67 ] ] [ (full) (40) //qrcode.v27to40 177 177 30 58 29648 [ 750 1372 2040 2430 ] [ 19 6 18 31 34 34 20 61 ] ] [ (rmqr) (R7x43) //qrcode.vR7x43 7 43 22 99 104 [ 99 7 99 10 ] [ -1 -1 1 0 -1 -1 1 0 ] ] [ (rmqr) (R7x59) //qrcode.vR7x59 7 59 20 40 171 [ 99 9 99 14 ] [ -1 -1 1 0 -1 -1 1 0 ] ] [ (rmqr) (R7x77) //qrcode.vR7x77 7 77 26 52 261 [ 99 12 99 22 ] [ -1 -1 1 0 -1 -1 1 0 ] ] [ (rmqr) (R7x99) //qrcode.vR7x99 7 99 24 50 358 [ 99 16 99 30 ] [ -1 -1 1 0 -1 -1 1 0 ] ] [ (rmqr) (R7x139) //qrcode.vR7x139 7 139 28 56 545 [ 99 24 99 44 ] [ -1 -1 1 0 -1 -1 2 0 ] ] [ (rmqr) (R9x43) //qrcode.vR9x43 9 43 22 99 170 [ 99 9 99 14 ] [ -1 -1 1 0 -1 -1 1 0 ] ] [ (rmqr) (R9x59) //qrcode.vR9x59 9 59 20 40 267 [ 99 12 99 22 ] [ -1 -1 1 0 -1 -1 1 0 ] ] [ (rmqr) (R9x77) //qrcode.vR9x77 9 77 26 52 393 [ 99 18 99 32 ] [ -1 -1 1 0 -1 -1 1 1 ] ] [ (rmqr) (R9x99) //qrcode.vR9x99 9 99 24 50 532 [ 99 24 99 44 ] [ -1 -1 1 0 -1 -1 2 0 ] ] [ (rmqr) (R9x139) //qrcode.vR9x139 9 139 28 56 797 [ 99 36 99 66 ] [ -1 -1 1 1 -1 -1 3 0 ] ] [ (rmqr) (R11x27) //qrcode.vR11x27 11 27 98 99 122 [ 99 8 99 10 ] [ -1 -1 1 0 -1 -1 1 0 ] ] [ (rmqr) (R11x43) //qrcode.vR11x43 11 43 22 99 249 [ 99 12 99 20 ] [ -1 -1 1 0 -1 -1 1 0 ] ] [ (rmqr) (R11x59) //qrcode.vR11x59 11 59 20 40 376 [ 99 16 99 32 ] [ -1 -1 1 0 -1 -1 1 1 ] ] [ (rmqr) (R11x77) //qrcode.vR11x77 11 77 26 52 538 [ 99 24 99 44 ] [ -1 -1 1 0 -1 -1 1 1 ] ] [ (rmqr) (R11x99) //qrcode.vR11x99 11 99 24 50 719 [ 99 32 99 60 ] [ -1 -1 1 1 -1 -1 1 1 ] ] [ (rmqr) (R11x139) //qrcode.vR11x139 11 139 28 56 1062 [ 99 48 99 90 ] [ -1 -1 2 0 -1 -1 3 0 ] ] [ (rmqr) (R13x27) //qrcode.vR13x27 13 27 98 99 172 [ 99 9 99 14 ] [ -1 -1 1 0 -1 -1 1 0 ] ] [ (rmqr) (R13x43) //qrcode.vR13x43 13 43 22 99 329 [ 99 14 99 28 ] [ -1 -1 1 0 -1 -1 1 0 ] ] [ (rmqr) (R13x59) //qrcode.vR13x59 13 59 20 40 486 [ 99 22 99 40 ] [ -1 -1 1 0 -1 -1 2 0 ] ] [ (rmqr) (R13x77) //qrcode.vR13x77 13 77 26 52 684 [ 99 32 99 56 ] [ -1 -1 1 1 -1 -1 1 1 ] ] [ (rmqr) (R13x99) //qrcode.vR13x99 13 99 24 50 907 [ 99 40 99 78 ] [ -1 -1 1 1 -1 -1 1 2 ] ] [ (rmqr) (R13x139) //qrcode.vR13x139 13 139 28 56 1328 [ 99 60 99 112 ] [ -1 -1 2 1 -1 -1 2 2 ] ] [ (rmqr) (R15x43) //qrcode.vR15x43 15 43 22 99 409 [ 99 18 99 36 ] [ -1 -1 1 0 -1 -1 1 1 ] ] [ (rmqr) (R15x59) //qrcode.vR15x59 15 59 20 40 596 [ 99 26 99 48 ] [ -1 -1 1 0 -1 -1 2 0 ] ] [ (rmqr) (R15x77) //qrcode.vR15x77 15 77 26 52 830 [ 99 36 99 72 ] [ -1 -1 1 1 -1 -1 2 1 ] ] [ (rmqr) (R15x99) //qrcode.vR15x99 15 99 24 50 1095 [ 99 48 99 88 ] [ -1 -1 2 0 -1 -1 4 0 ] ] [ (rmqr) (R15x139) //qrcode.vR15x139 15 139 28 56 1594 [ 99 72 99 130 ] [ -1 -1 2 1 -1 -1 1 4 ] ] [ (rmqr) (R17x43) //qrcode.vR17x43 17 43 22 99 489 [ 99 22 99 40 ] [ -1 -1 1 0 -1 -1 1 1 ] ] [ (rmqr) (R17x59) //qrcode.vR17x59 17 59 20 40 706 [ 99 32 99 60 ] [ -1 -1 2 0 -1 -1 2 0 ] ] [ (rmqr) (R17x77) //qrcode.vR17x77 17 77 26 52 976 [ 99 44 99 84 ] [ -1 -1 2 0 -1 -1 1 2 ] ] [ (rmqr) (R17x99) //qrcode.vR17x99 17 99 24 50 1283 [ 99 60 99 104 ] [ -1 -1 2 1 -1 -1 4 0 ] ] [ (rmqr) (R17x139) //qrcode.vR17x139 17 139 28 56 1860 [ 99 80 99 156 ] [ -1 -1 4 0 -1 -1 2 4 ] ] ] readonly def % % Finder patterns % /qrcode.fpat [ [ 1 1 1 1 1 1 1 0 ] [ 1 0 0 0 0 0 1 0 ] [ 1 0 1 1 1 0 1 0 ] dup % [ 1 0 1 1 1 0 1 0 ] dup % [ 1 0 1 1 1 0 1 0 ] 3 index % [ 1 0 0 0 0 0 1 0 ] 5 index % [ 1 1 1 1 1 1 1 0 ] [ 0 0 0 0 0 0 0 0 ] ] readonly def /qrcode.fsubpat [ [ 1 1 1 1 1 9 9 9 ] [ 1 0 0 0 1 9 9 9 ] [ 1 0 1 0 1 9 9 9 ] 1 index % [ 1 0 0 0 1 9 9 9 ] 3 index % [ 1 1 1 1 1 9 9 9 ] [ 9 9 9 9 9 9 9 9 ] dup % [ 9 9 9 9 9 9 9 9 ] dup % [ 9 9 9 9 9 9 9 9 ] ] readonly def /qrcode.fcorpat [ [ 1 1 1 9 9 9 9 9 ] [ 1 0 9 9 9 9 9 9 ] [ 1 9 9 9 9 9 9 9 ] [ 9 9 9 9 9 9 9 9 ] dup % [ 9 9 9 9 9 9 9 9 ] dup % [ 9 9 9 9 9 9 9 9 ] dup % [ 9 9 9 9 9 9 9 9 ] dup % [ 9 9 9 9 9 9 9 9 ] ] readonly def /qrcode.fnullpat [ [ 9 9 9 9 9 9 9 9 ] dup % [ 9 9 9 9 9 9 9 9 ] dup % [ 9 9 9 9 9 9 9 9 ] dup % [ 9 9 9 9 9 9 9 9 ] dup % [ 9 9 9 9 9 9 9 9 ] dup % [ 9 9 9 9 9 9 9 9 ] dup % [ 9 9 9 9 9 9 9 9 ] dup % [ 9 9 9 9 9 9 9 9 ] ] readonly def % % Finder pattern layout % /qrcode.fpatmap << % TL TR BL BR (full) [ //qrcode.fpat //qrcode.fpat //qrcode.fpat //qrcode.fnullpat ] (micro) [ //qrcode.fpat //qrcode.fnullpat //qrcode.fnullpat //qrcode.fnullpat ] (rmqr) [ //qrcode.fpat //qrcode.fcorpat //qrcode.fcorpat //qrcode.fsubpat ] >> readonly def % % Alignment patterns % /qrcode.algnpatfull [ [ 1 1 1 1 1 ] [ 1 0 0 0 1 ] [ 1 0 1 0 1 ] 1 index % [ 1 0 0 0 1 ] 3 index % [ 1 1 1 1 1 ] ] readonly def /qrcode.algnpatrmqr [ [ 1 1 1 9 9 ] [ 1 0 1 9 9 ] 1 index % [ 1 1 1 9 9 ] [ 9 9 9 9 9 ] dup % [ 9 9 9 9 9 ] ] readonly def % % Format information module map % /qrcode.formatfimmap << (full) [ [ { pop pop 0 8 } bind { pop 8 exch 1 sub } bind ] [ { pop pop 1 8 } bind { pop 8 exch 2 sub } bind ] [ { pop pop 2 8 } bind { pop 8 exch 3 sub } bind ] [ { pop pop 3 8 } bind { pop 8 exch 4 sub } bind ] [ { pop pop 4 8 } bind { pop 8 exch 5 sub } bind ] [ { pop pop 5 8 } bind { pop 8 exch 6 sub } bind ] [ { pop pop 7 8 } bind { pop 8 exch 7 sub } bind ] [ { pop pop 8 8 } bind { pop 8 sub 8 } bind ] [ { pop pop 8 7 } bind { pop 7 sub 8 } bind ] [ { pop pop 8 5 } bind { pop 6 sub 8 } bind ] [ { pop pop 8 4 } bind { pop 5 sub 8 } bind ] [ { pop pop 8 3 } bind { pop 4 sub 8 } bind ] [ { pop pop 8 2 } bind { pop 3 sub 8 } bind ] [ { pop pop 8 1 } bind { pop 2 sub 8 } bind ] [ { pop pop 8 0 } bind { pop 1 sub 8 } bind ] ] (micro) [ [ { pop pop 1 8 } bind ] [ { pop pop 2 8 } bind ] [ { pop pop 3 8 } bind ] [ { pop pop 4 8 } bind ] [ { pop pop 5 8 } bind ] [ { pop pop 6 8 } bind ] [ { pop pop 7 8 } bind ] [ { pop pop 8 8 } bind ] [ { pop pop 8 7 } bind ] [ { pop pop 8 6 } bind ] [ { pop pop 8 5 } bind ] [ { pop pop 8 4 } bind ] [ { pop pop 8 3 } bind ] [ { pop pop 8 2 } bind ] [ { pop pop 8 1 } bind ] ] (rmqr) [ [ { pop pop 11 3 } bind { 3 sub exch 6 sub } bind ] [ { pop pop 11 2 } bind { 4 sub exch 6 sub } bind ] [ { pop pop 11 1 } bind { 5 sub exch 6 sub } bind ] [ { pop pop 10 5 } bind { 6 sub exch 2 sub } bind ] [ { pop pop 10 4 } bind { 6 sub exch 3 sub } bind ] [ { pop pop 10 3 } bind { 6 sub exch 4 sub } bind ] [ { pop pop 10 2 } bind { 6 sub exch 5 sub } bind ] [ { pop pop 10 1 } bind { 6 sub exch 6 sub } bind ] [ { pop pop 9 5 } bind { 7 sub exch 2 sub } bind ] [ { pop pop 9 4 } bind { 7 sub exch 3 sub } bind ] [ { pop pop 9 3 } bind { 7 sub exch 4 sub } bind ] [ { pop pop 9 2 } bind { 7 sub exch 5 sub } bind ] [ { pop pop 9 1 } bind { 7 sub exch 6 sub } bind ] [ { pop pop 8 5 } bind { 8 sub exch 2 sub } bind ] [ { pop pop 8 4 } bind { 8 sub exch 3 sub } bind ] [ { pop pop 8 3 } bind { 8 sub exch 4 sub } bind ] [ { pop pop 8 2 } bind { 8 sub exch 5 sub } bind ] [ { pop pop 8 1 } bind { 8 sub exch 6 sub } bind ] ] >> readonly def % % ECC values for generating format information % /qrcode.ecidfull [ 1 0 3 2 ] readonly def /qrcode.ecidrmqr [ -1 0 -1 1 ] readonly def /qrcode.ecidmicrosym [ [0] [1 2] [3 4] [5 6 7] ] readonly def % % Version information module map (QR Code only) % /qrcode.vimmap [ [ { 9 sub 5 } bind { 5 exch 9 sub } bind ] [ { 10 sub 5 } bind { 5 exch 10 sub } bind ] [ { 11 sub 5 } bind { 5 exch 11 sub } bind ] [ { 9 sub 4 } bind { 4 exch 9 sub } bind ] [ { 10 sub 4 } bind { 4 exch 10 sub } bind ] [ { 11 sub 4 } bind { 4 exch 11 sub } bind ] [ { 9 sub 3 } bind { 3 exch 9 sub } bind ] [ { 10 sub 3 } bind { 3 exch 10 sub } bind ] [ { 11 sub 3 } bind { 3 exch 11 sub } bind ] [ { 9 sub 2 } bind { 2 exch 9 sub } bind ] [ { 10 sub 2 } bind { 2 exch 10 sub } bind ] [ { 11 sub 2 } bind { 2 exch 11 sub } bind ] [ { 9 sub 1 } bind { 1 exch 9 sub } bind ] [ { 10 sub 1 } bind { 1 exch 10 sub } bind ] [ { 11 sub 1 } bind { 1 exch 11 sub } bind ] [ { 9 sub 0 } bind { 0 exch 9 sub } bind ] [ { 10 sub 0 } bind { 0 exch 10 sub } bind ] [ { 11 sub 0 } bind { 0 exch 11 sub } bind ] ] readonly def % % Mode optimization arrays % % Number of before characters per vergrp, depending on current mode, for optimising modes % Generated by contrib/development/build-qr-mode-optim-arrs.php % /e 10000 def % Full Micro R7 R9 R11 R13 R15 R17 /qrcode.mode0forceKB [ 1 1 1 e e 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ] readonly def /qrcode.mode0forceA [ 1 1 1 e 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ] readonly def /qrcode.mode0forceN [ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ] readonly def /qrcode.mode0NbeforeB [ 4 4 5 e e 2 3 2 2 3 3 3 2 3 3 3 3 2 3 3 3 3 3 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ] readonly def /qrcode.modeBKbeforeB [ 9 12 13 e e 4 6 4 5 6 6 6 5 6 6 6 7 4 6 6 6 7 7 5 6 6 7 7 7 6 6 7 7 7 6 7 7 7 8 ] readonly def /qrcode.modeBKbeforeA [ 8 10 11 e e 4 5 4 5 5 6 6 5 5 6 6 6 4 5 6 6 6 6 5 6 6 6 6 7 6 6 6 6 7 6 6 6 7 7 ] readonly def /qrcode.modeBKbeforeN [ 8 9 11 e e 3 5 3 4 5 5 5 4 5 5 5 6 3 5 5 5 6 6 4 5 5 6 6 6 5 5 6 6 7 5 6 6 6 7 ] readonly def /qrcode.modeBKbeforeE [ 5 5 6 e e 2 3 2 3 3 3 3 3 3 3 3 4 2 3 3 3 4 4 3 3 3 4 4 4 3 3 4 4 4 3 4 4 4 4 ] readonly def /qrcode.modeBAbeforeK [ 11 12 14 e e 5 7 5 6 7 8 8 6 7 8 8 8 6 7 8 8 8 8 6 8 8 8 8 9 8 8 8 8 9 8 8 8 9 9 ] readonly def /qrcode.modeBAbeforeB [ 11 15 16 e e 6 7 6 7 7 8 8 7 7 8 8 8 6 7 8 8 8 9 7 8 8 8 9 9 8 8 9 9 9 8 8 9 9 10 ] readonly def /qrcode.modeBAbeforeN [ 12 13 15 e e 6 8 6 7 8 8 8 7 8 8 8 9 6 8 8 8 9 9 7 8 8 9 9 10 8 9 9 9 10 8 9 9 10 10 ] readonly def /qrcode.modeBAbeforeE [ 6 7 8 e e 3 4 3 4 4 4 4 4 4 4 4 5 4 4 4 4 5 5 4 4 4 5 5 5 4 5 5 5 5 4 5 5 5 5 ] readonly def /qrcode.modeBNbeforeK [ 6 7 8 e e 3 4 3 4 4 5 5 4 4 5 5 5 3 4 5 5 5 5 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 ] readonly def /qrcode.modeBNbeforeB [ 6 8 9 e e 3 4 3 4 4 5 5 4 4 5 5 5 3 4 5 5 5 5 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 6 ] readonly def /qrcode.modeBNbeforeA [ 6 7 8 e e 3 4 3 4 4 5 5 4 4 5 5 5 4 4 5 5 5 5 4 5 5 5 5 5 5 5 5 5 6 5 5 5 5 6 ] readonly def /qrcode.modeBNbeforeE [ 3 4 4 e e 2 3 2 2 3 3 3 2 3 3 3 3 2 3 3 3 3 3 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ] readonly def /qrcode.modeANbeforeA [ 13 15 17 e 5 7 9 7 8 9 9 9 8 9 9 9 11 7 9 9 9 11 11 8 9 9 10 11 11 9 10 11 11 11 9 11 11 11 11 ] readonly def /qrcode.modeANbeforeB [ 13 17 18 e e 7 9 7 8 9 9 9 8 9 9 9 10 7 9 9 9 10 11 8 9 9 9 11 11 9 9 11 11 11 9 10 11 11 11 ] readonly def /qrcode.modeANbeforeE [ 7 8 9 e 3 4 5 4 5 5 5 5 5 5 5 5 6 4 5 5 5 6 6 5 5 5 5 6 6 5 5 6 6 6 5 6 6 6 6 ] readonly def % % Mask functions % /qrcode.maskfuncs [ {add 2 mod} bind % 0: (i+j) % 2 {exch pop 2 mod} bind % 1: j % 2 {pop 3 mod} bind % 2: i % 3 {add 3 mod} bind % 3: (i+j) % 3 {2 idiv exch 3 idiv add 2 mod} bind % 4: (j/2 + i/3) % 2 {mul dup 2 mod exch 3 mod add} bind % 5: (i*j) % 2 + (i*j) % 3 {mul dup 2 mod exch 3 mod add 2 mod} bind % 6: ((i*j) % 2 + (i*j) % 3) % 2 {2 copy mul 3 mod 3 1 roll add 2 mod add 2 mod} bind % 7: ((i*j) % 3 + (i+j) % 2) % 2 ] readonly def % % Mask bit positions in funcpatlayers for each format % % Entries relate to the numbered mask functions above. % /qrcode.formatmaskbits << (full) [ 0 1 2 3 4 5 6 7 ] (micro) [ 1 4 6 7 ] (rmqr) [ 4 ] >> readonly def % % BCH remainder after division in GF(2) % /qrcode.bchrem { % gen shift data 1 index bitshift % gen shift val ; val = data << shift { % gen shift val dup 0 eq {exit} if dup 0 exch % ... vdeg tmp ; vdeg=0, tmp=val dup 65536 ge { -16 bitshift exch 16 add exch } if % Binary search for MSB position (vdeg) dup 256 ge { -8 bitshift exch 8 add exch } if dup 16 ge { -4 bitshift exch 4 add exch } if dup 4 ge { -2 bitshift exch 2 add exch } if 2 ge { 1 add } if % ... vdeg dup 3 index lt {pop exit} if % if vdeg < shift: done 2 index sub 3 index exch bitshift % ... gen<<(vdeg-shift) exch xor % gen shift val' ; val' = val^(gen<<(vdeg-shift)) } loop 3 1 roll pop pop % val' } bind def /qrcode.latevars dup 16 dict def load /init { (setup.latevars) //qrcode.before exec currentglobal true setglobal //qrcode.latevars begin % % Invert charmap to give character to value map % /charvals 44 dict def 0 1 44 {dup //qrcode.charmap exch get exch charvals 3 1 roll put} for /charvals charvals readonly def % % Calculate the Reed-Solomon log and anti-log tables % /rsalog [ 1 255 { dup 2 mul dup 256 ge {285 xor} if } repeat ] readonly def /rslog 256 array def 1 1 255 {dup rsalog exch get exch rslog 3 1 roll put} for /rslog rslog readonly def % % The mask functions have 6x12 periodicity, so we compute an 8-layer array % representing all mask function patterns at bit positions % /funcpatlayers 6 12 mul array def 0 1 11 { /j exch def 0 1 5 { /i exch def /bits 0 def 0 1 7 { /m exch def i j //qrcode.maskfuncs m get exec 0 eq { /bits bits 1 m bitshift or def } if } for funcpatlayers j 6 mul i add bits put } for } for /funcpatlayers funcpatlayers readonly def % % Generate format and version information tables via BCH encoding % /fmtvalsfull 32 array def /fmtvalsmicro 32 array def 0 1 31 { % BCH(15,5) with generator x^10+x^8+x^5+x^4+x^2+x+1 = 0x537 16#537 10 2 index //qrcode.bchrem exec 1 index 10 bitshift or dup 16#5412 xor fmtvalsfull 3 index 3 -1 roll put % Format info for Full QR 16#4445 xor fmtvalsmicro 3 1 roll put % Format info for Micro QR } for /fmtvalsfull fmtvalsfull readonly def /fmtvalsmicro fmtvalsmicro readonly def /fmtvalsrmqr1 64 array def /fmtvalsrmqr2 64 array def /vervals 34 array def 0 1 63 { % BCH(18,6) with generator x^12+x^11+x^10+x^9+x^8+x^5+x^2+1 = 0x1F25 16#1F25 12 2 index //qrcode.bchrem exec 1 index 12 bitshift or 2 copy 16#1FAB2 xor fmtvalsrmqr1 4 index 3 -1 roll put % Format info for rMQR pop dup 16#20A7B xor fmtvalsrmqr2 3 index 3 -1 roll put % Format info for rMQR exch dup 7 ge 1 index 40 le and { 7 sub exch vervals 3 1 roll put % Version info for QR V7-40 } { pop pop } ifelse } for /fmtvalsrmqr1 fmtvalsrmqr1 readonly def /fmtvalsrmqr2 fmtvalsrmqr2 readonly def /vervals vervals readonly def /init { //qrcode.latevars {def} forall } def end //qrcode.latevars /init get exec setglobal (setup.latevars) //qrcode.after exec } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//qrcode.latevars /init get exec} if } {pop} ifelse % % Function to calculate the product in the field % /qrcode.rsprod { dup 0 ne { 1 index 0 ne { rslog exch get exch rslog exch get add 255 mod rsalog exch get } { pop pop 0 } ifelse } { pop pop 0 } ifelse } bind def % % Generate Reed-Solomon coefficients for a given ecpb % /qrcode.gencoeffs { /coeffs [ 1 ecpb {0} repeat ] def 0 1 ecpb 1 sub { % i rsalog 1 index get % ai = rsalog[i] exch dup 1 add % ai i i+1 coeffs exch 2 copy 1 sub get put % ai i ; coeffs[i+1] = coeffs[i] -1 1 { % j coeffs exch 2 copy get % ... coeffs j coeffs[j] 3 index % ... ai //qrcode.rsprod exec % p = coeffs[j] * ai coeffs 2 index 1 sub get % ... coeffs[j-1] xor put % coeffs[j] = p ^ coeffs[j-1] } for coeffs 0 2 copy get % ... coeffs 0 coeffs[0] 3 index % ... ai //qrcode.rsprod exec put % coeffs[0] = coeffs[0] * ai pop % ai } for coeffs 0 coeffs length 1 sub getinterval } bind def % % FIFO cache for ECC polynomials % % 20 unique keys: per-block 2-30 from version/eclevel combinations % /qrcode.coeffscachemax 20 def % Override with global_ctx.qrcode.coeffscachemax /qrcode.coeffscachelimit 302 def % Override with global_ctx.qrcode.coeffscachelimit /uk.co.terryburton.bwipp.global_ctx dup where { exch get dup /qrcode.coeffscachemax 2 copy known {get /qrcode.coeffscachemax exch def} {pop pop} ifelse /qrcode.coeffscachelimit 2 copy known {get /qrcode.coeffscachelimit exch def} {pop pop} ifelse } {pop} ifelse /qrcode.coeffscache qrcode.coeffscachemax qrcode.coeffscachelimit //fifocache exec def /qrcode.coeffscachefetch { /ecpb exch def ecpb { //qrcode.gencoeffs exec } { length } //qrcode.coeffscache /fetch get exec } bind def /qrcode { 256 dict begin { (input.processoptions) //qrcode.before exec /dontdraw false def /strictspec false def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /format (unset) def % full or micro. rMQR symbols are specified using version /version (unset) def % 1-40 or M1-M4 or R7x43, etc /eclevel (unset) def % full: L, M, Q, H; micro: L, M, Q; rmqr: M, H /fixedeclevel false def /parse false def /parsefnc false def /mask -1 def /suppresskanjimode false def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def /modunit 2 def /uk.co.terryburton.bwipp.global_ctx dup where { exch get /default_modunit 2 copy known {get /modunit exch def} {pop pop} ifelse } {pop} ifelse % % Apply AST spec overrides and resolve physical specification % /qrcode ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec (input.processoptions) //qrcode.after exec //qrcode.latevars /init get exec % % Input validation % (input.validate) //qrcode.before exec barcode () eq { /bwipp.qrcodeEmptyData (The data must not be empty) //raiseerror exec } if barcode length 30000 gt { /bwipp.qrcodeInputTooLong (The input data is too long) //raiseerror exec } if % % If version is supplied and format is not given then set format to correspond % version (unset) ne { format (unset) eq { (full) version length 0 gt { version 0 1 getinterval (M) eq { pop (micro) } if version 0 1 getinterval (R) eq { pop (rmqr) } if } if /format exch def } if } { format (unset) eq { /format (full) def } if % Default to full } ifelse format (full) ne format (micro) ne format (rmqr) ne and and { /bwipp.qrcodeInvalidFormat (The format must be either full, micro or rmqr) //raiseerror exec } if format (rmqr) eq version (unset) eq and { /bwipp.qrcodeRMQRwithoutVersion (A version must be provided for RMQR) //raiseerror exec } if % % Default error correction level % eclevel (unset) eq {/eclevel format (micro) ne {(M)} {(L)} ifelse def} if eclevel (L) ne eclevel (M) ne eclevel (Q) ne eclevel (H) ne and and and { /bwipp.qrcodeInvalidEClevel (Error correction level must be either L, M, Q, or H) //raiseerror exec } if mask -1 ne format (rmqr) eq and { /bwipp.qrcodeRMQRmask (A mask cannot be supplied for RMQR) //raiseerror exec } if mask -1 ne { mask 1 lt mask format (full) eq {8} {4} ifelse gt or { /bwipp.qrcodeBadMask (An invalid mask was supplied) //raiseerror exec } if } if (input.validate) //qrcode.after exec % % Parse the input % (input.preprocess) //qrcode.before exec /fncvals << /parse parse /parsefnc parsefnc /eci true (FNC1) //qrcode.fn1 >> def barcode fncvals //parseinput exec /msg exch def /msglen msg length def % % If FNC1 in first position then escape % as %% % /fnc1first false def msglen 0 gt { msg 0 get //qrcode.fn1 eq { /fnc1first true def /msg [ msg 1 msglen 1 sub getinterval { dup 37 eq {dup} if } forall ] def /msglen msg length def } if } if % Absolute capacity is V40-L numeric. msglen 7089 gt { /bwipp.qrcodeInputTooLong (The input data is too long) //raiseerror exec } if (input.preprocess) //qrcode.after exec % % Encode the input % (input.encoding) //qrcode.before exec % % Encoding functions % /tobin { string dup length 1 sub 0 exch 1 exch {1 index exch 48 put} for dup 3 -1 roll 2 2 index length string cvrs dup length 2 index length exch sub exch putinterval } def /encA { /in exch def fnc1first { % FNC1 as % /in [ in { dup //qrcode.fn1 eq {pop 37} if } forall ] def } if in length 11 mul 2 idiv 1 add { string } stopped { pop /bwipp.qrcodeInputTooLarge (The input data exceeds the implementation limits) //raiseerror exec } if /out exch def /k 0 def /m 0 def { k in length eq {exit} if k in length 1 sub lt { charvals in k get get 45 mul charvals in k 1 add get get add 11 tobin /k k 2 add def } { % Final character charvals in k get get 6 tobin /k k 1 add def } ifelse dup out exch m exch putinterval length m add /m exch def } loop out 0 m getinterval } def /encN { /in exch def in length 10 mul 3 idiv 1 add { string } stopped { pop /bwipp.qrcodeInputTooLarge (The input data exceeds the implementation limits) //raiseerror exec } if /out exch def /k 0 def /m 0 def { k in length eq {exit} if k in length 2 sub lt { in k 3 getinterval 0 exch {exch 10 mul 48 sub add} forall 10 tobin /k k 3 add def } { k in length 2 sub eq { % Two final digits in k 2 getinterval 0 exch {exch 10 mul 48 sub add} forall 7 tobin /k k 2 add def } { % One final digit in k 1 getinterval 0 exch {exch 10 mul 48 sub add} forall 4 tobin /k k 1 add def } ifelse } ifelse dup out exch m exch putinterval length m add /m exch def } loop out 0 m getinterval } def /encB { /in exch def fnc1first { % FNC1 as GS /in [ in { dup //qrcode.fn1 eq {pop 29} if } forall ] def } if in length 8 mul { string } stopped { pop /bwipp.qrcodeInputTooLarge (The input data exceeds the implementation limits) //raiseerror exec } if /out exch def 0 1 in length 1 sub { /k exch def in k get cvi 8 tobin out k 8 mul 3 -1 roll putinterval } for out } def /encK { /in exch def in length 2 idiv 13 mul { string } stopped { pop /bwipp.qrcodeInputTooLarge (The input data exceeds the implementation limits) //raiseerror exec } if /out exch def /k 0 def /m 0 def { k in length eq {exit} if in k get 256 mul in k 1 add get add dup 16#E040 lt {16#8140} {16#C140} ifelse sub dup -8 bitshift 16#C0 mul exch 16#00FF and add 13 tobin dup out exch m exch putinterval length m add /m exch def /k k 2 add def } loop out } def /encE { 0 get neg 1000000 sub dup 000127 le { % ECI 000000 - 000127 8 tobin } { dup 016383 le { % ECI 000128 - 016383 2#1000000000000000 add 16 tobin } { % ECI 016384 - 999999 2#110000000000000000000000 add 24 tobin } ifelse } ifelse } def /addtobits { dup length j add bits length gt { pop /bwipp.qrcodeNoValidSymbol (Maximum length exceeded or invalid content) //raiseerror exec } if dup bits j 3 -1 roll putinterval length j add /j exch def } def /numNs [ msglen {0} repeat 0 ] def /numAs [ msglen {0} repeat 0 ] def /numAorNs [ msglen {0} repeat 0 ] def /numBs [ msglen {0} repeat 0 ] def /numKs [ msglen {0} repeat 0 ] def /nextNs [ msglen {0} repeat 9999 ] def /nextBs [ msglen {0} repeat 9999 ] def /nextAs [ msglen {0} repeat 9999 ] def /nextKs [ msglen {0} repeat 9999 ] def /isECI msglen array def msglen 1 sub -1 0 { /i exch def /barchar msg i get def //qrcode.Kexcl barchar known suppresskanjimode not and { i 1 add msglen lt { barchar 256 mul msg i 1 add get add } { 0 } ifelse dup % Double byte: dup dup 16#8140 ge exch 16#9FFC le and exch % 8140-9FFC or dup 16#E040 ge exch 16#EBBF le and or exch % E040-EBBF 16#FF and % Low byte: dup dup 16#40 ge exch 16#FC le and exch 16#7F ne % 40-FC except !7F and and { nextKs i 0 put numKs i numKs i 2 add get 1 add put } { nextKs i nextKs i 1 add get 1 add put } ifelse } { nextKs i nextKs i 1 add get 1 add put } ifelse //qrcode.Nexcl barchar known { nextNs i 0 put numNs i numNs i 1 add get 1 add put numAorNs i numAorNs i 1 add get 1 add put } { nextNs i nextNs i 1 add get 1 add put } ifelse //qrcode.Aexcl barchar known { nextAs i 0 put numAs i numAs i 1 add get 1 add put numAorNs i numAorNs i 1 add get 1 add put } { nextAs i nextAs i 1 add get 1 add put } ifelse isECI i barchar -1000000 le put } for 0 1 msglen 1 sub { % Scan forward to set any "2nd byte 1st byte" Kanji matches to zero /i exch def numKs i get 0 gt { numKs i 1 add 0 put nextKs i 1 add nextKs i 1 add get 1 add put } if } for msglen 1 sub -1 0 { % Finally scan backwards again to set numBs/nextBs from "not others" /i exch def numNs i get numAs i get numKs i get add add 0 eq isECI i get not and { nextBs i 0 put numBs i numBs i 1 add get 1 add put } { nextBs i nextBs i 1 add get 1 add put } ifelse } for /KbeforeB {numK exch ver get ge nextBs numK 2 mul i add get 0 eq and} def /KbeforeA {numK exch ver get ge nextAs numK 2 mul i add get 0 eq and} def /KbeforeN {numK exch ver get ge nextNs numK 2 mul i add get 0 eq and} def /KbeforeE {numK exch ver get ge numK 2 mul i add msglen eq and} def /AbeforeK {numA exch ver get ge nextKs numA i add get 0 eq and} def /AbeforeB {numA exch ver get ge nextBs numA i add get 0 eq and} def /AbeforeN {numA exch ver get ge nextNs numA i add get 0 eq and} def /AbeforeE {numA exch ver get ge numA i add msglen eq and} def /NbeforeK {numN exch ver get ge nextKs numN i add get 0 eq and} def /NbeforeB {numN exch ver get ge nextBs numN i add get 0 eq and} def /NbeforeA {numN exch ver get ge nextAs numN i add get 0 eq and} def /NbeforeE {numN exch ver get ge numN i add msglen eq and} def /AorNbeforeB {numAorN exch ver get ge nextBs numAorN i add get 0 eq and} def /AorNbeforeE {numAorN exch ver get ge numAorN i add msglen eq and} def /nextNslt { nextNs i get msglen ge { pop true } { numNs nextNs i get i add get exch ver get lt } ifelse } def % % Determine which groups we need to encode % % Elements of the encoded message have differing lengths based on the % resulting symbol size. The symbol sizes with different element lengths % are batched into vergrps. To pick the smallest symbol that holds our % content we encode the message according to each available vergrp, based % on the format of symbol. % version (unset) ne { % A specific version of symbol is given so encode in just the corresponding vergrp //qrcode.versetmap format get version 2 copy known not { pop pop format (full) eq { /bwipp.qrcodeInvalidFullVersion (Valid versions for QR Code symbols are 1 to 40) //raiseerror exec } { format (micro) eq { /bwipp.qrcodeInvalidMicroVersion (Valid versions for Micro QR Code symbols are M1 to M4) //raiseerror exec } { % rmqr /bwipp.qrcodeInvalidRMQRversion (Invalid version for an RMQR symbol) //raiseerror exec } ifelse } ifelse } if get [ exch ] /verset exch def } { % Just the format is specified so encode in each vergrp for the type of symbol format (full) eq { /verset //qrcode.versetfull def } if format (micro) eq { /verset //qrcode.versetmicro def } if % rMQR symbols are accessed with an explicit version } ifelse % % Encode unterminated bitstream for each compatible vergrp separately % /msgbits [ 39 {-1} repeat ] def verset { /ver exch def % % Derive optimal sequence using stack-based accumulation % /mode -1 def /seqok true def mark /i 0 def { i msglen ge {exit} if /numK numKs i get def /numB numBs i get def /numA numAs i get def /numN numNs i get def /numAorN numAorNs i get def /eci isECI i get def ver //qrcode.vM1 eq numA 1 ge and {/seqok false def exit} if ver //qrcode.vM1 eq numB 1 ge and {/seqok false def exit} if ver //qrcode.vM1 eq numK 1 ge and {/seqok false def exit} if ver //qrcode.vM1 eq eci and {/seqok false def exit} if ver //qrcode.vM2 eq numB 1 ge and {/seqok false def exit} if ver //qrcode.vM2 eq numK 1 ge and {/seqok false def exit} if ver //qrcode.vM2 eq eci and {/seqok false def exit} if ver //qrcode.vM3 eq eci and {/seqok false def exit} if ver //qrcode.vM4 eq eci and {/seqok false def exit} if { % common exit eci { //qrcode.E exit } if mode -1 eq { % Set initial mode (or mode after ECI) //qrcode.mode0forceKB KbeforeA {//qrcode.K exit} if //qrcode.mode0forceKB KbeforeN {//qrcode.K exit} if //qrcode.modeBKbeforeE KbeforeB {//qrcode.K exit} if % Reusing modeB KbeforeE array //qrcode.mode0forceKB KbeforeE {//qrcode.K exit} if numK 1 ge {//qrcode.B exit} if //qrcode.mode0NbeforeB NbeforeK {//qrcode.N exit} if //qrcode.mode0NbeforeB NbeforeB {//qrcode.N exit} if //qrcode.mode0forceKB NbeforeB {//qrcode.B exit} if //qrcode.modeANbeforeE NbeforeA {//qrcode.N exit} if % Reusing modeA NbeforeE array //qrcode.mode0forceN NbeforeE {//qrcode.N exit} if //qrcode.modeBAbeforeE AbeforeK {//qrcode.A exit} if % Reusing modeB AbeforeE array //qrcode.modeBAbeforeE AorNbeforeB {//qrcode.A exit} if % Reusing modeB AbeforeE array //qrcode.mode0forceA AorNbeforeE {//qrcode.A exit} if //qrcode.B exit } if mode //qrcode.B eq { //qrcode.modeBKbeforeB KbeforeB {//qrcode.K exit} if //qrcode.modeBKbeforeA KbeforeA {//qrcode.K exit} if //qrcode.modeBKbeforeN KbeforeN {//qrcode.K exit} if //qrcode.modeBKbeforeE KbeforeE {//qrcode.K exit} if //qrcode.modeBAbeforeK AbeforeK {//qrcode.A exit} if //qrcode.modeBAbeforeB AbeforeB {//qrcode.A exit} if //qrcode.modeBAbeforeN AbeforeN {//qrcode.A exit} if //qrcode.modeBAbeforeE AbeforeE {//qrcode.A exit} if //qrcode.modeBNbeforeK NbeforeK {//qrcode.N exit} if //qrcode.modeBNbeforeB NbeforeB {//qrcode.N exit} if //qrcode.modeBNbeforeA NbeforeA {//qrcode.N exit} if //qrcode.modeBNbeforeE NbeforeE {//qrcode.N exit} if //qrcode.modeBAbeforeE AorNbeforeE numAorN //qrcode.modeBAbeforeN ver get le and { % If A/N sequence at end and short //qrcode.modeBNbeforeA nextNslt {//qrcode.A exit} if % And next N sequence shorter than NbeforeA } if //qrcode.B exit } if mode //qrcode.A eq { numK 1 ge {//qrcode.K exit} if numB 1 ge {//qrcode.B exit} if //qrcode.modeANbeforeA NbeforeA {//qrcode.N exit} if //qrcode.modeANbeforeB NbeforeB {//qrcode.N exit} if //qrcode.modeANbeforeE NbeforeE {//qrcode.N exit} if numA 1 ge numN 1 ge or {//qrcode.A exit} if //qrcode.B exit } if mode //qrcode.N eq { numK 1 ge {//qrcode.K exit} if numB 1 ge {//qrcode.B exit} if numA 1 ge {//qrcode.A exit} if numN 1 ge {//qrcode.N exit} if //qrcode.B exit } if mode //qrcode.K eq { numB 1 ge {//qrcode.B exit} if numA 1 ge {//qrcode.A exit} if numN 1 ge {//qrcode.N exit} if numK 1 ge {//qrcode.K exit} if //qrcode.B exit } if } loop dup //qrcode.K eq fnc1first and {pop //qrcode.B} if % No kanji with fnc1first dup mode eq { % Same mode encode directly - extend data on stack pop /dat msg i mode //qrcode.K eq {2} {1} ifelse getinterval def [ exch aload pop dat aload pop ] % Extend top data array with dat } { % Change mode - push mode and data to stack /mode exch def mode //qrcode.K eq {//qrcode.K msg i numK 2 mul getinterval} if mode //qrcode.B eq {//qrcode.B msg i numB getinterval} if mode //qrcode.A eq {//qrcode.A msg i numA getinterval} if mode //qrcode.N eq {//qrcode.N msg i numN getinterval} if mode //qrcode.E eq {//qrcode.E msg i 1 getinterval /mode -1 def} if /dat 1 index def % Copy data to dat variable (sw and data stay on stack) } ifelse /i i dat length add def } loop % Build seq from stack (or set to -1 if invalid) seqok {counttomark array astore exch pop} {cleartomark -1} ifelse /seq exch def % % Encode the sequence % { % common exit seq -1 eq {exit} if % Sequence not available /bits 23648 string def /j 0 def fnc1first { ver //qrcode.vR7x43 lt { (0101) } { (101) } ifelse addtobits } if /abort false def 0 2 seq length 1 sub { /i exch def /mode seq i get def //qrcode.mids ver get mode get addtobits /chars seq i 1 add get def /charslen chars length mode //qrcode.K eq {2 idiv} if def mode //qrcode.E ne { /cclen //qrcode.cclens ver get mode get def charslen 2 cclen exp cvi ge { % Too many characters for cc indicator /abort true def exit } if charslen cclen tobin addtobits } if chars //qrcode.encfuncs mode get load exec addtobits } for abort {exit} if /bits bits 0 j getinterval def msgbits ver bits put exit } loop } forall options /debugbitseqs known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugbitseqs msgbits //raiseerror exec } if % % Lookup the most appropriate symbol specification % /eclval (LMQH) eclevel search pop length exch pop exch pop def 0 1 //qrcode.metrics length 1 sub { /i exch def /m //qrcode.metrics i get def /frmt m 0 get def % Format of the symbol /vers m 1 get def % Version of symbol /vergrp m 2 get def % Version group /verind i 44 sub def % Version indicator for rMQR format info /rows m 3 get def % Length of side /cols m 4 get def % Length of side /asp2 m 5 get def % Position of second alignment symbol /asp3 m 6 get def % Position of third alignment symbol /nmod m 7 get def % Number of modules /ncws nmod 8 idiv def % Total number of codewords /rbit nmod 8 mod def % Number of remainder bits /lc4b false def % Last data codeword is 4 bits long vers (M1) eq vers (M3) eq or { % Adjustments for M1 and M3 symbols /ncws ncws 1 add def /rbit 0 def /lc4b true def } if /ecws m 8 get eclval get def % Number of error correction codewords /dcws ncws ecws sub def % Number of data codewords /dmod dcws 8 mul lc4b {4} {0} ifelse sub def % Number of data modules /ecb1 m 9 get eclval 2 mul get def % First error correction blocks /ecb2 m 9 get eclval 2 mul 1 add get def % Second error correction blocks /okay true def format frmt ne {/okay false def} if % The format must match that supplied frmt (micro) eq fnc1first and {/okay false def} if % FNC1 mode is only available in full and rmqr version (unset) ne version vers ne and {/okay false def} if % The version must match that supplied ecb1 -1 eq ecb2 -1 eq or {/okay false def} if % Error correction level must be valid /verbits msgbits vergrp get def verbits -1 eq { % Bitstream must be available /okay false def } { verbits length dmod gt {/okay false def} if % and fit into data modules } ifelse /term (000000000) 0 //qrcode.termlens vergrp get getinterval def okay {exit} if } for okay not { /bwipp.qrcodeNoValidSymbol (Maximum length exceeded or invalid content) //raiseerror exec } if /format frmt def /version vers def /msgbits verbits def % % Opportunistically raise the error level if a better fit to the matrix is possible % fixedeclevel not { eclval 1 add 1 3 { /eclval_ exch def /ecws_ m 8 get eclval_ get def % Number of error correction codewords /dcws_ ncws ecws_ sub def % Number of data codewords /dmod_ dcws_ 8 mul lc4b {4} {0} ifelse sub def % Number of data modules /ecb1_ m 9 get eclval_ 2 mul get def % First error correction blocks /ecb2_ m 9 get eclval_ 2 mul 1 add get def % Second error correction blocks /okay true def ecb1_ -1 eq ecb2_ -1 eq or {/okay false def} if % Error correction level must be valid msgbits length dmod_ gt {/okay false def} if % and fit into data modules okay { /eclval eclval_ def /dcws dcws_ def /dmod dmod_ def /ecb1 ecb1_ def /ecb2 ecb2_ def } if } for } if /dcpb dcws ecb1 ecb2 add idiv def % Base data codewords per block /ecpb ncws ecb1 ecb2 add idiv dcpb sub def % Error correction codewords per block % % Complete the message bits by adding the terminator, truncated if necessary % /term term 0 dmod msgbits length sub term length 2 copy gt {exch} if pop getinterval def msgbits length term length add string dup 0 msgbits putinterval dup msgbits length term putinterval /msgbits exch def % % Expand the message bits by adding padding as necessary % /pad dmod string def 0 1 pad length 1 sub {pad exch 48 put} for pad 0 msgbits putinterval /padnum 0 def msgbits length 8 div ceiling 8 mul cvi 8 dmod lc4b {5} {1} ifelse sub { pad exch //qrcode.padstrs padnum get putinterval /padnum padnum 1 add 2 mod def } for % % Evaluate the padded message into codewords % /cws dcws array def 0 1 cws length 1 sub { /c exch def /bpcw 8 def lc4b c cws length 1 sub eq and {/bpcw 4 def} if /cwb pad c 8 mul bpcw getinterval def /cw 0 def 0 1 bpcw 1 sub { /i exch def /cw cw 2 bpcw i sub 1 sub exp cvi cwb i get 48 sub mul add def } for cws c cw put } for % % Short final data byte in M1 and M3 symbols has high-order value % lc4b {cws cws length 1 sub 2 copy get 4 bitshift put} if options /debugcws known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugcws cws //raiseerror exec } if (input.encoding) //qrcode.after exec % % Generate or fetch the coefficients % (ecc.coeffs) //qrcode.before exec /coeffs ecpb //qrcode.coeffscachefetch exec def (ecc.coeffs) //qrcode.after exec % % Reed-Solomon algorithm to derive the error correction codewords % (ecc.cws) //qrcode.before exec /rscodes { /rscws exch def /lfsr ecpb array def {rscws exch get} rscws length coeffs ecpb lfsr //qrcode.rsprod //rsecbinary exec lfsr } def % % Divide codewords into two groups of blocks and calculate the error correction codewords % /dcwsb ecb1 ecb2 add array def /ecwsb ecb1 ecb2 add array def 0 1 ecb1 1 sub { % First group of blocks has smaller number of data codewords /i exch def dcwsb i cws i dcpb mul dcpb getinterval put ecwsb i dcwsb i get rscodes put } for 0 1 ecb2 1 sub { % Second group of blocks has larger number of data codewords /i exch def dcwsb ecb1 i add cws ecb1 dcpb mul i dcpb 1 add mul add dcpb 1 add getinterval put ecwsb ecb1 i add dcwsb ecb1 i add get rscodes put } for % % Reassemble the codewords % /cws ncws array def /cw 0 def 0 1 dcpb { % Interleave the data codeword blocks /i exch def 0 1 ecb1 ecb2 add 1 sub { /j exch def i dcwsb j get length lt { % Ignore the end of short blocks cws cw dcwsb j get i get put /cw cw 1 add def } if } for } for 0 1 ecpb 1 sub { % Interleave the error codeword blocks /i exch def 0 1 ecb1 ecb2 add 1 sub { /j exch def cws cw ecwsb j get i get put /cw cw 1 add def } for } for % % Extend codewords by one if there are remainder bits % rbit 0 gt { /pad cws length 1 add array def pad 0 cws putinterval pad pad length 1 sub 0 put /cws pad def } if % % Fixups for the short final data byte in M1 and M3 symbols % lc4b { cws dcws 1 sub 2 copy get -4 bitshift put dcws 1 sub 1 ncws 2 sub { /i exch def cws i cws i get 15 and 4 bitshift put cws i cws i 1 add get -4 bitshift 15 and cws i get or put } for cws ncws 1 sub cws ncws 1 sub get 15 and 4 bitshift put } if options /debugecc known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugecc cws //raiseerror exec } if (ecc.cws) //qrcode.after exec % % Layout the fixtures and data in the bitmap % (matrix.layout) //qrcode.before exec /pixs [ rows cols mul {-1} repeat ] def /qmv {cols mul add} def % % Timing patterns % format (full) eq { 8 1 cols 9 sub { /i exch def pixs i 6 qmv i 1 add 2 mod put pixs 6 i qmv i 1 add 2 mod put } for } if format (micro) eq { 8 1 cols 1 sub { /i exch def pixs i 0 qmv i 1 add 2 mod put pixs 0 i qmv i 1 add 2 mod put } for } if format (rmqr) eq { 3 1 cols 4 sub { % Along top and bottom /i exch def pixs i 0 qmv i 1 add 2 mod put pixs i rows 1 sub qmv i 1 add 2 mod put } for 3 1 rows 4 sub { % Along left and right /i exch def pixs 0 i qmv i 1 add 2 mod put pixs cols 1 sub i qmv i 1 add 2 mod put } for asp2 1 sub asp3 asp2 sub cols 13 sub { % Down interior /i exch def 3 1 rows 4 sub { /j exch def pixs i j qmv j 1 add 2 mod put } for } for } if % % Place finder patterns % /fpats //qrcode.fpatmap format get def 0 1 7 { /y exch def 0 1 7 { /x exch def /fpb0 fpats 0 get y get x get def /fpb1 fpats 1 get y get x get def /fpb2 fpats 2 get y get x get def /fpb3 fpats 3 get y get x get def fpb0 9 ne y rows lt and {pixs x y qmv fpb0 put} if fpb1 9 ne {pixs cols x sub 1 sub y qmv fpb1 put} if fpb2 9 ne {pixs x rows y sub 1 sub qmv fpb2 put} if fpb3 9 ne {pixs cols x sub 1 sub rows y sub 1 sub qmv fpb3 put} if } for } for /putalgnpat { /py exch def /px exch def 0 1 4 { /pb exch def 0 1 4 { /pa exch def /algnb algnpat pb get pa get def algnb 9 ne { pixs px pa add py pb add qmv algnb put } if } for } for } def % % Place alignment patterns % format (full) eq { /algnpat //qrcode.algnpatfull def asp2 2 sub asp3 asp2 sub cols 13 sub { /i exch def i 4 putalgnpat 4 i putalgnpat } for asp2 2 sub asp3 asp2 sub cols 9 sub { /x exch def asp2 2 sub asp3 asp2 sub rows 9 sub { /y exch def x y putalgnpat } for } for } if format (rmqr) eq { /algnpat //qrcode.algnpatrmqr def asp2 2 sub asp3 asp2 sub cols 13 sub { /i exch def i 0 putalgnpat i rows 3 sub putalgnpat } for } if % % Derive the format information module map % /formatmap [ //qrcode.formatfimmap format get { [ exch { rows exch cols exch exec 2 array astore } forall ] } forall ] def % % Reserve the format information modules % formatmap { { aload pop qmv pixs exch 1 put } forall } forall % % Derive the version information module map % format (full) eq cols 45 ge and { /versionmap [ //qrcode.vimmap { [ exch { cols exch exec 2 array astore } forall ] } forall ] def } { /versionmap [] def } ifelse % % Reserve the version information modules % versionmap { { aload pop qmv pixs exch 0 put } forall } forall % % Reserve the solitary dark module in full symbols % format (full) eq { pixs 8 rows 8 sub qmv 0 put } if % % Lookup the mask bits corresponding to the mask functions applicable to % this format % mask -1 eq { /maskbits //qrcode.formatmaskbits format get def } { % Just the indicated function when given a user-specified mask /maskbits [ //qrcode.formatmaskbits format get mask 1 sub get ] def /bestmaskval mask 1 sub def } ifelse /nmasks maskbits length def % % Build masklayers from the extruded funcpatlayers, with function cell % values included (as 0 or 255) % /masklayers rows cols mul array def 0 1 rows 1 sub { /j exch def 0 1 cols 1 sub { /i exch def /pos i j qmv def masklayers pos pixs pos get dup -1 eq { pop funcpatlayers j 6 mul 72 mod i 6 mod add get } { 255 mul } ifelse put } for } for % % Walk the symbol placing the bitstream by merging it into masklayers % /posx cols format (rmqr) ne {1} {2} ifelse sub def /posy rows 1 sub def /dir -1 def % -1 is upwards, 1 is downwards /col 1 def % 0 is left bit, 1 is right bit /num 0 def { % loop posx 0 lt {exit} if /pos posx posy qmv def pixs pos get -1 eq { /bit cws num 8 idiv get 7 num 8 mod sub neg bitshift 1 and def masklayers pos masklayers pos get bit 255 mul xor put /num num 1 add def } if col 1 eq { /col 0 def /posx posx 1 sub def } { /col 1 def /posx posx 1 add def /posy posy dir add def posy 0 lt posy rows ge or { % Turn around at top and bottom /dir dir -1 mul def /posy posy dir add def /posx posx 2 sub def % Hop over the timing pattern in full size symbols format (full) eq posx 6 eq and {/posx posx 1 sub def} if } if } ifelse } loop (matrix.layout) //qrcode.after exec % % Symbol masking and evaluation to select prime candidate % (matrix.masking) //qrcode.before exec % % Evaluate runlength encoded rows or columns in full symbols % /evalfulln1n3 { /scrle exch def % Detect runs of 5 or more like modules /scr1 0 scrle { dup 5 ge {add 2 sub dup} if pop } forall def % Detect 1:1:3:1:1 ratio next to 4 modules of whitespace /scr3 0 def 3 2 scrle length 3 sub { % Scan odd (dark) runs within bounds /j exch def scrle j get 3 mod 0 eq { % Multiple of 3 black modules /fact scrle j get 3 idiv def scrle j 2 sub 5 getinterval {fact eq} forall and exch pop and and { j 3 eq j 4 add scrle length ge or { % At either extent of run /scr3 scr3 40 add def } { % Bounded by dark modules scrle j 3 sub get 4 ge scrle j 3 add get 4 ge or { /scr3 scr3 40 add def } if } ifelse } if } if } for scr1 scr3 } def % % Evaluation algorithm for full symbols % % Reads bestscore from enclosing scope for early termination % /evalfull { /sym exch def /n1 0 def /n2 0 def /n3 0 def /rle cols 1 add array def /lastpairs cols array def /thispairs cols array def /colsadd1 cols 1 add def /earlyexit false def 0 1 cols 1 sub { /i exch def % Runlength encode (light, dark, light, ...) and evaluate each column mark 0 0 i cols dup dup mul 1 sub { sym exch get exch 1 index eq {exch 1 add exch} {1 exch} ifelse } for pop rle 0 counttomark 2 sub getinterval astore evalfulln1n3 n3 add /n3 exch def n1 add /n1 exch def pop % Runlength encode (light, dark, light, ...) and evaluate each row /symrow sym i cols mul cols getinterval def mark 0 0 symrow { exch 1 index eq {exch 1 add exch} {1 exch} ifelse } forall pop rle 0 counttomark 2 sub getinterval astore evalfulln1n3 n3 add /n3 exch def n1 add /n1 exch def pop % Count and score same coloured blocks /lastpairs thispairs /thispairs lastpairs def def symrow 0 get 1 eq {0} {1} ifelse symrow {exch 1 index add exch} forall pop thispairs astore pop i 0 gt { mark lastpairs aload pop thispairs aload pop n2 cols { exch colsadd1 index add 3 and 0 eq {3 add} if } repeat /n2 exch def cleartomark } if % Early termination check n1 n2 add n3 add bestscore ge { /earlyexit true def exit } if } for earlyexit not { % Score dark/light imbalance /dark 0 sym {add} forall def /n4 dark 100 mul cols dup mul div 50 sub abs 5 div cvi 10 mul def n1 n2 add n3 add n4 add } { 999999999 } ifelse } def % % Evaluation algorithm for micro symbols % /evalmicro { /sym exch def /dkrhs 0 def /dkbot 0 def 1 1 cols 1 sub { /i exch def /dkrhs dkrhs sym cols 1 sub i qmv get add def /dkbot dkbot sym i cols 1 sub qmv get add def } for dkrhs dkbot le { dkrhs 16 mul dkbot add neg } { dkbot 16 mul dkrhs add neg } ifelse } def % % Extract each masked symbol from the required set and evaluate them to % find the most suitable % /bestscore 999999999 def 0 1 nmasks 1 sub { /m exch def /maskbit maskbits m get def /masksym rows cols mul array def 0 1 rows cols mul 1 sub { /i exch def masksym i masklayers i get maskbit neg bitshift 1 and put } for nmasks 1 ne { % Not rMQR nor user-specified mask /score masksym format (full) eq {evalfull} {evalmicro} ifelse def score bestscore lt { /bestsym masksym def /bestmaskval m def /bestscore score def } if } { /bestsym masksym def % Note: bestmaskval never set for rMQR, but is not required } ifelse } for /pixs bestsym def (matrix.masking) //qrcode.after exec % % Finalise the bitmap % (matrix.finalise) //qrcode.before exec % % Set the solitary dark module in full symbols % format (full) eq { pixs 8 cols 8 sub qmv 1 put } if % % Add the format information % format (full) eq { /ecid //qrcode.ecidfull eclval get def /fmtval fmtvalsfull ecid 3 bitshift bestmaskval add get def 0 1 formatmap length 1 sub { /i exch def formatmap i get { pixs exch aload pop qmv fmtval 14 i sub neg bitshift 1 and put } forall } for } if format (micro) eq { /symid //qrcode.ecidmicrosym cols 11 sub 2 idiv get eclval get def /fmtval fmtvalsmicro symid 2 bitshift bestmaskval add get def 0 1 formatmap length 1 sub { /i exch def pixs formatmap i get 0 get aload pop qmv fmtval 14 i sub neg bitshift 1 and put } for } if format (rmqr) eq { /fmtvalu //qrcode.ecidrmqr eclval get 5 bitshift verind add def /fmtval1 fmtvalsrmqr1 fmtvalu get def /fmtval2 fmtvalsrmqr2 fmtvalu get def 0 1 formatmap length 1 sub { /i exch def pixs formatmap i get 0 get aload pop qmv fmtval1 17 i sub neg bitshift 1 and put pixs formatmap i get 1 get aload pop qmv fmtval2 17 i sub neg bitshift 1 and put } for } if % % Add the version information % format (full) eq cols 45 ge and { /verval vervals cols 17 sub 4 idiv 7 sub get def 0 1 versionmap length 1 sub { /i exch def versionmap i get { pixs exch aload pop qmv verval 17 i sub neg bitshift 1 and put } forall } for } if (matrix.finalise) //qrcode.after exec % % Return the arguments % << /ren /renmatrix /pixs pixs /pixx cols /pixy rows /height rows modunit mul 72 div /width cols modunit mul 72 div /borderleft format (full) eq {4.0} {2.0} ifelse /borderright format (full) eq {4.0} {2.0} ifelse /bordertop format (full) eq {4.0} {2.0} ifelse /borderbottom format (full) eq {4.0} {2.0} ifelse /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /qrcode dup load /uk.co.terryburton.bwipp defineresource pop (setup.define) //qrcode.after exec end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER qrcode-- % --BEGIN ENCODER swissqrcode-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor fifocache rsecbinary render renmatrix qrcode-- % --DESC: Swiss QR Code % --EXAM: % --EXOP: % --RNDR: renmatrix % --FMLY: Payments %%BeginResource: uk.co.terryburton.bwipp swissqrcode 0.0 2026052800 83206 79727 %%BeginData: 139 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 8 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /qrcode dup /uk.co.terryburton.bwipp findresource put begin /swissqrcode { 8 dict begin { /dontdraw false def /parse false def null /apply //processoptions exec /options exch def /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Parse ordinals of the form ^NNN to ASCII % /fncvals << /parse parse /parseonly true /parsefnc false >> def barcode fncvals //parseinput exec /barcode exch def /barlen barcode length def options (parse) undef % % Validate the input length % barcode length 997 gt { /bwipp.swissqrcodeBadLength (Swiss QR Code input must not exceed 997 digits) //raiseerror exec } if % % Get the result of encoding with qrcode % /uk.co.terryburton.bwipp._dontdraw true def barcode options //qrcode exec /args exch def args (opt) options put args % % The 7mm-wide Swiss Cross is defined by the specification as being an % overlaid image, i.e. not made out of "modules", so very likely a % different pitch. It cannot therefore be represented by our standard image % dictionary and would be a nightmare to gridfit. The application assumes a % sufficient high-resolution print process that such issues do not matter. % % So for now we simply do as we're told and paint over the top of the % barcode image that has been scaled to 46mm, user be damned! % _render { gsave currentpoint translate 72 25.4 div dup scale % pt to mm % % Clipping path with 7mm hole for the Swiss Cross % gsave newpath 0 0 moveto 46 0 lineto 46 46 lineto 0 46 lineto closepath 19.5 19.5 moveto 19.5 26.5 lineto 26.5 26.5 lineto 26.5 19.5 lineto closepath clip % % Scale the QR Code to fit within 46mm % gsave 0 0 moveto 46 args (pixx) get div 2 div dup scale //renmatrix exec grestore grestore % Clipping % % Draw Swiss Cross % 19.5 dup translate 7 83 div dup scale newpath 6 6 moveto 6 77 lineto 77 77 lineto 77 6 lineto closepath 49 18 moveto 49 34 lineto 65 34 lineto 65 49 lineto 49 49 lineto 49 65 lineto 34 65 lineto 34 49 lineto 18 49 lineto 18 34 lineto 34 34 lineto 34 18 lineto closepath 0 0 0 setrgbcolor fill grestore } if } stopped {end stop} if end } [/barcode] {null def} forall bind def /swissqrcode dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER swissqrcode-- % --BEGIN ENCODER microqrcode-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor fifocache rsecbinary render renmatrix qrcode-- % --DESC: Micro QR Code % --EXAM: 1234 % --EXOP: % --RNDR: renmatrix % --FMLY: Two-dimensional symbols %%BeginResource: uk.co.terryburton.bwipp microqrcode 0.0 2026052800 78610 71731 %%BeginData: 47 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 4 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /qrcode dup /uk.co.terryburton.bwipp findresource put begin /microqrcode { 4 dict begin { /dontdraw false def null /apply //processoptions exec /options exch def /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Get the result of encoding with qrcode with format=micro % options (format) (micro) put /uk.co.terryburton.bwipp._dontdraw true def barcode options //qrcode exec /args exch def args (opt) options put args _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /microqrcode dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER microqrcode-- % --BEGIN ENCODER rectangularmicroqrcode-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor fifocache rsecbinary render renmatrix qrcode-- % --DESC: Rectangular Micro QR Code (rMQR) % --EXAM: 1234 % --EXOP: version=R17x139 % --RNDR: renmatrix % --FMLY: Two-dimensional symbols %%BeginResource: uk.co.terryburton.bwipp rectangularmicroqrcode 0.0 2026052800 78653 71763 %%BeginData: 47 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 4 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /qrcode dup /uk.co.terryburton.bwipp findresource put begin /rectangularmicroqrcode { 4 dict begin { /dontdraw false def null /apply //processoptions exec /options exch def /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Get the result of encoding with qrcode with format=micro % options (format) (rmqr) put /uk.co.terryburton.bwipp._dontdraw true def barcode options //qrcode exec /args exch def args (opt) options put args _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /rectangularmicroqrcode dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER rectangularmicroqrcode-- % --BEGIN ENCODER maxicode-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor fifocache rsecbinary renmaximatrix-- % --DESC: MaxiCode % --EXAM: [)>^03001^02996152382802^029840^029001^0291Z00004951^029UPSN^02906X610^029159^0291234567^0291/1^029^029Y^029634 ALPHA DR^029PITTSBURGH^029PA^029^004 % --EXOP: mode=2 parse % --RNDR: renmaximatrix % --FMLY: Postal Symbols %%BeginResource: uk.co.terryburton.bwipp maxicode 0.0 2026052800 259972 258486 %%BeginData: 1145 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 32 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /fifocache dup /uk.co.terryburton.bwipp findresource put dup /rsecbinary dup /uk.co.terryburton.bwipp findresource put dup /setuphooks dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renmaximatrix dup /uk.co.terryburton.bwipp findresource put begin /maxicode [/before /after] //setuphooks exec (setup.define) //maxicode.before exec % % Special function characters % /maxicode.eci -1 def /maxicode.pad -2 def /maxicode.ns -3 def /maxicode.la -4 def /maxicode.lb -5 def /maxicode.sa -6 def /maxicode.sb -7 def /maxicode.sc -8 def /maxicode.sd -9 def /maxicode.se -10 def /maxicode.sa2 -11 def /maxicode.sa3 -12 def /maxicode.lkc -13 def /maxicode.lkd -14 def /maxicode.lke -15 def /maxicode.pd2 -16 def /maxicode.pd3 -17 def /eci //maxicode.eci def /pad //maxicode.pad def /ns //maxicode.ns def /la //maxicode.la def /lb //maxicode.lb def /sa //maxicode.sa def /sb //maxicode.sb def /sc //maxicode.sc def /sd //maxicode.sd def /se //maxicode.se def /sa2 //maxicode.sa2 def /sa3 //maxicode.sa3 def /lkc //maxicode.lkc def /lkd //maxicode.lkd def /lke //maxicode.lke def /pd2 //maxicode.pd2 def /pd3 //maxicode.pd3 def % % Character maps for each state % /maxicode.charmaps [ % A B C D E [ 13 (`) 192 224 0 ] % 0 [ (A) (a) 193 225 1 ] % 1 [ (B) (b) 194 226 2 ] % 2 [ (C) (c) 195 227 3 ] % 3 [ (D) (d) 196 228 4 ] % 4 [ (E) (e) 197 229 5 ] % 5 [ (F) (f) 198 230 6 ] % 6 [ (G) (g) 199 231 7 ] % 7 [ (H) (h) 200 232 8 ] % 8 [ (I) (i) 201 233 9 ] % 9 [ (J) (j) 202 234 10 ] % 10 [ (K) (k) 203 235 11 ] % 11 [ (L) (l) 204 236 12 ] % 12 [ (M) (m) 205 237 13 ] % 13 [ (N) (n) 206 238 14 ] % 14 [ (O) (o) 207 239 15 ] % 15 [ (P) (p) 208 240 16 ] % 16 [ (Q) (q) 209 241 17 ] % 17 [ (R) (r) 210 242 18 ] % 18 [ (S) (s) 211 243 19 ] % 19 [ (T) (t) 212 244 20 ] % 20 [ (U) (u) 213 245 21 ] % 21 [ (V) (v) 214 246 22 ] % 22 [ (W) (w) 215 247 23 ] % 23 [ (X) (x) 216 248 24 ] % 24 [ (Y) (y) 217 249 25 ] % 25 [ (Z) (z) 218 250 26 ] % 26 [ eci eci eci eci eci ] % 27 [ 28 28 28 28 pad ] % 28 [ 29 29 29 29 pd2 ] % 29 [ 30 30 30 30 27 ] % 30 [ ns ns ns ns ns ] % 31 [ ( ) ({) 219 251 28 ] % 32 [ pad pad 220 252 29 ] % 33 [ (") (}) 221 253 30 ] % 34 [ (#) (~) 222 254 31 ] % 35 [ ($) 127 223 255 159 ] % 36 [ (%) (;) 170 161 160 ] % 37 [ (&) (<) 172 168 162 ] % 38 [ (') (=) 177 171 163 ] % 39 [ 40 (>) 178 175 164 ] % 40 [ 41 (?) 179 176 165 ] % 41 [ (*) ([) 181 180 166 ] % 42 [ (+) 92 185 183 167 ] % 43 [ (,) (]) 186 184 169 ] % 44 [ (-) (^) 188 187 173 ] % 45 [ (.) (_) 189 191 174 ] % 46 [ (/) ( ) 190 138 182 ] % 47 [ (0) (,) 128 139 149 ] % 48 [ (1) (.) 129 140 150 ] % 49 [ (2) (/) 130 141 151 ] % 50 [ (3) (:) 131 142 152 ] % 51 [ (4) (@) 132 143 153 ] % 52 [ (5) (!) 133 144 154 ] % 53 [ (6) (|) 134 145 155 ] % 54 [ (7) pd2 135 146 156 ] % 55 [ (8) sa2 136 147 157 ] % 56 [ (9) sa3 137 148 158 ] % 57 [ (:) pd3 la la la ] % 58 [ sb sa ( ) ( ) ( ) ] % 59 [ sc sc lkc sc sc ] % 60 [ sd sd sd lkd sd ] % 61 [ se se se se lke ] % 62 [ lb la lb lb lb ] % 63 ] readonly def % % Maps modules to pixels in the grid % /maxicode.modmap [ 469 529 286 316 347 346 673 672 703 702 647 676 283 282 313 312 370 610 618 379 378 409 408 439 705 704 559 589 588 619 458 518 640 701 675 674 285 284 315 314 310 340 531 289 288 319 349 348 456 486 517 516 471 470 369 368 399 398 429 428 549 548 579 578 609 608 649 648 679 678 709 708 639 638 669 668 699 698 279 278 309 308 339 338 381 380 411 410 441 440 561 560 591 590 621 620 547 546 577 576 607 606 367 366 397 396 427 426 291 290 321 320 351 350 651 650 681 680 711 710 1 0 31 30 61 60 3 2 33 32 63 62 5 4 35 34 65 64 7 6 37 36 67 66 9 8 39 38 69 68 11 10 41 40 71 70 13 12 43 42 73 72 15 14 45 44 75 74 17 16 47 46 77 76 19 18 49 48 79 78 21 20 51 50 81 80 23 22 53 52 83 82 25 24 55 54 85 84 27 26 57 56 87 86 117 116 147 146 177 176 115 114 145 144 175 174 113 112 143 142 173 172 111 110 141 140 171 170 109 108 139 138 169 168 107 106 137 136 167 166 105 104 135 134 165 164 103 102 133 132 163 162 101 100 131 130 161 160 99 98 129 128 159 158 97 96 127 126 157 156 95 94 125 124 155 154 93 92 123 122 153 152 91 90 121 120 151 150 181 180 211 210 241 240 183 182 213 212 243 242 185 184 215 214 245 244 187 186 217 216 247 246 189 188 219 218 249 248 191 190 221 220 251 250 193 192 223 222 253 252 195 194 225 224 255 254 197 196 227 226 257 256 199 198 229 228 259 258 201 200 231 230 261 260 203 202 233 232 263 262 205 204 235 234 265 264 207 206 237 236 267 266 297 296 327 326 357 356 295 294 325 324 355 354 293 292 323 322 353 352 277 276 307 306 337 336 275 274 305 304 335 334 273 272 303 302 333 332 271 270 301 300 331 330 361 360 391 390 421 420 363 362 393 392 423 422 365 364 395 394 425 424 383 382 413 412 443 442 385 384 415 414 445 444 387 386 417 416 447 446 477 476 507 506 537 536 475 474 505 504 535 534 473 472 503 502 533 532 455 454 485 484 515 514 453 452 483 482 513 512 451 450 481 480 511 510 541 540 571 570 601 600 543 542 573 572 603 602 545 544 575 574 605 604 563 562 593 592 623 622 565 564 595 594 625 624 567 566 597 596 627 626 657 656 687 686 717 716 655 654 685 684 715 714 653 652 683 682 713 712 637 636 667 666 697 696 635 634 665 664 695 694 633 632 663 662 693 692 631 630 661 660 691 690 721 720 751 750 781 780 723 722 753 752 783 782 725 724 755 754 785 784 727 726 757 756 787 786 729 728 759 758 789 788 731 730 761 760 791 790 733 732 763 762 793 792 735 734 765 764 795 794 737 736 767 766 797 796 739 738 769 768 799 798 741 740 771 770 801 800 743 742 773 772 803 802 745 744 775 774 805 804 747 746 777 776 807 806 837 836 867 866 897 896 835 834 865 864 895 894 833 832 863 862 893 892 831 830 861 860 891 890 829 828 859 858 889 888 827 826 857 856 887 886 825 824 855 854 885 884 823 822 853 852 883 882 821 820 851 850 881 880 819 818 849 848 879 878 817 816 847 846 877 876 815 814 845 844 875 874 813 812 843 842 873 872 811 810 841 840 871 870 901 900 931 930 961 960 903 902 933 932 963 962 905 904 935 934 965 964 907 906 937 936 967 966 909 908 939 938 969 968 911 910 941 940 971 970 913 912 943 942 973 972 915 914 945 944 975 974 917 916 947 946 977 976 919 918 949 948 979 978 921 920 951 950 981 980 923 922 953 952 983 982 925 924 955 954 985 984 927 926 957 956 987 986 58 89 88 118 149 148 178 209 208 238 269 268 298 329 328 358 389 388 418 449 448 478 509 508 538 569 568 598 629 628 658 689 688 718 749 748 778 809 808 838 869 868 898 929 928 958 989 988 ] readonly def % Prior code set Later code set % A B C D E /maxicode.latchseq [ [ [ ] [63 ] [58 ] [58 ] [58 ] ] % A [ [63 ] [ ] [63 ] [63 ] [63 ] ] % B [ [60 60] [60 60] [ ] [60 60] [60 60] ] % C [ [61 61] [61 61] [61 61] [ ] [61 61] ] % D [ [62 62] [62 62] [62 62] [62 62] [ ] ] % E ] readonly def /maxicode.latchlen [ [ 0 1 1 1 1 ] % A [ 1 0 1 1 1 ] % B [ 2 2 0 2 2 ] % C [ 2 2 2 0 2 ] % D [ 2 2 2 2 0 ] % E ] readonly def /maxicode.pad_code [33 33 0 0 28] readonly def /maxicode.max_int 16#7FFFFFFF def % % Function to calculate the product in the field % /maxicode.rsprod { 2 copy 0 ne exch 0 ne and { rslog exch get exch rslog exch get add 63 mod rsalog exch get } { pop pop 0 } ifelse } bind def % % Generate Reed-Solomon coefficients for a given k % /maxicode.gencoeffs { /coeffs [ 1 k {0} repeat ] def 1 1 k { % i coeffs 1 index 2 copy 1 sub get put % coeffs[i] = coeffs[i-1] rsalog 1 index get % ai = rsalog[i] exch 1 sub -1 1 { % j coeffs exch 2 copy get % ... coeffs j coeffs[j] 3 index % ... ai //maxicode.rsprod exec % p = coeffs[j] * ai coeffs 2 index 1 sub get % ... coeffs[j-1] xor put % coeffs[j] = p ^ coeffs[j-1] } for coeffs 0 2 copy get 3 index //maxicode.rsprod exec put % coeffs[0] = coeffs[0] * ai pop % ai } for coeffs 0 k getinterval } bind def % % FIFO cache for ECC polynomials % % 3 unique keys: primary=10, secondary=20 or 28 coefficients % /maxicode.coeffscachemax 3 def % Override with global_ctx.maxicode.coeffscachemax /maxicode.coeffscachelimit 58 def % Override with global_ctx.maxicode.coeffscachelimit /uk.co.terryburton.bwipp.global_ctx dup where { exch get dup /maxicode.coeffscachemax 2 copy known {get /maxicode.coeffscachemax exch def} {pop pop} ifelse /maxicode.coeffscachelimit 2 copy known {get /maxicode.coeffscachelimit exch def} {pop pop} ifelse } {pop} ifelse /maxicode.coeffscache maxicode.coeffscachemax maxicode.coeffscachelimit //fifocache exec def /maxicode.coeffscachefetch { /k exch def k { //maxicode.gencoeffs exec } { length } //maxicode.coeffscache /fetch get exec } bind def /maxicode.latevars dup 16 dict def load /init { (setup.latevars) //maxicode.before exec currentglobal true setglobal //maxicode.latevars begin % % Invert charmaps to give character to value maps for each state % /charvals [ 64 dict 64 dict 64 dict 64 dict 64 dict ] def 0 1 //maxicode.charmaps length 1 sub { /i exch def /encs //maxicode.charmaps i get def 0 1 4 { /j exch def encs j get dup type /stringtype eq {0 get} if charvals j get exch i put } for } for /seta charvals 0 get readonly def /setb charvals 1 get readonly def /setc charvals 2 get readonly def /setd charvals 3 get readonly def /sete charvals 4 get readonly def /charvals charvals readonly def % % Calculate the Reed-Solomon log and anti-log tables for GF(64) % /rsalog [ 1 63 { dup 2 mul dup 64 ge {67 xor} if } repeat ] readonly def /rslog 64 array def 1 1 63 {dup rsalog exch get exch rslog 3 1 roll put} for /rslog rslog readonly def /init { //maxicode.latevars {def} forall } def end //maxicode.latevars /init get exec setglobal (setup.latevars) //maxicode.after exec } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//maxicode.latevars /init get exec} if } {pop} ifelse /maxicode { 128 dict begin { (input.processoptions) //maxicode.before exec /dontdraw false def /strictspec false def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /modunit 2 def /mode -1 def /sam -1 def /parse false def /parsefnc false def /legacyencoder false def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Apply AST spec overrides and resolve physical specification % /maxicode ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec (input.processoptions) //maxicode.after exec //maxicode.latevars /init get exec (input.validate) //maxicode.before exec barcode () eq { /bwipp.maxicodeEmptyData (The data must not be empty) //raiseerror exec } if % 93 max alphanumeric; 4x for ^NNN parse expansion barcode length 1000 gt { /bwipp.maxicodeInputTooLong (The input data is too long) //raiseerror exec } if mode -1 ne mode 2 lt mode 6 gt or and { /bwipp.maxicodeBadMode (Mode must be 2 to 6) //raiseerror exec } if sam -1 ne { true 1 { sam dup 12 lt exch 88 gt or { pop false exit } if sam 10 mod dup 2 lt exch 8 gt or { pop false exit } if sam 10 idiv sam 10 mod gt { pop false exit } if } repeat not { /bwipp.maxicodeBadSAM (SAM must be formatted as "NM" for Nth of M symbols, from 2 to 8 symbols) //raiseerror exec } if } if (input.validate) //maxicode.after exec /encoding (new) def legacyencoder {/encoding (legacy) def} if % % Parse the input % (input.preprocess) //maxicode.before exec /fncvals << /parse parse /parsefnc parsefnc /eci true % ECIs only >> def barcode fncvals //parseinput exec /msg exch def /msglen msg length def % % Special message handling for modes 2 and 3 % mode 2 eq mode 3 eq or { % % Convert to a string (up to first ECI) for extracting the structured data % /barcode msglen string def /barlen msglen def 0 1 msglen 1 sub { /i exch def msg i get 0 lt {/barlen i def exit} if barcode i msg i get put } for /difflen msglen barlen sub def % % Normalise messages that begin with a field identifier [)>{RS}01{GS}yy % /fid () def barlen 9 ge { barcode dup 0 7 getinterval <5b293e1e30311d> eq exch dup 7 get dup 48 ge exch 57 le and exch 8 get dup 48 ge exch 57 le and and and { /fid barcode 0 9 getinterval def /barcode barcode 9 barlen 9 sub getinterval def } if } if % % Read the postcode, country code and service code fields separated by GS % barcode <1d> search { /pcode exch def pop mode 2 eq { true 1 { pcode length dup 9 gt exch 0 eq or { pop false exit } if pcode { dup 48 lt exch 57 gt or { pop false exit } if } forall } repeat not { pop /bwipp.maxicodeBadMode2PostCode (A mode 2 postcode must not be empty or exceed 9 digits) //raiseerror exec } if } { % mode=3 true 1 { pcode length dup 6 gt exch 0 eq or { pop false exit } if pcode { dup 32 eq % SP exch dup dup 34 ge exch 58 le and % punct, 0-9, : exch dup 65 ge exch 90 le and % A-Z or or not { pop false exit } if } forall } repeat not { pop /bwipp.maxicodeBadMode3PostCode (A mode 3 postcode must not be empty or exceed 6 characters) //raiseerror exec } if } ifelse } { pop /bwipp.maxicodeExpectedPostCode (Expected postcode followed by group separator character) //raiseerror exec } ifelse <1d> search { /ccode exch def pop true 1 { ccode length 3 ne { pop false exit } if ccode { dup 48 lt exch 57 gt or { pop false exit } if } forall } repeat not { pop /bwipp.maxicodeBadCountryCode (Country code must be three digits) //raiseerror exec } if } { pop /bwipp.maxicodeExpectedCountryCode (Expected country code followed by group separator character) //raiseerror exec } ifelse <1d> search { /scode exch def pop true 1 { scode length 3 ne { pop false exit } if scode { dup 48 lt exch 57 gt or { pop false exit } if } forall } repeat not { pop /bwipp.maxicodeBadServiceClass (Service class must be three digits) //raiseerror exec } if } { pop /bwipp.maxicodeExpectedServiceClass (Expected service class followed by group separator character) //raiseerror exec } ifelse /barcode exch def % % Prepend the field identifier % barcode length fid length add string dup 0 fid putinterval dup fid length barcode putinterval /barcode exch def /barlen barcode length def /msg [ barcode {} forall msg msglen difflen sub difflen getinterval aload pop ] def /msglen msg length def } if % Absolute capacity is mode 4/6 numeric. msglen 138 gt { /bwipp.maxicodeInputTooLong (The input data is too long) //raiseerror exec } if (input.preprocess) //maxicode.after exec (input.encoding) //maxicode.before exec /maxlen mode 5 eq {77} {mode 3 le {84} {93} ifelse} ifelse def % % TODO: Support for this encoder will be dropped in the near future. If % you require it then let your reason be known. % encoding (legacy) eq { % % Compute numeric runlengths % /nseq [ msglen 1 add {0} repeat ] def msglen 1 sub -1 0 { /i exch def msg i get dup 48 ge exch 57 le and { nseq i nseq i 1 add get 1 add put } { nseq i 0 put } ifelse } for /nseq nseq 0 msglen getinterval def % % Encode the message from ASCII to codewords % /prefixinset { 0 { 2 copy exch length ge {exit} if 2 copy get 3 index exch known {1 add} {exit} ifelse } loop exch pop exch pop } def /enc { exch get out exch j exch put /j j 1 add def } def /out 144 array def /i 0 def /j 0 def /cset (seta) def { % loop % % Exit when no characters remain latching back to A if necessary % i msglen eq { cset (seta) ne cset (setb) ne and out length maxlen lt and { //maxicode.la cset load enc exec /cset (seta) def } if exit } if { % not a loop but common exit point % % Immediately encode an ECI % msg i get -1000000 le { //maxicode.eci cset load enc exec msg i get neg 1000000 sub dup 000031 le { % ECI 000000 - 000031 63 and 1 array astore } { dup 001023 le { % ECI 000032 - 001023 dup -6 bitshift 31 and 32 or exch 63 and 2 array astore } { dup 032767 le { % ECI 001024 - 032767 dup -12 bitshift 47 and 48 or exch dup -6 bitshift 63 and exch 63 and 3 array astore } { % ECI 032768 - 999999 dup -18 bitshift 55 and 56 or exch dup -12 bitshift 63 and exch dup -6 bitshift 63 and exch 63 and 4 array astore } ifelse } ifelse } ifelse dup out exch j exch putinterval length j add /j exch def /i i 1 add def exit } if % % If 9 numerals available then use NS % nseq i get 9 ge { msg i 9 getinterval 0 exch {48 sub add 10 mul} forall 10 idiv 4 { dup 63 and exch -6 bitshift } repeat cset load //maxicode.ns get 0 2 10 {index} for 6 array astore 7 1 roll 6 {pop} repeat out exch j exch putinterval /i i 9 add def /j j 6 add def exit } if % % Read next three characters % /char1 msg i get def /char2 i 1 add msglen lt {msg i 1 add get} {-99} ifelse def /char3 i 2 add msglen lt {msg i 2 add get} {-99} ifelse def % % If current mode is sufficient then directly encode % cset load char1 known { char1 cset load enc exec /i i 1 add def exit } if % % For switching from A to B % cset (seta) eq setb char1 known and { setb char2 known { //maxicode.lb seta enc exec /cset (setb) def } { //maxicode.sb seta enc exec char1 setb enc exec /i i 1 add def } ifelse exit } if % % For switching from B to A encode according to length of prefix % cset (setb) eq seta char1 known and { /p seta msg i 4 msglen i sub 2 copy gt {exch} if pop getinterval prefixinset exec def p 1 eq { //maxicode.sa setb enc exec char1 seta enc exec /i i 1 add def } if p 2 eq { //maxicode.sa2 setb enc exec char1 seta enc exec char2 seta enc exec /i i 2 add def } if p 3 eq { //maxicode.sa3 setb enc exec char1 seta enc exec char2 seta enc exec char3 seta enc exec /i i 3 add def } if p 4 ge { //maxicode.la setb enc exec /cset (seta) def } if exit } if % % If character is in A or B then directly latch % seta char1 known { //maxicode.la cset load enc exec /cset (seta) def exit } if setb char1 known { //maxicode.lb cset load enc exec /cset (setb) def exit } if % % Determine which one of sets C, D or E the character is in % setc char1 known {/setx (setc) def /sx //maxicode.sc def /lkx //maxicode.lkc def} if setd char1 known {/setx (setd) def /sx //maxicode.sd def /lkx //maxicode.lkd def} if sete char1 known {/setx (sete) def /sx //maxicode.se def /lkx //maxicode.lke def} if % % Encode according to the length of the prefix % /p setx load msg i 4 msglen i sub 2 copy gt {exch} if pop getinterval prefixinset exec def p 1 eq { sx cset load enc exec char1 setx load enc exec /i i 1 add def } if p 2 eq { sx cset load enc exec char1 setx load enc exec sx cset load enc exec char2 setx load enc exec /i i 2 add def } if p 3 eq { sx cset load enc exec char1 setx load enc exec sx cset load enc exec char2 setx load enc exec sx cset load enc exec char3 setx load enc exec /i i 3 add def } if p 4 ge { sx cset load enc exec lkx setx load enc exec /cset setx def } if exit } loop % out } loop /encmsg out 0 j getinterval def /padval cset load //maxicode.pad get def } if encoding (new) eq { % % Check states needed (apart from A, which for typical data is always used) % /haveb false def /havec false def /haved false def /havee false def /havei false def % ECI 0 1 msglen 1 sub { msg exch get /c exch def c -1000000 le { /havei true def } { c 28 lt c 30 gt or c 32 ne and { % FS, GS, RS and space in all code sets setb c known { /haveb true def } if setc c known { /havec true def } if setd c known { /haved true def } if sete c known { /havee true def } if } if } ifelse } for % % Code sets with a pad code are first pick % % A B E C D /priority [0 haveb {1} if havee {4} if havec {2} if haved {3} if] def /priority_rest priority 1 priority length 1 sub getinterval def % May be empty /latch_sequence //maxicode.latchseq def /latch_length //maxicode.latchlen def % % The encoder needs 10 history rows. % The circular history buffers are 16 long for convenience % /best_length [16 {[0 0 0 0 0]} repeat] def /best_origin [16 {[0 0 0 0 0]} repeat] def % % Backtracking information % /prior_code_set [msglen {[5 {0} repeat]} repeat] def /path_op [msglen {[5 {0} repeat]} repeat] def % % Length of Extended Channel Interpretation % /out_eci {c neg 1000000 sub dup 1024 lt { 32 lt {2} {3} ifelse} {32768 lt {4} {5} ifelse} ifelse} def % % Operations that don't fit directly into the list below % /enc_eci {c neg 1000000 sub dup 32 ge {dup 1024 lt { dup -6 bitshift 32 or exch 63 and} {dup 32768 lt { dup -12 bitshift 48 or exch dup -6 bitshift 63 and exch 63 and} { dup -18 bitshift 56 or exch dup -12 bitshift 63 and exch dup -6 bitshift 63 and exch 63 and} ifelse} ifelse} if} def /enc_ns {0 msg n 9 getinterval {48 sub exch 10 mul add} forall % Numeric dup -24 bitshift exch % Sequence dup -18 bitshift 63 and exch dup -12 bitshift 63 and exch dup -6 bitshift 63 and exch 63 and} def /enc_sha2 {seta c get seta msg n 1 add get get} def % Shift 2 A /enc_sha3 {seta c get seta msg n 1 add get get seta msg n 2 add get get} def % Shift 3 A % % Table of operations % /op_tab [ % predicate applicable sets encoding havei { << /can {c -1000000 le} /intake 1 /output {out_eci} /sets 2#11111 /enc {27 enc_eci } >> } if % ECI1 ABCDE << /can {digits 9 ge } /intake 9 /output {6 } /sets 2#11111 /enc {31 enc_ns } >> % NS ABCDE << /can {seta c known } /intake 1 /output {1 } /sets 2#00001 /enc { seta c get} >> % A A haveb { << /can {setb c known } /intake 1 /output {1 } /sets 2#00010 /enc { setb c get} >> } if % B B havec { << /can {setc c known } /intake 1 /output {1 } /sets 2#00100 /enc { setc c get} >> } if % C C haved { << /can {setd c known } /intake 1 /output {1 } /sets 2#01000 /enc { setd c get} >> } if % D D havee { << /can {sete c known } /intake 1 /output {1 } /sets 2#10000 /enc { sete c get} >> } if % E E << /can {num_a 1 ge } /intake 1 /output {2 } /sets 2#00010 /enc {59 seta c get} >> % SHA B << /can {num_a 2 ge } /intake 2 /output {3 } /sets 2#00010 /enc {56 enc_sha2 } >> % SHA2 B << /can {num_a 3 ge } /intake 3 /output {4 } /sets 2#00010 /enc {57 enc_sha3 } >> % SHA3 B haveb { << /can {setb c known } /intake 1 /output {2 } /sets 2#00001 /enc {59 setb c get} >> } if % SHB A havec { << /can {setc c known } /intake 1 /output {2 } /sets 2#11011 /enc {60 setc c get} >> } if % SHC ABCDE haved { << /can {setd c known } /intake 1 /output {2 } /sets 2#10111 /enc {61 setd c get} >> } if % SHD ABCDE havee { << /can {sete c known } /intake 1 /output {2 } /sets 2#01111 /enc {62 sete c get} >> } if % SHE ABCDE ] def % % Add idx to each entry % 0 op_tab {/idx 2 index put 1 add} forall pop % % Filter table of operations into lists of operations that apply in each code set % /code_set_operations [[1 2 4 8 16] {/n exch def [op_tab {dup /sets get n and 0 eq {pop} if} forall]} forall] def % % Get the shortest encoded length for the code set (state) and plot the path % /get_best_length { /latch_length_s latch_length state get def % Get latch length row targeting the code set //maxicode.max_int % Length returned if this is not a viable code set code_set_operations state get { % Loop over operations that apply to this code set /op exch def % op /can get exec { % Determine if the operation accepts the input /m n op /intake get sub 15 and def % Get index into circular history buffers /org best_origin m get state get def % Get the best prior code set best_length m get org get % Get the corresponding encoding length latch_length_s org get add % Add latch length op /output get exec add % Add output length to yield resulting length 2 copy gt { % Compare lengths exch % Keep the shorter length path_op_0 state op /idx get put % Store operation in path prior_code_set_0 state org put % Store prior set in path } if pop % Pop off the longer (or equal) length } if } forall } def % % Loop to get the best prior code set using a row of best % encoded lengths and a row of latch sequence lengths. % /get_best_origin { /latch_length_s latch_length state get def best_length_0 0 get latch_length_s 0 get add /orglen exch def 0 priority_rest { /p exch def best_length_0 p get latch_length_s p get add dup orglen lt {/orglen exch def pop p} {pop} ifelse } forall } def /digits 0 def % Number of contiguous digits seen /num_a 0 def % Number of contiguous characters seen that are encodable in code set A % % Make a table of best path options % 0 1 msglen 1 sub { /n exch def % Input index /c msg n get def % Input character % % Keep tabs on digits and characters in code set A % /digits c 48 ge c 58 lt and {digits 1 add} {0} ifelse def /num_a seta c known {num_a 1 add} {0} ifelse def % % Get rows of interest % /path_op_0 path_op n get def /prior_code_set_0 prior_code_set n get def /best_length_0 best_length n 15 and get def /best_origin_0 best_origin n 15 and get def % % Get best encoded lengths, then best prior code sets % priority {/state exch def best_length_0 state get_best_length put} forall priority {/state exch def best_origin_0 state get_best_origin put} forall } for /n msglen def % % Get the best code set to end with. Code sets with a pad code are first pick % 0 //maxicode.max_int priority {dup best_length_0 exch get dup 3 index lt {4 2 roll} if pop pop} forall /j exch def /state exch def % % End in a code set which has a pad code % /final_code_set //maxicode.pad_code state get 0 eq {0} {state} ifelse def % % Insert a latch to A if padding is necessary and the code set does not have a pad code. % //maxicode.pad_code state get 0 eq j maxlen lt and {j 1 add array dup j 58 put} {j array} ifelse /padval //maxicode.pad_code final_code_set get def /len j def % Follow the best path back to the start of the message { n 0 le {exit} if /pcs prior_code_set n 1 sub get state get def /op_idx path_op n 1 sub get state get def /op op_tab op_idx get def /n n op /intake get sub def /c msg n get def /enc op /enc get def /output [enc exec] def /latch latch_sequence state get pcs get def /len len latch length sub output length sub def dup len latch 3 copy putinterval length add output putinterval /state pcs def } loop % Name the result /encmsg exch def } if % % Prefix the encoded message with the structured append insert % /sami sam -1 ne { [ seta //maxicode.pad get sam 10 idiv 1 sub 8 mul sam 10 mod 1 sub add ] } { [] } ifelse def /encmsg [ sami aload pop encmsg aload pop ] def % % Derive the primary and secondary codewords for modes 2 and 3 % mode 2 eq mode 3 eq or { encmsg length 84 gt { /bwipp.maxicodeMode23TooLong (The secondary message is too long) //raiseerror exec } if % % Calculate the fixed-width binary values for the mode, postcode, country code and service % /mdb (0000) 4 string copy dup mode cvi 2 4 string cvrs dup length 4 exch sub exch putinterval def /ccb (0000000000) 10 string copy dup ccode cvi 2 10 string cvrs dup length 10 exch sub exch putinterval def /scb (0000000000) 10 string copy dup scode cvi 2 10 string cvrs dup length 10 exch sub exch putinterval def /pcb (000000000000000000000000000000000000) 36 string copy def mode 2 eq { % % For US postcodes lacking "+4", pad with zeroes (ISO/IEC 16023:2000 Annex B.1.4a) % ccode (840) eq pcode length 5 eq and { /pcode ( 0000) 9 string copy dup 0 pcode putinterval def } if % % For numeric postcode, first six bits represent length and remaining 30 bits the value % pcb pcode length 2 6 string cvrs dup length 6 exch sub exch putinterval pcb pcode cvi 2 30 string cvrs dup length 36 exch sub exch putinterval } { % mode=3 % % For alphanumeric postcode, trim or pad with spaces to 6 chars and encode to binary % /pccw [ ( ) 6 string copy dup 0 pcode length 6 gt {pcode 0 6 getinterval} {pcode} ifelse putinterval {seta exch get} forall ] def 0 1 5 { /i exch def pcb pccw i get 2 6 string cvrs dup length 6 i mul 6 add exch sub exch putinterval } for } ifelse % % Convolute the binary values into the structured carrier message % /scm 60 string def scm 2 mdb putinterval scm 38 pcb 0 4 getinterval putinterval scm 30 pcb 4 6 getinterval putinterval scm 24 pcb 10 6 getinterval putinterval scm 18 pcb 16 6 getinterval putinterval scm 12 pcb 22 6 getinterval putinterval scm 6 pcb 28 6 getinterval putinterval scm 0 pcb 34 2 getinterval putinterval scm 52 ccb 0 2 getinterval putinterval scm 42 ccb 2 6 getinterval putinterval scm 36 ccb 8 2 getinterval putinterval scm 54 scb 0 6 getinterval putinterval scm 48 scb 6 4 getinterval putinterval % % Evaluate the structured carrier message as codewords % /pri [ 0 0 0 0 0 0 0 0 0 0 ] def 0 1 59 { /i exch def /ps i 6 idiv def /ep 2 5 i 6 mod sub exp cvi scm i get 48 sub mul def pri ps pri ps get ep add put } for % % Pad the encoded message into the secondary component % /sec [ 84 {padval} repeat ] def sec 0 encmsg putinterval } if % % Derive the primary and secondary codewords for modes 4, 5 and 6 % mode 4 eq mode 5 eq or mode 6 eq or mode -1 eq or { % % If mode isn't specified then use EEC if message fits, otherwise SEC % mode -1 eq { /mode encmsg length 77 le {5} {4} ifelse def } if /cws [ mode 5 eq {78} {94} ifelse {padval} repeat ] def encmsg length cws length 1 sub gt { /bwipp.maxicodeMode56TooLong (The message is too long) //raiseerror exec } if cws 0 mode put cws 1 encmsg putinterval % % Fit the message into the primary and secondary components % /pri cws 0 10 getinterval def /sec cws 10 cws length 10 sub getinterval def } if (input.encoding) //maxicode.after exec % % Generate error correction codewords % (ecc.cws) //maxicode.before exec /rscodes { /rsnum exch def /cwb exch def % % Fetch the coefficients % /coeffs rsnum //maxicode.coeffscachefetch exec def % % Calculate the error correction codewords % /lfsr rsnum array def {cwb exch get} cwb length coeffs rsnum lfsr //maxicode.rsprod //rsecbinary exec lfsr } def % % Split secondary codeword into odd and even elements % /seco [ 0 2 sec length 1 sub { sec exch get } for ] def /sece [ 1 2 sec length 1 sub { sec exch get } for ] def % % Calculate the parity codewords for secondary codeword parts based on mode % /scodes sec length 84 eq {20} {28} ifelse def % SEC/EEC mode /secochk seco scodes rscodes exec def /secechk sece scodes rscodes exec def % % Recompose the secondary parity codewords % /secchk [ 0 1 scodes 1 sub { dup secochk exch get exch secechk exch get } for ] def % % Compute primary parity and concatenate the data into final codewords % /prichk pri 10 rscodes exec def /codewords [ pri aload pop prichk aload pop sec aload pop secchk aload pop ] def options /debugcws known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugcws codewords //raiseerror exec } if options /debugecc known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugecc [ prichk aload pop secchk aload pop ] //raiseerror exec } if (ecc.cws) //maxicode.after exec (matrix.layout) //maxicode.before exec % % Convert the codewords into module bits % /mods [ 864 {0} repeat ] def 0 1 143 { /i exch def /cw [ codewords i get 2 6 string cvrs {48 sub} forall ] def mods 6 i mul 6 cw length sub add cw putinterval } for % % Lookup pixels for enabled modules from modmap % /pixs 864 array def /j 0 def 0 1 mods length 1 sub { /i exch def mods i get 1 eq { pixs j //maxicode.modmap i get put /j j 1 add def } if } for /pixs [ pixs 0 j getinterval aload pop 28 29 280 281 311 457 488 500 530 670 700 677 707 ] def (matrix.layout) //maxicode.after exec << /ren /renmaximatrix /pixs pixs /borderleft 1.0 /borderright 1.0 /bordertop 1.0 /borderbottom 1.0 /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmaximatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /maxicode dup load /uk.co.terryburton.bwipp defineresource pop (setup.define) //maxicode.after exec end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER maxicode-- % --BEGIN ENCODER azteccode-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor fifocache rsecbinary render renmatrix-- % --DESC: Aztec Code % --EXAM: This is Aztec Code % --EXOP: format=full % --RNDR: renmatrix % --FMLY: Two-dimensional symbols %%BeginResource: uk.co.terryburton.bwipp azteccode 0.0 2026052800 289641 288038 %%BeginData: 1117 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 33 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /fifocache dup /uk.co.terryburton.bwipp findresource put dup /rsecbinary dup /uk.co.terryburton.bwipp findresource put dup /setuphooks dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put begin /azteccode [/before /after] //setuphooks exec (setup.define) //azteccode.before exec % % State key: "U"pper, "L"ower, "M"ixed, "P"unctuation, "D"igit, "B"inary % /azteccode.u 0 def /azteccode.l 1 def /azteccode.m 2 def /azteccode.p 3 def /azteccode.d 4 def /azteccode.b 5 def % % Special function characters % /azteccode.lu -2 def /azteccode.ll -3 def /azteccode.lm -4 def /azteccode.lp -5 def /azteccode.ld -6 def /azteccode.su -7 def /azteccode.sp -8 def /azteccode.sb -9 def /azteccode.fl -10 def /azteccode.p2 -11 def /azteccode.p3 -12 def /azteccode.p4 -13 def /azteccode.p5 -14 def /lu azteccode.lu def /ll azteccode.ll def /lm azteccode.lm def /lp azteccode.lp def /ld azteccode.ld def /su azteccode.su def /sp azteccode.sp def /sb azteccode.sb def /fl azteccode.fl def /p2 azteccode.p2 def /p3 azteccode.p3 def /p4 azteccode.p4 def /p5 azteccode.p5 def % % Character maps for each state % /azteccode.charmaps [ % U L M P D [ sp sp sp fl sp ] % 0 [ 32 32 32 13 32 ] % 1 [ (A) (a) 1 p2 (0) ] % 2 p2 = CR LF [ (B) (b) 2 p3 (1) ] % 3 p3 = ". " [ (C) (c) 3 p4 (2) ] % 4 p4 = ", " [ (D) (d) 4 p5 (3) ] % 5 p5 = ": " [ (E) (e) 5 (!) (4) ] % 6 [ (F) (f) 6 (") (5) ] % 7 [ (G) (g) 7 (#) (6) ] % 8 [ (H) (h) 8 ($) (7) ] % 9 [ (I) (i) 9 (%) (8) ] % 10 [ (J) (j) 10 (&) (9) ] % 11 [ (K) (k) 11 (') (,) ] % 12 [ (L) (l) 12 40 (.) ] % 13 [ (M) (m) 13 41 lu ] % 14 [ (N) (n) 27 (*) su ] % 15 [ (O) (o) 28 (+) -99 ] % 16 [ (P) (p) 29 (,) -99 ] % 17 [ (Q) (q) 30 (-) -99 ] % 18 [ (R) (r) 31 (.) -99 ] % 19 [ (S) (s) (@) (/) -99 ] % 20 [ (T) (t) 92 (:) -99 ] % 21 [ (U) (u) (^) (;) -99 ] % 22 [ (V) (v) (_) (<) -99 ] % 23 [ (W) (w) (`) (=) -99 ] % 24 [ (X) (x) (|) (>) -99 ] % 25 [ (Y) (y) (~) (?) -99 ] % 26 [ (Z) (z) 127 ([) -99 ] % 27 [ ll su ll (]) -99 ] % 28 [ lm lm lu ({) -99 ] % 29 [ ld ld lp (}) -99 ] % 30 [ sb sb sb lu -99 ] % 31 ] readonly def % % Punctuation compression % /azteccode.pcomp << <0d0a> p2 % CR LF (. ) p3 (, ) p4 (: ) p5 >> readonly def % % Bit length of latch between states % /azteccode.latlen [ % To: U L M P D B From [ 0 5 5 10 5 10 ] % U [ 9 0 5 10 5 10 ] % L [ 5 5 0 5 10 10 ] % M [ 5 10 10 0 10 15 ] % P [ 4 9 9 14 0 14 ] % D [ 0 0 0 0 0 0 ] % B ] readonly def % % Latch sequences between states % /azteccode.latseq [ % To: U L M P D B From [ [] [ll] [lm] [lm lp] [ld] [sb] ] % U [ [ld lu] [] [lm] [lm lp] [ld] [sb] ] % L [ [lu] [ll] [] [lp] [lu ld] [sb] ] % M [ [lu] [lu ll] [lu lm] [] [lu ld] [lu sb] ] % P [ [lu] [lu ll] [lu lm] [lu lm lp] [] [lu sb] ] % D [ [lu] [ll] [lm] [] [] [] ] % B ] readonly def /azteccode.e 1000000 def % "Empty" /e azteccode.e def % % Bit length of shift to state % /azteccode.shftlen [ % To: U L M P D From [ e e e 5 e ] % U [ 5 e e 5 e ] % L [ e e e 5 e ] % M [ e e e e e ] % P [ 4 e e 4 e ] % D ] readonly def /azteccode.metrics [ [ (rune) 0 0 0 6 ] % Special metric for rune symbols [ (compact) 1 1 17 6 ] [ (full) 1 1 21 6 ] [ (compact) 2 0 40 6 ] [ (full) 2 1 48 6 ] [ (compact) 3 0 51 8 ] [ (full) 3 1 60 8 ] [ (compact) 4 0 76 8 ] [ (full) 4 1 88 8 ] [ (full) 5 1 120 8 ] [ (full) 6 1 156 8 ] [ (full) 7 1 196 8 ] [ (full) 8 1 240 8 ] [ (full) 9 1 230 10 ] [ (full) 10 1 272 10 ] [ (full) 11 1 316 10 ] [ (full) 12 1 364 10 ] [ (full) 13 1 416 10 ] [ (full) 14 1 470 10 ] [ (full) 15 1 528 10 ] [ (full) 16 1 588 10 ] [ (full) 17 1 652 10 ] [ (full) 18 1 720 10 ] [ (full) 19 1 790 10 ] [ (full) 20 1 864 10 ] [ (full) 21 1 940 10 ] [ (full) 22 1 1020 10 ] [ (full) 23 0 920 12 ] [ (full) 24 0 992 12 ] [ (full) 25 0 1066 12 ] [ (full) 26 0 1144 12 ] [ (full) 27 0 1224 12 ] [ (full) 28 0 1306 12 ] [ (full) 29 0 1392 12 ] [ (full) 30 0 1480 12 ] [ (full) 31 0 1570 12 ] [ (full) 32 0 1664 12 ] ] readonly def /azteccode.rsparams [ [] [] [] [] [ 16 19 ] % 4-bit codewords for mode message [] [ 64 67 ] % 6-bit codewords [] [ 256 301 ] % 8-bit codewords [] [ 1024 1033 ] % 10-bit codewords [] [ 4096 4201 ] % 12-bit codewords ] readonly def /azteccode.modemapfull [ [-5 7] [-4 7] [-3 7] [-2 7] [-1 7] [ 1 7] [ 2 7] [ 3 7] [ 4 7] [ 5 7] [ 7 5] [ 7 4] [ 7 3] [ 7 2] [ 7 1] [ 7 -1] [ 7 -2] [ 7 -3] [ 7 -4] [ 7 -5] [ 5 -7] [ 4 -7] [ 3 -7] [ 2 -7] [ 1 -7] [-1 -7] [-2 -7] [-3 -7] [-4 -7] [-5 -7] [-7 -5] [-7 -4] [-7 -3] [-7 -2] [-7 -1] [-7 1] [-7 2] [-7 3] [-7 4] [-7 5] ] readonly def /azteccode.modemapcompact [ [-3 5] [-2 5] [-1 5] [ 0 5] [ 1 5] [ 2 5] [ 3 5] [ 5 3] [ 5 2] [ 5 1] [ 5 0] [ 5 -1] [ 5 -2] [ 5 -3] [ 3 -5] [ 2 -5] [ 1 -5] [ 0 -5] [-1 -5] [-2 -5] [-3 -5] [-5 -3] [-5 -2] [-5 -1] [-5 0] [-5 1] [-5 2] [-5 3] ] readonly def /azteccode.encfuncs [ /encu /encl /encm /encp /encd ] readonly def /azteccode.states [ //azteccode.u //azteccode.l //azteccode.m //azteccode.p //azteccode.d //azteccode.b ] readonly def /azteccode.charsizes [ 5 5 5 5 4 8 ] readonly def % % FIFO cache for ECC polynomials % % 551 unique keys (5 GFs, single-block up to 1581 coeffs); memory-bounded % /azteccode.coeffscachemax 551 def % Override with global_ctx.azteccode.coeffscachemax /azteccode.coeffscachelimit 6000 def % Override with global_ctx.azteccode.coeffscachelimit /uk.co.terryburton.bwipp.global_ctx dup where { exch get dup /azteccode.coeffscachemax 2 copy known {get /azteccode.coeffscachemax exch def} {pop pop} ifelse /azteccode.coeffscachelimit 2 copy known {get /azteccode.coeffscachelimit exch def} {pop pop} ifelse } {pop} ifelse /azteccode.gencoeffs { /coeffs [ 1 rsnc {0} repeat ] def 1 1 rsnc { % i coeffs 1 index 2 copy 1 sub get put % coeffs[i] = coeffs[i-1] rsalog 1 index get % ai = rsalog[i] exch 1 sub -1 1 { % for j in i-1 -> 1 coeffs exch 2 copy get % ... coeffs j coeffs[j] 3 index % ... ai rsprod % p = coeffs[j] * ai coeffs 2 index 1 sub get % ... coeffs[j-1] xor put % coeffs[j] = p ^ coeffs[j-1] } for coeffs 0 2 copy get 3 index rsprod put % coeffs[0] = coeffs[0] * ai pop % ai } for coeffs } bind def /azteccode.coeffscache azteccode.coeffscachemax azteccode.coeffscachelimit //fifocache exec def /azteccode.coeffscachefetch { 100000 mul add % key = rsbt * 100000 + rsnc { //azteccode.gencoeffs exec } { length } //azteccode.coeffscache /fetch get exec } bind def /azteccode.latevars dup 8 dict def load /init { (setup.latevars) //azteccode.before exec currentglobal true setglobal //azteccode.latevars begin % % Invert charmaps to give character to value maps for each state % /charvals [ 32 dict 32 dict 32 dict 32 dict 16 dict ] def 0 1 //azteccode.charmaps length 1 sub { /i exch def /encs //azteccode.charmaps i get def 0 1 4 { /j exch def encs j get dup type /stringtype eq {0 get} if % convert string to ASCII if required charvals j get exch i put } for } for /charvals charvals readonly def % % Calculate the log and anti-log tables for each GF % /rstables [ //azteccode.rsparams { dup length 0 ne { aload pop /rspm exch def /rsgf exch def /rsalog [ 1 rsgf 1 sub { dup 2 mul dup rsgf ge {rspm xor} if } repeat ] def /rslog rsgf array def 1 1 rsgf 1 sub {dup rsalog exch get exch rslog 3 1 roll put} for [ rslog rsalog ] } { pop [] } ifelse } forall ] readonly def /init { //azteccode.latevars {def} forall } def end //azteccode.latevars /init get exec setglobal (setup.latevars) //azteccode.after exec } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//azteccode.latevars /init get exec} if } {pop} ifelse /azteccode { 128 dict begin { (input.processoptions) //azteccode.before exec /dontdraw false def /format (full) def % full, compact or rune /readerinit false def /layers -1 def /eclevel 23 def /ecaddchars 3 def /raw false def /parse false def /parsefnc false def /strictspec false def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def /modunit 2 def /uk.co.terryburton.bwipp.global_ctx dup where { exch get /default_modunit 2 copy known {get /modunit exch def} {pop pop} ifelse } {pop} ifelse % % Apply AST spec overrides and resolve physical specification % /azteccode ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec (input.processoptions) //azteccode.after exec //azteccode.latevars /init get exec (input.validate) //azteccode.before exec barcode () eq { /bwipp.aztecEmptyData (The data must not be empty) //raiseerror exec } if barcode length 20000 gt { /bwipp.azteccodeInputTooLong (The input data is too long) //raiseerror exec } if eclevel 5 lt eclevel 95 gt or { /bwipp.aztecInvalidEClevel (The EC percentage must be from 5 to 95) //raiseerror exec } if ecaddchars 3 lt { /bwipp.aztecInvalidECaddChars (The number of additional EC codewords must be 3 or more) //raiseerror exec } if format (full) ne format (compact) ne format (rune) ne and and { /bwipp.aztecInvalidFormat (The format must be either full, compact or rune) //raiseerror exec } if format (full) eq { readerinit layers 1 lt layers 22 gt or and { /bwipp.aztecFullInitInvalidLayers (Full-range symbols for reader programming must specify from 1 to 22 layers) //raiseerror exec } if layers -1 ne layers 1 lt layers 32 gt or and { /bwipp.aztecFullInvalidLayers (Layers for full-range symbols must be from 1 to 32) //raiseerror exec } if } if format (compact) eq { readerinit { layers -1 ne layers 1 ne and { /bwipp.aztecCompactInitInvalidLayers (Compact symbols for reader programming must have 1 layer) //raiseerror exec } if /layers 1 def } if layers -1 ne layers 1 lt layers 4 gt or and { /bwipp.aztecCompactInvalidLayers (Layers for compact symbols must be from 1 to 4) //raiseerror exec } if } if format (rune) eq { layers -1 ne { /bwipp.aztecRuneInvalidLayers (It is not valid to specify layers for runes) //raiseerror exec } if readerinit { /bwipp.aztecRuneReaderInit (Reader initialisation is not compactible with Aztec Runes) //raiseerror exec } if barcode length 0 eq { /bwipp.aztecRuneNotNumeric (Aztec runes must be numeric) //raiseerror exec } if barcode { dup 48 lt exch 57 gt or { /bwipp.aztecRuneNotNumeric (Aztec runes must be numeric) //raiseerror exec } if } forall barcode length 3 gt { /bwipp.aztecRuneInvalid (Aztec runes must be 0 to 255) //raiseerror exec } if barcode cvi dup 0 lt exch 255 gt or { /bwipp.aztecRuneInvalid (Aztec runes must be 0 to 255) //raiseerror exec } if } if (input.validate) //azteccode.after exec % % Parse the input % (input.preprocess) //azteccode.before exec /fn1 -1 def /fncvals << /parse parse /parsefnc parsefnc /eci true (FNC1) fn1 >> def barcode fncvals //parseinput exec /msg exch def /msglen msg length def % Absolute capacity is 32-layer full at eclevel=5 ecaddchars=3, numeric. msglen 4729 gt { /bwipp.azteccodeInputTooLong (The input data is too long) //raiseerror exec } if (input.preprocess) //azteccode.after exec % % Convert from input into message bitstream % (input.encoding) //azteccode.before exec /msgbits () def format (rune) ne raw and {/msgbits barcode def} if format (rune) ne raw not and { /charsize { dup 0 ge { pop //azteccode.charsizes exch get } { % FNC or ECI in P exch pop dup fn1 eq { % FNC1: PS{Flg(0)} + 3 pop 8 } { % ECI: PS{Flg(n)} + 3 + 4n neg 1000000 sub dup 0 eq {pop 1} if ln 10 ln div cvi 1 add 4 mul 8 add } ifelse } ifelse } def /e //azteccode.e def % % Each char adds 1, latches add up to 3 % /maxseqlen msglen 4 mul def /seq0 [ 6 { maxseqlen { array } stopped { pop /bwipp.azteccodeInputTooLarge (The input data exceeds the implementation limits) //raiseerror exec } if } repeat ] def /seq1 [ 6 { maxseqlen { array } stopped { pop /bwipp.azteccodeInputTooLarge (The input data exceeds the implementation limits) //raiseerror exec } if } repeat ] def /len0 6 array def 0 1 5 { len0 exch 0 put } for /len1 6 array def /curseq seq0 def /curseqlen len0 def /nxtseq seq1 def /nxtseqlen len1 def % U L M P D B /curlen [ 0 e e e e e ] def /backto //azteccode.u def % U /lastchar () def % Derive the optimal sequences ending in each state msg { /char exch def % % Check for optimisations in the current sequences by latching from x to y % { % loop /imp false def //azteccode.states { /x exch def //azteccode.states { /y exch def x //azteccode.b ne y backto eq or { % Only B -> backto /cost curlen x get //azteccode.latlen x get y get add def cost curlen y get lt { curlen y cost put % Copy curseq[x] to curseq[y] and append latseq codes /srclen curseqlen x get def srclen 0 gt { curseq y get 0 curseq x get 0 srclen getinterval putinterval } if //azteccode.latseq x get y get { curseq y get srclen 3 -1 roll put /srclen srclen 1 add def } forall curseqlen y srclen put y //azteccode.b eq { % Set backto to previous state /backto x //azteccode.p eq x //azteccode.d eq or {//azteccode.u} {x} ifelse def } if /imp true def } if } if } forall } forall imp not {exit} if % Repeat unless no improvement } loop % % Determine optimal next sequences for each valid encoding % % U L M P D B /nxtlen [ e e e e e e ] def 0 1 5 { nxtseqlen exch 0 put } for //azteccode.states { /x exch def { % loop for common exit % % Skip states that cannot encode character % char 0 ge { x //azteccode.b ne {charvals x get char known not {exit} if} if } { x //azteccode.p ne {exit} if % Only P can encode FNC1 and ECI } ifelse % % Extend directly: copy curseq[x] + char to nxtseq[x] % /cost curlen x get x char charsize add def cost nxtlen x get lt { nxtlen x cost put /srclen curseqlen x get def srclen 0 gt { nxtseq x get 0 curseq x get 0 srclen getinterval putinterval } if nxtseq x get srclen char put nxtseqlen x srclen 1 add put } if % % Optimise for direct shifts from y to x % x //azteccode.b eq {exit} if % B is treated as a latch //azteccode.states { /y exch def y //azteccode.b eq {exit} if x y ne { /cost curlen y get //azteccode.shftlen y get x get add x char charsize add def cost nxtlen y get lt { nxtlen y cost put % Copy curseq[y] + shift + char to nxtseq[y] /srclen curseqlen y get def srclen 0 gt { nxtseq y get 0 curseq y get 0 srclen getinterval putinterval } if nxtseq y get srclen x //azteccode.u eq {//azteccode.su} {//azteccode.sp} ifelse put nxtseq y get srclen 1 add char put nxtseqlen y srclen 2 add put } if } if } forall exit } loop } forall % % Optimise using P compression % lastchar () ne char 0 ge and { /pchars 2 string dup 0 lastchar put dup 1 char put def //azteccode.pcomp pchars known { //azteccode.states { /i exch def i //azteccode.b eq {exit} if /inP true def % U and L can't encode CR, comma, dot or colon i //azteccode.m eq { % M can encode CR lastchar 13 eq { /inP false def } if } { i //azteccode.d eq { % D can encode comma and dot lastchar 44 eq lastchar 46 eq or { /inP false def } if } if } ifelse /curseqilen curseqlen i get def inP curlen i get nxtlen i get lt and { /lastld false def /lastsp false def /lastidx -1 def curseqilen 1 sub -1 0 { % Search backwards for lastchar /idx exch def /ch curseq i get idx get def lastidx -1 eq { ch lastchar eq { /lastidx idx def idx 0 gt { curseq i get idx 1 sub get //azteccode.sp eq { /lastsp true def } if % Preceded by P/S } if } if } { % Found lastchar, check latch ch //azteccode.sb eq { % In B/S, do nothing /lastidx -1 def exit } if ch 0 lt ch //azteccode.ld ge and { % If have latch i //azteccode.p eq { ch //azteccode.ld eq { /lastld true def } if % Set flag if D/L for adjustment below } { ch //azteccode.lp ne { /inP lastsp def } if % If not P/L only in P if have P/S } ifelse exit } if } ifelse } for inP lastidx 0 ge and { nxtlen i curlen i get put lastidx curseqilen 1 sub lt { % If lastchar not at end of sequence i //azteccode.p eq { lastld { nxtlen i nxtlen i get 1 add put } if % Adjust count if D/L % Copy curseq[i], move lastchar to end and replace with pcomp /srclen curseqilen def nxtseq i get 0 curseq i get 0 lastidx getinterval putinterval nxtseq i get lastidx curseq i get lastidx 1 add srclen lastidx sub 1 sub getinterval putinterval nxtseq i get srclen 1 sub //azteccode.pcomp pchars get put nxtseqlen i srclen put } { % Copy curseq[i] and replace lastchar in situ curseqilen 0 gt { nxtseq i get 0 curseq i get 0 curseqilen getinterval putinterval } if nxtseq i get lastidx //azteccode.pcomp pchars get put nxtseqlen i curseqilen put } ifelse } { % Copy curseq[i] except last element, append pcomp /srclen curseqilen 1 sub def srclen 0 gt { nxtseq i get 0 curseq i get 0 srclen getinterval putinterval } if nxtseq i get srclen //azteccode.pcomp pchars get put nxtseqlen i srclen 1 add put } ifelse } if } if } forall } if } if % % Account for binary extension for 32 or more bytes % nxtseqlen //azteccode.b get 0 gt { /numbytes 0 def 0 1 nxtseqlen //azteccode.b get 1 sub { nxtseq //azteccode.b get exch get //azteccode.sb eq {0} {numbytes 1 add} ifelse /numbytes exch def } for numbytes 32 eq {nxtlen //azteccode.b nxtlen //azteccode.b get 11 add put} if } if /curlen nxtlen def % Swap cur and nxt buffers curseq nxtseq /curseq exch def /nxtseq exch def curseqlen nxtseqlen /curseqlen exch def /nxtseqlen exch def /lastchar char 0 ge {char} {()} ifelse def } forall % % Select the optimal sequence % /minseq //azteccode.e def //azteccode.states { /i exch def curlen i get minseq lt { /minseq curlen i get def /seq curseq i get 0 curseqlen i get getinterval def } if } forall % % Encoding functions % /tobin { string dup length 1 sub 0 exch 1 exch {1 index exch 48 put} for dup 3 -1 roll 2 2 index length string cvrs dup length 2 index length exch sub exch putinterval } def /encu {charvals //azteccode.u get exch get 5 tobin} def /encl {charvals //azteccode.l get exch get 5 tobin} def /encm {charvals //azteccode.m get exch get 5 tobin} def /encd {charvals //azteccode.d get exch get 4 tobin} def /encp { dup fn1 eq { % FNC1: Flg(0) pop (00000000) } { dup -1000000 le { % ECI: Flg(n) + n-Digits neg 1000000 sub dup dup 0 eq {pop 1} if ln 10 ln div cvi dup 1 add 4 mul 8 add string dup 0 (00000) putinterval % Flg(n) dup 2 index 1 add 3 tobin 5 exch putinterval % len 3 1 roll -1 0 { % ECI digits in "Digit" encoding 4 mul 8 add exch dup 10 idiv 3 index 4 2 roll 10 mod 2 add 4 tobin putinterval } for pop } { charvals //azteccode.p get exch get 5 tobin } ifelse } ifelse } def /addtomsgbits { /v exch def j v length add msgbits length gt { /bwipp.aztecNoValidSymbol (Maximum length exceeded) //raiseerror exec } if msgbits j v putinterval /j j v length add def } def % % Encode the sequence % /state //azteccode.u def minseq { string } stopped { pop /bwipp.azteccodeInputTooLarge (The input data exceeds the implementation limits) //raiseerror exec } if /msgbits exch def /i 0 def /j 0 def { i seq length ge {exit} if state //azteccode.b ne { /char seq i get def % Encode character char //azteccode.encfuncs state get load exec addtomsgbits /i i 1 add def % Encode shifted next character char //azteccode.su eq char //azteccode.sp eq or { seq i get char //azteccode.su eq {encu} {encp} ifelse addtomsgbits /i i 1 add def } if % Latches to new state char //azteccode.lu eq {/state //azteccode.u def} if char //azteccode.ll eq {/state //azteccode.l def} if char //azteccode.lm eq {/state //azteccode.m def} if char //azteccode.lp eq {/state //azteccode.p def} if char //azteccode.ld eq {/state //azteccode.d def} if char //azteccode.sb eq {/state //azteccode.b def} if } { % Binary % Find number of bytes before latch or end, capped at 2078 /numbytes 0 def { i numbytes add seq length ge {exit} if seq i numbytes add get 0 lt {exit} if numbytes 2078 eq {exit} if % 11-bit length field maximum /numbytes numbytes 1 add def } loop % Encode length numbytes 31 le { numbytes 5 tobin addtomsgbits } { 0 5 tobin addtomsgbits numbytes 31 sub 11 tobin addtomsgbits } ifelse % Encode bytes numbytes { seq i get 8 tobin addtomsgbits /i i 1 add def } repeat % Return to previous state as indicated i seq length lt { /char seq i get def /i i 1 add def char //azteccode.lu eq {/state //azteccode.u def} if char //azteccode.ll eq {/state //azteccode.l def} if char //azteccode.lm eq {/state //azteccode.m def} if } if } ifelse } loop /msgbits msgbits 0 j getinterval def } if options /debugbits known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugbits msgbits //raiseerror exec } if % % Lookup the most appropriate symbol specification % //azteccode.metrics { /m exch def /frmt m 0 get def % Format of the symbol /mlyr m 1 get def % Data layers /icap m 2 get def % Reader initialisation capable /ncws m 3 get def % Total of codewords /bpcw m 4 get def % Bits per codeword /numecw ncws eclevel mul 100 div ecaddchars add ceiling cvi def msgbits length 0 eq {/numecw 0 def} if % Error correction codewords /numdcw ncws numecw sub def % Data codewords /okay true def format frmt ne {/okay false def} if readerinit icap 1 ne and {/okay false def} if layers -1 ne layers mlyr ne and {/okay false def} if msgbits length bpcw div ceiling cvi numdcw gt {/okay false def} if okay {exit} if } forall okay not { /bwipp.aztecNoValidSymbol (Maximum length exceeded) //raiseerror exec } if /layers mlyr def % % Expand message bits into codewords avoiding codewords with all zeros or all ones % /allzero {dup length (000000000000) 0 3 -1 roll getinterval eq} def /allones {dup length (111111111111) 0 3 -1 roll getinterval eq} def /cws ncws array def /m 0 def /c 0 def { msgbits length m le {exit} if msgbits length m sub bpcw ge { /cwb msgbits m bpcw 1 sub getinterval def % All but last bit /cwf msgbits m bpcw add 1 sub 1 getinterval def % Last bit cwb allzero {/cwf (1) def /m m 1 sub def} if % Flip last bit to avoid zeros cwb allones {/cwf (0) def /m m 1 sub def} if % Flip last bit to avoid ones % Concatenate the bits 12 string dup 0 cwb putinterval dup bpcw 1 sub cwf putinterval 0 bpcw getinterval /cwb exch def } { % Final codeword /cwb msgbits m msgbits length m sub getinterval def /cwb (111111111111) 12 string copy dup 0 cwb putinterval 0 bpcw getinterval def cwb allones {cwb cwb length 1 sub (0) putinterval} if % Prevent all ones } ifelse % Conversion of binary data into byte array /cw 0 def 0 1 bpcw 1 sub { /i exch def /cw cw 2 bpcw i sub 1 sub exp cvi cwb i get 48 sub mul add def } for cws c cw put /m m bpcw add def /c c 1 add def } loop /cws cws 0 c getinterval def options /debugcws known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugcws cws //raiseerror exec } if (input.encoding) //azteccode.after exec % % Reed-Solomon algorithm. Returns rsnc ECC codewords. The GF parameters % (and hence rsprod) vary with rsbt, so both are bound per call. % /rscodes { (ecc.cws) //azteccode.before exec /rsbt exch def /rsnc exch def /rscws exch def % % Lookup the Reed Solomon error correction parameters for the codeword size % //azteccode.rsparams rsbt get aload pop /rspm exch def /rsgf-1 exch 1 sub def rstables rsbt get aload pop /rsalog exch def /rslog exch def % % Function to calculate the product in the field % /rsprod { dup 0 ne { 1 index 0 ne { rslog exch get exch rslog exch get add rsgf-1 mod rsalog exch get } { pop pop 0 } ifelse } { pop pop 0 } ifelse } def (ecc.coeffs) //azteccode.before exec /coeffs rsnc rsbt //azteccode.coeffscachefetch exec def (ecc.coeffs) //azteccode.after exec /lfsr rsnc array def {rscws exch get} rscws length coeffs rsnc lfsr /rsprod load //rsecbinary exec lfsr (ecc.cws) //azteccode.after exec } def % % Create the codewords and bit string for the mode % format (full) eq { /mode layers 1 sub 11 bitshift cws length 1 sub add def readerinit {/mode mode 2#0000010000000000 or def} if /mode [ mode 2#1111000000000000 and -12 bitshift mode 2#0000111100000000 and -8 bitshift mode 2#0000000011110000 and -4 bitshift mode 2#0000000000001111 and ] def /mode [ mode aload pop mode 6 4 rscodes aload pop ] def } if format (compact) eq { /mode layers 1 sub 6 bitshift cws length 1 sub add def readerinit {/mode mode 2#00100000 or def} if /mode [ mode 2#11110000 and -4 bitshift mode 2#00001111 and ] def /mode [ mode aload pop mode 5 4 rscodes aload pop ] def } if format (rune) eq { /mode barcode cvi def /mode [ mode 2#11110000 and -4 bitshift mode 2#00001111 and ] def /mode [ mode aload pop mode 5 4 rscodes aload pop ] def /mode [mode {2#1010 xor} forall] def % Invert alternate bits } if /modebits mode length 4 mul string def 0 1 modebits length 1 sub {modebits exch (0) putinterval} for 0 1 mode length 1 sub { /i exch def modebits mode i get 2 4 string cvrs dup length 4 exch sub 4 i mul add exch putinterval } for % % Extend the data codewords with error correction codewords to create the bit string for the data % /ecws cws ncws cws length sub bpcw rscodes def options /debugecc known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugecc ecws //raiseerror exec } if /cws [ cws aload pop ecws aload pop ] def format (full) eq { /databits layers layers mul 16 mul layers 112 mul add string def } { /databits layers layers mul 16 mul layers 88 mul add string def } ifelse 0 1 databits length 1 sub {databits exch (0) putinterval} for 0 1 ncws 1 sub { /i exch def databits cws i get 2 bpcw string cvrs dup length bpcw exch sub bpcw i mul add databits length ncws bpcw mul sub add exch putinterval } for (matrix.layout) //azteccode.before exec % % Move to a point in the cartesian plane centered on the bullseye % /cmv {size mul sub mid add} def % % Move to a bit position within a layer % /lmv { /lbit exch def /llyr exch def /lwid fw llyr 4 mul add def /ldir lbit 2 idiv lwid idiv def ldir 0 eq { % Top lwid 1 sub 2 idiv neg 1 add lbit 2 idiv lwid mod add fw 1 sub 2 idiv llyr 2 mul add lbit 2 mod add cmv } if ldir 1 eq { % Right fw 2 idiv llyr 2 mul add lbit 2 mod add lwid 1 sub 2 idiv 1 sub lbit 2 idiv lwid mod sub cmv } if ldir 2 eq { % Bottom lwid 2 idiv neg 1 add lbit 2 idiv lwid mod add neg fw 2 idiv llyr 2 mul add lbit 2 mod add neg cmv } if ldir 3 eq { % Left fw 1 sub 2 idiv llyr 2 mul add lbit 2 mod add neg lwid 2 idiv 1 sub lbit 2 idiv lwid mod sub neg cmv } if } def % % Create the pixel map % % For full symbols we disregard the reference grid at this stage % format (full) eq {/fw 12 def} {/fw 9 def} ifelse /size fw layers 4 mul add 2 add def /pixs [size size mul {-1} repeat] def /mid size 1 sub 2 idiv size mul size 1 sub 2 idiv add def % % Data layers % /i 0 def 1 1 layers { /layer exch def 0 1 fw layer 4 mul add 8 mul 1 sub { /pos exch def pixs layer pos lmv databits databits length i sub 1 sub get 48 sub put /i i 1 add def } for } for % % For full symbols expand the pixel map by inserting the reference grid % format (full) eq { /fw 13 def /size fw layers 4 mul add 2 add layers 10.5 add 7.5 div 1 sub cvi 2 mul add def /mid size size mul 2 idiv def /npixs [size size mul {-2} repeat] def 0 16 size 2 idiv { /i exch def 0 1 size 1 sub { /j exch def npixs size 2 idiv neg j add i cmv [size 2 idiv j add i add 1 add 2 mod] putinterval npixs size 2 idiv neg j add i neg cmv [size 2 idiv j add i add 1 add 2 mod] putinterval npixs i size 2 idiv neg j add cmv [size 2 idiv j add i add 1 add 2 mod] putinterval npixs i neg size 2 idiv neg j add cmv [size 2 idiv j add i add 1 add 2 mod] putinterval } for } for /j 0 def 0 1 npixs length 1 sub { /i exch def npixs i get -2 eq { npixs i pixs j get put /j j 1 add def } if } for /pixs npixs def } if % % Finder pattern % /fw fw 2 idiv def fw neg 1 fw { /i exch def fw neg 1 fw { /j exch def pixs i j cmv i abs j abs gt {i abs} {j abs} ifelse 1 add 2 mod put } for } for % % Orientation bits % [ [ fw 1 add neg fw 1 ] [ fw 1 add neg fw 1 add 1 ] [ fw neg fw 1 add 1 ] [ fw 1 add fw 1 add 1 ] [ fw 1 add fw 1 ] [ fw 1 add fw neg 1 ] [ fw fw 1 add 0 ] [ fw 1 add fw 1 add neg 0 ] [ fw fw 1 add neg 0 ] [ fw neg fw 1 add neg 0 ] [ fw 1 add neg fw 1 add neg 0 ] [ fw 1 add neg fw neg 0 ] ] {pixs exch aload pop 3 1 roll cmv exch put} forall % % Mode ring % /modemap format (full) eq {//azteccode.modemapfull} {//azteccode.modemapcompact} ifelse def 0 1 modemap length 1 sub { pixs modemap 2 index get aload pop cmv modebits 3 index get 48 sub put pop } for (matrix.layout) //azteccode.after exec << /ren /renmatrix /pixs pixs /pixx size /pixy size /height size modunit mul 72 div /width size modunit mul 72 div /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /azteccode dup load /uk.co.terryburton.bwipp defineresource pop (setup.define) //azteccode.after exec end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER azteccode-- % --BEGIN ENCODER azteccodecompact-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor fifocache rsecbinary render renmatrix azteccode-- % --DESC: Compact Aztec Code % --EXAM: 1234 % --EXOP: % --RNDR: renmatrix % --FMLY: Two-dimensional symbols %%BeginResource: uk.co.terryburton.bwipp azteccodecompact 0.0 2026052800 75206 75186 %%BeginData: 47 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 4 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /azteccode dup /uk.co.terryburton.bwipp findresource put begin /azteccodecompact { 4 dict begin { /dontdraw false def null /apply //processoptions exec /options exch def /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Get the result of encoding with azteccode with format=compact % options (format) (compact) put /uk.co.terryburton.bwipp._dontdraw true def barcode options //azteccode exec /args exch def args (opt) options put args _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /azteccodecompact dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER azteccodecompact-- % --BEGIN ENCODER aztecrune-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor fifocache rsecbinary render renmatrix azteccode-- % --DESC: Aztec Runes % --EXAM: 1 % --EXOP: % --RNDR: renmatrix % --FMLY: Two-dimensional symbols %%BeginResource: uk.co.terryburton.bwipp aztecrune 0.0 2026052800 75175 75162 %%BeginData: 47 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 4 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /azteccode dup /uk.co.terryburton.bwipp findresource put begin /aztecrune { 4 dict begin { /dontdraw false def null /apply //processoptions exec /options exch def /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Get the result of encoding with azteccode with format=rune % options (format) (rune) put /uk.co.terryburton.bwipp._dontdraw true def barcode options //azteccode exec /args exch def args (opt) options put args _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /aztecrune dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER aztecrune-- % --BEGIN ENCODER codeone-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor fifocache rsecbinary render renmatrix-- % --DESC: Code One % --EXAM: Code One % --EXOP: % --RNDR: renmatrix % --FMLY: Less-used Symbols %%BeginResource: uk.co.terryburton.bwipp codeone 0.0 2026052800 285225 287241 %%BeginData: 1212 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 33 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /fifocache dup /uk.co.terryburton.bwipp findresource put dup /rsecbinary dup /uk.co.terryburton.bwipp findresource put dup /setuphooks dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put begin /codeone [/before /after] //setuphooks exec (setup.define) //codeone.before exec /codeone.versionopts << [ (T-16) (T-32) (T-48) (S-10) (S-20) (S-30) (A) (B) (C) (D) (E) (F) (G) (H) ] {dup} forall >> readonly def /codeone.stypevals [ (1) (1010) (1100100) (1111101000) (10011100010000) (11000011010100000) (11110100001001000000) (100110001001011010000000) (101111101011110000100000000) (111011100110101100101000000000) (1001010100000010111110010000000000) (1011101001000011101101110100000000000) (1110100011010100101001010001000000000000) (10010001100001001110011100101010000000000000) (10110101111001100010000011110100100000000000000) (11100011010111111010100100110001101000000000000000) (100011100001101111001001101111110000010000000000000000) (101100011010001010111100001011101100010100000000000000000) ] readonly def % % Basic metrics for the each symbol % /codeone.stypemetrics [ % ver row col dcol dcws rscw rsbl ro ri rl [ (S-10) 8 11 10 4 4 1 99 99 99 ] [ (S-20) 8 21 20 8 8 1 99 99 99 ] [ (S-30) 8 31 30 12 12 1 99 99 99 ] ] readonly def % % Basic metrics for the each symbol % /codeone.nonstypemetrics [ % ver row col dcol dcws rscw rsbl ro ri rl [ (A) 16 18 16 10 10 1 4 99 6 ] [ (B) 22 22 20 19 16 1 4 99 8 ] [ (C) 28 32 28 44 26 1 4 22 11 ] [ (D) 40 42 36 91 44 1 4 16 16 ] [ (E) 52 54 48 182 70 1 4 22 22 ] [ (F) 70 76 68 370 140 2 4 22 31 ] [ (G) 104 98 88 732 280 4 6 21 47 ] [ (H) 148 134 120 1480 560 8 6 20 69 ] [ (T-16) 16 17 16 10 10 1 99 99 99 ] [ (T-32) 16 33 32 24 16 1 99 99 99 ] [ (T-48) 16 49 48 38 22 1 99 99 99 ] ] readonly def % % Special characters % /codeone.fnc1 -1 def /codeone.fnc3 -2 def /codeone.lc -5 def /codeone.lb -6 def /codeone.lx -7 def /codeone.lt -8 def /codeone.ld -9 def /codeone.unl -10 def /codeone.fnc2 -11 def /codeone.fnc4 -12 def /codeone.sft1 -13 def /codeone.sft2 -14 def /codeone.sft3 -15 def /codeone.eci -16 def /codeone.pad -17 def /codeone.fnc1ld -18 def /codeone.unlcw 255 def /codeone.a 0 def /codeone.c 1 def /codeone.t 2 def /codeone.x 3 def /codeone.d 4 def /codeone.b 5 def /codeone.encfuncs [ /encA /encCTX /encCTX /encCTX /encD /encB ] readonly def /codeone.cpatmap << /A (121343) /B (12134343) /C (12121343) /D (1213434343) /E (1212134343) /F (1212121343) /G (121213434343) /H (121212134343) /S (56661278) /T (5666666666127878) >> readonly def /codeone.blackdotmap << /A [ [12 5] ] /B [ [16 7] ] /C [ [26 12] ] /D [] /E [ [26 23] ] /F [ [26 32] [70 32] [26 34] [70 34] ] /G [ [27 48] [69 48] ] /H [ [26 70] [66 70] [106 70] [26 72] [66 72] [106 72] ] /S-10 [] /S-20 [ [10 4] ] /S-30 [ [15 4] [15 6] ] /T-16 [ [8 10] ] /T-32 [ [16 10] [16 12] ] /T-48 [ [24 10] [24 12] [24 14] ] >> readonly def % % Reed-Solomon parameters % /codeone.rsparams [ % GF PM [] [] [] [] [] [ 32 37 ] % 5-bit S-type codewords [] [] [ 256 301 ] % 8-bit standard codewords ] readonly def /codeone.latevars dup 16 dict def load /init { (setup.latevars) //codeone.before exec currentglobal true setglobal //codeone.latevars begin % % Character mapping dictionaries % /avals << 0 1 128 {dup 1 add} for //codeone.pad 129 0 1 99 { % Double digits dup 10 2 string cvrs (00) 2 string copy dup 2 3 index length sub 4 -1 roll putinterval exch 130 add } for 229 [ //codeone.lc //codeone.lb //codeone.fnc1 //codeone.fnc2 //codeone.fnc3 //codeone.fnc4 //codeone.fnc1ld ] {exch 1 add dup} forall pop //codeone.lx 238 //codeone.lt 239 % 240-255 lD + 4 bits >> def /avals << avals {[exch]} bind forall >> def /cnvals << //codeone.sft1 0 //codeone.sft2 1 //codeone.sft3 2 32 3 48 1 57 {dup 44 sub} for % 0-9 65 1 90 {dup 51 sub} for % A-Z >> readonly def /c1vals << 0 1 31 {dup} for >> readonly def /c2vals << 33 1 47 {dup 33 sub} for 58 1 64 {dup 43 sub} for 91 1 95 {dup 69 sub} for //codeone.fnc1 27 //codeone.fnc2 28 //codeone.fnc3 29 //codeone.fnc4 30 //codeone.pad 31 >> readonly def /c3vals << 96 1 127 {dup 96 sub} for >> readonly def /cvals << cnvals {[exch]} bind forall c1vals {[exch cnvals //codeone.sft1 get exch]} bind forall c2vals {[exch cnvals //codeone.sft2 get exch]} bind forall c3vals {[exch cnvals //codeone.sft3 get exch]} bind forall >> def /tnvals << //codeone.sft1 0 //codeone.sft2 1 //codeone.sft3 2 32 3 48 1 57 {dup 44 sub} for % 0-9 97 1 122 {dup 83 sub} for % a-z >> readonly def /t1vals << 0 1 31 {dup} for >> readonly def /t2vals << 33 1 47 {dup 33 sub} for 58 1 64 {dup 43 sub} for 91 1 95 {dup 69 sub} for //codeone.fnc1 27 //codeone.fnc2 28 //codeone.fnc3 29 //codeone.fnc4 30 //codeone.pad 31 >> readonly def /t3vals << 96 0 65 1 90 {dup 64 sub} for 123 1 127 {dup 96 sub} for >> readonly def /tvals << tnvals {[exch]} bind forall t1vals {[exch tnvals //codeone.sft1 get exch]} bind forall t2vals {[exch tnvals //codeone.sft2 get exch]} bind forall t3vals {[exch tnvals //codeone.sft3 get exch]} bind forall >> def % % Extended ASCII mappings % 128 1 255 { /i exch def avals i [ avals //codeone.fnc4 get aload pop avals i 128 sub get aload pop ] put cvals i [ cvals //codeone.fnc4 get aload pop cvals i 128 sub get aload pop ] put tvals i [ tvals //codeone.fnc4 get aload pop tvals i 128 sub get aload pop ] put } bind for /avals avals readonly def /cvals cvals readonly def /tvals tvals readonly def /xvals << 13 0 42 1 62 2 32 3 48 1 57 {dup 44 sub} for 65 1 90 {dup 51 sub} for >> readonly def /xvals << xvals {[exch]} bind forall >> readonly def /bvals << 0 1 255 {dup} for >> readonly def /bvals << bvals {[exch]} bind forall >> readonly def /encvals [ avals cvals tvals xvals -1 bvals ] readonly def % % Calculate the log and anti-log tables for each Galois field % /rstables [ //codeone.rsparams { dup length 0 ne { aload pop /rspm exch def /rsgf exch def /rsalog [ 1 rsgf 1 sub { dup 2 mul dup rsgf ge {rspm xor} if } repeat ] def /rslog rsgf array def 1 1 rsgf 1 sub {dup rsalog exch get exch rslog 3 1 roll put} for [ rslog rsalog ] } { pop [] } ifelse } forall ] readonly def /init { //codeone.latevars {def} forall } def end //codeone.latevars /init get exec setglobal (setup.latevars) //codeone.after exec } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//codeone.latevars /init get exec} if } {pop} ifelse % % Function to calculate the product in the field % /codeone.rsprod { dup 0 ne { 1 index 0 ne { rslog exch get exch rslog exch get add gf-1 mod rsalog exch get } { pop pop 0 } ifelse } { pop pop 0 } ifelse } bind def % % Generate Reed-Solomon coefficients for given ecpb % /codeone.gencoeffs { /coeffs [ 1 ecpb {0} repeat ] def 0 1 ecpb 1 sub { % i rsalog 1 index get % ai = rsalog[i] exch dup 1 add % ai i i+1 coeffs exch 2 copy 1 sub get put % ai i ; coeffs[i+1] = coeffs[i] -1 1 { % j coeffs exch 2 copy get % ... coeffs j coeffs[j] 3 index % ... ai //codeone.rsprod exec % p = coeffs[j] * ai coeffs 2 index 1 sub get % ... coeffs[j-1] xor put % coeffs[j] = p ^ coeffs[j-1] } for coeffs 0 2 copy get % ... coeffs 0 coeffs[0] 3 index % ... ai //codeone.rsprod exec put % coeffs[0] = coeffs[0] * ai pop % ai } for coeffs 0 coeffs length 1 sub getinterval } bind def % % FIFO cache for ECC polynomials % % 9 unique keys: S-type GF31 (4,8,12) + standard GF128 (10,16,22,26,44,70) % /codeone.coeffscachemax 9 def % Override with global_ctx.codeone.coeffscachemax /codeone.coeffscachelimit 212 def % Override with global_ctx.codeone.coeffscachelimit /uk.co.terryburton.bwipp.global_ctx dup where { exch get dup /codeone.coeffscachemax 2 copy known {get /codeone.coeffscachemax exch def} {pop pop} ifelse /codeone.coeffscachelimit 2 copy known {get /codeone.coeffscachelimit exch def} {pop pop} ifelse } {pop} ifelse /codeone.coeffscache codeone.coeffscachemax codeone.coeffscachelimit //fifocache exec def /codeone.coeffscachefetch { /rsbt exch def /ecpb exch def /rslog rstables rsbt get 0 get def /rsalog rstables rsbt get 1 get def /gf rsalog length def /gf-1 gf 1 sub def rsbt 10000 mul ecpb add % key = rsbt * 10000 + ecpb { //codeone.gencoeffs exec } { length } //codeone.coeffscache /fetch get exec } bind def /codeone { 128 dict begin { (input.processoptions) //codeone.before exec /dontdraw false def /version (unset) def /parse false def /parsefnc false def /strictspec false def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def barcode length 4000 gt { /bwipp.codeoneInputTooLong (The input data is too long) //raiseerror exec } if /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def /modunit 2 def /uk.co.terryburton.bwipp.global_ctx dup where { exch get /default_modunit 2 copy known {get /modunit exch def} {pop pop} ifelse } {pop} ifelse % % Apply AST spec overrides and resolve physical specification % /codeone ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec (input.processoptions) //codeone.after exec //codeone.latevars /init get exec (input.validate.common) //codeone.before exec version (unset) ne { //codeone.versionopts version known not { /bwipp.codeoneBadVersion (version must be A to H, T-16, T-32, T-48, S-10, S-20 or S-30) //raiseerror exec } if } if /stype version 0 1 getinterval (S) eq def /ttype version 0 1 getinterval (T) eq def (input.validate.common) //codeone.after exec stype { (input.validate.stype) //codeone.before exec barcode { dup 48 lt exch 57 gt or { /bwipp.codeoneStypeNonDigit (S-Type symbols can only contain digits) //raiseerror exec } if } forall /barlen barcode length def barlen 18 gt { /bwipp.codeoneStypeTooLong (Maximum length exceeded) //raiseerror exec } if (input.validate.stype) //codeone.after exec (input.encoding.stype) //codeone.before exec /normalize { /base exch def /num exch def num length 1 sub -1 1 { /i exch def num i 1 sub 2 copy get num i get base idiv add put num i num i get base mod put } for % % Extend array using stack accumulation % num 0 get base ge { mark num 0 get { % loop dup base lt {exit} if dup base mod exch base idiv } loop % % Stack: mark lsb lsb-1 ... msb % % (Note: msb < base) % counttomark 1 sub /extcnt exch def counttomark array astore /extdigits exch def pop % mark % % Build num with reversed extension digits prepended to num[1:] % /num [ extcnt -1 0 { extdigits exch get } for num 1 num length 1 sub getinterval aload pop ] def } if % % Trim leading zeros and return % 0 { dup num length ge {exit} if num 1 index get 0 ne {exit} if 1 add } loop dup num length ge { pop [0] } { num exch num length 1 index sub getinterval } ifelse } def /bigadd { 2 copy length exch length 2 copy sub abs /offset exch def lt {exch} if /a exch def /b exch def 0 1 b length 1 sub { dup a exch offset add 2 copy get b 5 -1 roll get add put } for a } def /barlen barcode length def % % Convert value plus one to binary % /v [ 1 ] def 0 1 barlen 1 sub { /i exch def [ //codeone.stypevals i get {48 sub barcode barlen i sub 1 sub get 48 sub mul} forall ] v bigadd /v exch def } for /v v 2 normalize def % % Split into 5-bit codewords % /v [ 5 v length 5 mod sub 5 mod {0} repeat v aload pop ] def /cws v length 5 idiv array def 0 1 cws length 1 sub { /i exch def v i 5 mul 5 getinterval 0 exch {add 2 mul} forall 2 idiv cws exch i exch put } for /metrics //codeone.stypemetrics def (input.encoding) //codeone.after exec } { % Standard and type-T (input.preprocess) //codeone.before exec % % Convert input into bytes accounting for FNC characters % /fncvals << /parse parse /parsefnc parsefnc /eci true (FNC1) //codeone.fnc1 (FNC3) //codeone.fnc3 >> def barcode fncvals //parseinput exec /msg exch def /msglen msg length def % % Code One stores ECIs in data % /eciesc 16#5c def % We choose \ as a typical default /numecis 0 msg { -1000000 le {1 add} if } forall def numecis 0 gt { /msgtmp msg length 2 mul numecis 6 mul add 2 add array def msgtmp 0 //codeone.pad put msgtmp 1 eciesc put /j 2 def 0 1 msg length 1 sub { msg exch get dup -1000000 le { neg 10 7 string cvrs 1 6 getinterval {} forall 6 array astore msgtmp exch j 1 add exch putinterval msgtmp j eciesc put /j j 7 add def } { dup eciesc ne { msgtmp exch j exch put /j j 1 add def } { pop msgtmp j eciesc put msgtmp j 1 add eciesc put /j j 2 add def } ifelse } ifelse } for /msg msgtmp 0 j getinterval def /msglen msg length def } if % Absolute capacity is H format numeric. msglen 3550 gt { /bwipp.codeoneInputTooLong (The input data is too long) //raiseerror exec } if (input.preprocess) //codeone.after exec (input.encoding.non_stype) //codeone.before exec /metrics //codeone.nonstypemetrics def % % Select metrics of an appropriate symbol using stack-based accumulation % mark metrics { /m exch def /vers m 0 get def % Version of symbol /dcws m 4 get def % Data codewords in symbol /okay true def version (unset) eq { vers length 1 ne {/okay false def} if } { version vers ne {/okay false def} if } ifelse okay { dcws } if % Push dcws } forall counttomark array astore /fullcws exch def pop /numremcws [ 1480 {10000} repeat ] def fullcws {numremcws exch 1 sub 1 put} bind forall 1478 -1 0 { /i exch def numremcws i get 1 ne { numremcws i numremcws i 1 add get 1 add put } if } for /getnumremcws { dup numremcws length ge { pop /bwipp.codeoneTooLong (Maximum length exceeded) //raiseerror exec } if numremcws exch get } def /numD [ msglen {0} repeat 0 ] def /nextXterm [ msglen {0} repeat 9999 ] def /nextNonX [ msglen {0} repeat 9999 ] def msglen 1 sub -1 0 { /i exch def /barchar msg i get def barchar 48 ge barchar 57 le and { numD i numD i 1 add get 1 add put } if barchar 13 eq barchar 42 eq or barchar 62 eq or { nextXterm i 0 put } { nextXterm i nextXterm i 1 add get 1 add put } ifelse xvals barchar known not { nextNonX i 0 put } { nextNonX i nextNonX i 1 add get 1 add put } ifelse } for /nextXterm [nextXterm {dup 10000 gt {pop 10000} if} forall] def /nextNonX [nextNonX {dup 10000 gt {pop 10000} if} forall] def /isD {char 48 ge char 57 le and} def /isC {cnvals char known} def /isT {tnvals char known} def /isX {xvals char known} def /isEA {char 127 gt} def /isFN {char 0 lt} def /XtermFirst {dup nextXterm exch get exch nextNonX exch get lt} def /lookup { /ac 1 def /cc 2 def /tc 2 def /xc 2 def /bc 3 def mode //codeone.a eq {/ac 0 def /cc 1 def /tc 1 def /xc 1 def /bc 2 def} if mode //codeone.c eq {/cc 0 def} if mode //codeone.t eq {/tc 0 def} if mode //codeone.x eq {/xc 0 def} if % Assume mistake in spec mode //codeone.b eq {/bc 0 def} if 1 { % common exit /k 0 def { % loop i k add msglen eq { true [ac cc tc xc ] {bc exch ceiling le and} forall {//codeone.b exit} if true [ cc tc xc bc] {ac exch ceiling le and} forall {//codeone.a exit} if true [ tc xc ] {cc ceiling exch ceiling le and} forall {//codeone.c exit} if true [ xc ] {tc ceiling exch ceiling le and} forall {//codeone.t exit} if //codeone.x exit } if /char msg i k add get def /ac ac isD {1 2 div add} {isEA {ceiling 2 add} {ceiling 1 add} ifelse} ifelse def /cc cc isC {2 3 div add} {isEA { 8 3 div add } { 4 3 div add } ifelse} ifelse def /tc tc isT {2 3 div add} {isEA { 8 3 div add } { 4 3 div add } ifelse} ifelse def /xc xc isX {2 3 div add} {isEA {13 3 div add } {10 3 div add } ifelse} ifelse def /bc bc isFN {3 add} {1 add} ifelse def k 3 ge { % Checking after at least 4 characters (cf. Data Matrix), not 3 as in spec Step Q true [ac cc tc xc ] {bc 1 add exch ceiling le and} forall {//codeone.b exit} if true [ cc tc xc bc] {ac 1 add exch ceiling le and} forall {//codeone.a exit} if true [ac cc xc bc] {tc ceiling 1 add exch ceiling le and} forall {//codeone.t exit} if true [ac tc ] {cc ceiling 1 add exch ceiling le and} forall { cc ceiling xc ceiling lt {//codeone.c exit} if cc xc eq {i k add 1 add XtermFirst {//codeone.x exit} {//codeone.c exit} ifelse} if } if true [ac cc tc bc] {xc ceiling 1 add exch ceiling le and} forall {//codeone.x exit} if } if /k k 1 add def } loop } repeat } def /addtocws { dup length j add 1480 gt { pop /bwipp.codeoneTooLong (Maximum length exceeded) //raiseerror exec } if dup cws exch j exch putinterval /j exch length j add def } def /tobin { string dup length 1 sub 0 exch 1 exch {1 index exch 48 put} for dup 3 -1 roll 2 2 index length string cvrs dup length 2 index length exch sub exch putinterval [ exch {48 sub} forall ] } def % % Decimal mode: 3 digits -> 10 bits, plus entry/unlatch/padding overhead % /Dbitsbuf msglen 10 mul 3 idiv 20 add array def /Dbitslen 0 def % Helper to append bits to Dbitsbuf /appendbits { % bits... count -> - /apnd_n exch def % bits... apnd_n array astore % [bits] Dbitsbuf Dbitslen 3 -1 roll putinterval % - /Dbitslen Dbitslen apnd_n add def % - } def /encA { 1 { % Common exit numD i get 21 ge { % Initialize Dbits buffer with [ 1 1 1 1 ] Dbitsbuf 0 1 put Dbitsbuf 1 1 put Dbitsbuf 2 1 put Dbitsbuf 3 1 put /Dbitslen 4 def /mode //codeone.d def exit } if numD i get dup 13 ge exch i add msglen eq and { % Initialize Dbits buffer with [ 1 1 1 1 ] Dbitsbuf 0 1 put Dbitsbuf 1 1 put Dbitsbuf 2 1 put Dbitsbuf 3 1 put /Dbitslen 4 def /mode //codeone.d def exit } if numD i get 2 ge { 2 string dup 0 msg i get put dup 1 msg i 1 add get put avals exch get addtocws /i i 2 add def exit } if msg i get //codeone.fnc1 eq { numD i 1 add get 15 ge { avals //codeone.fnc1ld get addtocws /i i 1 add def /Dbitslen 0 def % Initialize Dbits buffer as empty /mode //codeone.d def exit } if numD i 1 add get dup 7 ge exch i add 1 add msglen eq and { avals //codeone.fnc1ld get addtocws /i i 1 add def /Dbitslen 0 def % Initialize Dbits buffer as empty /mode //codeone.d def exit } if } if /newmode lookup def newmode mode ne { avals [-1 //codeone.lc //codeone.lt //codeone.lx //codeone.ld //codeone.lb] newmode get get addtocws /mode newmode def exit } if avals msg i get get addtocws /i i 1 add def exit } repeat } def /CTXvalstocws { /in exch def mark 0 3 in length 1 sub { in exch 3 getinterval 0 exch {add 40 mul} forall 40 idiv 1 add dup 256 idiv exch 256 mod } for counttomark array astore exch pop } def /encCTX { /p 0 def /ctxvals 2220 array def % % Lookup the values for each character % { i msglen eq {exit} if p 3 mod 0 eq { numD i get 12 ge { ctxvals 0 p getinterval CTXvalstocws addtocws [//codeone.unlcw] addtocws /mode //codeone.a def exit } if numD i get dup 8 ge exch i add msglen eq and { ctxvals 0 p getinterval CTXvalstocws addtocws [//codeone.unlcw] addtocws /mode //codeone.a def exit } if mode //codeone.x eq { % Steps E1c, E2 xvals msg i get known not { ctxvals 0 p getinterval CTXvalstocws addtocws % Unlatch to ASCII unless one codeword left and single ASCII to encode j getnumremcws 1 ne msg i get 127 gt or { [//codeone.unlcw] addtocws } if /mode //codeone.a def exit } if i 1 add msglen lt { xvals msg i 1 add get known not {exit} if i 2 add msglen lt { xvals msg i 2 add get known not {exit} if } if } if } { lookup mode ne { ctxvals 0 p getinterval CTXvalstocws addtocws [//codeone.unlcw] addtocws /mode //codeone.a def exit } if } ifelse msglen i sub 3 le { % Check end of data conditions j p 3 idiv 2 mul add getnumremcws /remcws exch def /remvals [ msg i msglen i sub getinterval { dup encvals mode get exch known { encvals mode get exch get aload pop } { % Unencodable X12 characters pop -1 -1 -1 -1 } ifelse } forall ] def remcws 2 eq remvals length 3 eq and { % Encode and omit unlatch [ ctxvals 0 p getinterval aload pop remvals aload pop ] CTXvalstocws addtocws /mode //codeone.a def /i msglen def exit } if remcws 2 eq remvals length 2 eq and mode //codeone.x ne and { % Encode with sft1 as third value, omit unlatch [ ctxvals 0 p getinterval aload pop remvals aload pop encvals mode get //codeone.sft1 get aload pop ] CTXvalstocws addtocws /mode //codeone.a def /i msglen def exit } if remcws 2 eq remvals length 1 eq and { % Unlatch to ASCII ctxvals 0 p getinterval CTXvalstocws addtocws [//codeone.unlcw] addtocws avals msg i get get addtocws /mode //codeone.a def /i msglen def exit } if remcws 1 eq remvals length 1 eq and { % Implied unlatch to ASCII ctxvals 0 p getinterval CTXvalstocws addtocws avals msg i get get addtocws /mode //codeone.a def /i msglen def exit } if } if } if encvals mode get msg i get get dup length p add ctxvals length gt { pop /bwipp.codeoneTooLong (Maximum length exceeded) //raiseerror exec } if dup ctxvals exch p exch putinterval /p exch length p add def /i i 1 add def } loop % % Backtrack to a boundary and return to ASCII % mode //codeone.a ne { { p 3 mod 0 eq {exit} if /i i 1 sub def /p p encvals mode get msg i get get length sub def } loop [ ctxvals 0 p getinterval aload pop ] CTXvalstocws addtocws [//codeone.unlcw] addtocws /mode //codeone.a def i msglen ne { % Encode something to avoid latching immediately back numD i get 2 ge { 2 string dup 0 msg i get put dup 1 msg i 1 add get put avals exch get addtocws /i i 2 add def } { avals msg i get get addtocws /i i 1 add def } ifelse } if } if } def /encD { { % loop numD i get 3 lt { /Drem 8 Dbitslen 8 mod sub 8 mod def j Dbitslen 8 idiv add getnumremcws /remcws exch def % % Final codeword with no data % j Dbitslen 8 idiv add 1 sub getnumremcws 1 sub 0 eq Drem 0 eq and % No remaining codewords and no bits remcws 1 eq Drem 0 ne and or % Or 1 remaining codeword and some bits i msglen eq and { Drem 4 eq Drem 6 eq or { 1 1 1 1 4 appendbits } if Drem 2 eq Drem 6 eq or { 0 1 2 appendbits } if exit } if % % Final digit or double-digit into final codeword as ASCII % i msglen 1 sub eq numD i get 1 eq and i msglen 2 sub eq numD i get 2 eq and or remcws 1 eq and Drem 0 eq and {exit} if % % Latch to ASCII unless 4 or 6 bits remain in final codeword % i msglen 1 sub eq numD i get 1 eq and remcws 1 eq and Drem 4 eq Drem 6 eq or and not { 1 1 1 1 1 1 6 appendbits /Drem 8 Dbitslen 8 mod sub 8 mod def } if % % Try to encode a digit in remaining bits % Drem 4 eq Drem 6 eq or { numD i get 1 ge { msg i get 48 sub 1 add 4 tobin aload pop 4 appendbits /i i 1 add def } { 1 1 1 1 4 appendbits } ifelse /Drem Drem 4 sub def } if Drem 2 eq { 0 1 2 appendbits /Drem 0 def } if exit } if % % Three digit value plus one to ten bits % 0 msg i 3 getinterval {48 sub add 10 mul} forall 10 idiv 1 add 10 tobin aload pop 10 appendbits /i i 3 add def } loop /Dbits Dbitsbuf 0 Dbitslen getinterval def mark Dbitslen 0 gt { 0 8 Dbitslen 1 sub { Dbits exch 8 getinterval 0 exch {add 2 mul} forall 2 idiv } for } if counttomark array astore exch pop addtocws /mode //codeone.a def } def /encB { /p 0 def /bvals 1480 array def { i msglen eq {exit} if msg i get 0 lt {exit} if % Function character lookup mode ne {exit} if p bvals length ge { /bwipp.codeoneTooLong (Maximum length exceeded) //raiseerror exec } if bvals p msg i get put /p p 1 add def /i i 1 add def } loop j p add getnumremcws 1 sub /remcws exch def /bvals [ remcws 0 eq i msglen eq and { % Terminates symbol 0 } { p 250 lt {p} {p 250 idiv 249 add p 250 mod} ifelse } ifelse bvals 0 p getinterval aload pop ] def bvals addtocws /mode //codeone.a def } def % % Derive the codewords % /cws 1480 array def /mode //codeone.a def /i 0 def /j 0 def { i msglen ge {exit} if //codeone.encfuncs mode get load exec } loop /cws cws 0 j getinterval def (input.encoding.non_stype) //codeone.after exec } ifelse % % Select metrics of an appropriate symbol % metrics { /m exch def /vers m 0 get def % Version of symbol /rows m 1 get def % Rows in symbol /cols m 2 get def % Columns in symbol /dcol m 3 get def % Data columns in symbol /dcws m 4 get def % Data codewords in symbol /rscw m 5 get def % Error correction codewords /rsbl m 6 get def % Error correction blocks /riso m 7 get def % Riser offset /risi m 8 get def % Riser interval /risl m 9 get def % Riser length /dcpb dcws rsbl idiv def % Data codewords per block /ecpb rscw rsbl idiv def % Error codewords per block /okay true def version (unset) ne version vers ne and {/okay false def} if % The version must match that supplied cws length dcws gt {/okay false def} if okay {exit} if } forall okay not { /bwipp.codeoneNoValidSymbol (Maximum length exceeded) //raiseerror exec } if % % Extend cws to ncws codewords by addition of pad characters % stype not { /cws [ cws aload pop dcws cws length sub {129} repeat ] def } { /cws [ dcws cws length sub {0} repeat cws aload pop ] def } ifelse options /debugcws known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugcws cws //raiseerror exec } if % % Fetch the coefficients % (ecc.coeffs) //codeone.before exec /rsbt stype {5} {8} ifelse def /coeffs ecpb rsbt //codeone.coeffscachefetch exec def (ecc.coeffs) //codeone.after exec (ecc.cws) //codeone.before exec % % Reed-Solomon algorithm. Each block's data is read directly from cws via % interleaved indexing. % /ecbs rsbl array def 0 1 rsbl 1 sub { /blk exch def ecbs blk /lfsr ecpb array def {cws exch rsbl mul blk add get} dcpb coeffs ecpb lfsr //codeone.rsprod //rsecbinary exec lfsr put } for options /debugecc known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugecc [ ecbs {aload pop} forall ] //raiseerror exec } if % % Extend codewords with the interleaved error correction codes % /cws cws length rscw add array dup 0 cws putinterval def 0 1 rscw 1 sub { /i exch def cws dcws i add ecbs i rsbl mod get i rsbl idiv get put } for (ecc.cws) //codeone.after exec (matrix.layout) //codeone.before exec % % Module matrix for layout of the codewords % /mmat dcws rscw add stype {5} {8} ifelse mul array def /r 0 def /c 0 def 0 stype {2} {1} ifelse cws length 1 sub { /i exch def stype not { (00000000) 8 string copy dup cws i get 2 8 string cvrs dup length 8 exch sub exch putinterval [ exch {48 sub} forall ] dup 0 4 getinterval /top exch def 4 4 getinterval /bot exch def } { (00000) 5 string copy dup cws i get 2 5 string cvrs dup length 5 exch sub exch putinterval [ exch {48 sub} forall ] /c1 exch def (00000) 5 string copy dup cws i 1 add get 2 5 string cvrs dup length 5 exch sub exch putinterval [ exch {48 sub} forall ] /c2 exch def /top [ c1 0 3 getinterval aload pop c2 0 2 getinterval aload pop ] def /bot [ c1 3 2 getinterval aload pop c2 2 3 getinterval aload pop ] def } ifelse mmat r dcol mul c add top putinterval mmat r 1 add dcol mul c add bot putinterval /c c top length add def c dcol eq {/c 0 def /r r 2 add def} if } for % % Create bitmap and add finder patterns % /mmv {cols mul add} def /pixs [ rows cols mul {-1} repeat ] def % % Centre pattern % /artifact [ {cols {0} repeat} {cols {1} repeat} {0 cols 2 sub {1} repeat 0} {0 1 cols 4 sub {0} repeat 1 0} {cols 1 sub 2 idiv {-1} repeat 1 cols 1 sub 2 idiv {-1} repeat} {cols 1 sub 2 idiv {-1} repeat 0 cols 1 sub 2 idiv {-1} repeat} {1 cols 2 sub {0} repeat 1} {1 0 cols 4 sub {1} repeat 0 1} ] def /cpat //codeone.cpatmap vers 0 1 getinterval get def pixs 0 rows cpat length sub 2 idiv mmv [ cpat {artifact exch 49 sub get exec} forall ] putinterval % % Risers % 0 1 risl 1 sub { /i exch def riso risi cols 1 sub { /j exch def [ 1 i 12 mod 0 eq {1} {0} ifelse ] dup pixs j i mmv 3 -1 roll putinterval i risl 1 sub ne { pixs cols j sub 2 sub rows i sub 1 sub mmv 3 -1 roll putinterval } {pop} ifelse } for } for % % Black dots % //codeone.blackdotmap vers get {pixs exch aload pop mmv 1 put} bind forall % % Place the modules onto a pixel map between alignment patterns % /j 0 def 0 1 pixs length 1 sub { /i exch def pixs i get -1 eq { pixs i mmat j get put /j j 1 add def } if } for (matrix.layout) //codeone.after exec << /ren /renmatrix /pixs pixs /pixx cols /pixy rows /height rows modunit mul 72 div /width cols modunit mul 72 div stype ttype or { /borderleft 1.0 /borderright 1.0 /bordertop 0.0 /borderbottom 1.0 } if /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /codeone dup load /uk.co.terryburton.bwipp defineresource pop (setup.define) //codeone.after exec end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER codeone-- % --BEGIN ENCODER hanxin-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor fifocache rsecbinary render renmatrix-- % --DESC: Han Xin Code % --EXAM: This is Han Xin % --EXOP: % --RNDR: renmatrix % --FMLY: Two-dimensional symbols %%BeginResource: uk.co.terryburton.bwipp hanxin 0.0 2026052800 541177 543508 %%BeginData: 1308 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 17 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /fifocache dup /uk.co.terryburton.bwipp findresource put dup /rsecbinary dup /uk.co.terryburton.bwipp findresource put dup /setuphooks dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put begin /hanxin [/before /after] //setuphooks exec (setup.define) //hanxin.before exec /hanxin.noblk [ 0 -1 -1 ] readonly def % % Encoding modes % /hanxin.NUM 1 def % 0001 Numeric /hanxin.TXT 2 def % 0010 Text /hanxin.BYT 3 def % 0011 Byte /hanxin.CN1 4 def % 0100 Common Chinese Region 1 /hanxin.CN2 5 def % 0101 Common Chinese Region 2 /hanxin.GB2 6 def % 0110 GB18030 2-byte /hanxin.GB4 7 def % 0111 GB18030 4-byte /hanxin.FN1SEP 9 def % pseudo mode for FNC1 separator /hanxin.fn1 -1 def % % GS1 mode requires framing % /hanxin.gs1pre (11100001) readonly def /hanxin.gs1post (11111111) readonly def % % FNC1 encoding within numeric mode % /hanxin.fnc1ext (1111101000) readonly def /hanxin.metrics [ % vers size align modules error correction blocks [ (1) 23 -1 0 205 [ 1 21 4 ] //hanxin.noblk //hanxin.noblk [ 1 17 8 ] //hanxin.noblk //hanxin.noblk [ 1 13 12 ] //hanxin.noblk //hanxin.noblk [ 1 9 16 ] //hanxin.noblk //hanxin.noblk ] [ (2) 25 -1 0 301 [ 1 31 6 ] //hanxin.noblk //hanxin.noblk [ 1 25 12 ] //hanxin.noblk //hanxin.noblk [ 1 19 18 ] //hanxin.noblk //hanxin.noblk [ 1 15 22 ] //hanxin.noblk //hanxin.noblk ] [ (3) 27 -1 0 405 [ 1 42 8 ] //hanxin.noblk //hanxin.noblk [ 1 34 16 ] //hanxin.noblk //hanxin.noblk [ 1 26 24 ] //hanxin.noblk //hanxin.noblk [ 1 20 30 ] //hanxin.noblk //hanxin.noblk ] [ (4) 29 14 1 439 [ 1 46 8 ] //hanxin.noblk //hanxin.noblk [ 1 38 16 ] //hanxin.noblk //hanxin.noblk [ 1 30 24 ] //hanxin.noblk //hanxin.noblk [ 1 22 32 ] //hanxin.noblk //hanxin.noblk ] [ (5) 31 16 1 555 [ 1 57 12 ] //hanxin.noblk //hanxin.noblk [ 1 49 20 ] //hanxin.noblk //hanxin.noblk [ 1 37 32 ] //hanxin.noblk //hanxin.noblk [ 1 14 20 ] [ 1 13 22 ] //hanxin.noblk ] [ (6) 33 16 1 675 [ 1 70 14 ] //hanxin.noblk //hanxin.noblk [ 1 58 26 ] //hanxin.noblk //hanxin.noblk [ 1 24 20 ] [ 1 22 18 ] //hanxin.noblk [ 1 16 24 ] [ 1 18 26 ] //hanxin.noblk ] [ (7) 35 17 1 805 [ 1 84 16 ] //hanxin.noblk //hanxin.noblk [ 1 70 30 ] //hanxin.noblk //hanxin.noblk [ 1 26 22 ] [ 1 28 24 ] //hanxin.noblk [ 2 14 20 ] [ 1 12 20 ] //hanxin.noblk ] [ (8) 37 18 1 943 [ 1 99 18 ] //hanxin.noblk //hanxin.noblk [ 1 40 18 ] [ 1 41 18 ] //hanxin.noblk [ 1 31 26 ] [ 1 32 28 ] //hanxin.noblk [ 2 16 24 ] [ 1 15 22 ] //hanxin.noblk ] [ (9) 39 19 1 1089 [ 1 114 22 ] //hanxin.noblk //hanxin.noblk [ 2 48 20 ] //hanxin.noblk //hanxin.noblk [ 2 24 20 ] [ 1 26 22 ] //hanxin.noblk [ 2 18 28 ] [ 1 18 26 ] //hanxin.noblk ] [ (10) 41 20 1 1243 [ 1 131 24 ] //hanxin.noblk //hanxin.noblk [ 1 52 22 ] [ 1 57 24 ] //hanxin.noblk [ 2 27 24 ] [ 1 29 24 ] //hanxin.noblk [ 2 21 32 ] [ 1 19 30 ] //hanxin.noblk ] [ (11) 43 14 2 1289 [ 1 135 26 ] //hanxin.noblk //hanxin.noblk [ 1 56 24 ] [ 1 57 24 ] //hanxin.noblk [ 2 28 24 ] [ 1 31 26 ] //hanxin.noblk [ 2 22 32 ] [ 1 21 32 ] //hanxin.noblk ] [ (12) 45 15 2 1455 [ 1 153 28 ] //hanxin.noblk //hanxin.noblk [ 1 62 26 ] [ 1 65 28 ] //hanxin.noblk [ 2 32 28 ] [ 1 33 28 ] //hanxin.noblk [ 3 17 26 ] [ 1 22 30 ] //hanxin.noblk ] [ (13) 47 16 2 1629 [ 1 86 16 ] [ 1 85 16 ] //hanxin.noblk [ 1 71 30 ] [ 1 72 30 ] //hanxin.noblk [ 2 37 32 ] [ 1 35 30 ] //hanxin.noblk [ 3 20 30 ] [ 1 21 32 ] //hanxin.noblk ] [ (14) 49 16 2 1805 [ 1 94 18 ] [ 1 95 18 ] //hanxin.noblk [ 2 51 22 ] [ 1 55 24 ] //hanxin.noblk [ 3 30 26 ] [ 1 31 26 ] //hanxin.noblk [ 4 18 28 ] [ 1 17 24 ] //hanxin.noblk ] [ (15) 51 17 2 1995 [ 1 104 20 ] [ 1 105 20 ] //hanxin.noblk [ 2 57 24 ] [ 1 61 26 ] //hanxin.noblk [ 3 33 28 ] [ 1 36 30 ] //hanxin.noblk [ 4 20 30 ] [ 1 19 30 ] //hanxin.noblk ] [ (16) 53 17 2 2187 [ 1 115 22 ] [ 1 114 22 ] //hanxin.noblk [ 2 65 28 ] [ 1 61 26 ] //hanxin.noblk [ 3 38 32 ] [ 1 33 30 ] //hanxin.noblk [ 5 19 28 ] [ 1 14 24 ] //hanxin.noblk ] [ (17) 55 18 2 2393 [ 1 126 24 ] [ 1 125 24 ] //hanxin.noblk [ 2 70 30 ] [ 1 69 30 ] //hanxin.noblk [ 4 33 28 ] [ 1 29 26 ] //hanxin.noblk [ 5 20 30 ] [ 1 19 30 ] //hanxin.noblk ] [ (18) 57 19 2 2607 [ 1 136 26 ] [ 1 137 26 ] //hanxin.noblk [ 3 56 24 ] [ 1 59 26 ] //hanxin.noblk [ 5 35 30 ] //hanxin.noblk //hanxin.noblk [ 6 18 28 ] [ 1 21 28 ] //hanxin.noblk ] [ (19) 59 20 2 2829 [ 1 148 28 ] [ 1 149 28 ] //hanxin.noblk [ 3 61 26 ] [ 1 64 28 ] //hanxin.noblk [ 7 24 20 ] [ 1 23 22 ] //hanxin.noblk [ 6 20 30 ] [ 1 21 32 ] //hanxin.noblk ] [ (20) 61 20 2 3053 [ 3 107 20 ] //hanxin.noblk //hanxin.noblk [ 3 65 28 ] [ 1 72 30 ] //hanxin.noblk [ 7 26 22 ] [ 1 23 22 ] //hanxin.noblk [ 7 19 28 ] [ 1 20 32 ] //hanxin.noblk ] [ (21) 63 21 2 3291 [ 3 115 22 ] //hanxin.noblk //hanxin.noblk [ 4 56 24 ] [ 1 63 28 ] //hanxin.noblk [ 7 28 24 ] [ 1 25 22 ] //hanxin.noblk [ 8 18 28 ] [ 1 21 22 ] //hanxin.noblk ] [ (22) 65 16 3 3383 [ 2 116 22 ] [ 1 122 24 ] //hanxin.noblk [ 4 56 24 ] [ 1 72 30 ] //hanxin.noblk [ 7 28 24 ] [ 1 32 26 ] //hanxin.noblk [ 8 18 28 ] [ 1 24 30 ] //hanxin.noblk ] [ (23) 67 17 3 3631 [ 3 127 24 ] //hanxin.noblk //hanxin.noblk [ 5 51 22 ] [ 1 62 26 ] //hanxin.noblk [ 7 30 26 ] [ 1 35 26 ] //hanxin.noblk [ 8 20 30 ] [ 1 21 32 ] //hanxin.noblk ] [ (24) 69 17 3 3887 [ 2 135 26 ] [ 1 137 26 ] //hanxin.noblk [ 5 56 24 ] [ 1 59 26 ] //hanxin.noblk [ 7 33 28 ] [ 1 30 28 ] //hanxin.noblk [ 11 16 24 ] [ 1 19 26 ] //hanxin.noblk ] [ (25) 71 18 3 4151 [ 3 105 20 ] [ 1 121 22 ] //hanxin.noblk [ 5 61 26 ] [ 1 57 26 ] //hanxin.noblk [ 9 28 24 ] [ 1 28 22 ] //hanxin.noblk [ 10 19 28 ] [ 1 18 30 ] //hanxin.noblk ] [ (26) 73 18 3 4423 [ 2 157 30 ] [ 1 150 28 ] //hanxin.noblk [ 5 65 28 ] [ 1 61 26 ] //hanxin.noblk [ 8 33 28 ] [ 1 34 30 ] //hanxin.noblk [ 10 19 28 ] [ 2 15 26 ] //hanxin.noblk ] [ (27) 75 19 3 4703 [ 3 126 24 ] [ 1 115 22 ] //hanxin.noblk [ 7 51 22 ] [ 1 54 22 ] //hanxin.noblk [ 8 35 30 ] [ 1 37 30 ] //hanxin.noblk [ 15 15 22 ] [ 1 10 22 ] //hanxin.noblk ] [ (28) 77 19 3 4991 [ 4 105 20 ] [ 1 103 20 ] //hanxin.noblk [ 7 56 24 ] [ 1 45 18 ] //hanxin.noblk [ 10 31 26 ] [ 1 27 26 ] //hanxin.noblk [ 10 17 26 ] [ 3 20 28 ] [ 1 21 28 ] ] [ (29) 79 20 3 5287 [ 3 139 26 ] [ 1 137 28 ] //hanxin.noblk [ 6 66 28 ] [ 1 66 30 ] //hanxin.noblk [ 9 36 30 ] [ 1 34 32 ] //hanxin.noblk [ 13 19 28 ] [ 1 17 32 ] //hanxin.noblk ] [ (30) 81 20 3 5591 [ 6 84 16 ] [ 1 82 16 ] //hanxin.noblk [ 6 70 30 ] [ 1 68 30 ] //hanxin.noblk [ 7 35 30 ] [ 3 33 28 ] [ 1 32 28 ] [ 13 20 30 ] [ 1 20 28 ] //hanxin.noblk ] [ (31) 83 21 3 5903 [ 5 105 20 ] [ 1 94 18 ] //hanxin.noblk [ 6 74 32 ] [ 1 71 30 ] //hanxin.noblk [ 11 33 28 ] [ 1 34 32 ] //hanxin.noblk [ 13 19 28 ] [ 3 16 26 ] //hanxin.noblk ] [ (32) 85 17 4 6033 [ 4 127 24 ] [ 1 126 24 ] //hanxin.noblk [ 7 66 28 ] [ 1 66 30 ] //hanxin.noblk [ 12 30 24 ] [ 1 24 28 ] [ 1 24 30 ] [ 15 19 28 ] [ 1 17 32 ] //hanxin.noblk ] [ (33) 87 17 4 6353 [ 7 84 16 ] [ 1 78 16 ] //hanxin.noblk [ 7 70 30 ] [ 1 66 28 ] //hanxin.noblk [ 12 33 28 ] [ 1 32 30 ] //hanxin.noblk [ 14 21 32 ] [ 1 24 28 ] //hanxin.noblk ] [ (34) 89 18 4 6689 [ 5 117 22 ] [ 1 117 24 ] //hanxin.noblk [ 8 66 28 ] [ 1 58 26 ] //hanxin.noblk [ 11 38 32 ] [ 1 34 32 ] //hanxin.noblk [ 15 20 30 ] [ 2 17 26 ] //hanxin.noblk ] [ (35) 91 18 4 7025 [ 4 148 28 ] [ 1 146 28 ] //hanxin.noblk [ 8 68 30 ] [ 1 70 24 ] //hanxin.noblk [ 10 36 32 ] [ 3 38 28 ] //hanxin.noblk [ 16 19 28 ] [ 3 16 26 ] //hanxin.noblk ] [ (36) 93 19 4 7377 [ 4 126 24 ] [ 2 135 26 ] //hanxin.noblk [ 8 70 28 ] [ 2 43 26 ] //hanxin.noblk [ 13 32 28 ] [ 2 41 30 ] //hanxin.noblk [ 17 19 28 ] [ 3 15 26 ] //hanxin.noblk ] [ (37) 95 19 4 7729 [ 5 136 26 ] [ 1 132 24 ] //hanxin.noblk [ 5 67 30 ] [ 4 68 28 ] [ 1 69 28 ] [ 14 35 30 ] [ 1 32 24 ] //hanxin.noblk [ 18 18 26 ] [ 3 16 28 ] [ 1 14 28 ] ] [ (38) 97 19 4 8089 [ 3 142 26 ] [ 3 141 28 ] //hanxin.noblk [ 8 70 30 ] [ 1 73 32 ] [ 1 74 32 ] [ 12 34 30 ] [ 3 34 26 ] [ 1 35 28 ] [ 18 21 32 ] [ 1 27 30 ] //hanxin.noblk ] [ (39) 99 20 4 8465 [ 5 116 22 ] [ 2 103 20 ] [ 1 102 20 ] [ 9 74 32 ] [ 1 74 30 ] //hanxin.noblk [ 14 34 28 ] [ 2 32 32 ] [ 1 32 30 ] [ 19 21 32 ] [ 1 25 26 ] //hanxin.noblk ] [ (40) 101 20 4 8841 [ 7 116 22 ] [ 1 117 22 ] //hanxin.noblk [ 11 65 28 ] [ 1 58 24 ] //hanxin.noblk [ 15 38 32 ] [ 1 27 28 ] //hanxin.noblk [ 20 20 30 ] [ 1 20 32 ] [ 1 21 32 ] ] [ (41) 103 17 5 9009 [ 6 136 26 ] [ 1 130 24 ] //hanxin.noblk [ 11 66 28 ] [ 1 62 30 ] //hanxin.noblk [ 14 34 28 ] [ 3 34 32 ] [ 1 30 30 ] [ 18 20 30 ] [ 3 20 28 ] [ 2 15 26 ] ] [ (42) 105 17 5 9401 [ 5 105 20 ] [ 2 115 22 ] [ 2 116 22 ] [ 10 75 32 ] [ 1 73 32 ] //hanxin.noblk [ 16 38 32 ] [ 1 27 28 ] //hanxin.noblk [ 22 19 28 ] [ 2 16 30 ] [ 1 19 30 ] ] [ (43) 107 18 5 9799 [ 6 147 28 ] [ 1 146 28 ] //hanxin.noblk [ 11 66 28 ] [ 2 65 30 ] //hanxin.noblk [ 18 33 28 ] [ 2 33 30 ] //hanxin.noblk [ 22 21 32 ] [ 1 28 30 ] //hanxin.noblk ] [ (44) 109 18 5 10207 [ 6 116 22 ] [ 3 125 24 ] //hanxin.noblk [ 11 75 32 ] [ 1 68 30 ] //hanxin.noblk [ 13 35 28 ] [ 6 34 32 ] [ 1 30 30 ] [ 23 21 32 ] [ 1 26 30 ] //hanxin.noblk ] [ (45) 111 18 5 10623 [ 7 105 20 ] [ 4 95 18 ] //hanxin.noblk [ 12 67 28 ] [ 1 63 30 ] [ 1 62 32 ] [ 21 31 26 ] [ 2 33 32 ] //hanxin.noblk [ 23 21 32 ] [ 2 24 30 ] //hanxin.noblk ] [ (46) 113 19 5 11045 [ 10 116 22 ] //hanxin.noblk //hanxin.noblk [ 12 74 32 ] [ 1 78 30 ] //hanxin.noblk [ 18 37 32 ] [ 1 39 30 ] [ 1 41 28 ] [ 25 21 32 ] [ 1 27 28 ] //hanxin.noblk ] [ (47) 115 19 5 11477 [ 5 126 24 ] [ 4 115 22 ] [ 1 114 22 ] [ 12 67 28 ] [ 2 66 32 ] [ 1 68 30 ] [ 21 35 30 ] [ 1 39 30 ] //hanxin.noblk [ 26 21 32 ] [ 1 28 28 ] //hanxin.noblk ] [ (48) 117 19 5 11917 [ 9 126 24 ] [ 1 117 22 ] //hanxin.noblk [ 13 75 32 ] [ 1 68 30 ] //hanxin.noblk [ 20 35 30 ] [ 3 35 28 ] //hanxin.noblk [ 27 21 32 ] [ 1 28 30 ] //hanxin.noblk ] [ (49) 119 17 6 12111 [ 9 126 24 ] [ 1 137 26 ] //hanxin.noblk [ 13 71 30 ] [ 2 68 32 ] //hanxin.noblk [ 20 37 32 ] [ 1 39 28 ] [ 1 38 28 ] [ 24 20 32 ] [ 5 25 28 ] //hanxin.noblk ] [ (50) 121 17 6 12559 [ 8 147 28 ] [ 1 141 28 ] //hanxin.noblk [ 10 73 32 ] [ 4 74 30 ] [ 1 73 30 ] [ 16 36 32 ] [ 6 39 30 ] [ 1 37 30 ] [ 27 21 32 ] [ 3 20 26 ] //hanxin.noblk ] [ (51) 123 18 6 13025 [ 9 137 26 ] [ 1 135 26 ] //hanxin.noblk [ 12 70 30 ] [ 4 75 32 ] //hanxin.noblk [ 24 35 30 ] [ 1 40 28 ] //hanxin.noblk [ 23 20 32 ] [ 8 24 30 ] //hanxin.noblk ] [ (52) 125 18 6 13489 [ 14 95 18 ] [ 1 86 18 ] //hanxin.noblk [ 13 73 32 ] [ 3 77 30 ] //hanxin.noblk [ 24 35 30 ] [ 2 35 28 ] //hanxin.noblk [ 26 21 32 ] [ 5 21 30 ] [ 1 23 30 ] ] [ (53) 127 18 6 13961 [ 9 147 28 ] [ 1 142 28 ] //hanxin.noblk [ 10 73 30 ] [ 6 70 32 ] [ 1 71 32 ] [ 25 35 30 ] [ 2 34 26 ] //hanxin.noblk [ 29 21 32 ] [ 4 22 30 ] //hanxin.noblk ] [ (54) 129 18 6 14441 [ 11 126 24 ] [ 1 131 24 ] //hanxin.noblk [ 16 74 32 ] [ 1 79 30 ] //hanxin.noblk [ 25 38 32 ] [ 1 25 30 ] //hanxin.noblk [ 33 21 32 ] [ 1 28 28 ] //hanxin.noblk ] [ (55) 131 19 6 14939 [ 14 105 20 ] [ 1 99 18 ] //hanxin.noblk [ 19 65 28 ] [ 1 72 28 ] //hanxin.noblk [ 24 37 32 ] [ 2 40 30 ] [ 1 41 30 ] [ 31 21 32 ] [ 4 24 32 ] //hanxin.noblk ] [ (56) 133 19 6 15435 [ 10 147 28 ] [ 1 151 28 ] //hanxin.noblk [ 15 71 30 ] [ 3 71 32 ] [ 1 73 32 ] [ 24 37 32 ] [ 3 38 30 ] [ 1 39 30 ] [ 36 19 30 ] [ 3 29 26 ] //hanxin.noblk ] [ (57) 135 19 6 15939 [ 15 105 20 ] [ 1 99 18 ] //hanxin.noblk [ 19 70 30 ] [ 1 64 28 ] //hanxin.noblk [ 27 38 32 ] [ 2 25 26 ] //hanxin.noblk [ 38 20 30 ] [ 2 18 28 ] //hanxin.noblk ] [ (58) 137 17 7 16171 [ 14 105 20 ] [ 1 113 22 ] [ 1 114 22 ] [ 17 67 30 ] [ 3 92 32 ] //hanxin.noblk [ 30 35 30 ] [ 1 41 30 ] //hanxin.noblk [ 36 21 32 ] [ 1 26 30 ] [ 1 27 30 ] ] [ (59) 139 17 7 16691 [ 11 146 28 ] [ 1 146 26 ] //hanxin.noblk [ 20 70 30 ] [ 1 60 26 ] //hanxin.noblk [ 29 38 32 ] [ 1 24 32 ] //hanxin.noblk [ 40 20 30 ] [ 2 17 26 ] //hanxin.noblk ] [ (60) 141 18 7 17215 [ 3 137 26 ] [ 1 136 26 ] [ 10 126 24 ] [ 22 65 28 ] [ 1 75 30 ] //hanxin.noblk [ 30 37 32 ] [ 1 51 30 ] //hanxin.noblk [ 42 20 30 ] [ 1 21 30 ] //hanxin.noblk ] [ (61) 143 18 7 17751 [ 12 126 24 ] [ 2 118 22 ] [ 1 116 22 ] [ 19 74 32 ] [ 1 74 30 ] [ 1 72 28 ] [ 30 38 32 ] [ 2 29 30 ] //hanxin.noblk [ 39 20 32 ] [ 2 37 26 ] [ 1 38 26 ] ] [ (62) 145 18 7 18295 [ 12 126 24 ] [ 3 136 26 ] //hanxin.noblk [ 21 70 30 ] [ 2 65 28 ] //hanxin.noblk [ 34 35 30 ] [ 1 44 32 ] //hanxin.noblk [ 42 20 30 ] [ 2 19 28 ] [ 2 18 28 ] ] [ (63) 147 18 7 18847 [ 12 126 24 ] [ 3 117 22 ] [ 1 116 22 ] [ 25 61 26 ] [ 2 62 28 ] //hanxin.noblk [ 34 35 30 ] [ 1 40 32 ] [ 1 41 32 ] [ 45 20 30 ] [ 1 20 32 ] [ 1 21 32 ] ] [ (64) 149 19 7 19403 [ 15 105 20 ] [ 2 115 22 ] [ 2 116 22 ] [ 25 65 28 ] [ 1 72 28 ] //hanxin.noblk [ 18 35 30 ] [ 17 37 32 ] [ 1 50 32 ] [ 42 20 30 ] [ 6 19 28 ] [ 1 15 28 ] ] [ (65) 151 19 7 19971 [ 19 105 20 ] [ 1 101 20 ] //hanxin.noblk [ 33 51 22 ] [ 1 65 22 ] //hanxin.noblk [ 40 33 28 ] [ 1 28 28 ] //hanxin.noblk [ 49 20 30 ] [ 1 18 28 ] //hanxin.noblk ] [ (66) 153 17 8 20229 [ 18 105 20 ] [ 2 117 22 ] //hanxin.noblk [ 26 65 28 ] [ 1 80 30 ] //hanxin.noblk [ 35 35 30 ] [ 3 35 28 ] [ 1 36 28 ] [ 52 18 28 ] [ 2 38 30 ] //hanxin.noblk ] [ (67) 155 17 8 20805 [ 26 84 16 ] //hanxin.noblk //hanxin.noblk [ 26 70 30 ] //hanxin.noblk //hanxin.noblk [ 45 31 26 ] [ 1 9 26 ] //hanxin.noblk [ 52 20 30 ] //hanxin.noblk //hanxin.noblk ] [ (68) 157 17 8 21389 [ 16 126 24 ] [ 1 114 22 ] [ 1 115 22 ] [ 23 70 30 ] [ 3 65 28 ] [ 1 66 28 ] [ 40 35 30 ] [ 1 43 30 ] //hanxin.noblk [ 46 20 30 ] [ 7 19 28 ] [ 1 16 28 ] ] [ (69) 159 18 8 21993 [ 19 116 22 ] [ 1 105 22 ] //hanxin.noblk [ 20 70 30 ] [ 7 66 28 ] [ 1 63 28 ] [ 40 35 30 ] [ 1 42 32 ] [ 1 43 32 ] [ 54 20 30 ] [ 1 19 30 ] //hanxin.noblk ] [ (70) 161 18 8 22593 [ 17 126 24 ] [ 2 115 22 ] //hanxin.noblk [ 24 70 30 ] [ 4 74 32 ] //hanxin.noblk [ 48 31 26 ] [ 2 18 26 ] //hanxin.noblk [ 54 19 28 ] [ 6 15 26 ] [ 1 14 26 ] ] [ (71) 163 18 8 23201 [ 29 84 16 ] //hanxin.noblk //hanxin.noblk [ 29 70 30 ] //hanxin.noblk //hanxin.noblk [ 6 34 30 ] [ 3 36 30 ] [ 38 33 28 ] [ 58 20 30 ] //hanxin.noblk //hanxin.noblk ] [ (72) 165 18 8 23817 [ 16 147 28 ] [ 1 149 28 ] //hanxin.noblk [ 31 66 28 ] [ 1 37 26 ] //hanxin.noblk [ 48 33 28 ] [ 1 23 26 ] //hanxin.noblk [ 53 20 30 ] [ 6 19 28 ] [ 1 17 28 ] ] [ (73) 167 19 8 24453 [ 20 115 22 ] [ 2 134 24 ] //hanxin.noblk [ 29 66 28 ] [ 2 56 26 ] [ 2 57 26 ] [ 45 36 30 ] [ 2 15 28 ] //hanxin.noblk [ 59 20 30 ] [ 2 21 32 ] //hanxin.noblk ] [ (74) 169 19 8 25085 [ 17 147 28 ] [ 1 134 26 ] //hanxin.noblk [ 26 70 30 ] [ 5 75 32 ] //hanxin.noblk [ 47 35 30 ] [ 1 48 32 ] //hanxin.noblk [ 64 18 28 ] [ 2 33 30 ] [ 1 35 30 ] ] [ (75) 171 17 9 25373 [ 22 115 22 ] [ 1 133 24 ] //hanxin.noblk [ 33 65 28 ] [ 1 74 28 ] //hanxin.noblk [ 43 36 30 ] [ 5 27 28 ] [ 1 30 28 ] [ 57 20 30 ] [ 5 21 32 ] [ 1 24 32 ] ] [ (76) 173 17 9 26021 [ 18 136 26 ] [ 2 142 26 ] //hanxin.noblk [ 33 66 28 ] [ 2 49 26 ] //hanxin.noblk [ 48 35 30 ] [ 2 38 28 ] //hanxin.noblk [ 64 20 30 ] [ 1 20 32 ] //hanxin.noblk ] [ (77) 175 17 9 26677 [ 19 126 24 ] [ 2 135 26 ] [ 1 136 26 ] [ 32 66 28 ] [ 2 55 26 ] [ 2 56 26 ] [ 49 36 30 ] [ 2 18 32 ] //hanxin.noblk [ 65 18 28 ] [ 5 27 30 ] [ 1 29 30 ] ] [ (78) 177 18 9 27335 [ 20 137 26 ] [ 1 130 26 ] //hanxin.noblk [ 30 75 32 ] [ 2 71 32 ] //hanxin.noblk [ 46 35 30 ] [ 6 39 32 ] //hanxin.noblk [ 3 12 30 ] [ 70 19 28 ] //hanxin.noblk ] [ (79) 179 18 9 28007 [ 20 147 28 ] //hanxin.noblk //hanxin.noblk [ 35 70 30 ] //hanxin.noblk //hanxin.noblk [ 49 35 30 ] [ 5 35 28 ] //hanxin.noblk [ 70 20 30 ] //hanxin.noblk //hanxin.noblk ] [ (80) 181 18 9 28687 [ 21 136 26 ] [ 1 155 28 ] //hanxin.noblk [ 34 70 30 ] [ 1 64 28 ] [ 1 65 28 ] [ 54 35 30 ] [ 1 45 30 ] //hanxin.noblk [ 68 20 30 ] [ 3 18 28 ] [ 1 19 28 ] ] [ (81) 183 18 9 29375 [ 19 126 24 ] [ 5 115 22 ] [ 1 114 22 ] [ 33 70 30 ] [ 3 65 28 ] [ 1 64 28 ] [ 52 35 30 ] [ 3 41 32 ] [ 1 40 32 ] [ 67 20 30 ] [ 5 21 32 ] [ 1 24 32 ] ] [ (82) 185 18 9 30071 [ 2 150 28 ] [ 21 136 26 ] //hanxin.noblk [ 32 70 30 ] [ 6 65 28 ] //hanxin.noblk [ 52 38 32 ] [ 2 27 32 ] //hanxin.noblk [ 73 20 30 ] [ 2 22 32 ] //hanxin.noblk ] [ (83) 187 17 10 30387 [ 21 126 24 ] [ 4 136 26 ] //hanxin.noblk [ 30 74 32 ] [ 6 73 30 ] //hanxin.noblk [ 54 35 30 ] [ 4 40 32 ] //hanxin.noblk [ 75 20 30 ] [ 1 20 28 ] //hanxin.noblk ] [ (84) 189 17 10 31091 [ 30 105 20 ] [ 1 114 22 ] //hanxin.noblk [ 3 45 22 ] [ 55 47 20 ] //hanxin.noblk [ 2 26 26 ] [ 62 33 28 ] //hanxin.noblk [ 79 18 28 ] [ 4 33 30 ] //hanxin.noblk ] ] readonly def % % Finder patterns % /hanxin.fpat [ [ 1 1 1 1 1 1 1 0 ] [ 1 0 0 0 0 0 0 0 ] [ 1 0 1 1 1 1 1 0 ] [ 1 0 1 0 0 0 0 0 ] [ 1 0 1 0 1 1 1 0 ] [ 1 0 1 0 1 1 1 0 ] [ 1 0 1 0 1 1 1 0 ] [ 0 0 0 0 0 0 0 0 ] ] readonly def /hanxin.fpat2 [ [ 1 1 1 0 1 0 1 0 ] [ 1 1 1 0 1 0 1 0 ] [ 1 1 1 0 1 0 1 0 ] [ 0 0 0 0 1 0 1 0 ] [ 1 1 1 1 1 0 1 0 ] [ 0 0 0 0 0 0 1 0 ] [ 1 1 1 1 1 1 1 0 ] [ 0 0 0 0 0 0 0 0 ] ] readonly def % % Function modules % /hanxin.funmap [ [ { pop 0 8 } bind { dup 1 sub exch 9 sub } bind ] [ { pop 1 8 } bind { dup 2 sub exch 9 sub } bind ] [ { pop 2 8 } bind { dup 3 sub exch 9 sub } bind ] [ { pop 3 8 } bind { dup 4 sub exch 9 sub } bind ] [ { pop 4 8 } bind { dup 5 sub exch 9 sub } bind ] [ { pop 5 8 } bind { dup 6 sub exch 9 sub } bind ] [ { pop 6 8 } bind { dup 7 sub exch 9 sub } bind ] [ { pop 7 8 } bind { dup 8 sub exch 9 sub } bind ] [ { pop 8 8 } bind { dup 9 sub exch 9 sub } bind ] [ { pop 8 7 } bind { dup 9 sub exch 8 sub } bind ] [ { pop 8 6 } bind { dup 9 sub exch 7 sub } bind ] [ { pop 8 5 } bind { dup 9 sub exch 6 sub } bind ] [ { pop 8 4 } bind { dup 9 sub exch 5 sub } bind ] [ { pop 8 3 } bind { dup 9 sub exch 4 sub } bind ] [ { pop 8 2 } bind { dup 9 sub exch 3 sub } bind ] [ { pop 8 1 } bind { dup 9 sub exch 2 sub } bind ] [ { pop 8 0 } bind { dup 9 sub exch 1 sub } bind ] [ { 9 sub 0 } bind { 8 exch 1 sub } bind ] [ { 9 sub 1 } bind { 8 exch 2 sub } bind ] [ { 9 sub 2 } bind { 8 exch 3 sub } bind ] [ { 9 sub 3 } bind { 8 exch 4 sub } bind ] [ { 9 sub 4 } bind { 8 exch 5 sub } bind ] [ { 9 sub 5 } bind { 8 exch 6 sub } bind ] [ { 9 sub 6 } bind { 8 exch 7 sub } bind ] [ { 9 sub 7 } bind { 8 exch 8 sub } bind ] [ { 9 sub 8 } bind { 8 exch 9 sub } bind ] [ { 8 sub 8 } bind { 7 exch 9 sub } bind ] [ { 7 sub 8 } bind { 6 exch 9 sub } bind ] [ { 6 sub 8 } bind { 5 exch 9 sub } bind ] [ { 5 sub 8 } bind { 4 exch 9 sub } bind ] [ { 4 sub 8 } bind { 3 exch 9 sub } bind ] [ { 3 sub 8 } bind { 2 exch 9 sub } bind ] [ { 2 sub 8 } bind { 1 exch 9 sub } bind ] [ { 1 sub 8 } bind { 0 exch 9 sub } bind ] ] readonly def % % Reed-Solomon GF and PM for each codeword size % /hanxin.rsparams [ % GF PM [] [] [] [] [ 16 19 ] % 4-bit format information [] [] [] [ 256 355 ] % 8-bit data blocks ] readonly def /hanxin.maskfuncs [ {pop pop 1} bind {add 2 mod} bind {1 index add 3 mod exch 3 mod add 2 mod} bind {2 copy mod 3 1 roll 2 copy exch mod 3 1 roll 3 mod exch 3 mod add add add 2 mod} bind ] readonly def /hanxin.latevars dup 4 dict def load /init { (setup.latevars) //hanxin.before exec currentglobal true setglobal //hanxin.latevars begin % % Calculate the log and anti-log tables for each Galois field % /rstables [ //hanxin.rsparams { dup length 0 ne { aload pop /rspm exch def /rsgf exch def /rsalog [ 1 rsgf 1 sub { dup 2 mul dup rsgf ge {rspm xor} if } repeat ] def /rslog rsgf array def 1 1 rsgf 1 sub {dup rsalog exch get exch rslog 3 1 roll put} for [ rslog rsalog ] } { pop [] } ifelse } forall ] readonly def /init { //hanxin.latevars {def} forall } def end //hanxin.latevars /init get exec setglobal (setup.latevars) //hanxin.after exec } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//hanxin.latevars /init get exec} if } {pop} ifelse % % Function to calculate the product in the field % /hanxin.rsprod { dup 0 ne { 1 index 0 ne { rslog exch get exch rslog exch get add rsgf-1 mod rsalog exch get } { pop pop 0 } ifelse } { pop pop 0 } ifelse } bind def % % Generate Reed-Solomon coefficients for given rsnc % /hanxin.gencoeffs { /coeffs [ 1 rsnc {0} repeat ] def 1 1 rsnc { % i coeffs 1 index 2 copy 1 sub get put % coeffs[i] = coeffs[i-1] rsalog 1 index get % ai = rsalog[i] exch 1 sub -1 1 { % j coeffs exch 2 copy get % ... coeffs j coeffs[j] 3 index % ... ai //hanxin.rsprod exec % p = coeffs[j] * ai coeffs 2 index 1 sub get % ... coeffs[j-1] xor put % coeffs[j] = p ^ coeffs[j-1] } for coeffs 0 2 copy get % ... coeffs 0 coeffs[0] 3 index % ... ai //hanxin.rsprod exec put % coeffs[0] = coeffs[0] * ai pop % ai } for coeffs 0 coeffs length 1 sub getinterval } bind def % % FIFO cache for ECC polynomials % % 15 unique keys: 1 format (GF16) + 14 data (GF256) with per-block 4-32 % /hanxin.coeffscachemax 15 def % Override with global_ctx.hanxin.coeffscachemax /hanxin.coeffscachelimit 264 def % Override with global_ctx.hanxin.coeffscachelimit /uk.co.terryburton.bwipp.global_ctx dup where { exch get dup /hanxin.coeffscachemax 2 copy known {get /hanxin.coeffscachemax exch def} {pop pop} ifelse /hanxin.coeffscachelimit 2 copy known {get /hanxin.coeffscachelimit exch def} {pop pop} ifelse } {pop} ifelse /hanxin.coeffscache hanxin.coeffscachemax hanxin.coeffscachelimit //fifocache exec def /hanxin.coeffscachefetch { /rsbt exch def /rsnc exch def rstables rsbt get aload pop /rsalog exch def /rslog exch def /rsgf-1 rsalog length 1 sub def rsbt 10000 mul rsnc add % key = rsbt * 10000 + rsnc { //hanxin.gencoeffs exec } { length } //hanxin.coeffscache /fetch get exec } bind def /hanxin { 128 dict begin { (input.processoptions) //hanxin.before exec /dontdraw false def /version (unset) def % 1-84 /eclevel (L2) def % L1, L2, L3 or L4 /parse false def /parsefnc false def /mask -1 def /strictspec false def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def /modunit 2 def /uk.co.terryburton.bwipp.global_ctx dup where { exch get /default_modunit 2 copy known {get /modunit exch def} {pop pop} ifelse } {pop} ifelse % % Apply AST spec overrides and resolve physical specification % /hanxin ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec (input.processoptions) //hanxin.after exec //hanxin.latevars /init get exec (input.validate) //hanxin.before exec barcode () eq { /bwipp.hanxinEmptyData (The data must not be empty) //raiseerror exec } if barcode length 14000 gt { /bwipp.hanxinInputTooLong (The input data is too long) //raiseerror exec } if version (unset) ne { version length dup 1 ge exch 2 le and dup { pop true version {dup 48 lt exch 57 gt or { pop false } if } forall dup { pop version cvi dup 1 ge exch 84 le and } if } if not { /bwipp.hanxinInvalidVersion (Valid versions are 1 to 84) //raiseerror exec } if } if eclevel length 2 eq dup { pop eclevel 0 1 getinterval (L) eq dup { pop eclevel 1 get 48 sub dup 1 ge exch 4 le and } if } if not { /bwipp.hanxinInvalidErrorCorrectionLevel (Valid error correction levels are L1 to L4) //raiseerror exec } if mask -1 ne { mask 1 lt mask 4 gt or { /bwipp.hanxinInvalidErrorCorrectionLevel (The valid masks are 1 to 4) //raiseerror exec } if } if (input.validate) //hanxin.after exec % % Parse the input % (input.preprocess) //hanxin.before exec /fncvals << /parse parse /parsefnc parsefnc (FNC1) //hanxin.fn1 >> def barcode fncvals //parseinput exec /msg exch def /msglen msg length def % % FNC1 in first position activates GS1 mode % /fnc1first false def msglen 0 gt { msg 0 get //hanxin.fn1 eq { /fnc1first true def /msg msg 1 msglen 1 sub getinterval def /msglen msg length def } if } if % Absolute capacity is version 84 eclevel=L1 numeric. msglen 7827 gt { /bwipp.hanxinInputTooLong (The input data is too long) //raiseerror exec } if % % Outside GS1 mode, FNC1 defined as having no encoding % fnc1first not { 0 1 msglen 1 sub { /i exch def msg i get //hanxin.fn1 eq { /bwipp.hanxinFNC1NotFirstPosition (Han Xin requires that FNC1 only appears in the first position) //raiseerror exec } if } for } if (input.preprocess) //hanxin.after exec % % Input encoding % (input.encoding) //hanxin.before exec /tobin { string dup length 1 sub 0 exch 1 exch {1 index exch 48 put} for dup 3 -1 roll 2 2 index length string cvrs dup length 2 index length exch sub exch putinterval } def /numD [ msglen {0} repeat 0 ] def msglen 1 sub -1 0 { /i exch def msg i get dup 48 ge exch 57 le and { numD i numD i 1 add get 1 add put } if } for % % Byte-mode encoder with numeric run switching, including FNC1 support % mark /i 0 def /bytestart -1 def { % loop i msglen ge { bytestart -1 ne { //hanxin.BYT msg bytestart i bytestart sub getinterval } if exit } if /d numD i get def d i d add msglen ge {5} {8} ifelse ge { bytestart -1 ne { //hanxin.BYT msg bytestart i bytestart sub getinterval /bytestart -1 def } if //hanxin.NUM msg i d getinterval /i i d add def } { msg i get //hanxin.fn1 eq { bytestart -1 ne { //hanxin.BYT msg bytestart i bytestart sub getinterval /bytestart -1 def } if //hanxin.FN1SEP null /i i 1 add def } { bytestart -1 eq { /bytestart i def } if /i i 1 add def } ifelse } ifelse } loop counttomark array astore exch pop /seq exch def % % Reject byte chunks larger than the 13-bit count field can express % 0 2 seq length 1 sub { /si exch def seq si get //hanxin.BYT eq { seq si 1 add get length 1 13 bitshift ge { /bwipp.hanxinInputTooLarge (The input data exceeds the maximum symbol capacity) //raiseerror exec } if } if } for % % Optimise when NUM and FN1SEP run together % /numRhs { % "{FNC1}N..." => N drops indicator dup 0 gt { seq 1 index 2 sub get //hanxin.FN1SEP eq } { false } ifelse exch pop } def /numLhs { % "N%3{FNC1}" => N drops terminator dup 2 add seq length lt { seq 1 index 2 add get //hanxin.FN1SEP eq seq 2 index 1 add get length 3 mod 0 eq and } { false } ifelse exch pop } def /fncRhs { % "{FNC1}N..." => FNC1 drops terminator dup 2 add seq length lt { seq 1 index 2 add get //hanxin.NUM eq } { false } ifelse exch pop } def /fncLhs { % "N%3{FNC1}" => FNC1 drops indicator dup 0 gt { seq 1 index 2 sub get //hanxin.NUM eq { seq 1 index 1 sub get length 3 mod 0 eq } { false } ifelse } { false } ifelse exch pop } def /addtobits { dup length pos add bits length gt { pop /bwipp.hanxinNoValidSymbol (Maximum length exceeded or invalid content) //raiseerror exec } if dup bits pos 3 -1 roll putinterval length pos add /pos exch def } def % % Encode the sequence, merging FNC1 at numeric boundaries % /bits 26120 string def /pos 0 def fnc1first { //hanxin.gs1pre addtobits } if 0 2 seq length 1 sub { /si exch def /st seq si get def st //hanxin.BYT eq { /sd seq si 1 add get def (0011) addtobits sd length 13 tobin addtobits sd { 8 tobin addtobits } forall } { st //hanxin.FN1SEP eq { si fncLhs not { (0001) addtobits } if //hanxin.fnc1ext addtobits si fncRhs not { (1111111111) addtobits } if } { % //hanxin.NUM /sd seq si 1 add get def /D sd length def si numRhs not { (0001) addtobits } if /numgroups D 3 div ceiling cvi def 0 1 numgroups 1 sub { /gstart exch 3 mul def /gsize D gstart sub 3 lt {D gstart sub} {3} ifelse def 0 0 1 gsize 1 sub { sd exch gstart add get 48 sub exch 10 mul add } for 10 tobin addtobits } for si numLhs not { D 1 sub 3 mod 0 eq { (1111111101) } { D 1 sub 3 mod 1 eq { (1111111110) } { (1111111111) } ifelse } ifelse addtobits } if } ifelse } ifelse } for fnc1first { //hanxin.gs1post addtobits } if /bits bits 0 pos getinterval def options /debugbits known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugbits bits //raiseerror exec } if % % Lookup the most appropriate symbol specification % /eclval eclevel 1 get 49 sub def //hanxin.metrics { /m exch def /vers m 0 get def % Version of symbol /size m 1 get def % Length of side /alnk m 2 get def % Regular alignment pattern length /alnn m 3 get def % Number of alignment patterns /alnr size alnk alnn mul sub def % Remainder alignment pattern length /nmod m 4 get def % Number of modules /ncws nmod 8 idiv def % Total number of codewords /rbit nmod 8 mod def % Number of remainder bits /ecbs m 5 eclval 3 mul add 3 getinterval def % Error correction blocks /ecws 0 ecbs {dup 0 get exch 2 get mul add} forall def % Number of error correction codewords /dcws ncws ecws sub def % Number of data codewords /dmod dcws 8 mul def % Number of data modules /okay true def version (unset) ne version vers ne and {/okay false def} if % The version must match that supplied bits length dmod gt {/okay false def} if % Bitstream must fit into data modules okay {exit} if } forall okay not { /bwipp.hanxinNoValidSymbol (Maximum length exceeded or invalid content) //raiseerror exec } if /version vers def /msgbits bits def /e1nb ecbs 0 get 0 get def /e2nb ecbs 1 get 0 get def /e3nb ecbs 2 get 0 get def /e1dcws ecbs 0 get 1 get def /e2dcws ecbs 1 get 1 get def /e3dcws ecbs 2 get 1 get def /e1ecws ecbs 0 get 2 get def /e2ecws ecbs 1 get 2 get def /e3ecws ecbs 2 get 2 get def % % Expand the message bits by adding padding as necessary % /pad dmod string def 0 1 pad length 1 sub {pad exch 48 put} for pad 0 msgbits putinterval % % Evaluate the padded message into codewords % /cws dcws array def 0 1 cws length 1 sub { /c exch def /cwb pad c 8 mul 8 getinterval def /cw 0 def 0 1 7 { /i exch def /cw cw 2 8 i sub 1 sub exp cvi cwb i get 48 sub mul add def } for cws c cw put } for options /debugcws known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugcws cws //raiseerror exec } if (input.encoding) //hanxin.after exec /rscodes { /rsbt exch def /rsnc exch def /rscws exch def % % Fetch the coefficients % (ecc.coeffs) //hanxin.before exec /coeffs rsnc rsbt //hanxin.coeffscachefetch exec def (ecc.coeffs) //hanxin.after exec % % Calculate the error correction codewords % (ecc.cws) //hanxin.before exec /lfsr rsnc array def {rscws exch get} rscws length coeffs rsnc lfsr //hanxin.rsprod //rsecbinary exec lfsr (ecc.cws) //hanxin.after exec } def % % Divide codewords into two groups of blocks and calculate the error correction codewords % /dcwsb e1nb e2nb add e3nb add array def /ecwsb dcwsb length array def /in 0 def /out 0 def e1nb { cws in e1dcws getinterval dup dcwsb out 3 -1 roll put e1ecws 8 rscodes ecwsb out 3 -1 roll put /in in e1dcws add def /out out 1 add def } repeat e2nb { cws in e2dcws getinterval dup dcwsb out 3 -1 roll put e2ecws 8 rscodes ecwsb out 3 -1 roll put /in in e2dcws add def /out out 1 add def } repeat e3nb { cws in e3dcws getinterval dup dcwsb out 3 -1 roll put e3ecws 8 rscodes ecwsb out 3 -1 roll put /in in e3dcws add def /out out 1 add def } repeat options /debugecc known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugecc [ ecwsb {aload pop} forall ] //raiseerror exec } if (codewords.finalise) //hanxin.before exec % % Reassemble the codewords % /cws ncws array def /cw 0 def 0 1 dcwsb length 1 sub { /i exch def dcwsb i get dup cws exch cw exch putinterval length cw add /cw exch def ecwsb i get dup cws exch cw exch putinterval length cw add /cw exch def } for % % Split codewords into groups of 13 and concatenate % /cws [ 0 1 ncws 1 sub 12 2 copy gt {exch} if pop { 13 ncws 1 sub { dup ncws lt {cws exch get} {pop} ifelse } for } for ] def % % Extend codewords by one if there are remainder bits % rbit 0 gt { /pad cws length 1 add array def pad 0 cws putinterval pad pad length 1 sub 0 put /cws pad def } if (codewords.finalise) //hanxin.after exec (matrix.layout) //hanxin.before exec % % Create the bitmap % /pixs [ size size mul {-1} repeat ] def /qmv {size mul add} def % % Alignment patterns % alnn 0 ne { /trmv {size mul size add 1 sub exch sub} def /aplot { 3 1 roll 3 copy exch trmv pixs exch 3 -1 roll put trmv pixs exch 3 -1 roll put } def /i 0 def /stag 0 def { i size ge {exit} if 0 1 size 1 sub { /j exch def j alnr add size lt { j alnk idiv stag add 2 mod 0 eq % Staggered groups of k modules i 0 eq j alnk lt and not and % Keep clear at top right j alnk mod 0 eq or % Complete regular-spaced grid } { alnn stag add 2 mod 0 eq % Bottom right remainder } ifelse { j i 1 aplot j 1 add i 1 add 2 copy size lt exch size lt and {0 aplot} {pop pop} ifelse } if } for i alnr add size eq { /i i alnr add 1 sub def } { /i i alnk add def } ifelse /stag 1 stag sub def } loop alnk alnk size 2 sub { /i exch def i alnk idiv 2 mod 0 ne { pixs 0 i 1 sub trmv 0 put pixs 0 i 1 add trmv 0 put pixs 1 i 1 sub trmv 0 put pixs 1 i trmv 0 put pixs 1 i 1 add trmv 0 put pixs i 1 sub 0 trmv 0 put pixs i 1 add 0 trmv 0 put pixs i 1 sub 1 trmv 0 put pixs i 1 trmv 0 put pixs i 1 add 1 trmv 0 put } if pixs size 1 sub i 1 sub trmv get 1 ne { pixs size 1 sub i 1 sub trmv 0 put pixs size 2 sub i 1 sub trmv 0 put pixs size 2 sub i trmv 0 put pixs size 2 sub i 1 add trmv 0 put pixs size 1 sub i 1 add trmv 0 put pixs i 1 sub size 1 sub trmv 0 put pixs i 1 sub size 2 sub trmv 0 put pixs i size 2 sub trmv 0 put pixs i 1 add size 2 sub trmv 0 put pixs i 1 add size 1 sub trmv 0 put } if } for } if % % Finder patterns % 0 1 //hanxin.fpat length 1 sub { /y exch def 0 1 //hanxin.fpat 0 get length 1 sub { /x exch def /fpb //hanxin.fpat y get x get def /fpb2 //hanxin.fpat2 y get x get def pixs x y qmv fpb put pixs size x sub 1 sub y qmv fpb put pixs size x sub 1 sub size y sub 1 sub qmv fpb put pixs x size y sub 1 sub qmv fpb2 put } for } for % % Derive the function module map % /functionmap [ //hanxin.funmap { [ exch { size exch exec 2 array astore } forall ] } forall ] def % % Reserve the format information modules % functionmap { { aload pop qmv pixs exch 0 put } forall } forall /maskfuncs //hanxin.maskfuncs def mask -1 ne { % User specifies a mask /maskfuncs [//hanxin.maskfuncs mask 1 sub get] def /bestmaskval mask 1 sub def } if % % Build a candidate mask layer for each mask function % /masks maskfuncs length array def 0 1 masks length 1 sub { /m exch def /mask size size mul array def 0 1 size 1 sub { /j exch def 0 1 size 1 sub { /i exch def i 1 add j 1 add maskfuncs m get exec 0 eq pixs i j qmv get -1 eq and {1} {0} ifelse mask i j qmv 3 -1 roll put } for } for masks m mask put } for % % Walk the symbol placing the bitstream % /posx 0 def /posy 0 def /num 0 def { % loop posy size eq {exit} if pixs posx posy qmv get -1 eq { cws num 8 idiv get 7 num 8 mod sub neg bitshift 1 and pixs posx posy qmv 3 -1 roll put /num num 1 add def } if /posx posx 1 add def posx size eq {/posx 0 def /posy posy 1 add def} if } loop (matrix.layout) //hanxin.after exec (matrix.evaluate) //hanxin.before exec % % Evaluate runlength encoded rows or columns in full symbols % /evalfulln1n3 { /scrle exch def % Detect runs of 3 or more like modules /scr1 0 scrle { dup 3 ge {4 mul add dup} if pop } forall def /scr3 0 def % Detect 1:1:1:1:3 ratio next to 3 modules of whitespace 5 2 scrle length 1 sub { % Scan odd (dark) runs within bounds /j exch def scrle j get 3 mod 0 eq { % Multiple of 3 black modules /fact scrle j get 3 idiv def scrle j 4 sub 4 getinterval {fact eq} forall and and and { j 5 eq j 2 add scrle length ge or { % At either extent of run /scr3 scr3 50 add def } { % Bounded by dark modules scrle j 5 sub get 3 ge scrle j 1 add get 3 ge or { /scr3 scr3 50 add def } if } ifelse } if } if } for % Detect 3:1:1:1:1 ratio next to 3 modules of whitespace 1 2 scrle length 5 sub { % Scan odd (dark) runs within bounds /j exch def scrle j get 3 mod 0 eq { % Multiple of 3 black modules /fact scrle j get 3 idiv def scrle j 1 add 4 getinterval {fact eq} forall and and and { j 1 eq j 6 add scrle length ge or { % At either extent of run /scr3 scr3 50 add def } { % Bounded by dark modules scrle j 1 sub get 3 ge scrle j 5 add get 3 ge or { /scr3 scr3 50 add def } if } ifelse } if } if } for scr1 scr3 } def % % Evaluation algorithm % /evalfull { /sym exch def /n1 0 def /n3 0 def /rle size 1 add array def /lastpairs size array def /thispairs size array def /sizeadd1 size 1 add def 0 1 size 1 sub { /i exch def % Runlength encode (light, dark, light, ...) and evaluate each column mark 0 0 i size dup dup mul 1 sub { sym exch get exch 1 index eq {exch 1 add exch} {1 exch} ifelse } for pop rle 0 counttomark 2 sub getinterval astore evalfulln1n3 n3 add /n3 exch def n1 add /n1 exch def pop % Runlength encode (light, dark, light, ...) and evaluate each row /symrow sym i size mul size getinterval def mark 0 0 symrow { exch 1 index eq {exch 1 add exch} {1 exch} ifelse } forall pop rle 0 counttomark 2 sub getinterval astore evalfulln1n3 n3 add /n3 exch def n1 add /n1 exch def pop } for n1 n3 add } def % % Evaluate the masked symbols to find the most suitable % /bestscore 999999999 def 0 1 masks length 1 sub { /m exch def /masksym size size mul array def 0 1 size size mul 1 sub { /i exch def masksym i pixs i get masks m get i get xor put } for masks length 1 ne { masksym evalfull /score exch def score bestscore lt { /bestsym masksym def /bestmaskval m def /bestscore score def } if } { /bestsym masksym def } ifelse } for /pixs bestsym def (matrix.evaluate) //hanxin.after exec % % Add the function information % /funval size 21 sub 2 idiv 20 add 4 mul eclval add 4 mul bestmaskval add def /fundata [ funval 16#0F00 and -8 bitshift funval 16#00F0 and -4 bitshift funval 16#000F and ] def /funbits [ fundata { 4 tobin {48 sub} forall } forall fundata 4 4 rscodes { 4 tobin {48 sub} forall } forall 0 1 0 1 0 1 ] def 0 1 functionmap length 1 sub { /i exch def functionmap i get { pixs exch aload pop qmv funbits i get put } forall } for << /ren /renmatrix /pixs pixs /pixx size /pixy size /height size modunit mul 72 div /width size modunit mul 72 div /borderleft 3.0 /borderright 3.0 /bordertop 3.0 /borderbottom 3.0 /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /hanxin dup load /uk.co.terryburton.bwipp defineresource pop (setup.define) //hanxin.after exec end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER hanxin-- % --BEGIN ENCODER dotcode-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor fifocache rsecprime render renmatrix-- % --DESC: DotCode % --EXAM: This is DotCode % --EXOP: inkspread=0.16 % --RNDR: renmatrix % --FMLY: Less-used Symbols %%BeginResource: uk.co.terryburton.bwipp dotcode 0.0 2026052800 318783 317254 %%BeginData: 1304 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 33 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /fifocache dup /uk.co.terryburton.bwipp findresource put dup /rsecprime dup /uk.co.terryburton.bwipp findresource put dup /setuphooks dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put begin /dotcode [/before /after] //setuphooks exec (setup.define) //dotcode.before exec /dotcode.laa -1 def /dotcode.lab -2 def /dotcode.lac -3 def /dotcode.bin -4 def /dotcode.sfa -5 def /dotcode.sfb -6 def /dotcode.sb2 -7 def /dotcode.sb3 -8 def /dotcode.sb4 -9 def /dotcode.sb5 -10 def /dotcode.sb6 -11 def /dotcode.sfc -12 def /dotcode.sc2 -13 def /dotcode.sc3 -14 def /dotcode.sc4 -15 def /dotcode.sc5 -16 def /dotcode.sc6 -17 def /dotcode.sc7 -18 def /dotcode.bsa -19 def /dotcode.bsb -20 def /dotcode.tma -21 def /dotcode.tmb -22 def /dotcode.tmc -23 def /dotcode.tms -24 def /dotcode.fn1 -25 def /dotcode.fn2 -26 def /dotcode.fn3 -27 def /dotcode.crl -28 def /dotcode.aim -29 def /dotcode.m05 -30 def /dotcode.m06 -31 def /dotcode.m12 -32 def /dotcode.mac -33 def /laa //dotcode.laa def /lab //dotcode.lab def /lac //dotcode.lac def /bin //dotcode.bin def /sfa //dotcode.sfa def /sfb //dotcode.sfb def /sb2 //dotcode.sb2 def /sb3 //dotcode.sb3 def /sb4 //dotcode.sb4 def /sb5 //dotcode.sb5 def /sb6 //dotcode.sb6 def /sfc //dotcode.sfc def /sc2 //dotcode.sc2 def /sc3 //dotcode.sc3 def /sc4 //dotcode.sc4 def /sc5 //dotcode.sc5 def /sc6 //dotcode.sc6 def /sc7 //dotcode.sc7 def /bsa //dotcode.bsa def /bsb //dotcode.bsb def /tma //dotcode.tma def /tmb //dotcode.tmb def /tmc //dotcode.tmc def /tms //dotcode.tms def /fn1 //dotcode.fn1 def /fn2 //dotcode.fn2 def /fn3 //dotcode.fn3 def /crl //dotcode.crl def /aim //dotcode.aim def /m05 //dotcode.m05 def /m06 //dotcode.m06 def /m12 //dotcode.m12 def /mac //dotcode.mac def /dotcode.charmaps [ % A B C A B C A B C [ 32 32 (00) ] [ (!) (!) (01) ] [ (") (") (02) ] % 0-2 [ (#) (#) (03) ] [ ($) ($) (04) ] [ (%) (%) (05) ] % 3-5 [ (&) (&) (06) ] [ (') (') (07) ] [ 40 40 (08) ] % 6-8 [ 41 41 (09) ] [ (*) (*) (10) ] [ (+) (+) (11) ] % 9-11 [ (,) (,) (12) ] [ (-) (-) (13) ] [ (.) (.) (14) ] % 12-14 [ (/) (/) (15) ] [ (0) (0) (16) ] [ (1) (1) (17) ] % 15-17 [ (2) (2) (18) ] [ (3) (3) (19) ] [ (4) (4) (20) ] % 18-20 [ (5) (5) (21) ] [ (6) (6) (22) ] [ (7) (7) (23) ] % 21-23 [ (8) (8) (24) ] [ (9) (9) (25) ] [ (:) (:) (26) ] % 24-26 [ (;) (;) (27) ] [ (<) (<) (28) ] [ (=) (=) (29) ] % 27-29 [ (>) (>) (30) ] [ (?) (?) (31) ] [ (@) (@) (32) ] % 30-32 [ (A) (A) (33) ] [ (B) (B) (34) ] [ (C) (C) (35) ] % 33-35 [ (D) (D) (36) ] [ (E) (E) (37) ] [ (F) (F) (38) ] % 36-38 [ (G) (G) (39) ] [ (H) (H) (40) ] [ (I) (I) (41) ] % 39-41 [ (J) (J) (42) ] [ (K) (K) (43) ] [ (L) (L) (44) ] % 42-44 [ (M) (M) (45) ] [ (N) (N) (46) ] [ (O) (O) (47) ] % 45-47 [ (P) (P) (48) ] [ (Q) (Q) (49) ] [ (R) (R) (50) ] % 48-50 [ (S) (S) (51) ] [ (T) (T) (52) ] [ (U) (U) (53) ] % 51-53 [ (V) (V) (54) ] [ (W) (W) (55) ] [ (X) (X) (56) ] % 54-56 [ (Y) (Y) (57) ] [ (Z) (Z) (58) ] [ ([) ([) (59) ] % 57-59 [ 92 92 (60) ] [ (]) (]) (61) ] [ (^) (^) (62) ] % 60-62 [ (_) (_) (63) ] [ 0 (`) (64) ] [ 1 (a) (65) ] % 63-65 [ 2 (b) (66) ] [ 3 (c) (67) ] [ 4 (d) (68) ] % 66-68 [ 5 (e) (69) ] [ 6 (f) (70) ] [ 7 (g) (71) ] % 69-71 [ 8 (h) (72) ] [ 9 (i) (73) ] [ 10 (j) (74) ] % 72-74 [ 11 (k) (75) ] [ 12 (l) (76) ] [ 13 (m) (77) ] % 75-77 [ 14 (n) (78) ] [ 15 (o) (79) ] [ 16 (p) (80) ] % 78-80 [ 17 (q) (81) ] [ 18 (r) (82) ] [ 19 (s) (83) ] % 81-83 [ 20 (t) (84) ] [ 21 (u) (85) ] [ 22 (v) (86) ] % 84-86 [ 23 (w) (87) ] [ 24 (x) (88) ] [ 25 (y) (89) ] % 87-89 [ 26 (z) (90) ] [ 27 ({) (91) ] [ 28 (|) (92) ] % 90-92 [ 29 (}) (93) ] [ 30 (~) (94) ] [ 31 127 (95) ] % 93-95 [ sfb crl (96) ] [ sb2 9 (97) ] [ sb3 28 (98) ] % 96-98 [ sb4 29 (99) ] [ sb5 30 aim ] [ sb6 sfa laa ] % 99-101 [ lab laa sfb ] [ sc2 sc2 sb2 ] [ sc3 sc3 sb3 ] % 102-104 [ sc4 sc4 sb4 ] [ lac lac lab ] [ fn1 fn1 fn1 ] % 105-107 [ fn2 fn2 fn2 ] [ fn3 fn3 fn3 ] [ bsa bsa bsa ] % 108-110 [ bsb bsb bsb ] [ bin bin bin ] % 111-112 ] readonly def /dotcode.encs [ (101010101) (010101011) (010101101) (010110101) (011010101) (101010110) (101011010) (101101010) (110101010) (010101110) (010110110) (010111010) (011010110) (011011010) (011101010) (100101011) (100101101) (100110101) (101001011) (101001101) (101010011) (101011001) (101100101) (101101001) (110010101) (110100101) (110101001) (001010111) (001011011) (001011101) (001101011) (001101101) (001110101) (010010111) (010011011) (010011101) (010100111) (010110011) (010111001) (011001011) (011001101) (011010011) (011011001) (011100101) (011101001) (100101110) (100110110) (100111010) (101001110) (101011100) (101100110) (101101100) (101110010) (101110100) (110010110) (110011010) (110100110) (110101100) (110110010) (110110100) (111001010) (111010010) (111010100) (001011110) (001101110) (001110110) (001111010) (010011110) (010111100) (011001110) (011011100) (011100110) (011101100) (011110010) (011110100) (100010111) (100011011) (100011101) (100100111) (100110011) (100111001) (101000111) (101100011) (101110001) (110001011) (110001101) (110010011) (110011001) (110100011) (110110001) (111000101) (111001001) (111010001) (000101111) (000110111) (000111011) (000111101) (001001111) (001100111) (001110011) (001111001) (010001111) (011000111) (011100011) (011110001) (100011110) (100111100) (101111000) (110001110) (110011100) (110111000) (111000110) (111001100) ] readonly def /dotcode.encfuncs [ /encA /encB /encC /encBIN ] readonly def /dotcode.maskvals [ 0 3 7 17 ] readonly def /dotcode.maskbits [ (00) (01) (10) (11) ] readonly def /dotcode.latevars dup 16 dict def load /init { (setup.latevars) //dotcode.before exec currentglobal true setglobal //dotcode.latevars begin /rsalog [ 1 112 { dup 3 mul 113 mod } repeat ] readonly def % % Invert charmaps to give character to value maps for each state % /charvals [ 113 dict 117 dict 113 dict ] def 0 1 //dotcode.charmaps length 1 sub { /i exch def /encs //dotcode.charmaps i get def 0 1 2 { /j exch def encs j get dup type /stringtype eq {0 get} if % convert string to ASCII if required charvals j get exch i put } for } for /Avals charvals 0 get readonly def /Bvals charvals 1 get def Bvals //dotcode.m05 97 put Bvals //dotcode.m06 98 put Bvals //dotcode.m12 99 put Bvals //dotcode.mac 100 put /Bvals Bvals readonly def /Cvals charvals 2 get readonly def /charvals charvals readonly def /BINvals << 102 [ //dotcode.sc2 //dotcode.sc3 //dotcode.sc4 //dotcode.sc5 //dotcode.sc6 //dotcode.sc7 //dotcode.tma //dotcode.tmb //dotcode.tmc //dotcode.tms ] {exch 1 add dup} forall pop >> readonly def /init { //dotcode.latevars {def} forall } def end //dotcode.latevars /init get exec setglobal (setup.latevars) //dotcode.after exec } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//dotcode.latevars /init get exec} if } {pop} ifelse % % Generate Reed-Solomon coefficients for given NC (uses rsalog from currentdict) % /dotcode.gencoeffs { /coeffs [ 1 NC {0} repeat ] def 1 1 NC { NC -1 1 { coeffs 1 index 2 copy get 113 add % ... coeffs j coeffs[j]+113 rsalog 5 index get % ... rsalog[i] coeffs 6 -1 roll 1 sub get % ... coeffs[j-1] mul 113 mod % p = (rsalog[i] * coeffs[j-1]) mod 113 sub 113 mod put % coeffs[j] = ((coeffs[j]+113) - p) mod 113 } for pop % i } for % Flip to standard g(x) form: drop the leading 1 and reverse coeffs[1..NC] % so the constant term ends up at index 0. NC -1 1 { coeffs exch get } for NC array astore } bind def % % FIFO cache for ECC polynomials % % 79 unique keys: NC=1-79 continuous range from symbol interleaving % /dotcode.coeffscachemax 79 def % Override with global_ctx.dotcode.coeffscachemax /dotcode.coeffscachelimit 3160 def % Override with global_ctx.dotcode.coeffscachelimit /uk.co.terryburton.bwipp.global_ctx dup where { exch get dup /dotcode.coeffscachemax 2 copy known {get /dotcode.coeffscachemax exch def} {pop pop} ifelse /dotcode.coeffscachelimit 2 copy known {get /dotcode.coeffscachelimit exch def} {pop pop} ifelse } {pop} ifelse /dotcode.coeffscache dotcode.coeffscachemax dotcode.coeffscachelimit //fifocache exec def /dotcode.coeffscachefetch { /NC exch def NC { //dotcode.gencoeffs exec } { length } //dotcode.coeffscache /fetch get exec } bind def /dotcode { 128 dict begin { (input.processoptions) //dotcode.before exec /dontdraw false def /rows -1 def /columns -1 def /ratio -1.0 def /parse false def /parsefnc false def /raw false def /fast false def /mask -1 def /strictspec false def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def barcode length 2000 gt { /bwipp.dotcodeinputTooLong (The input data is too long) //raiseerror exec } if /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def /modunit 2 def /uk.co.terryburton.bwipp.global_ctx dup where { exch get /default_modunit 2 copy known {get /modunit exch def} {pop pop} ifelse } {pop} ifelse % % Apply AST spec overrides and resolve physical specification % /dotcode ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec (input.processoptions) //dotcode.after exec //dotcode.latevars /init get exec (input.validate) //dotcode.before exec rows -1 ne { rows 5 lt rows 200 gt or { /bwipp.dotcodeBadRows (Rows must be from 5 to 200) //raiseerror exec } if } if columns -1 ne { columns 5 lt columns 200 gt or { /bwipp.dotcodeBadColumns (Columns must be from 5 to 200) //raiseerror exec } if } if rows -1 ne columns -1 ne and rows columns add 2 mod 1 ne and { /bwipp.dotcodeRowsColumnsBadParity (Sum of rows and columns must be odd) //raiseerror exec } if % % Set the ratio to 3:2 if no size is specified % ratio -1 eq rows -1 eq and columns -1 eq and { /ratio 3 2 div def } if ratio -1 ne { ratio 0 le { /bwipp.dotcodeRatio (The ratio must be greater than 0) //raiseerror exec } if } if mask -1 ne { mask 0 lt mask 3 gt or { /bwipp.dotcodeBadMask (Valid mask values are 0 to 3) //raiseerror exec } if } if (input.validate) //dotcode.after exec % % Parse the input % (input.preprocess) //dotcode.before exec /fncvals << /parse parse /parsefnc parsefnc /eci true (FNC1) //dotcode.fn1 % (FNC2) fn2 % Use ^ECInnnnnn for ECI; Structured append not supported (FNC3) //dotcode.fn3 >> def barcode fncvals //parseinput exec /msg exch def /msglen msg length def % % Special FNC2 semantics: Expand ECI characters into ^FNC2nnnnnn % /numecis 0 msg { -1000000 le {1 add} if } forall def /msgtmp msg length numecis 6 mul add array def /j 0 def 0 1 msg length 1 sub { msg exch get dup -1000000 le { neg 10 7 string cvrs 1 6 getinterval {} forall 6 array astore msgtmp exch j 1 add exch putinterval msgtmp j //dotcode.fn2 put /j j 7 add def } { msgtmp exch j exch put /j j 1 add def } ifelse } for /msg msgtmp def /msglen msg length def (input.preprocess) //dotcode.after exec (input.encoding) //dotcode.before exec /A 0 def /B 1 def /C 2 def /BIN 3 def % % Pre-compute properties of the input at each point % /nDigits [ msglen 1 add {0} repeat ] def /SeventeenTen [ msglen 1 add {false} repeat ] def /ECI [ msglen 1 add {false} repeat ] def /DatumA [ msglen 1 add {false} repeat ] def /DatumB [ msglen 1 add {false} repeat ] def /DatumC [ msglen 1 add {false} repeat ] def /Binary [ msglen 8 add {false} repeat ] def /AheadC [ msglen 1 add {0} repeat ] def /TryC [ msglen 1 add {0} repeat ] def /AheadA [ msglen 1 add {0} repeat ] def /AheadB [ msglen 1 add {0} repeat ] def /UntilEndSeg [ msglen 1 add {0} repeat ] def msglen 1 sub -1 0 { /i exch def /barchar msg i get def barchar 48 ge barchar 57 le and { nDigits i nDigits i 1 add get 1 add put } if Avals barchar known {DatumA i true put} if Bvals barchar known {DatumB i true put} if /CRLF false def barchar 13 eq i msglen 1 sub lt and { msg i 1 add get 10 eq {/CRLF true def} if } if CRLF {DatumB i true put} if nDigits i get 2 ge {DatumC i true put} if barchar 0 lt {DatumC i true put} if % FNCx barchar 128 ge {Binary i true put} if nDigits i get 10 ge { % 17xxxxxx10 mark msg i 10 getinterval aload pop 1 { % common exit 48 ne {false exit} if 49 ne {false exit} if pop pop pop pop pop pop 55 ne {false exit} if 49 ne {false exit} if true } repeat SeventeenTen i 3 -1 roll put cleartomark } if nDigits i 1 add get 6 ge msg i get //dotcode.fn2 eq and { % ^FNC2xxxxxx ECI i true put } if barchar 0 lt barchar //dotcode.fn3 ne and { % FNCx, except FNC3 AheadC i AheadC i 1 add get 1 add put } { nDigits i get 1 le { AheadC i 0 put } { AheadC i AheadC i 2 add get 1 add put } ifelse } ifelse nDigits i get 0 gt AheadC i get AheadC i 1 add get gt and { TryC i AheadC i get put } if DatumA i get TryC i get 2 lt and barchar //dotcode.fn3 ne and { AheadA i AheadA i 1 add get 1 add put } if DatumB i get TryC i get 2 lt and barchar //dotcode.fn3 ne and { AheadB i AheadB i 1 add CRLF {1 add} if get 1 add put } if barchar //dotcode.fn3 ne { UntilEndSeg i UntilEndSeg i 1 add get 1 add put } if } for /addtocws { dup cws exch j exch putinterval /j exch length j add def } def % % Base 259 to one more in base 103 % /base259to103 { /in exch def /inlen in length def /in [ 5 inlen sub {0} repeat in aload pop ] def /out 6 array def /msbs [ in 0 2 getinterval aload pop ] def /mscs [ msbs aload pop exch 259 mul add 2 {dup 103 mod exch 103 idiv} repeat ] def /lsbs [ in 2 3 getinterval aload pop ] def /lscs [ lsbs aload pop exch 259 mul add exch 67081 mul add 3 {dup 103 mod exch 103 idiv} repeat ] def lscs 0 get mscs 0 get 42 mul add out 5 2 index 103 mod put 103 idiv lscs 1 get add mscs 0 get 68 mul add mscs 1 get 42 mul add out 4 2 index 103 mod put 103 idiv lscs 2 get add mscs 0 get 92 mul add mscs 1 get 68 mul add mscs 2 get 42 mul add out 3 2 index 103 mod put 103 idiv lscs 3 get add mscs 0 get 15 mul add mscs 1 get 92 mul add mscs 2 get 68 mul add out 2 2 index 103 mod put 103 idiv mscs 1 get 15 mul add mscs 2 get 92 mul add out 1 2 index 103 mod put 103 idiv mscs 2 get 15 mul add out 0 3 -1 roll 103 mod put out 6 inlen sub 1 sub inlen 1 add getinterval } def /finaliseBIN { bpos 0 ne { bvals 0 bpos getinterval base259to103 aload pop /bpos 0 def } if } def /addtobin { bvals exch bpos exch put /bpos bpos 1 add def bpos 5 eq { finaliseBIN } if } def /ECIabc { % ECI encoding for modes A, B and C msg i 1 add 6 getinterval 0 exch {48 sub add 10 mul} forall 10 idiv dup 40 ge { 40 sub dup 12769 idiv 40 add exch 12769 mod dup 113 idiv exch 113 mod } if } def /ECIbin { % ECI encoding for binary mode [ msg i 1 add 6 getinterval 0 exch {48 sub add 10 mul} forall 10 idiv dup 65536 ge { 258 exch dup 65536 idiv exch 65536 mod dup 256 idiv exch 256 mod } { dup 256 ge { 257 exch dup 256 idiv exch 256 mod } { 256 exch } ifelse } ifelse ] { addtobin } forall } def /encC { 1 { % Common exit i segstart eq { % Structured data macros 1 { % common exit i segend 7 sub gt {0 exit} if msg segstart get 91 ne {0 exit} if % [ msg segstart 1 add get 41 ne {0 exit} if % ) msg segstart 2 add get 62 ne {0 exit} if % > msg segstart 3 add get 30 ne {0 exit} if % {RS} msg segstart 4 add get dup 48 lt exch 57 gt or {0 exit} if % digit msg segstart 5 add get dup 48 lt exch 57 gt or {0 exit} if % digit msg segend 1 sub get 4 ne {0 exit} if % End: {EOT} msg segstart 4 add get 48 sub 10 mul msg segstart 5 add get 48 sub add dup dup 05 ne exch dup 06 ne exch 12 ne and and {pop //dotcode.mac exit} if msg segstart 6 add get 29 ne {pop 0 exit} if % {GS} msg segend 2 sub get 30 ne {pop 0 exit} if % End: {RS} dup 05 eq {pop //dotcode.m05 exit} if 06 eq { //dotcode.m06 exit} if //dotcode.m12 exit } repeat /inmac exch def inmac 0 ne { [ Cvals //dotcode.lab get ] addtocws /mode B def [ Bvals inmac get ] addtocws inmac //dotcode.mac eq { [ Bvals msg segstart 4 add get get ] addtocws [ Bvals msg segstart 5 add get get ] addtocws /i i 6 add def } { /i i 7 add def } ifelse exit } if } if % Special treatment of FNC1 in First for Dotcode i segstart eq { % Encode an FNC1 if two digits start a segment nDigits i get 2 ge { [ Cvals //dotcode.fn1 get ] addtocws } if % Skip an FNC1 if followed by two digits at start of segment msg i get //dotcode.fn1 eq nDigits i 1 add get 2 ge and { /i i 1 add def } if } if SeventeenTen i get { [ % 17xxxxxx10 macro Cvals //dotcode.aim get msg i 2 add get 48 sub 10 mul msg i 3 add get 48 sub add msg i 4 add get 48 sub 10 mul msg i 5 add get 48 sub add msg i 6 add get 48 sub 10 mul msg i 7 add get 48 sub add ] addtocws /i i 10 add def exit } if DatumC i get { msg i get dup //dotcode.fn1 eq exch dup //dotcode.fn2 eq exch //dotcode.fn3 eq or or { % FNCx [ Cvals msg i get get ] addtocws ECI i get { % FNC2 then 6 digits [ ECIabc ] addtocws /i i 7 add def exit } if msg i get //dotcode.fn3 eq segstart i ne and { % FNC3 /i i 1 add def /inmac 0 def /segstart i def /segend i UntilEndSeg i get add def exit } if /i i 1 add def exit } if [ msg i get 48 sub 10 mul msg i 1 add get 48 sub add ] addtocws /i i 2 add def exit } if Binary i get { % Binary nDigits i 1 add get 0 gt { msg i get 160 lt { [ Cvals //dotcode.bsa get Avals msg i get 128 sub get ] addtocws } { [ Cvals //dotcode.bsb get Bvals msg i get 128 sub get ] addtocws } ifelse /i i 1 add def exit } if [ Cvals //dotcode.bin get ] addtocws /mode BIN def exit } if /m AheadA i get def /n AheadB i get def m n gt { [ Cvals //dotcode.laa get ] addtocws /mode A def exit } if i segstart eq { msg i get dup 9 eq exch dup 28 eq exch dup 29 eq exch 30 eq or or or { [ Cvals //dotcode.laa get ] addtocws /mode A def exit } if } if n 4 gt { [ Cvals //dotcode.lab get ] addtocws /mode B def exit } if [ Cvals [ //dotcode.sfb //dotcode.sb2 //dotcode.sb3 //dotcode.sb4 ] n 1 sub get get ] addtocws n { msg i get 13 eq { [ Bvals //dotcode.crl get ] addtocws /i i 2 add def } { [ Bvals msg i get get ] addtocws /i i 1 add def } ifelse } repeat exit } repeat } def % encC /encB { 1 { % Common exit /n TryC i get def n 2 ge { n 4 gt { [ Bvals //dotcode.lac get ] addtocws /mode C def exit } if [ Bvals [ //dotcode.sfc //dotcode.sc2 //dotcode.sc3 //dotcode.sc4 ] n 1 sub get get ] addtocws n { msg i get 0 lt { [ Cvals msg i get get ] addtocws /i i 1 add def } { [ msg i get 48 sub 10 mul msg i 1 add get 48 sub add ] addtocws /i i 2 add def } ifelse } repeat exit } if DatumB i get { msg i get dup //dotcode.fn1 eq exch dup //dotcode.fn2 eq exch //dotcode.fn3 eq or or { % FNCx [ Bvals msg i get get ] addtocws ECI i get { % FNC2 then 6 digits [ ECIabc ] addtocws /i i 7 add def exit } if msg i get //dotcode.fn3 eq i segstart ne and { % FNC3 /i i 1 add def /mode C def /inmac 0 def /segstart i def /segend i UntilEndSeg i get add def exit } if /i i 1 add def exit } if msg i get 13 eq i msglen 1 sub lt and { msg i 1 add get 10 eq { % CRLF [ Bvals //dotcode.crl get ] addtocws /i i 2 add def exit } if } if [ Bvals msg i get get ] addtocws /i i 1 add def exit } if Binary i get { % Binary DatumB i 1 add get { msg i get 160 lt { [ Bvals //dotcode.bsa get Avals msg i get 128 sub get ] addtocws } { [ Bvals //dotcode.bsb get Bvals msg i get 128 sub get ] addtocws } ifelse /i i 1 add def exit } if [ Bvals //dotcode.bin get ] addtocws /mode BIN def exit } if AheadA i get 1 eq { [ Bvals //dotcode.sfa get Avals msg i get get ] addtocws /i i 1 add def exit } if [ Bvals //dotcode.laa get ] addtocws /mode A def exit } repeat } def /encA { 1 { % Common exit /n TryC i get def n 2 ge { n 4 gt { [ Avals //dotcode.lac get ] addtocws /mode C def exit } if [ Avals [ //dotcode.sfc //dotcode.sc2 //dotcode.sc3 //dotcode.sc4 ] n 1 sub get get ] addtocws n { msg i get 0 lt { [ Cvals msg i get get ] addtocws /i i 1 add def } { [ msg i get 48 sub 10 mul msg i 1 add get 48 sub add ] addtocws /i i 2 add def } ifelse } repeat exit } if DatumA i get { msg i get dup //dotcode.fn1 eq exch dup //dotcode.fn2 eq exch //dotcode.fn3 eq or or { % FNCx [ Avals msg i get get ] addtocws ECI i get { % FNC2 then 6 digits [ ECIabc ] addtocws /i i 7 add def exit } if msg i get //dotcode.fn3 eq i segstart ne and { % FNC3 /i i 1 add def /mode C def /inmac 0 def /segstart i def /segend i UntilEndSeg i get add def exit } if /i i 1 add def exit } if [ Avals msg i get get ] addtocws /i i 1 add def exit } if Binary i get { % Binary DatumA i 1 add get { msg i get 160 lt { [ Avals //dotcode.bsa get Avals msg i get 128 sub get ] addtocws } { [ Avals //dotcode.bsb get Bvals msg i get 128 sub get ] addtocws } ifelse /i i 1 add def exit } if [ Avals //dotcode.bin get ] addtocws /mode BIN def exit } if /n AheadB i get def n 6 gt { [ Avals //dotcode.lab get ] addtocws /mode B def exit } if [ Avals [ //dotcode.sfb //dotcode.sb2 //dotcode.sb3 //dotcode.sb4 //dotcode.sb5 //dotcode.sb6 ] n 1 sub get get ] addtocws n { msg i get 13 eq { [ Bvals //dotcode.crl get ] addtocws /i i 2 add def } { [ Bvals msg i get get ] addtocws /i i 1 add def } ifelse } repeat exit } repeat } def /encBIN { 1 { % Common exit /n TryC i get def n 2 ge { [ finaliseBIN ] addtocws n 7 gt { % Terminate to C [ BINvals //dotcode.tmc get ] addtocws /mode C def exit } if [ BINvals [ //dotcode.sc2 //dotcode.sc3 //dotcode.sc4 //dotcode.sc5 //dotcode.sc6 //dotcode.sc7 ] n 2 sub get get ] addtocws n { msg i get 0 lt { [ Cvals msg i get get ] addtocws /i i 1 add def } { [ msg i get 48 sub 10 mul msg i 1 add get 48 sub add ] addtocws /i i 2 add def } ifelse } repeat exit } if ECI i get Binary i 7 add get and { % ECI then binary [ ECIbin ] addtocws /i i 7 add def i msglen eq { [ finaliseBIN ] addtocws } if exit } if msg i get 0 ge { % Not FNCx Binary i get Binary i 1 add get or Binary i 2 add get or Binary i 3 add get or ECI i 1 add get Binary i 8 add get and or { [ msg i get addtobin ] addtocws /i i 1 add def i msglen eq { [ finaliseBIN ] addtocws } if exit } if } if [ finaliseBIN ] addtocws msg i get //dotcode.fn3 eq i segstart ne and { % FNC3 [ BINvals //dotcode.tms get ] addtocws /i i 1 add def /mode C def /inmac 0 def /segstart i def /segend i UntilEndSeg i get add def exit } if AheadA i get AheadB i get gt { [ BINvals //dotcode.tma get ] addtocws /mode A def } { [ BINvals //dotcode.tmb get ] addtocws /mode B def } ifelse exit } repeat } def /cws msglen 2 mul 1 add array def /mode C def /bvals 5 array def /bpos 0 def /inmac 0 def /segstart 0 def /segend UntilEndSeg 0 get def /i 0 def /j 0 def { i msglen ge {exit} if inmac 0 ne { % Jump over macro trailers inmac //dotcode.mac ne i segend 2 sub eq and { % {RS}{EOT} /i i 2 add def i msglen ge {exit} if } if inmac //dotcode.mac eq i segend 1 sub eq and { % {EOT} /i i 1 add def i msglen ge {exit} if } if } if //dotcode.encfuncs mode get load exec } loop /cws cws 0 j getinterval def % % Determine the symbol size % /nd cws length def /minarea nd 3 add nd 2 idiv add 9 mul 2 add 2 mul def ratio -1 ne { % Fixed ratio /hgt minarea ratio div sqrt def /wid minarea ratio mul sqrt def /h hgt cvi def /w wid cvi def h w add 2 mod 1 eq { h w mul minarea lt {/h h 1 add def /w w 1 add def} if } { hgt w mul wid h mul lt { /w w 1 add def h w mul minarea lt { /w w 1 sub def /h h 1 add def h w mul minarea lt {/w w 2 add def} if } if } { /h h 1 add def h w mul minarea lt { /h h 1 sub def /w w 1 add def h w mul minarea lt {/h h 2 add def} if } if } ifelse } ifelse /rows h def /columns w def } { columns -1 eq { % Fixed height /columns minarea rows add 1 sub rows idiv dup rows add 2 mod 0 eq {1 add} if def columns 5 lt { /columns 5 rows -1 ne { rows 2 mod add } if def } if } if rows -1 eq { % Fixed width /rows minarea columns add 1 sub columns idiv dup columns add 2 mod 0 eq {1 add} if def rows 5 lt { /rows 5 columns 2 mod add def } if } if } ifelse % % Extend the codewords with padding % /ndots rows columns mul 2 idiv def { nd 1 add dup 2 idiv 3 add add 9 mul 2 add ndots gt {exit} if /nd nd 1 add def } loop /nc nd 2 idiv 3 add def /nw nd nc add def /rembits ndots nw 9 mul 2 add sub def nd cws length gt { /cws [ cws aload pop mode BIN eq {109} {106} ifelse nd cws length sub 1 sub {106} repeat ] def } if options /debugcws known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugcws cws //raiseerror exec } if % % Check that the codewords will fit in the symbol % nw 9 mul ndots 2 sub gt { /bwipp.dotcodeTooLong (Maximum length exceeded) //raiseerror exec } if (input.encoding) //dotcode.after exec % % Final six dots arranged at edges % rows 2 mod 0 eq { /sixedges [ [ columns 1 sub rows 2 sub ] [ 0 rows 2 sub ] [ columns 2 sub rows 1 sub ] [ 1 rows 1 sub ] [ columns 1 sub 0 ] [ 0 0 ] ] def } { /sixedges [ [ columns 2 sub 0 ] [ columns 2 sub rows 1 sub ] [ columns 1 sub 1 ] [ columns 1 sub rows 2 sub ] [ 0 0 ] [ 0 rows 1 sub ] ] def } ifelse /dmv {columns mul add} def % % Construct the template % rows columns mul { array } stopped { pop /bwipp.dotcodeSymbolTooLarge (The resulting symbol exceeds the implementation maximum array size) //raiseerror exec } if /outline exch def 0 1 rows 1 sub { /y exch def 0 1 columns 1 sub { /x exch def outline x y dmv x y add 2 mod 1 sub put } for } for sixedges { outline exch aload pop dmv 1 put } forall /clearcol { /x exch def true x 1 and 2 rows 1 sub { x exch dmv sym exch get 1 eq {pop false exit} if } for } def /clearrow { /y exch def true y 1 and 2 columns 1 sub { y dmv sym exch get 1 eq {pop false exit} if } for } def % % Evaluate the symbol % /evalsymbol { /sym exch def % % Identify the worst side % /worst 9999999 def [ [ /x 0 ] [ /x 1 ] [ /y 0 ] [ /y 1 ] ] { % Top Bottom Left Right aload pop /fl exch def /dir exch def /sum 0 def /first -1 def /last -1 def 0 1 dir /x eq {columns} {rows} ifelse 1 sub { dir exch def sym dir load dir /x eq {rows} {columns} ifelse 1 sub fl mul dir /y eq {exch} if dmv get 1 eq { first -1 eq {/first dir load def} if /last dir load def /sum sum 1 add def } if } for sum last add first sub dir /x eq {rows} {columns} ifelse mul dup worst lt {/worst exch def} {pop} ifelse } forall /pen 0 def % % Check for groups of blank columns unless data is encoded vertically % in a symbol of sufficient height to overcome up to six consecutive 0s % in two neighbouring 5 of 9 dot patterns % rows 2 mod 1 eq rows 12 le or { /sum 0 def /p 0 def 1 1 columns 2 sub { clearcol { /sum sum 1 add def /p sum 1 eq {rows} {p rows mul} ifelse def } { /sum 0 def /pen pen p add def /p 0 def } ifelse } for /pen pen p add def } if % % Check for groups of blank rows unless data is encoded horizontally % in a symbol of sufficient width to overcome up to six consecutive 0s % in two neighbouring 5 of 9 dot patterns % rows 2 mod 0 eq columns 12 le or { /sum 0 def /p 0 def 1 1 rows 2 sub { clearrow { /sum sum 1 add def /p sum 1 eq {columns} {p columns mul} ifelse def } { /sum 0 def /pen pen p add def /p 0 def } ifelse } for /pen pen p add def } if % % Pad twice on all sides % /symp [ columns 4 add 2 mul {0} repeat 0 columns sym length 1 sub { 0 exch 0 exch sym exch columns getinterval aload pop 0 0 } for columns 4 add 2 mul {0} repeat ] def % % Count voids and isolated dots % /columns columns 4 add def /rows rows 4 add def /sum 0 def 2 1 rows 3 sub { /y exch def y 1 and 2 add 2 columns 3 sub { /x exch def 1 { % Common exit symp x 1 sub y 1 sub dmv get 1 eq {exit} if symp x 1 add y 1 sub dmv get 1 eq {exit} if symp x 1 sub y 1 add dmv get 1 eq {exit} if symp x 1 add y 1 add dmv get 1 eq {exit} if symp x y dmv get 0 eq {/sum sum 1 add def exit} if symp x 2 sub y dmv get 1 eq {exit} if symp x y 2 sub dmv get 1 eq {exit} if symp x 2 add y dmv get 1 eq {exit} if symp x y 2 add dmv get 1 eq {exit} if /sum sum 1 add def } repeat } for } for /columns columns 4 sub def /rows rows 4 sub def worst 0 eq { % Fixed penalty to disqualify a symbol with an unlit edge -99999 } { worst sum sum mul sub pen sub } ifelse } def /step nw 112 idiv 1 add def /offset {step mul start add} def % % Evaluate the symbols in the following order: % fast mode: m3 -> m3' -> m2 -> m2' -> m1 -> m1' -> m0 -> m0' % dflt mode: (m0 m1 m2 m3) -> (m0' m1' m2' m3') % -> : Test if we have met the HxW/2 threshold % m' : Symbols with six edge dots forcibly lit % () : Best of % /bestscore -99999999 def /masks mask -1 ne { [ mask ] } { fast { [ 2#11 2#10 2#01 2#00 ] } { [ 2#00 2#01 2#10 2#11 ] } ifelse } ifelse def /litmasks 4 array def masks { % For each mask pattern /mask exch def % % Calculate the error correction codewords for each block % /rscws [ mask //dotcode.maskvals mask get 0 cws {1 index add 113 mod exch 2 index add exch 3 1 roll} forall pop pop nc {0} repeat ] def 0 1 step 1 sub { /start exch def /ND nd 1 add start sub step add 1 sub step idiv def /NW nw 1 add start sub step add 1 sub step idiv def /NC NW ND sub def (ecc.coeffs) //dotcode.before exec /coeffs NC //dotcode.coeffscachefetch exec def (ecc.coeffs) //dotcode.after exec (ecc.cws) //dotcode.before exec % % Compute ECC via the shared rsecprime helper. Data lives at % interleaved positions rscws[offset(0..ND-1)]; ECC goes back to % rscws[offset(ND..NW-1)]. The helper leaves codewords in the % spec's negated form in lfsr[0..NC), so no post-pass is needed. % /lfsr NC array def {step mul start add rscws exch get} ND coeffs NC lfsr 113 //rsecprime exec 0 1 NC 1 sub { /j exch def rscws ND j add offset lfsr j get put } for (ecc.cws) //dotcode.after exec } for options /debugecc known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugecc rscws //raiseerror exec } if (matrix.layout) //dotcode.before exec % % Create the bitstream % /bits ndots string def bits 0 //dotcode.maskbits mask get putinterval 1 1 nw { /i exch def bits i 1 sub 9 mul 2 add //dotcode.encs rscws i get get putinterval } for rembits 0 gt { bits nw 9 mul 2 add (11111111111111111) 0 rembits getinterval putinterval } if % % Walk the symbol placing the bitstream % /pixs outline dup length array copy def /posx 0 def /posy rows 2 mod 0 eq {0} {rows 1 sub} ifelse def bits 0 bits length 6 sub getinterval { { % Move to next vacant position pixs posx posy dmv get -1 eq {exit} if rows 2 mod 0 eq { /posy posy 1 add def posy rows eq { /posy 0 def /posx posx 1 add def } if } { /posx posx 1 add def posx columns eq { /posx 0 def /posy posy 1 sub def } if } ifelse } loop pixs posx posy dmv 3 -1 roll 48 sub put } forall 0 1 5 { % Last six edge dots /i exch def pixs sixedges i get aload pop dmv bits bits length 6 sub i add get 48 sub put } for (matrix.layout) //dotcode.after exec (matrix.evaluate.normal) //dotcode.before exec % % Evaluate the symbol to find the most suitable mask % /score pixs evalsymbol def score bestscore gt { /bestsym pixs def /bestscore score def fast bestscore rows columns mul 2 idiv gt and {exit} if } if % % Make a copy with lit edges for possible later evaluation % /litmask pixs dup length array copy def 0 1 5 { % Light last six edge dots /i exch def litmask sixedges i get aload pop dmv 1 put } for litmasks mask litmask put % % In fast mode immediately score the lit symbol % fast { /score litmask evalsymbol def score bestscore gt { /bestsym litmask def /bestscore score def bestscore rows columns mul 2 idiv gt {exit} if } if } if (matrix.evaluate.normal) //dotcode.after exec } forall /pixs bestsym def % % For default mode, if best mask fails threshold then recalculate with lit corners and pick best % fast not bestscore rows columns mul 2 idiv le and { (matrix.evaluate.fixup) //dotcode.before exec /bestscore -99999999 def masks { litmasks exch get /litmask exch def /score litmask evalsymbol def score bestscore gt { /bestsym litmask def /bestscore score def } if } forall /pixs bestsym def (matrix.evaluate.fixup) //dotcode.after exec } if << /ren /renmatrix /dotty true /pixs pixs /pixx columns /pixy rows /height rows modunit mul 72 div /width columns modunit mul 72 div /borderleft 3.0 /borderright 3.0 /bordertop 3.0 /borderbottom 3.0 /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /dotcode dup load /uk.co.terryburton.bwipp defineresource pop (setup.define) //dotcode.after exec end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER dotcode-- % --BEGIN ENCODER ultracode-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor fifocache rsecprime render renmatrix-- % --DESC: Ultracode % --EXAM: Awesome colours! % --EXOP: eclevel=EC2 % --RNDR: renmatrix % --FMLY: Two-dimensional symbols %%BeginResource: uk.co.terryburton.bwipp ultracode 0.0 2026052800 148025 150812 %%BeginData: 515 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 17 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /fifocache dup /uk.co.terryburton.bwipp findresource put dup /rsecprime dup /uk.co.terryburton.bwipp findresource put dup /setuphooks dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put begin /ultracode [/before /after] //setuphooks exec (setup.define) //ultracode.before exec /ultracode.metrics [ % rows minc maxc mcol [ 2 7 37 5 ] [ 3 36 84 13 ] [ 4 85 161 22 ] [ 5 142 282 29 ] ] readonly def /ultracode.tiles [ 13135 13136 13153 13156 13163 13165 13513 13515 13516 13531 % 0-9 13535 13536 13561 13563 13565 13613 13615 13616 13631 13635 % 10-19 13636 13651 13653 13656 15135 15136 15153 15163 15165 15313 % 20-29 15315 15316 15351 15353 15356 15361 15363 15365 15613 15615 % 30-39 15616 15631 15635 15636 15651 15653 15656 16135 16136 16153 % 40-49 16156 16165 16313 16315 16316 16351 16353 16356 16361 16363 % 50-59 16365 16513 16515 16516 16531 16535 16536 16561 16563 16565 % 60-69 31315 31316 31351 31356 31361 31365 31513 31515 31516 31531 % 70-79 31535 31536 31561 31563 31565 31613 31615 31631 31635 31636 % 80-89 31651 31653 31656 35131 35135 35136 35151 35153 35156 35161 % 90-99 35163 35165 35315 35316 35351 35356 35361 35365 35613 35615 % 100-109 35616 35631 35635 35636 35651 35653 35656 36131 36135 36136 % 110-119 36151 36153 36156 36163 36165 36315 36316 36351 36356 36361 % 120-129 36365 36513 36515 36516 36531 36535 36536 36561 36563 36565 % 130-139 51313 51315 51316 51351 51353 51356 51361 51363 51365 51513 % 140-149 51516 51531 51536 51561 51563 51613 51615 51616 51631 51635 % 150-159 51636 51651 51653 51656 53131 53135 53136 53151 53153 53156 % 160-169 53161 53163 53165 53513 53516 53531 53536 53561 53563 53613 % 170-179 53615 53616 53631 53635 53636 53651 53653 53656 56131 56135 % 180-189 56136 56151 56153 56156 56161 56163 56165 56313 56315 56316 % 190-199 56351 56353 56356 56361 56363 56365 56513 56516 56531 56536 % 200-209 56561 56563 61313 61315 61316 61351 61353 61356 61361 61363 % 210-219 61365 61513 61515 61516 61531 61535 61536 61561 61563 61565 % 220-229 61615 61631 61635 61651 61653 63131 63135 63136 63151 63153 % 230-239 63156 63161 63163 63165 63513 63515 63516 63531 63535 63536 % 240-249 63561 63563 63565 63613 63615 63631 63635 63651 63653 65131 % 250-259 65135 65136 65151 65153 65156 65161 65163 65165 65313 65315 % 260-269 65316 65351 65353 65356 65361 65363 65365 65613 65615 65631 % 270-279 65635 65651 65653 56565 51515 % 280-284 ] readonly def /ultracode.dccurev1 [ 51363 51563 51653 53153 53163 53513 53563 53613 % 0-7 53653 56153 56163 56313 56353 56363 56513 56563 % 8-15 51316 51356 51536 51616 53156 53516 53536 53616 % 16-23 53636 53656 56136 56156 56316 56356 56516 56536 % 24-31 ] readonly def /ultracode.dcclrev1 [ 61351 61361 61531 61561 61631 61651 63131 63151 % 0-7 63161 63531 63561 63631 65131 65161 65351 65631 % 8-15 31351 31361 31531 31561 31631 31651 35131 35151 % 16-23 35161 35361 35631 35651 36131 36151 36351 36531 % 24-31 ] readonly def /ultracode.dccurev2 [ 15316 16316 13516 16516 13616 15616 13136 15136 % 0-7 16136 13536 16536 13636 13156 16156 15356 13656 % 8-15 15313 16313 13513 16513 13613 15613 13153 15153 % 16-23 16153 16353 13653 15653 13163 15163 15363 13563 % 24-31 ] readonly def /ultracode.dcclrev2 [ 36315 36515 35615 35135 36135 31535 36535 31635 % 0-7 35635 35165 36165 31365 35365 36365 31565 36565 % 8-15 61315 65315 63515 61615 65135 61535 63535 61635 % 16-23 63635 65635 63165 65165 61365 65365 61565 63565 % 24-31 ] readonly def /ultracode.colormap << 0 (FFFFFF) % W 9 (000000) % K 1 (00FFFF) % C 3 (FF00FF) % M 5 (FFFF00) % Y 6 (00FF00) % G >> readonly def /ultracode.qccfact [ 0 1 2 4 6 8 ] readonly def /ultracode.latevars dup 4 dict def load /init { (setup.latevars) //ultracode.before exec currentglobal true setglobal //ultracode.latevars begin /rsalog [ 1 282 {dup 3 mul 283 mod} repeat ] readonly def /rslog 283 array def 1 1 282 {dup rsalog exch get exch rslog 3 1 roll put} for /rslog rslog readonly def /init { //ultracode.latevars {def} forall } def end //ultracode.latevars /init get exec setglobal (setup.latevars) //ultracode.after exec } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//ultracode.latevars /init get exec} if } {pop} ifelse % % Function to calculate the product in the field % /ultracode.rsprod { dup 0 ne { 1 index 0 ne { rslog exch get exch rslog exch get add 282 mod rsalog exch get } { pop pop 0 } ifelse } { pop pop 0 } ifelse } bind def % % Generate Reed-Solomon coefficients for a given k % /ultracode.gencoeffs { /coeffs [ 1 k {0} repeat ] def 1 1 k { % i coeffs 1 index 2 copy 1 sub get put % coeffs[i] = coeffs[i-1] rsalog 1 index get % ai = rsalog[i] exch 1 sub -1 1 { % j coeffs exch 2 copy get % ... coeffs j coeffs[j] 3 index % ... ai //ultracode.rsprod exec % p = coeffs[j] * ai coeffs 2 index 1 sub get % ... coeffs[j-1] add 283 mod put % coeffs[j] = (p + coeffs[j-1]) mod 283 } for coeffs 0 2 copy get % coeffs 0 coeffs[0] 3 index % ... ai //ultracode.rsprod exec put % coeffs[0] = coeffs[0] * ai pop % ai } for /coeffs coeffs 0 coeffs length 1 sub getinterval def coeffs length 1 sub -2 0 { coeffs exch 2 copy get 283 exch sub put } for coeffs } bind def % % FIFO cache for ECC polynomials % % 37 unique keys: qcc=factor*ceil(mcc/25)+5 yields sparse values 3-101 % /ultracode.coeffscachemax 37 def % Override with global_ctx.ultracode.coeffscachemax /ultracode.coeffscachelimit 1311 def % Override with global_ctx.ultracode.coeffscachelimit /uk.co.terryburton.bwipp.global_ctx dup where { exch get dup /ultracode.coeffscachemax 2 copy known {get /ultracode.coeffscachemax exch def} {pop pop} ifelse /ultracode.coeffscachelimit 2 copy known {get /ultracode.coeffscachelimit exch def} {pop pop} ifelse } {pop} ifelse /ultracode.coeffscache ultracode.coeffscachemax ultracode.coeffscachelimit //fifocache exec def /ultracode.coeffscachefetch { /k exch def k { //ultracode.gencoeffs exec } { length } //ultracode.coeffscache /fetch get exec } bind def /ultracode { 64 dict begin { (input.processoptions) //ultracode.before exec /dontdraw false def /eclevel (EC2) def % EC1-EC5, and EC0 for rev 1 /parse false def /parsefnc false def /start 257 def % 8-bit ISO-8859-1, until we write high-level encoders /link1 0 def /raw false def /rev 2 def % Ultracode specification revision /strictspec false def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def /modunit 2 def /uk.co.terryburton.bwipp.global_ctx dup where { exch get /default_modunit 2 copy known {get /modunit exch def} {pop pop} ifelse } {pop} ifelse % % Apply AST spec overrides and resolve physical specification % /ultracode ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec (input.processoptions) //ultracode.after exec //ultracode.latevars /init get exec (input.validate) //ultracode.before exec % 282 max codewords; 4x for ^NNN parse expansion barcode length 2500 gt { /bwipp.ultracodeInputTooLong (The input data is too long) //raiseerror exec } if rev dup 1 ne exch 2 ne and { /bwipp.ultracodeInvalidRevision (Valid revisions are 1 and 2) //raiseerror exec } if eclevel length 3 eq dup { pop eclevel 0 2 getinterval (EC) eq dup { pop eclevel 2 get 48 sub dup rev 2 eq {1} {0} ifelse ge exch 5 le and } if } if not { /bwipp.ultracodeInvalidErrorCorrectionLevel (Valid error correction levels are EC1 to EC5, and EC0 for legacy revision 1) //raiseerror exec } if (input.validate) //ultracode.after exec raw { (input.encoding.raw) //ultracode.before exec /dcws barcode length array def /i 0 def /j 0 def { % loop i barcode length 3 sub ge {exit} if barcode i get 94 ne {exit} if barcode i 1 add 3 getinterval false 1 index { dup 48 lt exch 57 gt or { pop true } if } forall { pop exit } if cvi /cw exch def cw 284 gt { /bwipp.ultracodeBadRawCodeword (Raw codewords must be 0 to 284) //raiseerror exec } if dcws j cw put /i i 4 add def /j j 1 add def } loop i barcode length ne { /bwipp.ultracodeBadRawFormat (Raw codewords must be formatted as ^NNN) //raiseerror exec } if /dcws dcws 0 j getinterval def (input.encoding.raw) //ultracode.after exec } { (input.preprocess) //ultracode.before exec % Parse the input /fn1 -1 def /fn3 -2 def /fncvals << /parse parse /parsefnc parsefnc (FNC1) fn1 (FNC3) fn3 >> def barcode fncvals //parseinput exec /msg exch def /msglen msg length def % Absolute capacity at rev=1 eclevel=EC0. msglen 276 gt { /bwipp.ultracodeInputTooLong (The input data is too long) //raiseerror exec } if (input.preprocess) //ultracode.after exec (input.encoding.normal) //ultracode.before exec /scr [] def % Empty symbol control region /scp [] def % Empty start sequence parameters /dcws [ scr aload pop scp aload pop msg { dup fn1 eq {pop 268} if dup fn3 eq {pop 269} if } forall ] def (input.encoding.normal) //ultracode.before exec } ifelse options /debugcws known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugcws dcws //raiseerror exec } if (metrics.selection) //ultracode.before exec /mcc dcws length 3 add def % Message codewords: start mcc acc [dcws ...] /eclval eclevel 2 get 48 sub def eclval 0 ne { /qcc //ultracode.qccfact eclval get mcc 25 idiv mcc 25 mod 0 ne {1 add} if mul 5 add def } { /qcc 3 def } ifelse /acc qcc 3 sub 78 link1 mul add def /tcc mcc qcc add def % % Lookup the most appropriate symbol specification % //ultracode.metrics { /m exch def /rows m 0 get def /minc m 1 get def % Minimum permissible codewords /maxc m 2 get def % Maximum permissible codewords /mcol m 3 get def % Minimum tile columns /okay true def tcc minc lt tcc maxc gt or {/okay false def} if okay {exit} if } forall okay not { /bwipp.ultracodeNoValidSymbol (Maximum length exceeded or invalid content) //raiseerror exec } if % % Determine required number of columns and pads % mcol 1 61 { /columns exch def columns columns 15 ge {1 sub} if columns 31 ge {1 sub} if columns 47 ge {1 sub} if rows mul 3 sub tcc sub dup 0 ge { /pads exch def exit } if pop } for /dcc columns mcol sub def (metrics.selection) //ultracode.after exec % % Fetch the coefficients % (ecc.coeffs) //ultracode.before exec /n mcc def /k qcc def /coeffs k //ultracode.coeffscachefetch exec def (ecc.coeffs) //ultracode.after exec (ecc.cws) //ultracode.before exec % % Reed-Solomon error correction over GF(283). Input is the concatenation % [start, mcc, acc, dcws...]. % /rsdata [ start mcc acc dcws aload pop ] def /ecws k array def {rsdata exch get} n coeffs k ecws 283 //rsecprime exec options /debugecc known /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse and { /bwipp.debugecc ecws //raiseerror exec } if (ecc.cws) //ultracode.after exec (matrix.layout) //ultracode.before exec /dccu rev 1 eq {//ultracode.dccurev1} {//ultracode.dccurev2} ifelse def /dccl rev 1 eq {//ultracode.dcclrev1} {//ultracode.dcclrev2} ifelse def % % Create the bitmap % /rows rows 6 mul 1 add def /columns columns 6 add def /pixs [ rows columns mul {-1} repeat ] def /qmv {columns mul add} def 0 1 columns 1 sub { /i exch def 0 6 rows 1 sub { /j exch def i 5 ge {pixs i j qmv i 2 mod 9 mul put} if } for pixs i 0 qmv 9 put pixs i rows 1 sub qmv 9 put } for 1 1 rows 2 sub { /i exch def 3 16 columns 1 sub { /j exch def pixs j i qmv 1 i 2 mod sub 9 mul put } for pixs 0 i qmv 9 put pixs 1 i qmv 1 i 2 mod sub 9 mul put pixs 2 i qmv 0 put pixs 3 i qmv 9 put pixs 4 i qmv 0 put pixs columns 1 sub i qmv 9 put } for % % DCCU and DCCL tiles % /i rows 2 idiv 5 sub def [ dccu dcc get 10 5 string cvrs {48 sub} forall 0 dccl dcc get 10 5 string cvrs {48 sub} forall ] { pixs 2 i qmv 3 -1 roll put /i i 1 add def } forall % % Data tiles % /tileseq [ start mcc ecws aload pop tcc 283 % SEP acc dcws aload pop pads {284} repeat qcc ] def /x 5 def /y 1 def tileseq { //ultracode.tiles exch get 10 5 string cvrs { pixs x y qmv 3 -1 roll 48 sub put /y y 1 add def } forall y rows 1 sub ne { /y y 1 add def % Jump horizontal timing pattern } { /x x 1 add def /y 1 def pixs x y qmv get -1 ne { /x x 1 add def % Jump vertical timing pattern } if } ifelse } forall (matrix.layout) //ultracode.after exec << /ren /renmatrix /pixs pixs /pixx columns /pixy rows /height rows modunit mul 72 div /width columns modunit mul 72 div /colormap //ultracode.colormap /borderleft 1.0 /borderright 1.0 /bordertop 1.0 /borderbottom 1.0 /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /ultracode dup load /uk.co.terryburton.bwipp defineresource pop (setup.define) //ultracode.after exec end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER ultracode-- % --BEGIN ENCODER gs1-cc-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput gs1process setanycolor fifocache rsecprime render renmatrix micropdf417 pdf417-- % --DESC: GS1 Composite 2D Component % --EXAM: (01)09521234543213(3103)000123 % --EXOP: ccversion=b cccolumns=4 % --RNDR: renmatrix %%BeginResource: uk.co.terryburton.bwipp gs1-cc 0.0 2026052800 220870 220253 %%BeginData: 715 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 20 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions 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 dup /pdf417 dup /uk.co.terryburton.bwipp findresource put dup /micropdf417 dup /uk.co.terryburton.bwipp findresource put begin /gs1-cc.lintypecccolumns << /ean13 4 /upca 4 /ean8 3 /upce 2 /gs1-128 4 /databaromni 4 /databarstacked 2 /databarstackedomni 2 /databartruncated 4 /databarlimited 3 /databarexpanded 4 /databarexpandedstacked 4 >> readonly def /gs1-cc.bitcapsmaps << /a [ [167 138 118 108 88 78 59] [167 138 118 98 78] [197 167 138 108 78] ] /b [ [ 336 296 256 208 160 104 56] [ 768 648 536 416 304 208 152 112 72 32] [1184 1016 840 672 496 352 264 208 152 96 56] ] >> readonly def /gs1-cc.fillpat [ 0 0 1 0 0 ] readonly def /gs1-cc.pwr928init [ 0 0 0 0 0 0 1 ] readonly def /gs1-cc.tobin { string dup length 1 sub 0 exch 1 exch {1 index exch 48 put} for dup 3 -1 roll 2 2 index length string cvrs dup length 2 index length exch sub exch putinterval } bind def /gs1-cc.fnc1 -1 def /gs1-cc.lnumeric -2 def /gs1-cc.lalphanumeric -3 def /gs1-cc.liso646 -4 def /gs1-cc.latevars dup 16 dict def load /init { currentglobal true setglobal //gs1-cc.latevars begin /alpha << 65 1 90 {dup 65 sub 5 //gs1-cc.tobin exec} for 48 1 57 {dup 4 add 6 //gs1-cc.tobin exec} for //gs1-cc.fnc1 (11111) >> readonly def /numeric << 0 1 119 { dup (00) 2 string copy dup 3 -1 roll 11 2 string cvrs dup length 2 exch sub exch putinterval dup 0 get 65 eq {dup 0 94 put} if dup 1 get 65 eq {dup 1 94 put} if exch 8 add (0000000) 7 string copy dup 3 -1 roll 2 7 string cvrs dup length 7 exch sub exch putinterval } for //gs1-cc.lalphanumeric (0000) >> readonly def /alphanumeric << 48 1 57 {dup 43 sub 5 //gs1-cc.tobin exec} for //gs1-cc.fnc1 (01111) 65 1 90 {dup 33 sub 6 //gs1-cc.tobin exec} for 42 (111010) 44 1 47 {dup 15 add 6 //gs1-cc.tobin exec} for //gs1-cc.lnumeric (000) //gs1-cc.liso646 (00100) >> readonly def /iso646 << 48 1 57 {dup 43 sub 5 //gs1-cc.tobin exec} for //gs1-cc.fnc1 (01111) 65 1 90 {dup 1 sub 7 //gs1-cc.tobin exec} for 97 1 122 {dup 7 sub 7 //gs1-cc.tobin exec} for 33 (11101000) 34 (11101001) 37 1 47 {dup 197 add 8 //gs1-cc.tobin exec} for 58 1 63 {dup 187 add 8 //gs1-cc.tobin exec} for 95 (11111011) 32 (11111100) //gs1-cc.lnumeric (000) //gs1-cc.lalphanumeric (00100) >> readonly def % % Powers of 2 in base-928 representation for CC-A encoding % /pwr928 [ //gs1-cc.pwr928init 68 {7 array} repeat ] def 1 1 68 { /j exch def /v 0 def 6 -1 1 { /i exch def /v pwr928 j 1 sub get i get 2 mul v 928 idiv add def pwr928 j get i v 928 mod put } for pwr928 j get 0 pwr928 j 1 sub get 0 get 2 mul v 928 idiv add put } for /pwr928 pwr928 readonly def /init { //gs1-cc.latevars {def} forall } def end //gs1-cc.latevars /init get exec setglobal } bind put /uk.co.terryburton.bwipp.global_ctx dup where { exch get /preload known {//gs1-cc.latevars /init get exec} if } {pop} ifelse /gs1-cc { 20 dict begin % Confine variables to local scope { /parse false def /dontlint false def /lintreqs false def /dontdraw false def /ccversion (a) def /cccolumns -1 def /lintype () def /linwidth -1 def null /apply //processoptions exec /options exch def /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def //gs1-cc.latevars /init get exec ccversion (a) ne ccversion (b) ne and ccversion (c) ne and { /bwipp.gs1ccBadCCversion (ccversion must be a, b or c) //raiseerror exec } if cccolumns 30 gt { /bwipp.gs1ccColumnsTooBig (The maximum number of composite component columns is 30) //raiseerror exec } if lintype () ne { //gs1-cc.lintypecccolumns lintype known not { /bwipp.gs1ccBadLinType (The lintype is not recognised) //raiseerror exec } if } if % % Select columns based on linear type % cccolumns -1 eq { lintype (gs1-128) eq ccversion (c) eq and { linwidth 0 lt { /bwipp.gs1ccMissingLinWidth (linwidth must be set for a GS1-128 with a CC-C composite component) //raiseerror exec } if linwidth 68 lt { /bwipp.gs1ccMinimumLinWidth (Minimum linwidth for a GS1-128 with a CC-C composite component is 68) //raiseerror exec } if linwidth 68 eq { 1 } { linwidth 52 sub 17 idiv } ifelse % Ensure cccolumns != 0 if minimum linwidth } { lintype () ne { //gs1-cc.lintypecccolumns lintype get } {2} ifelse } ifelse /cccolumns exch def } if ccversion (c) ne { cccolumns 2 lt cccolumns 4 gt or { /bwipp.gs1ccBadColumns (CC-A and CC-B require 2 to 4 columns) //raiseerror exec } if } if lintype () ne ccversion (c) ne and { cccolumns //gs1-cc.lintypecccolumns lintype get lt { /bwipp.gs1ccColumnsTooSmall (The cccolumns value is too small for the linear symbology) //raiseerror exec } if } if barcode /ai //gs1process exec /fncs exch def /vals exch def /ais exch def % % Method selection % /isupper {dup 65 ge exch 90 le and} def % A-Z /isnum0 {dup 48 ge exch 57 le and} def % 0-9 /isnum1 {dup 49 ge exch 57 le and} def % 1-9 { % common exit % (10/11/17)... ais length 1 ge { ais 0 get (10) eq ais 0 get (11) eq or ais 0 get (17) eq or { -1 (10) exit } if } if % (90){0-3 digits not starting 0}{upper alpha}... ais length 1 ge { ais 0 get (90) eq { /v vals 0 get def v length 1 ge { v 0 get isupper { 0 (11) exit } if } if v length 2 ge { v 0 get isnum1 v 1 get isupper and { 1 (11) exit } if } if v length 3 ge { v 0 get isnum1 v 1 get isnum0 and v 2 get isupper and { 2 (11) exit } if } if v length 4 ge { v 0 get isnum1 v 1 get isnum0 and v 2 get isnum0 and v 3 get isupper and { 3 (11) exit } if } if } if } if % Freeform -1 (0) exit } loop /method exch def /npre exch def method (10) eq { ais 0 get (11) eq ais 0 get (17) eq or vals 0 get dup length 6 ge { true exch 0 6 getinterval { dup 48 lt exch 57 gt or { pop false } if } forall } { pop false } ifelse and { vals 0 get dup 0 2 getinterval cvi 384 mul exch dup 2 2 getinterval cvi 1 sub 32 mul exch 4 2 getinterval cvi add add (0000000000000000) 16 string copy dup 3 -1 roll 2 16 string cvrs dup length 16 exch sub exch putinterval [ 1 0 4 -1 roll {48 sub} forall ais 0 get (11) eq {0} {1} ifelse ] /cdf exch def /ais ais 1 ais length 1 sub getinterval def /vals vals 1 vals length 1 sub getinterval def /fncs fncs 1 fncs length 1 sub getinterval def } { /cdf [ 1 0 1 1 ] def } ifelse ais length 0 ne { ais 0 get (10) eq { /gpf [ vals 0 get {} forall ] def ais length 1 gt {/gpf [ gpf aload pop //gs1-cc.fnc1 ] def} if % TODO: check /ais ais 1 ais length 1 sub getinterval def /vals vals 1 vals length 1 sub getinterval def /fncs fncs 1 fncs length 1 sub getinterval def } { /gpf [//gs1-cc.fnc1] def % TODO: check } ifelse } { /cdf [ cdf aload pop 0 0 0 0 0 1 1 1 1 ] def /gpf [] def } ifelse /mode (numeric) def } if method (11) eq { /cdf [ 1 1 ] def /ai90 vals 0 get def npre 1 add ai90 length ne { ai90 npre 1 add ai90 length npre sub 1 sub getinterval } { () } ifelse /ai90rem exch def /nalpha 0 ai90rem {dup 65 ge exch 90 le and {1 add} if} forall def /nnums 0 ai90rem {dup 48 ge exch 57 le and {1 add} if} forall def /mode nalpha nnums gt {(alpha)} { nalpha 0 eq {(numeric)} {(alphanumeric)} ifelse } ifelse def nalpha nnums add ai90rem length ne {/mode (alphanumeric) def} if /cdf [ cdf aload pop mode (alphanumeric) eq {0} if mode (numeric) eq {1 0} if mode (alpha) eq {1 1} if ] def /ais1 ais length 1 gt {ais 1 get} {-1} ifelse def /vals1 vals length 1 gt {vals 1 get} {-1} ifelse def ais1 (21) eq ais1 (8004) eq or { /cdf [ cdf aload pop ais1 (21) eq {1 0} {1 1} ifelse ] def } { /cdf [ cdf aload pop 0 ] def } ifelse /nval npre 0 ne {ai90 0 npre getinterval cvi} {0} ifelse def (BDHIJKLNPQRSTVXZ) ai90 npre 1 getinterval search { length exch pop exch pop /aval exch def } { pop /aval -1 def } ifelse nval 31 lt aval -1 ne and { (00000) 5 string copy dup nval 2 5 string cvrs dup length 5 exch sub exch putinterval [ exch {48 sub} forall ] /nbits exch def (0000) 4 string copy dup aval 2 4 string cvrs dup length 4 exch sub exch putinterval [ exch {48 sub} forall ] /abits exch def /cdf [ cdf aload pop nbits aload pop abits aload pop ] def } { (0000000000) 10 string copy dup nval 2 10 string cvrs dup length 10 exch sub exch putinterval [ exch {48 sub} forall ] /nbits exch def (00000) 5 string copy dup ai90 npre get 65 sub 2 5 string cvrs dup length 5 exch sub exch putinterval [ exch {48 sub} forall ] /abits exch def /cdf [ cdf aload pop 1 1 1 1 1 nbits aload pop abits aload pop ] def } ifelse mode (alpha) ne { /gpf [ ai90rem {} forall ais length 1 gt {//gs1-cc.fnc1} if ] def } { /in [ ai90rem {} forall ais length 1 gt {//gs1-cc.fnc1} if ] def /out in length 6 mul array def /j 0 def 0 1 in length 1 sub { in exch get alpha exch get dup [ exch {48 sub} forall ] out exch j exch putinterval length j add /j exch def } for /cdf [ cdf aload pop out 0 j getinterval aload pop ] def /gpf [] def ais length 1 gt {/mode (numeric) def} if } ifelse /ais ais 1 ais length 1 sub getinterval def /vals vals 1 vals length 1 sub getinterval def /fncs fncs 1 fncs length 1 sub getinterval def ais length 0 ne { ais1 (21) eq ais1 (8004) eq or { /gpf [ gpf aload pop vals1 {} forall ] def /ais ais 1 ais length 1 sub getinterval def /vals vals 1 vals length 1 sub getinterval def /fncs fncs 1 fncs length 1 sub getinterval def ais length 0 ne {/gpf [gpf aload pop //gs1-cc.fnc1] def} if } if } if } if method (0) eq { /cdf [ 0 ] def /gpf [] def /mode (numeric) def } if % % Append the remaining AI data using stack-based accumulation % mark gpf aload pop 0 1 ais length 1 sub { /i exch def ais i get { } forall % Push AI characters vals i get { } forall % Push value characters i ais length 1 sub ne fncs i get and { //gs1-cc.fnc1 % Push FNC1 separator } if } for counttomark array astore /gpf exch def pop % % Calculate the number of bits remaining to the next valid symbol size % /rembits { /used exch def ccversion (c) ne { % cc-a or cc-b /bitcaps //gs1-cc.bitcapsmaps ccversion get cccolumns 2 sub get def -1 bitcaps {dup used ge {exch} if pop} forall dup -1 ne {used sub} if } { << /c -1 >> ccversion get pop % Assert cc-c /m used 8 div ceiling cvi dup 6 idiv 5 mul exch 6 mod add def m 40 le {8 } if m 41 ge m 160 le and {16} if m 161 ge m 320 le and {32} if m 321 ge m 833 le and {64} if % 833 = 900 - 3 - 64, where 900 = 30 rows x 30 cols limit m 834 ge {32} if % Reduce to meet advertised "up to 2361 digits" (allows max 2372) within 900 limit /eccws exch def /m m eccws add 3 add def cccolumns 30 gt { /cccolumns 30 def } if { % Loop until rows <= 30 or columns >= 30 (GS1 General Specifications 5.11.2.3) m cccolumns div ceiling cvi 30 le cccolumns 30 ge or {exit} if /cccolumns cccolumns 1 add def } loop /r m cccolumns div ceiling cvi def r 3 lt { /r 3 def } if % GS1 General Specifications 5.11.2.3 "3 to 30 rows" /tgt cccolumns r mul eccws sub 3 sub dup 5 idiv 6 mul exch 5 mod add 8 mul def used 8304 le {tgt used sub} {-1} ifelse } ifelse dup -1 eq { % Upgrade CC-A to CC-B or CC-B to CC-C to fit pop ccversion (a) eq { /ccversion (b) def used rembits } { ccversion (b) eq lintype (gs1-128) eq and { /ccversion (c) def /cccolumns linwidth 52 sub 17 idiv def used rembits } { -1 % Can't upgrade; data exceeds composite capacity } ifelse } ifelse } if } def /encode { dup /raw ne {exch get} {pop} ifelse [ exch {48 sub} forall ] dup length dup j add gpfenc length gt { pop pop /bwipp.gs1ccDataTooLarge (Data too large for the composite component) //raiseerror exec } if exch gpfenc exch j exch putinterval /j exch j add def } def % % Pre-compute alphanumeric and numeric runlengths and position of next ISO646-only characters % /numericruns [ gpf length {0} repeat 0 -1 ] def /alphanumericruns [ gpf length {0} repeat 0 ] def /nextiso646only [ gpf length {0} repeat 9999 ] def gpf length 1 sub -1 0 { /i exch def gpf i get (00) 2 string copy dup 0 gpf i get dup //gs1-cc.fnc1 eq {pop 94} if put i gpf length 1 sub lt {dup 1 gpf i 1 add get dup //gs1-cc.fnc1 eq {pop 94} if put} if numeric exch known { numericruns i numericruns i 2 add get 2 add put } { numericruns i 0 put } ifelse dup alphanumeric exch known { alphanumericruns i alphanumericruns i 1 add get 1 add put } { alphanumericruns i 0 put } ifelse dup iso646 exch known exch alphanumeric exch known not and { nextiso646only i 0 put } { nextiso646only i nextiso646only i 1 add get 1 add put } ifelse } for % % Encode the general purpose field % /gpfenc 8304 array def % 8304 = (865 / 5) * 6 * 8, where 865 = 900 - 3 - 32 /i 0 def /j 0 def { % loop i gpf length eq {exit} if { % not a loop but common exit point mode (numeric) eq { i gpf length 2 sub le { 2 string dup 0 gpf i get dup //gs1-cc.fnc1 eq {pop 94} if put dup 1 gpf i 1 add get dup //gs1-cc.fnc1 eq {pop 94} if put dup numeric exch known { numeric encode /i i 2 add def exit } if pop //gs1-cc.lalphanumeric numeric encode /mode (alphanumeric) def exit } { gpf i get dup 48 lt exch 57 gt or { //gs1-cc.lalphanumeric numeric encode /mode (alphanumeric) def exit } if /rem cdf length j add rembits def rem 4 ge rem 6 le and { % C1 + 1 into 4 to 6 bits (000000) 6 string copy 0 rem getinterval dup gpf i get 47 sub 2 4 string cvrs dup length 4 exch sub exch putinterval /raw encode /i i 1 add def exit } { % C1.FNC1 2 string dup 0 gpf i get put dup 1 94 put numeric encode /i i 1 add def exit } ifelse } ifelse } if mode (alphanumeric) eq { gpf i get //gs1-cc.fnc1 eq { //gs1-cc.fnc1 alphanumeric encode /mode (numeric) def /i i 1 add def exit } if gpf i get dup iso646 exch known exch alphanumeric exch known not and { //gs1-cc.liso646 alphanumeric encode /mode (iso646) def exit } if numericruns i get 6 ge { //gs1-cc.lnumeric alphanumeric encode /mode (numeric) def exit } if numericruns i get dup 4 ge exch i add gpf length eq and { //gs1-cc.lnumeric alphanumeric encode /mode (numeric) def exit } if gpf i get alphanumeric encode /i i 1 add def exit } if mode (iso646) eq { gpf i get //gs1-cc.fnc1 eq { //gs1-cc.fnc1 iso646 encode /mode (numeric) def /i i 1 add def exit } if numericruns i get 4 ge nextiso646only i get 10 ge and { //gs1-cc.lnumeric iso646 encode /mode (numeric) def exit } if alphanumericruns i get 5 ge nextiso646only i get 10 ge and { //gs1-cc.lalphanumeric iso646 encode /mode (alphanumeric) def exit } if gpf i get iso646 encode /i i 1 add def exit } if } loop } loop /gpf gpfenc 0 j getinterval def % % Create pad % cdf length gpf length add rembits dup -1 eq { pop /bwipp.gs1ccDataTooLarge (Data too large for the composite component) //raiseerror exec } if /pad exch array def pad length 0 gt { 0 5 pad length 1 sub { % Fill with 00100 /i exch def pad i //gs1-cc.fillpat 0 pad length i sub 5 2 copy gt {exch} if pop getinterval putinterval } for mode (numeric) eq { % Prefix shift from numeric to ASCII /pad [ 0 0 0 0 pad aload pop ] 0 pad length getinterval def } if mode (alpha) eq { % Prefix FNC1 + shift from numeric to ASCII /pad [ 1 1 1 1 1 0 0 0 0 pad aload pop ] 0 pad length getinterval def } if } if % % Concatenate fields % /bits [ cdf aload pop gpf aload pop pad aload pop ] def ccversion (a) eq { /cws [ 28 {0} repeat ] def /b 0 def /c 0 def { % loop b bits length eq {exit} if /bs bits b 69 bits length b sub 2 copy gt {exch} if pop getinterval def /bsl bs length def /cs cws c bsl 10 idiv 1 add getinterval def /csl cs length def 0 1 bsl 1 sub { /i exch def 0 1 csl 1 sub { /j exch def cs j 2 copy get pwr928 i get j 7 add csl sub get bs bsl i sub 1 sub get mul add put } for } for csl 1 sub -1 1 { /i exch def cs i 1 sub 2 copy get cs i get 928 idiv add put cs i 2 copy get 928 mod put } for /b b bsl add def /c c csl add def } loop /cws cws 0 c getinterval def /barcode cws length 4 mul string def 0 1 cws length 1 sub { /i exch def (^000) 4 string copy dup cws i get 10 4 string cvrs dup length 4 exch sub exch putinterval barcode i 4 mul 3 -1 roll putinterval } for options (parse) undef options (cca) true put options (columns) cccolumns put /uk.co.terryburton.bwipp._dontdraw true def barcode options //micropdf417 exec /args exch def } if ccversion (b) eq { /barcode bits length 8 idiv string def 0 1 barcode length 1 sub { /i exch def bits i 8 mul 8 getinterval 0 exch {add 2 mul} forall 2 idiv barcode exch i exch put } for options (parse) undef options (ccb) true put options (columns) cccolumns put /uk.co.terryburton.bwipp._dontdraw true def barcode options //micropdf417 exec /args exch def } if ccversion (c) eq { /barcode bits length 8 idiv string def 0 1 barcode length 1 sub { /i exch def bits i 8 mul 8 getinterval 0 exch {add 2 mul} forall 2 idiv barcode exch i exch put } for options (parse) undef options (ccc) true put options (columns) cccolumns put options (eclevel) eccws ln 2 ln div cvi 1 sub put /uk.co.terryburton.bwipp._dontdraw true def barcode options //pdf417 exec /args exch def } if args _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /gs1-cc dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER gs1-cc-- % --BEGIN ENCODER ean13composite-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput gs1process setanycolor fifocache rsecprime render renlinear renmatrix ean5 ean2 ean13 micropdf417 pdf417 gs1-cc-- % --DESC: EAN-13 Composite % --EXAM: 9520123456788|(99)1234-abcd % --EXOP: includetext % --RNDR: renmatrix % --FMLY: GS1 Composite Symbols %%BeginResource: uk.co.terryburton.bwipp ean13composite 0.0 2026052800 136907 140191 %%BeginData: 264 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 5 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /ean13 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 /ean13composite { 32 dict begin { /dontdraw false def /parse false def /dontlint false def /lintreqs true def /guardwhitespace false def /guardwidth 5.0 def /guardheight 7.0 def /strictspec false def /width 0 def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % 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 % % Apply AST spec overrides and resolve physical specification % /ean13composite ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec options (ast) undef options (mag) undef options (propspec) propspec put options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put options (hnom) hnom put options (modunit) modunit put options (lintype) (ean13) put options (inkspreadv) 0.0 put options (dontlint) true put % % Lint with a fake AI (01) % comp length 18 add string dup 0 ((01)00000000000000) putinterval dup 18 comp putinterval /ai //gs1process exec pop pop pop % % Generate metrics for the linear part % /uk.co.terryburton.bwipp._dontdraw true def linear options //ean13 exec /linsym exch def /sbs linsym /sbs get def /bhs linsym /bhs get def /bbs linsym /bbs get def /linwidth 0 sbs {cvi add} forall def % % Generate metrics for the 2D part % options (strictspec) undef options (loosespec) undef options (propspec) undef comp options //gs1-cc exec /compsym exch def /ccpixs compsym /pixs get def /ccrowheights compsym /rowheights get def /ccpixx compsym /pixx get def % % Construct the composite symbol from the linear and 2D parts % /linpad [ ccpixx 97 sub {0} repeat ] def /txt [ linsym /txt 2 copy known { get { aload pop 4 -1 roll linpad length 1 add add 4 1 roll 5 array astore } forall } { pop pop } ifelse ] def /text1xalign linsym /text1xalign 2 copy known { get } { pop pop (unset) } ifelse def /text1yalign linsym /text1yalign 2 copy known { get } { pop pop (unset) } ifelse def /diff linwidth linpad length add 1 add ccpixx sub def % An add-on can make linear wider than composite diff 0 gt { % Left align composite /ccrpad [ diff {0} repeat ] def /pixx ccpixx diff add def } { /ccrpad 0 array def /pixx ccpixx def } ifelse /ccrows ccrowheights length def % Pre-compute bbs and bbs+bhs in row units to avoid repeated calculation /nbars sbs length 1 add 2 idiv def /bbsrow nbars array def /bhsrow nbars array def 0 1 nbars 1 sub { /b exch def bbsrow b bbs b get 72 mul cvi put bhsrow b bbsrow b get bhs b get 72 mul add put } for % Main symbol bars extend to full height connecting to separator; add-on bars keep their height /linheight 0 bhsrow { ceiling cvi 2 copy lt { exch } if pop } forall def /lindescent 0 bbsrow { floor cvi 2 copy gt { exch } if pop } forall def txt { dup 2 get lindescent neg add 2 exch put } forall /mainbars nbars def 0 1 sbs length 1 sub { dup sbs exch get type /realtype eq { 1 add 2 idiv /mainbars exch def exit } { pop } ifelse } for 0 1 mainbars 1 sub { bhsrow exch linheight put } for % Rasterize linear rows, deduplicating identical adjacent rows using a string buffer /rowbuf pixx string def /prevrow () def /linrowheights 72 array def /lri 0 def /linpixs [ linheight 1 sub -1 lindescent { /y exch def /p 0 def linpad { rowbuf p 3 -1 roll put /p p 1 add def } forall rowbuf p 0 put /p p 1 add def 0 1 sbs length 1 sub { /i exch def i 2 mod 0 eq { bbsrow i 2 idiv get y gt bhsrow i 2 idiv get y lt or { 0 } { 1 } ifelse } { 0 } ifelse sbs i get cvi { rowbuf p 2 index put /p p 1 add def } repeat pop } for diff 0 lt { rowbuf p 0 put /p p 1 add def } if rowbuf prevrow eq { linrowheights lri 1 sub 2 copy get 1 add put % Bump multiplier } { prevrow length 0 gt { prevrow {} forall } if % Commit previous batch /prevrow rowbuf pixx string copy def linrowheights lri 1 put /lri lri 1 add def } ifelse } for prevrow {} forall % Commit final batch ] def /linrowheights linrowheights 0 lri getinterval def /pixs [ 0 ccpixx ccpixs length 1 sub { /i exch def ccpixs i ccpixx getinterval aload pop ccrpad aload pop } for linpad aload pop 0 1 93 {0} repeat 1 0 ccrpad aload pop linpad aload pop 1 0 93 {0} repeat 0 1 ccrpad aload pop linpad aload pop 0 1 93 {0} repeat 1 0 ccrpad aload pop linpixs aload pop ] def /rowheights [ ccrowheights aload pop 2 2 2 linrowheights aload pop ] def /pixy 0 rowheights {add} forall def /borderleft linsym /borderleft 2 copy known { get } { pop pop 10 } ifelse linpad length 1 add sub 1 % CC-A QZ; left inset 0 2 copy lt { exch } if pop dup 0 lt { pop 0 } if def /borderright linsym /borderright 2 copy known { get } { pop pop 10 } ifelse pixx linpad length sub 1 sub linwidth sub sub 1 ccrpad length sub % CC-A QZ; right inset ccrpad 2 copy lt { exch } if pop dup 0 lt { pop 0 } if def /bordertop 1 def /borderbottom linsym /borderbottom 2 copy known { get } { pop pop 0 } ifelse lindescent add def % Guard positions adjusted for linear offset within matrix /guardleftpos linsym /guardleftpos 2 copy known { get linpad length 1 add sub } { pop pop 0 } ifelse def /guardleftypos linsym /guardleftypos 2 copy known { get lindescent neg add } { pop pop 0 } ifelse def /guardrightpos linsym /guardrightpos 2 copy known { get linpad length 1 add linwidth add pixx sub add } { pop pop 0 } ifelse def /guardrightypos linsym /guardrightypos 2 copy known { get lindescent neg add } { pop pop 0 } ifelse def % Height is already applied to the linear bars via bhs; don't let renmatrix rescale options /height undef << /ren /renmatrix /pixs pixs /pixx pixx /pixy pixy /rowheights rowheights /height pixy 72 div /width pixx 72 div /borderleft borderleft /borderright borderright /bordertop bordertop /borderbottom borderbottom /guardwhitespace guardwhitespace /guardleftpos guardleftpos /guardleftypos guardleftypos /guardrightpos guardrightpos /guardrightypos guardrightypos /guardwidth guardwidth /guardheight guardheight /txt txt /text1xalign text1xalign /text1yalign text1yalign /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /ean13composite dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER ean13composite-- % --BEGIN ENCODER ean8composite-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput gs1process setanycolor fifocache rsecprime render renlinear renmatrix ean5 ean2 ean8 micropdf417 pdf417 gs1-cc-- % --DESC: EAN-8 Composite % --EXAM: 95200002|(21)A12345678 % --EXOP: includetext % --RNDR: renmatrix % --FMLY: GS1 Composite Symbols %%BeginResource: uk.co.terryburton.bwipp ean8composite 0.0 2026052800 136989 140153 %%BeginData: 260 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 5 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /ean8 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 /ean8composite { 32 dict begin { /dontdraw false def /parse false def /dontlint false def /lintreqs true def /guardwhitespace false def /guardwidth 5.0 def /guardheight 7.0 def /strictspec false def /width 0 def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % 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 % % Apply AST spec overrides and resolve physical specification % /ean8composite ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec options (ast) undef options (mag) undef options (propspec) propspec put options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put options (hnom) hnom put options (modunit) modunit put % % Get the result of encoding with ean8 and gs1-cc % options (lintype) (ean8) put options (inkspreadv) 0.0 put options (dontlint) true put % % Lint with a fake AI (01) % comp length 18 add string dup 0 ((01)00000000000000) putinterval dup 18 comp putinterval /ai //gs1process exec pop pop pop % % Generate metrics for the linear part % /uk.co.terryburton.bwipp._dontdraw true def linear options //ean8 exec /linsym exch def /sbs linsym /sbs get def /bhs linsym /bhs get def /bbs linsym /bbs get def /linwidth 0 sbs {cvi add} forall def % % Generate metrics for the 2D part % options (strictspec) undef options (loosespec) undef options (propspec) undef comp options //gs1-cc exec /compsym exch def /ccpixs compsym /pixs get def /ccrowheights compsym /rowheights get def /ccpixx compsym /pixx get def /linpad [ ccpixx 69 sub {0} repeat ] def /txt [ linsym /txt 2 copy known { get { aload pop 4 -1 roll linpad length 1 add add 4 1 roll 5 array astore } forall } { pop pop } ifelse ] def /text1xalign linsym /text1xalign 2 copy known { get } { pop pop (unset) } ifelse def /text1yalign linsym /text1yalign 2 copy known { get } { pop pop (unset) } ifelse def /diff linwidth linpad length add 1 add ccpixx sub def % An add-on can make linear wider than composite diff 0 gt { % Left align composite /ccrpad [ diff {0} repeat ] def /pixx ccpixx diff add def } { /ccrpad 0 array def /pixx ccpixx def } ifelse /ccrows ccrowheights length def % Pre-compute bbs and bbs+bhs in row units to avoid repeated calculation /nbars sbs length 1 add 2 idiv def /bbsrow nbars array def /bhsrow nbars array def 0 1 nbars 1 sub { /b exch def bbsrow b bbs b get 72 mul cvi put bhsrow b bbsrow b get bhs b get 72 mul add put } for % Main symbol bars extend to full height connecting to separator; add-on bars keep their height /linheight 0 bhsrow { ceiling cvi 2 copy lt { exch } if pop } forall def /lindescent 0 bbsrow { floor cvi 2 copy gt { exch } if pop } forall def txt { dup 2 get lindescent neg add 2 exch put } forall /mainbars nbars def 0 1 sbs length 1 sub { dup sbs exch get type /realtype eq { 1 add 2 idiv /mainbars exch def exit } { pop } ifelse } for 0 1 mainbars 1 sub { bhsrow exch linheight put } for % Rasterize linear rows, deduplicating identical adjacent rows using a string buffer /rowbuf pixx string def /prevrow () def /linrowheights 72 array def /lri 0 def /linpixs [ linheight 1 sub -1 lindescent { /y exch def /p 0 def linpad { rowbuf p 3 -1 roll put /p p 1 add def } forall rowbuf p 0 put /p p 1 add def 0 1 sbs length 1 sub { /i exch def i 2 mod 0 eq { bbsrow i 2 idiv get y gt bhsrow i 2 idiv get y lt or { 0 } { 1 } ifelse } { 0 } ifelse sbs i get cvi { rowbuf p 2 index put /p p 1 add def } repeat pop } for diff 0 lt { rowbuf p 0 put /p p 1 add def } if rowbuf prevrow eq { linrowheights lri 1 sub 2 copy get 1 add put % Bump multiplier } { prevrow length 0 gt { prevrow {} forall } if % Commit previous batch /prevrow rowbuf pixx string copy def linrowheights lri 1 put /lri lri 1 add def } ifelse } for prevrow {} forall % Commit final batch ] def /linrowheights linrowheights 0 lri getinterval def /pixs [ 0 ccpixx ccpixs length 1 sub { /i exch def ccpixs i ccpixx getinterval aload pop ccrpad aload pop } for linpad aload pop 0 1 65 {0} repeat 1 0 ccrpad aload pop linpad aload pop 1 0 65 {0} repeat 0 1 ccrpad aload pop linpad aload pop 0 1 65 {0} repeat 1 0 ccrpad aload pop linpixs aload pop ] def /rowheights [ ccrowheights aload pop 2 2 2 linrowheights aload pop ] def /pixy 0 rowheights {add} forall def /borderleft linsym /borderleft 2 copy known { get } { pop pop 10 } ifelse linpad length 1 add sub 1 % CC-A QZ; left inset 0 2 copy lt { exch } if pop dup 0 lt { pop 0 } if def /borderright linsym /borderright 2 copy known { get } { pop pop 10 } ifelse pixx linpad length sub 1 sub linwidth sub sub 1 ccrpad length sub % CC-A QZ; right inset ccrpad 2 copy lt { exch } if pop dup 0 lt { pop 0 } if def /bordertop 1 def /borderbottom linsym /borderbottom 2 copy known { get } { pop pop 0 } ifelse lindescent add def % Guard positions adjusted for linear offset within matrix /guardleftpos linsym /guardleftpos 2 copy known { get linpad length 1 add sub } { pop pop 0 } ifelse def /guardleftypos linsym /guardleftypos 2 copy known { get lindescent neg add } { pop pop 0 } ifelse def /guardrightpos linsym /guardrightpos 2 copy known { get linpad length 1 add linwidth add pixx sub add } { pop pop 0 } ifelse def /guardrightypos linsym /guardrightypos 2 copy known { get lindescent neg add } { pop pop 0 } ifelse def % Height is already applied to the linear bars via bhs; don't let renmatrix rescale options /height undef << /ren /renmatrix /pixs pixs /pixx pixx /pixy pixy /rowheights rowheights /height pixy 72 div /width pixx 72 div /borderleft borderleft /borderright borderright /bordertop bordertop /borderbottom borderbottom /guardwhitespace guardwhitespace /guardleftpos guardleftpos /guardleftypos guardleftypos /guardrightpos guardrightpos /guardrightypos guardrightypos /guardwidth guardwidth /guardheight guardheight /txt txt /text1xalign text1xalign /text1yalign text1yalign /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /ean8composite dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER ean8composite-- % --BEGIN ENCODER upcacomposite-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput gs1process setanycolor fifocache rsecprime render renlinear renmatrix ean5 ean2 upca micropdf417 pdf417 gs1-cc-- % --DESC: UPC-A Composite % --EXAM: 012345000058|(99)1234-abcd % --EXOP: includetext % --RNDR: renmatrix % --FMLY: GS1 Composite Symbols %%BeginResource: uk.co.terryburton.bwipp upcacomposite 0.0 2026052800 137414 140754 %%BeginData: 257 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 8 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /upca 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 /upcacomposite { 32 dict begin { /dontdraw false def /parse false def /dontlint false def /lintreqs true def /guardwhitespace false def /guardwidth 5.0 def /guardheight 7.0 def /strictspec false def /width 0 def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % 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 % % Apply AST spec overrides and resolve physical specification % /upcacomposite ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec options (ast) undef options (mag) undef options (propspec) propspec put options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put options (hnom) hnom put options (modunit) modunit put options (lintype) (ean13) put options (inkspreadv) 0.0 put options (dontlint) true put % % Lint with a fake AI (01) % comp length 18 add string dup 0 ((01)00000000000000) putinterval dup 18 comp putinterval /ai //gs1process exec pop pop pop % % Generate metrics for the linear part % /uk.co.terryburton.bwipp._dontdraw true def linear options //upca exec /linsym exch def /sbs linsym /sbs get def /bhs linsym /bhs get def /bbs linsym /bbs get def /linwidth 0 sbs {cvi add} forall def % % Generate metrics for the 2D part % options (strictspec) undef options (loosespec) undef options (propspec) undef comp options //gs1-cc exec /compsym exch def /ccpixs compsym /pixs get def /ccrowheights compsym /rowheights get def /ccpixx compsym /pixx get def /linpad [ ccpixx 97 sub {0} repeat ] def /txt [ linsym /txt 2 copy known { get { aload pop 4 -1 roll linpad length 1 add add 4 1 roll 5 array astore } forall } { pop pop } ifelse ] def /text1xalign linsym /text1xalign 2 copy known { get } { pop pop (unset) } ifelse def /text1yalign linsym /text1yalign 2 copy known { get } { pop pop (unset) } ifelse def /diff linwidth linpad length add 1 add ccpixx sub def % An add-on can make linear wider than composite diff 0 gt { % Left align composite /ccrpad [ diff {0} repeat ] def /pixx ccpixx diff add def } { /ccrpad 0 array def /pixx ccpixx def } ifelse /ccrows ccrowheights length def % Pre-compute bbs and bbs+bhs in row units to avoid repeated calculation /nbars sbs length 1 add 2 idiv def /bbsrow nbars array def /bhsrow nbars array def 0 1 nbars 1 sub { /b exch def bbsrow b bbs b get 72 mul cvi put bhsrow b bbsrow b get bhs b get 72 mul add put } for % Main symbol bars extend to full height connecting to separator; add-on bars keep their height /linheight 0 bhsrow { ceiling cvi 2 copy lt { exch } if pop } forall def /lindescent 0 bbsrow { floor cvi 2 copy gt { exch } if pop } forall def txt { dup 2 get lindescent neg add 2 exch put } forall /mainbars nbars def 0 1 sbs length 1 sub { dup sbs exch get type /realtype eq { 1 add 2 idiv /mainbars exch def exit } { pop } ifelse } for 0 1 mainbars 1 sub { bhsrow exch linheight put } for % Rasterize linear rows, deduplicating identical adjacent rows using a string buffer /rowbuf pixx string def /prevrow () def /linrowheights 72 array def /lri 0 def /linpixs [ linheight 1 sub -1 lindescent { /y exch def /p 0 def linpad { rowbuf p 3 -1 roll put /p p 1 add def } forall rowbuf p 0 put /p p 1 add def 0 1 sbs length 1 sub { /i exch def i 2 mod 0 eq { bbsrow i 2 idiv get y gt bhsrow i 2 idiv get y lt or { 0 } { 1 } ifelse } { 0 } ifelse sbs i get cvi { rowbuf p 2 index put /p p 1 add def } repeat pop } for diff 0 lt { rowbuf p 0 put /p p 1 add def } if rowbuf prevrow eq { linrowheights lri 1 sub 2 copy get 1 add put % Bump multiplier } { prevrow length 0 gt { prevrow {} forall } if % Commit previous batch /prevrow rowbuf pixx string copy def linrowheights lri 1 put /lri lri 1 add def } ifelse } for prevrow {} forall % Commit final batch ] def /linrowheights linrowheights 0 lri getinterval def /pixs [ 0 ccpixx ccpixs length 1 sub { /i exch def ccpixs i ccpixx getinterval aload pop ccrpad aload pop } for linpad aload pop 0 1 93 {0} repeat 1 0 ccrpad aload pop linpad aload pop 1 0 93 {0} repeat 0 1 ccrpad aload pop linpad aload pop 0 1 93 {0} repeat 1 0 ccrpad aload pop linpixs aload pop ] def /rowheights [ ccrowheights aload pop 2 2 2 linrowheights aload pop ] def /pixy 0 rowheights {add} forall def /borderleft linsym /borderleft 2 copy known { get } { pop pop 10 } ifelse linpad length 1 add sub 1 % CC-A QZ; left inset 0 2 copy lt { exch } if pop dup 0 lt { pop 0 } if def /borderright linsym /borderright 2 copy known { get } { pop pop 10 } ifelse pixx linpad length sub 1 sub linwidth sub sub 1 ccrpad length sub % CC-A QZ; right inset ccrpad 2 copy lt { exch } if pop dup 0 lt { pop 0 } if def /bordertop 1 def /borderbottom linsym /borderbottom 2 copy known { get } { pop pop 0 } ifelse lindescent add def % Guard positions adjusted for linear offset within matrix /guardleftpos linsym /guardleftpos 2 copy known { get linpad length 1 add sub } { pop pop 0 } ifelse def /guardleftypos linsym /guardleftypos 2 copy known { get lindescent neg add } { pop pop 0 } ifelse def /guardrightpos linsym /guardrightpos 2 copy known { get linpad length 1 add linwidth add pixx sub add } { pop pop 0 } ifelse def /guardrightypos linsym /guardrightypos 2 copy known { get lindescent neg add } { pop pop 0 } ifelse def % Height is already applied to the linear bars via bhs; don't let renmatrix rescale options /height undef << /ren /renmatrix /pixs pixs /pixx pixx /pixy pixy /rowheights rowheights /height pixy 72 div /width pixx 72 div /borderleft borderleft /borderright borderright /bordertop bordertop /borderbottom borderbottom /guardwhitespace guardwhitespace /guardleftpos guardleftpos /guardleftypos guardleftypos /guardrightpos guardrightpos /guardrightypos guardrightypos /guardwidth guardwidth /guardheight guardheight /txt txt /text1xalign text1xalign /text1yalign text1yalign /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /upcacomposite dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER upcacomposite-- % --BEGIN ENCODER upcecomposite-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput gs1process setanycolor fifocache rsecprime render renlinear renmatrix ean5 ean2 upce micropdf417 pdf417 gs1-cc-- % --DESC: UPC-E Composite % --EXAM: 01234558|(15)021231 % --EXOP: includetext % --RNDR: renmatrix % --FMLY: GS1 Composite Symbols %%BeginResource: uk.co.terryburton.bwipp upcecomposite 0.0 2026052800 136813 140065 %%BeginData: 257 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /upce 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 /upcecomposite { 32 dict begin { /dontdraw false def /parse false def /dontlint false def /lintreqs true def /guardwhitespace false def /guardwidth 5.0 def /guardheight 7.0 def /strictspec false def /width 0 def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % 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 % % Apply AST spec overrides and resolve physical specification % /upcecomposite ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec options (ast) undef options (mag) undef options (propspec) propspec put options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put options (hnom) hnom put options (modunit) modunit put options (lintype) (upce) put options (inkspreadv) 0.0 put options (dontlint) true put % % Lint with a fake AI (01) % comp length 18 add string dup 0 ((01)00000000000000) putinterval dup 18 comp putinterval /ai //gs1process exec pop pop pop % % Generate metrics for the linear part % /uk.co.terryburton.bwipp._dontdraw true def linear options //upce exec /linsym exch def /sbs linsym /sbs get def /bhs linsym /bhs get def /bbs linsym /bbs get def /linwidth 0 sbs {cvi add} forall def % % Generate metrics for the 2D part % options (strictspec) undef options (loosespec) undef options (propspec) undef comp options //gs1-cc exec /compsym exch def /ccpixs compsym /pixs get def /ccrowheights compsym /rowheights get def /ccpixx compsym /pixx get def /linpad [ ccpixx 53 sub {0} repeat ] def /txt [ linsym /txt 2 copy known { get { aload pop 4 -1 roll linpad length 1 add add 4 1 roll 5 array astore } forall } { pop pop } ifelse ] def /text1xalign linsym /text1xalign 2 copy known { get } { pop pop (unset) } ifelse def /text1yalign linsym /text1yalign 2 copy known { get } { pop pop (unset) } ifelse def /diff linwidth linpad length add 1 add ccpixx sub def % An add-on can make linear wider than composite diff 0 gt { % Left align composite /ccrpad [ diff {0} repeat ] def /pixx ccpixx diff add def } { /ccrpad 0 array def /pixx ccpixx def } ifelse /ccrows ccrowheights length def % Pre-compute bbs and bbs+bhs in row units to avoid repeated calculation /nbars sbs length 1 add 2 idiv def /bbsrow nbars array def /bhsrow nbars array def 0 1 nbars 1 sub { /b exch def bbsrow b bbs b get 72 mul cvi put bhsrow b bbsrow b get bhs b get 72 mul add put } for % Main symbol bars extend to full height connecting to separator; add-on bars keep their height /linheight 0 bhsrow { ceiling cvi 2 copy lt { exch } if pop } forall def /lindescent 0 bbsrow { floor cvi 2 copy gt { exch } if pop } forall def txt { dup 2 get lindescent neg add 2 exch put } forall /mainbars nbars def 0 1 sbs length 1 sub { dup sbs exch get type /realtype eq { 1 add 2 idiv /mainbars exch def exit } { pop } ifelse } for 0 1 mainbars 1 sub { bhsrow exch linheight put } for % Rasterize linear rows, deduplicating identical adjacent rows using a string buffer /rowbuf pixx string def /prevrow () def /linrowheights 72 array def /lri 0 def /linpixs [ linheight 1 sub -1 lindescent { /y exch def /p 0 def linpad { rowbuf p 3 -1 roll put /p p 1 add def } forall rowbuf p 0 put /p p 1 add def 0 1 sbs length 1 sub { /i exch def i 2 mod 0 eq { bbsrow i 2 idiv get y gt bhsrow i 2 idiv get y lt or { 0 } { 1 } ifelse } { 0 } ifelse sbs i get cvi { rowbuf p 2 index put /p p 1 add def } repeat pop } for diff 0 lt { rowbuf p 0 put /p p 1 add def } if rowbuf prevrow eq { linrowheights lri 1 sub 2 copy get 1 add put % Bump multiplier } { prevrow length 0 gt { prevrow {} forall } if % Commit previous batch /prevrow rowbuf pixx string copy def linrowheights lri 1 put /lri lri 1 add def } ifelse } for prevrow {} forall % Commit final batch ] def /linrowheights linrowheights 0 lri getinterval def /pixs [ 0 ccpixx ccpixs length 1 sub { /i exch def ccpixs i ccpixx getinterval aload pop ccrpad aload pop } for linpad aload pop 0 1 49 {0} repeat 1 0 ccrpad aload pop linpad aload pop 1 0 49 {0} repeat 0 1 ccrpad aload pop linpad aload pop 0 1 49 {0} repeat 1 0 ccrpad aload pop linpixs aload pop ] def /rowheights [ ccrowheights aload pop 2 2 2 linrowheights aload pop ] def /pixy 0 rowheights {add} forall def /borderleft linsym /borderleft 2 copy known { get } { pop pop 10 } ifelse linpad length 1 add sub 1 % CC-A QZ; left inset 0 2 copy lt { exch } if pop dup 0 lt { pop 0 } if def /borderright linsym /borderright 2 copy known { get } { pop pop 10 } ifelse pixx linpad length sub 1 sub linwidth sub sub 1 ccrpad length sub % CC-A QZ; right inset ccrpad 2 copy lt { exch } if pop dup 0 lt { pop 0 } if def /bordertop 1 def /borderbottom linsym /borderbottom 2 copy known { get } { pop pop 0 } ifelse lindescent add def % Guard positions adjusted for linear offset within matrix /guardleftpos linsym /guardleftpos 2 copy known { get linpad length 1 add sub } { pop pop 0 } ifelse def /guardleftypos linsym /guardleftypos 2 copy known { get lindescent neg add } { pop pop 0 } ifelse def /guardrightpos linsym /guardrightpos 2 copy known { get linpad length 1 add linwidth add pixx sub add } { pop pop 0 } ifelse def /guardrightypos linsym /guardrightypos 2 copy known { get lindescent neg add } { pop pop 0 } ifelse def % Height is already applied to the linear bars via bhs; don't let renmatrix rescale options /height undef << /ren /renmatrix /pixs pixs /pixx pixx /pixy pixy /rowheights rowheights /height pixy 72 div /width pixx 72 div /borderleft borderleft /borderright borderright /bordertop bordertop /borderbottom borderbottom /guardwhitespace guardwhitespace /guardleftpos guardleftpos /guardleftypos guardleftypos /guardrightpos guardrightpos /guardrightypos guardrightypos /guardwidth guardwidth /guardheight guardheight /txt txt /text1xalign text1xalign /text1yalign text1yalign /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /upcecomposite dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER upcecomposite-- % --BEGIN ENCODER databaromnicomposite-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput gs1process setanycolor fifocache rsecprime render renlinear renmatrix databaromni micropdf417 pdf417 gs1-cc-- % --DESC: GS1 DataBar Omnidirectional Composite % --EXAM: (01)09521234543213|(11)990102 % --EXOP: % --RNDR: renmatrix % --FMLY: GS1 Composite Symbols %%BeginResource: uk.co.terryburton.bwipp databaromnicomposite 0.0 2026052800 136700 120516 %%BeginData: 226 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render 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 /renmatrix dup /uk.co.terryburton.bwipp findresource put begin /databaromnicomposite.seppad [ 0 0 0 0 ] readonly def /databaromnicomposite.findersep [ 0 0 0 0 0 0 0 0 0 0 1 0 0 ] readonly def /databaromnicomposite.f3pat [ 1 1 1 1 1 1 1 1 1 0 1 1 1 ] readonly def /databaromnicomposite { 32 dict begin { /dontdraw false def /parse false def /dontlint false def /lintreqs true def /strictspec false def /width 0 def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % 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 % % Apply AST spec overrides and resolve physical specification % /databaromnicomposite ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec options (ast) undef options (mag) undef options (propspec) propspec put options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put options (hnom) hnom put options (modunit) modunit put options (lintype) (databaromni) put options (linkage) true put options (inkspreadv) 0.0 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 % % Generate metrics for the linear part % /uk.co.terryburton.bwipp._dontdraw true def linear options //databaromni exec dup (sbs) get /linsbs exch def dup (bhs) get 0 get 72 mul /linheight exch def /linsym exch def % % 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 true 0 1 12 {dup bot exch fp add get exch //databaromnicomposite.f3pat exch get eq and} for { % Right shifted module for value 3 finder sep fp //databaromnicomposite.findersep putinterval } if } def mark 0 1 linsbs length 1 sub { /i exch def linsbs i get cvi { i 2 mod 0 eq {1} {0} ifelse } repeat % Emit sbs[i] pixels of bar(1)/space(0) per index parity } for counttomark array astore /bot exch def pop /sep [ bot {1 exch sub} forall ] def sep 0 //databaromnicomposite.seppad putinterval sep sep length 4 sub //databaromnicomposite.seppad putinterval 19 sepfinder 65 sepfinder % Finder positions shifted for the 96-module linear layout (was 18 and 64 for the former 95-module layout) % % Generate metrics for the 2D part % options (strictspec) undef options (loosespec) undef options (propspec) undef comp options //gs1-cc exec /compsym exch def /ccpixs compsym /pixs get def /ccrowheights compsym /rowheights get def /ccpixx compsym /pixx get def /linpixs [ 0 1 linsbs length 1 sub { /i exch def linsbs i get cvi { i 2 mod 0 eq {1} {0} ifelse } repeat % Emit sbs[i] pixels of bar(1)/space(0) per index parity } for ] def /linheight linheight cvi def /ccrows ccrowheights length 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 0 0 0 0 linpixs aload pop % Left pad with 4 spaces ] def /rowheights [ ccrowheights aload pop 1 linheight ] def /pixx ccpixx 1 add def % 100 /txt [ linsym /txt 2 copy known { get { aload pop 4 -1 roll pixx linpixs length sub 1 add add 4 1 roll 5 array astore } forall } { pop pop } ifelse ] def /text1xalign linsym /text1xalign 2 copy known { get } { pop pop (unset) } ifelse def /text1yalign linsym /text1yalign 2 copy known { get } { pop pop (unset) } ifelse def /pixy 0 rowheights {add} forall def /borderleft linsym /borderleft 2 copy known { get } { pop pop 10 } ifelse pixx linpixs length sub 1 add sub 1 % CC QZ; left inset 0 2 copy lt { exch } if pop dup 0 lt { pop 0 } if def /borderright linsym /borderright 2 copy known { get } { pop pop 10 } ifelse % right inset 0 0 % CC QZ 1; right inset 1 2 copy lt { exch } if pop dup 0 lt { pop 0 } if def /bordertop 1 def /borderbottom linsym /borderbottom 2 copy known { get } { pop pop 0 } ifelse def % Height is already applied to the linear bars via bhs; don't let renmatrix rescale options /height undef << /ren /renmatrix /pixs pixs /pixx pixx /pixy pixy /rowheights rowheights /height pixy 72 div /width pixx 72 div /borderleft borderleft /borderright borderright /bordertop bordertop /borderbottom borderbottom /txt txt /text1xalign text1xalign /text1yalign text1yalign /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /databaromnicomposite dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER databaromnicomposite-- % --BEGIN ENCODER databarstackedcomposite-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput gs1process setanycolor fifocache rsecprime render renlinear renmatrix databaromni databarstacked micropdf417 pdf417 gs1-cc-- % --DESC: GS1 DataBar Stacked Composite % --EXAM: (01)09521234543213|(17)010200 % --EXOP: % --RNDR: renmatrix % --FMLY: GS1 Composite Symbols %%BeginResource: uk.co.terryburton.bwipp databarstackedcomposite 0.0 2026052800 137555 121355 %%BeginData: 220 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /databarstacked 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 /databarstackedcomposite.seppad [ 0 0 0 0 ] readonly def /databarstackedcomposite.findersep [ 0 0 0 0 0 0 0 0 0 0 1 0 0 ] readonly def /databarstackedcomposite.f3pat [ 1 1 1 1 1 1 1 1 1 0 1 1 1 ] readonly def /databarstackedcomposite { 32 dict begin { /dontdraw false def /parse false def /dontlint false def /lintreqs true def /strictspec false def /width 0 def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % 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 % % Apply AST spec overrides and resolve physical specification % /databarstackedcomposite ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec options (ast) undef options (mag) undef options (propspec) propspec put options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put options (hnom) hnom put options (modunit) modunit put options (lintype) (databarstacked) put options (linkage) true put options (inkspreadv) 0.0 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 % % Generate metrics for the linear part % /uk.co.terryburton.bwipp._dontdraw true def linear options //databarstacked exec dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def dup (pixy) get /linheight exch def /linsym exch def /linpixs linsym /pixs get def /linrowheights linsym /rowheights get def % % 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 true 0 1 12 {dup bot exch fp add get exch //databarstackedcomposite.f3pat exch get eq and} for { % Right shifted module for value 3 finder sep fp //databarstackedcomposite.findersep putinterval } if } def /sep [ bot {1 exch sub} forall ] def sep 0 //databarstackedcomposite.seppad putinterval sep sep length 4 sub //databarstackedcomposite.seppad putinterval 18 sepfinder % % Generate metrics for the 2D part % options (strictspec) undef options (loosespec) undef options (propspec) undef comp options //gs1-cc exec /compsym exch def /ccpixs compsym /pixs get def /ccrowheights compsym /rowheights get def /ccpixx compsym /pixx get def /linwidth sep length def % 50 /ccrows ccrowheights length def % ccpixx is 55 for both 2-col CC-A and 2-col CC-B /pixs [ 0 ccpixx ccpixs length 1 sub { % Left pad composite with 1 space /i exch def 0 ccpixs i ccpixx getinterval aload pop } for sep aload pop 0 0 0 0 0 0 0 linwidth linpixs length 1 sub { % Right pad linear with 6 spaces /i exch def linpixs i linwidth getinterval aload pop 0 0 0 0 0 0 } for ] def /rowheights [ ccrowheights aload pop 1 linrowheights aload pop ] def /pixx ccpixx 1 add def % 56 /txt [ linsym /txt 2 copy known { get { aload pop 5 array astore % No x offset needed; linear at column 0 } forall } { pop pop } ifelse ] def /text1xalign linsym /text1xalign 2 copy known { get } { pop pop (unset) } ifelse def /text1yalign linsym /text1yalign 2 copy known { get } { pop pop (unset) } ifelse def /pixy 0 rowheights {add} forall def % Quiet zone borders: T=2D, L/R=max(1D,2D), B=1D /borderleft linsym /borderleft 2 copy known { get } { pop pop 0 } ifelse % linear left inset 0 1 1 sub % CC QZ; left inset 1 2 copy lt { exch } if pop dup 0 lt { pop 0 } if def /borderright linsym /borderright 2 copy known { get } { pop pop 0 } ifelse pixx linwidth sub sub % linear right inset 1 % CC QZ; right inset 0 2 copy lt { exch } if pop dup 0 lt { pop 0 } if def /bordertop 1 def /borderbottom linsym /borderbottom 2 copy known { get } { pop pop 0 } ifelse def % Height is already applied to the linear bars via bhs; don't let renmatrix rescale options /height undef << /ren /renmatrix /pixs pixs /pixx pixx /pixy pixy /rowheights rowheights /height pixy 72 div /width pixx 72 div /borderleft borderleft /borderright borderright /bordertop bordertop /borderbottom borderbottom /txt txt /text1xalign text1xalign /text1yalign text1yalign /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /databarstackedcomposite dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER databarstackedcomposite-- % --BEGIN ENCODER databarstackedomnicomposite-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput gs1process setanycolor fifocache rsecprime render renlinear renmatrix databaromni databarstackedomni micropdf417 pdf417 gs1-cc-- % --DESC: GS1 DataBar Stacked Omnidirectional Composite % --EXAM: (01)03612345678904|(11)990102 % --EXOP: % --RNDR: renmatrix % --FMLY: GS1 Composite Symbols %%BeginResource: uk.co.terryburton.bwipp databarstackedomnicomposite 0.0 2026052800 137591 121467 %%BeginData: 220 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /databarstackedomni 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 /databarstackedomnicomposite.seppad [ 0 0 0 0 ] readonly def /databarstackedomnicomposite.findersep [ 0 0 0 0 0 0 0 0 0 0 1 0 0 ] readonly def /databarstackedomnicomposite.f3pat [ 1 1 1 1 1 1 1 1 1 0 1 1 1 ] readonly def /databarstackedomnicomposite { 32 dict begin { /dontdraw false def /parse false def /dontlint false def /lintreqs true def /strictspec false def /width 0 def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % 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 % % Apply AST spec overrides and resolve physical specification % /databarstackedomnicomposite ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec options (ast) undef options (mag) undef options (propspec) propspec put options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put options (hnom) hnom put options (modunit) modunit put options (lintype) (databarstackedomni) put options (linkage) true put options (inkspreadv) 0.0 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 % % Generate metrics for the linear part % /uk.co.terryburton.bwipp._dontdraw true def linear options //databarstackedomni exec dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def dup (pixy) get /linheight exch def /linsym exch def /linpixs linsym /pixs get def /linrowheights linsym /rowheights get def % % 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 true 0 1 12 {dup bot exch fp add get exch //databarstackedomnicomposite.f3pat exch get eq and} for { % Right shifted module for value 3 finder sep fp //databarstackedomnicomposite.findersep putinterval } if } def /sep [ bot {1 exch sub} forall ] def sep 0 //databarstackedomnicomposite.seppad putinterval sep sep length 4 sub //databarstackedomnicomposite.seppad putinterval 18 sepfinder % % Generate metrics for the 2D part % options (strictspec) undef options (loosespec) undef options (propspec) undef comp options //gs1-cc exec /compsym exch def /ccpixs compsym /pixs get def /ccrowheights compsym /rowheights get def /ccpixx compsym /pixx get def /linwidth sep length def % 50 /ccrows ccrowheights length def % ccpixx is 55 for both 2-col CC-A and 2-col CC-B /pixs [ 0 ccpixx ccpixs length 1 sub { % Left pad composite with 1 space /i exch def 0 ccpixs i ccpixx getinterval aload pop } for sep aload pop 0 0 0 0 0 0 0 linwidth linpixs length 1 sub { % Right pad linear with 6 spaces /i exch def linpixs i linwidth getinterval aload pop 0 0 0 0 0 0 } for ] def /rowheights [ ccrowheights aload pop 1 linrowheights aload pop ] def /pixx ccpixx 1 add def % 56 /txt [ linsym /txt 2 copy known { get { aload pop 5 array astore % No x offset needed; linear at column 0 } forall } { pop pop } ifelse ] def /text1xalign linsym /text1xalign 2 copy known { get } { pop pop (unset) } ifelse def /text1yalign linsym /text1yalign 2 copy known { get } { pop pop (unset) } ifelse def /pixy 0 rowheights {add} forall def % Quiet zone borders: T=2D, L/R=max(1D,2D), B=1D /borderleft linsym /borderleft 2 copy known { get } { pop pop 0 } ifelse % linear left inset 0 1 1 sub % CC QZ; left inset 1 2 copy lt { exch } if pop dup 0 lt { pop 0 } if def /borderright linsym /borderright 2 copy known { get } { pop pop 0 } ifelse pixx linwidth sub sub % linear right inset 1 % CC QZ; right inset 0 2 copy lt { exch } if pop dup 0 lt { pop 0 } if def /bordertop 1 def /borderbottom linsym /borderbottom 2 copy known { get } { pop pop 0 } ifelse def % Height is already applied to the linear bars via bhs; don't let renmatrix rescale options /height undef << /ren /renmatrix /pixs pixs /pixx pixx /pixy pixy /rowheights rowheights /height pixy 72 div /width pixx 72 div /borderleft borderleft /borderright borderright /bordertop bordertop /borderbottom borderbottom /txt txt /text1xalign text1xalign /text1yalign text1yalign /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /databarstackedomnicomposite dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER databarstackedomnicomposite-- % --BEGIN ENCODER databartruncatedcomposite-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput gs1process setanycolor fifocache rsecprime render renlinear renmatrix databaromni databartruncated micropdf417 pdf417 gs1-cc-- % --DESC: GS1 DataBar Truncated Composite % --EXAM: (01)09521234543213|(11)990102 % --EXOP: % --RNDR: renmatrix % --FMLY: GS1 Composite Symbols %%BeginResource: uk.co.terryburton.bwipp databartruncatedcomposite 0.0 2026052800 139520 123321 %%BeginData: 226 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 17 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /databartruncated 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 /databartruncatedcomposite.seppad [ 0 0 0 0 ] readonly def /databartruncatedcomposite.findersep [ 0 0 0 0 0 0 0 0 0 0 1 0 0 ] readonly def /databartruncatedcomposite.f3pat [ 1 1 1 1 1 1 1 1 1 0 1 1 1 ] readonly def /databartruncatedcomposite { 32 dict begin { /dontdraw false def /parse false def /dontlint false def /lintreqs true def /strictspec false def /width 0 def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % 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 % % Apply AST spec overrides and resolve physical specification % /databartruncatedcomposite ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec options (ast) undef options (mag) undef options (propspec) propspec put options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put options (hnom) hnom put options (modunit) modunit put options (lintype) (databartruncated) put options (linkage) true put options (inkspreadv) 0.0 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 % % Generate metrics for the linear part % /uk.co.terryburton.bwipp._dontdraw true def linear options //databartruncated exec dup (sbs) get /linsbs exch def dup (bhs) get 0 get 72 mul /linheight exch def /linsym exch def % % 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 true 0 1 12 {dup bot exch fp add get exch //databartruncatedcomposite.f3pat exch get eq and} for { % Right shifted module for value 3 finder sep fp //databartruncatedcomposite.findersep putinterval } if } def mark 0 1 linsbs length 1 sub { /i exch def linsbs i get cvi { i 2 mod 0 eq {1} {0} ifelse } repeat % Emit sbs[i] pixels of bar(1)/space(0) per index parity } for counttomark array astore /bot exch def pop /sep [ bot {1 exch sub} forall ] def sep 0 //databartruncatedcomposite.seppad putinterval sep sep length 4 sub //databartruncatedcomposite.seppad putinterval 19 sepfinder 65 sepfinder % Finder positions shifted for the 96-module linear layout (was 18 and 64 for the former 95-module layout) % % Generate metrics for the 2D part % options (strictspec) undef options (loosespec) undef options (propspec) undef comp options //gs1-cc exec /compsym exch def /ccpixs compsym /pixs get def /ccrowheights compsym /rowheights get def /ccpixx compsym /pixx get def /linpixs [ 0 1 linsbs length 1 sub { /i exch def linsbs i get cvi { i 2 mod 0 eq {1} {0} ifelse } repeat % Emit sbs[i] pixels of bar(1)/space(0) per index parity } for ] def /linheight linheight cvi def /ccrows ccrowheights length 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 0 0 0 0 linpixs aload pop % Left pad with 4 spaces ] def /rowheights [ ccrowheights aload pop 1 linheight ] def /pixx ccpixx 1 add def % 100 /txt [ linsym /txt 2 copy known { get { aload pop 4 -1 roll pixx linpixs length sub 1 add add 4 1 roll 5 array astore } forall } { pop pop } ifelse ] def /text1xalign linsym /text1xalign 2 copy known { get } { pop pop (unset) } ifelse def /text1yalign linsym /text1yalign 2 copy known { get } { pop pop (unset) } ifelse def /pixy 0 rowheights {add} forall def /borderleft linsym /borderleft 2 copy known { get } { pop pop 10 } ifelse pixx linpixs length sub 1 add sub 1 % CC QZ; left inset 0 2 copy lt { exch } if pop dup 0 lt { pop 0 } if def /borderright linsym /borderright 2 copy known { get } { pop pop 10 } ifelse % right inset 0 0 % CC QZ 1; right inset 1 2 copy lt { exch } if pop dup 0 lt { pop 0 } if def /bordertop 1 def /borderbottom linsym /borderbottom 2 copy known { get } { pop pop 0 } ifelse def % Height is already applied to the linear bars via bhs; don't let renmatrix rescale options /height undef << /ren /renmatrix /pixs pixs /pixx pixx /pixy pixy /rowheights rowheights /height pixy 72 div /width pixx 72 div /borderleft borderleft /borderright borderright /bordertop bordertop /borderbottom borderbottom /txt txt /text1xalign text1xalign /text1yalign text1yalign /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /databartruncatedcomposite dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER databartruncatedcomposite-- % --BEGIN ENCODER databarlimitedcomposite-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput gs1process setanycolor fifocache rsecprime render renlinear renmatrix databarlimited micropdf417 pdf417 gs1-cc-- % --DESC: GS1 DataBar Limited Composite % --EXAM: (01)09521234543213|(21)abcdefghijklmnopqrst % --EXOP: % --RNDR: renmatrix % --FMLY: GS1 Composite Symbols %%BeginResource: uk.co.terryburton.bwipp databarlimitedcomposite 0.0 2026052800 118066 117790 %%BeginData: 208 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /databarlimited 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 /databarlimitedcomposite.sepleft [ 0 0 0 ] readonly def /databarlimitedcomposite.sepright [ 0 0 0 0 0 0 0 0 0 ] readonly def /databarlimitedcomposite { 16 dict begin { /dontdraw false def /parse false def /dontlint false def /lintreqs true def /strictspec false def /width 0 def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % 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 % % Apply AST spec overrides and resolve physical specification % /databarlimitedcomposite ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec options (ast) undef options (mag) undef options (propspec) propspec put options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put options (hnom) hnom put options (modunit) modunit put options (lintype) (databarlimited) put options (linkage) true put options (inkspreadv) 0.0 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 % % Generate metrics for the linear part % /uk.co.terryburton.bwipp._dontdraw true def linear options //databarlimited exec dup (sbs) get /linsbs exch def dup (bhs) get 0 get 72 mul /linheight exch def /linsym exch def % % Plot the separator and linear bitmap (index-based expansion of sbs) % /linpixs [ 0 1 linsbs length 1 sub { /i exch def linsbs i get cvi { i 2 mod 0 eq {1} {0} ifelse } repeat % Emit sbs[i] pixels of bar(1)/space(0) per index parity } for ] def /sep [ linpixs {1 exch sub} forall ] def sep 0 //databarlimitedcomposite.sepleft putinterval sep sep length 9 sub //databarlimitedcomposite.sepright putinterval % 4 + 5 right guard spaces % % Generate metrics for the 2D part % options (strictspec) undef options (loosespec) undef options (propspec) undef comp options //gs1-cc exec /compsym exch def /ccpixs compsym /pixs get def /ccrowheights compsym /rowheights get def /ccpixx compsym /pixx get def /linheight linheight cvi def /ccrows ccrowheights length def % ccpixx is 72 for CC-A and 82 for CC-B; linpixs length is 79 ccpixx 72 eq { % 3-col CC-A /pixs [ 0 ccpixx ccpixs length 1 sub { % Left pad CC with 1 space; right pad with 1 space + 5 right guard spaces /i exch def 0 ccpixs i ccpixx getinterval aload pop 0 0 0 0 0 0 } for sep aload pop linpixs aload pop ] def /pixx linpixs length def % 79 } { % 3-col CC-B /pixs [ 0 ccpixx ccpixs length 1 sub { % Right pad CC with 1 space + 5 right guard spaces /i exch def ccpixs i ccpixx getinterval aload pop 0 0 0 0 0 0 } for 0 0 0 0 0 0 0 0 0 sep aload pop 0 0 0 0 0 0 0 0 0 linpixs aload pop % Left pad sep/linpixs with 9 spaces ] def /pixx ccpixx 6 add def % 88 } ifelse /rowheights [ ccrowheights aload pop 1 linheight ] def /txt [ linsym /txt 2 copy known { get { aload pop 4 -1 roll pixx linpixs length sub 1 add add 4 1 roll 5 array astore } forall } { pop pop } ifelse ] def /text1xalign linsym /text1xalign 2 copy known { get } { pop pop (unset) } ifelse def /text1yalign linsym /text1yalign 2 copy known { get } { pop pop (unset) } ifelse def /pixy 0 rowheights {add} forall def /borderleft linsym /borderleft 2 copy known { get } { pop pop 10 } ifelse pixx linpixs length sub 1 add sub 1 pixx ccpixx sub 1 sub sub % CC QZ; left inset pixx-ccpixx-1 2 copy lt { exch } if pop dup 0 lt { pop 0 } if def /borderright linsym /borderright 2 copy known { get } { pop pop 10 } ifelse % right inset 0 0 % CC QZ 1; right inset 1 2 copy lt { exch } if pop dup 0 lt { pop 0 } if def /bordertop 1 def /borderbottom linsym /borderbottom 2 copy known { get } { pop pop 0 } ifelse def % Height is already applied to the linear bars via bhs; don't let renmatrix rescale options /height undef << /ren /renmatrix /pixs pixs /pixx pixx /pixy pixy /rowheights rowheights /height pixy 72 div /width pixx 72 div /borderleft borderleft /borderright borderright /bordertop bordertop /borderbottom borderbottom /txt txt /text1xalign text1xalign /text1yalign text1yalign /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /databarlimitedcomposite dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER databarlimitedcomposite-- % --BEGIN ENCODER databarexpandedcomposite-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput gs1process setanycolor fifocache rsecprime render renlinear renmatrix databarexpanded micropdf417 pdf417 gs1-cc-- % --DESC: GS1 DataBar Expanded Composite % --EXAM: (01)09521234543213(3103)001234|(91)1A2B3C4D5E % --EXOP: % --RNDR: renmatrix % --FMLY: GS1 Composite Symbols %%BeginResource: uk.co.terryburton.bwipp databarexpandedcomposite 0.0 2026052800 120574 116924 %%BeginData: 222 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /databarexpanded 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 /databarexpandedcomposite { 32 dict begin { /dontdraw false def /parse false def /dontlint false def /lintreqs true def /strictspec false def /width 0 def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % 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 % % Apply AST spec overrides and resolve physical specification % /databarexpandedcomposite ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec options (ast) undef options (mag) undef options (propspec) propspec put options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put options (hnom) hnom put options (modunit) modunit put options (lintype) (databarexpanded) put options (linkage) true put options (inkspreadv) 0.0 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 % % Generate metrics for the linear part % /uk.co.terryburton.bwipp._dontdraw true def linear options //databarexpanded exec dup (sbs) get /linsbs exch def dup (bhs) get 0 get 72 mul /linheight exch def /linsym exch def % % 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 mark 0 1 linsbs length 1 sub { /i exch def linsbs i get cvi { i 2 mod 0 eq {1} {0} ifelse } repeat % Emit sbs[i] pixels of bar(1)/space(0) per index parity } for counttomark array astore /bot exch def pop /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 (shifted +1 from 18, 69 for the 96/100-module layout that now includes the left guard space) 19 98 bot length 13 sub {} for 70 98 bot length 13 sub {} for ] {sepfinder} forall % % Generate metrics for the 2D part % options (strictspec) undef options (loosespec) undef options (propspec) undef comp options //gs1-cc exec /compsym exch def /ccpixs compsym /pixs get def /ccrowheights compsym /rowheights get def /ccpixx compsym /pixx get def /linpixs [ 0 1 linsbs length 1 sub { /i exch def linsbs i get cvi { i 2 mod 0 eq {1} {0} ifelse } repeat % Emit sbs[i] pixels of bar(1)/space(0) per index parity } for ] def /linheight linheight cvi def /ccrows ccrowheights length def /diff linpixs length ccpixx sub def % Minimum linpixs length is 102, ccpixx is 99 /ccrpad [ diff 2 sub {0} repeat ] def /pixs [ 0 ccpixx ccpixs length 1 sub { /i exch def 0 0 ccpixs i ccpixx getinterval aload pop ccrpad aload pop } for sep aload pop linpixs aload pop ] def /rowheights [ ccrowheights aload pop 1 linheight ] def /pixx linpixs length def /txt [ linsym /txt 2 copy known { get { aload pop 4 -1 roll pixx linpixs length sub 1 add add 4 1 roll 5 array astore } forall } { pop pop } ifelse ] def /text1xalign linsym /text1xalign 2 copy known { get } { pop pop (unset) } ifelse def /text1yalign linsym /text1yalign 2 copy known { get } { pop pop (unset) } ifelse def /pixy 0 rowheights {add} forall def /borderleft linsym /borderleft 2 copy known { get } { pop pop 10 } ifelse pixx linpixs length sub 1 add sub 1 2 sub % CC QZ; left inset 2 2 copy lt { exch } if pop dup 0 lt { pop 0 } if def /borderright linsym /borderright 2 copy known { get } { pop pop 10 } ifelse % right inset 0 1 ccrpad length sub % CC QZ; right inset ccrpad 2 copy lt { exch } if pop dup 0 lt { pop 0 } if def /bordertop 1 def /borderbottom linsym /borderbottom 2 copy known { get } { pop pop 0 } ifelse def % Height is already applied to the linear bars via bhs; don't let renmatrix rescale options /height undef << /ren /renmatrix /pixs pixs /pixx pixx /pixy pixy /rowheights rowheights /height pixy 72 div /width pixx 72 div /borderleft borderleft /borderright borderright /bordertop bordertop /borderbottom borderbottom /txt txt /text1xalign text1xalign /text1yalign text1yalign /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /databarexpandedcomposite dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER databarexpandedcomposite-- % --BEGIN ENCODER databarexpandedstackedcomposite-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput gs1process setanycolor fifocache rsecprime render 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 % --FMLY: GS1 Composite Symbols %%BeginResource: uk.co.terryburton.bwipp databarexpandedstackedcomposite 0.0 2026052800 118220 124907 %%BeginData: 213 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render 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.seppad [ 0 0 0 0 ] readonly def /databarexpandedstackedcomposite { 32 dict begin { /dontdraw false def /parse false def /dontlint false def /lintreqs true def /strictspec false def /width 0 def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % 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 % % Apply AST spec overrides and resolve physical specification % /databarexpandedstackedcomposite ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec options (ast) undef options (mag) undef options (propspec) propspec put options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put options (hnom) hnom put options (modunit) modunit put options (lintype) (databarexpandedstacked) put options (linkage) true put options (inkspreadv) 0.0 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 % % Generate metrics for the linear part % /uk.co.terryburton.bwipp._dontdraw true def linear options //databarexpandedstacked exec dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def dup (pixy) get /linheight exch def /linsym exch def /linpixs linsym /pixs get def /linrowheights linsym /rowheights get def % % 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 //databarexpandedstackedcomposite.seppad putinterval sep sep length 4 sub //databarexpandedstackedcomposite.seppad putinterval [ % Finder pattern module positions 19 98 bot length 13 sub {} for 70 98 bot length 13 sub {} for ] {sepfinder} forall % % Generate metrics for the 2D part % options (strictspec) undef options (loosespec) undef options (propspec) undef comp options //gs1-cc exec /compsym exch def /ccpixs compsym /pixs get def /ccrowheights compsym /rowheights 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 /ccrows ccrowheights length 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 /rowheights [ ccrowheights aload pop 1 linrowheights aload pop ] def /txt [ linsym /txt 2 copy known { get { aload pop 5 array astore % No x offset needed; linear at column 0 } forall } { pop pop } ifelse ] def /text1xalign linsym /text1xalign 2 copy known { get } { pop pop (unset) } ifelse def /text1yalign linsym /text1yalign 2 copy known { get } { pop pop (unset) } ifelse def /pixy 0 rowheights {add} forall def % Quiet zone borders: T=2D, L/R=max(1D,2D), B=1D /borderleft linsym /borderleft 2 copy known { get } { pop pop 0 } ifelse % linear left inset 0 1 cclpad length sub % CC QZ; left inset cclpad 2 copy lt { exch } if pop dup 0 lt { pop 0 } if def /borderright linsym /borderright 2 copy known { get } { pop pop 0 } ifelse % linear right inset 0 1 ccrpad length sub % CC QZ; right inset ccrpad 2 copy lt { exch } if pop dup 0 lt { pop 0 } if def /bordertop 1 def /borderbottom linsym /borderbottom 2 copy known { get } { pop pop 0 } ifelse def % Height is already applied to the linear bars via bhs; don't let renmatrix rescale options /height undef << /ren /renmatrix /pixs pixs /pixx pixx /pixy pixy /rowheights rowheights /height pixy 72 div /width pixx 72 div /borderleft borderleft /borderright borderright /bordertop bordertop /borderbottom borderbottom /txt txt /text1xalign text1xalign /text1yalign text1yalign /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /databarexpandedstackedcomposite dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER databarexpandedstackedcomposite-- % --BEGIN ENCODER gs1-128composite-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput gs1process setanycolor fifocache rsecprime render renlinear renmatrix code128 gs1-128 micropdf417 pdf417 gs1-cc-- % --DESC: GS1-128 Composite % --EXAM: (00)095287654321012346|(02)09521234543213(37)24(10)1234567ABCDEFG % --EXOP: ccversion=c % --RNDR: renmatrix % --FMLY: GS1 Composite Symbols %%BeginResource: uk.co.terryburton.bwipp gs1-128composite 0.0 2026052800 126387 126236 %%BeginData: 234 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 9 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /gs1-128 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 /gs1-128composite { 32 dict begin { /dontdraw false def /parse false def /dontlint false def /lintreqs true def /propspec false def /loosespec false def /strictspec false def /width 0 def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def /hnom -1.0 def /modunit 1 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % 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 % % Apply AST spec overrides and resolve physical specification % /gs1-128composite ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec options (ast) undef options (mag) undef options (propspec) propspec put options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put options (hnom) hnom put options (modunit) modunit put options (inkspreadv) 0.0 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 % % Dummy linear metrics with CC-A to get width % options (linkagea) true put /uk.co.terryburton.bwipp._dontdraw true def linear << options {} forall >> //gs1-128 exec (sbs) get 0 exch {add} forall /linwidth exch def % % Generate metrics for the 2D part % options (lintype) (gs1-128) put options (linwidth) linwidth put comp << options {} forall >> dup (strictspec) undef dup (propspec) undef dup (loosespec) undef //gs1-cc exec /compsym exch def compsym (pixx) get 99 eq {(a)} {(c)} ifelse /linktype exch def compsym (borderbottom) 0 put % % Generate metrics for the linear part % linktype (a) eq { options (linkagea) true put options (linkagec) false put } { options (linkagea) false put options (linkagec) true put } ifelse linear << options {} forall >> //gs1-128 exec dup (sbs) get /linsbs exch def dup (bhs) get 0 get 72 mul /linheight exch def /linsym exch def % % Plot the separator % mark 1 linsbs {1 index 0 eq {{1}} {{0}} ifelse repeat} forall counttomark 1 sub array astore /sep exch def pop pop % % Construct the composite symbol from the linear and 2D parts % linktype (a) eq { /s linwidth 2 sub 11 idiv def /p s 9 sub 2 idiv def /x s p sub 1 sub 11 mul 10 add p 0 eq {2 add} if 99 sub def } { /x -7 def } ifelse /ccpixs compsym /pixs get def /ccrowheights compsym /rowheights get def /ccpixx compsym /pixx get def /linpixs [ linsbs { 1 index 1 eq {{0}} {{1}} ifelse repeat } forall % Alternates i 1/0's (linsbs always begins with "2") ] def x 0 gt { % Left pad composite /cclpad [ x {0} repeat ] def /linlpad 0 array def } { % Left pad linear /cclpad 0 array def /linlpad [ x neg {0} repeat ] def } ifelse /diff linwidth ccpixx x add sub def diff 0 gt { % Right pad composite /ccrpad [ diff {0} repeat ] def /linrpad 0 array def } { % Right pad linear /ccrpad 0 array def /linrpad [ diff neg {0} repeat ] def } ifelse /txt [ linsym /txt 2 copy known { get { aload pop 4 -1 roll linlpad length add 4 1 roll 5 array astore } forall } { pop pop } ifelse ] def /text1xalign linsym /text1xalign 2 copy known { get } { pop pop (unset) } ifelse def /text1yalign linsym /text1yalign 2 copy known { get } { pop pop (unset) } ifelse def /linheight linheight cvi def /ccrows ccrowheights length def /pixs [ 0 ccpixx ccpixs length 1 sub { /i exch def cclpad aload pop ccpixs i ccpixx getinterval aload pop ccrpad aload pop } for linlpad aload pop sep aload pop linrpad aload pop linlpad aload pop linpixs aload pop linrpad aload pop ] def /rowheights [ ccrowheights aload pop 1 linheight ] def /pixx cclpad length ccpixx add ccrpad length add def /pixy 0 rowheights {add} forall def /ccqz linktype (a) eq { 1 } { 2 } ifelse def /borderleft linsym /borderleft 2 copy known { get } { pop pop 10 } ifelse linlpad length sub ccqz cclpad length sub 2 copy lt { exch } if pop dup 0 lt { pop 0 } if def /borderright linsym /borderright 2 copy known { get } { pop pop 10 } ifelse linrpad length sub ccqz ccrpad length sub 2 copy lt { exch } if pop dup 0 lt { pop 0 } if def /bordertop ccqz def /borderbottom linsym /borderbottom 2 copy known { get } { pop pop 0 } ifelse def % Height is already applied to the linear bars via bhs; don't let renmatrix rescale options /height undef << /ren /renmatrix /pixs pixs /pixx pixx /pixy pixy /rowheights rowheights /height pixy 72 div /width pixx 72 div /borderleft borderleft /borderright borderright /bordertop bordertop /borderbottom borderbottom /txt txt /text1xalign text1xalign /text1yalign text1yalign /strictspec strictspec /loosespec loosespec /xdim xdim /xmin xmin /xmax xmax /modunit modunit /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /gs1-128composite dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER gs1-128composite-- % --BEGIN ENCODER d3aqr-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor fifocache rsecbinary render renmatrix qrcode-- % --DESC: D3 AQR (beta) % --EXAM: HTTPS://ID.GS1.ORG/01/09521234543213/22/ABC%2D123?99=XYZ-987 % --EXOP: category=2842 hostratio=2 % --RNDR: renmatrix % --FMLY: Two-dimensional symbols %%BeginResource: uk.co.terryburton.bwipp d3aqr 0.0 2026052800 101181 97432 %%BeginData: 230 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 6 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /qrcode dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put begin % % Positions of the four 0.5X dash tips (two per arm) % /d3aqr.tips [ [ 6 2 ] [ 6 3 ] [ 2 6 ] [ 3 6 ] ] readonly def % % Accepted D3:host pitch ratios mapped to (halfx, hostmod) cell counts. % /d3aqr.hostratios << 2.0 << /halfx 1 /hostmod 1 >> 2.5 << /halfx 5 /hostmod 4 >> 3.0 << /halfx 3 /hostmod 2 >> >> readonly def /d3aqr { 32 dict begin { /dontdraw false def /category -1 def /hostratio 2.0 def /strictspec false def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Validate options. % category -1 eq { /bwipp.d3aqrMissingCategory (The category option is required) //raiseerror exec } if category 0 lt category 16383 gt or { /bwipp.d3aqrCategoryOutOfRange (Category must be between 0 and 16383 inclusive) //raiseerror exec } if % % Resolve halfx and hostmod from hostratio. % //d3aqr.hostratios hostratio 2 copy known not { pop pop /bwipp.d3aqrInvalidHostRatio (hostratio must be 2, 2.5 or 3) //raiseerror exec } if get dup /halfx get /halfx exch def /hostmod get /hostmod exch def % % Apply AST spec overrides and resolve physical specification % /d3aqr ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec % % Encode the host QR Code, forcing modunit to 2 so that each host module is % 1 cell of the composite grid. Ensures that 2.5 D3-X finder and host are % pixel-locked. % /uk.co.terryburton.bwipp._dontdraw true def << options {} forall >> % Deep copy of options dup (modunit) 2 put dup (category) undef dup (strictspec) undef dup (loosespec) undef dup (propspec) undef dup (mag) undef dup (ast) undef dup (xdim) undef dup (xnom) undef dup (xmin) undef dup (xmax) undef barcode exch //qrcode exec /args exch def % % Extract metrics of host symbol % /hostpixs args /pixs get def /hostsize args /pixx get def % % Matrix sized to fit the full 9.5 D3-X arms and host symbol. % hostoffset is the top-left padding in cells; it grows beyond a % single 1 D3-X frame as necessary to fit the D3 component. % /hostcells hostsize hostmod mul def /hostoffset 2 halfx mul 29 halfx mul hostcells sub 2 copy lt {exch} if pop def /size hostoffset hostcells add 6 halfx mul add def % % 0-filled matrix. Each cell is half a D3-X; each host module % occupies hostmod x hostmod cells. % /pixs size size mul array def 0 1 size size mul 1 sub { pixs exch 0 put } for % % Place the host: each input cell maps to a hostmod x hostmod output block. % 0 1 hostcells 1 sub { /j exch def /pixrow j hostoffset add size mul hostoffset add def /hostrow j hostmod idiv hostsize mul def 0 1 hostcells 1 sub { /i exch def hostpixs hostrow i hostmod idiv add get 1 eq { pixs pixrow i add 1 put } if } for } for % % Coordinate positions are measured in half-D3-X units (cells) from % the bottom-right corner of the matrix, with x and y increasing % leftward and upward respectively. % /paintcell { % paint a halfx x halfx cell block at half-D3-X (x,y) halfx mul size 1 sub exch sub /row0 exch def halfx mul size 1 sub exch sub /col0 exch def 0 1 halfx 1 sub { /dy exch def 0 1 halfx 1 sub { /dx exch def pixs row0 dy sub size mul col0 dx sub add 1 put } for } for } bind def /paintmod { % paint 2x2 module with bottom-right cell at (x, y) 2 copy paintcell % x y 2 copy 1 add paintcell % x y+1 2 copy exch 1 add exch paintcell % x+1 y 1 add exch 1 add exch paintcell % x+1 y+1 } bind def /paintmodsym { % paints a module at (x,y) and (y,x) 2 copy paintmod % x y exch paintmod % y x } bind def % % Finder (reversed-L and dots) % 2 2 paintmod % Elbow 4 2 paintmodsym % Arm //d3aqr.tips { % Tips aload pop paintcell } forall 9 2 paintmodsym % Dots 13 2 paintmodsym % % Place timing modules alongside data bits and accumulated parity. % 0 0 1 6 { /i exch def i 2 mod 0 eq { 0 31 i 2 mul sub paintmod } if category -1 i mul bitshift 1 and dup 1 eq { 2 31 i 2 mul sub paintmod } if xor } for 1 eq { 2 33 paintmod } if % parity p0 1 7 1 13 { /i exch def i 2 mod 1 eq { 45 i 2 mul sub 0 paintmod } if category -1 i mul bitshift 1 and dup 1 eq { 45 i 2 mul sub 2 paintmod } if xor } for 1 eq { 33 2 paintmod } if % parity p1 % % Build the intermediate dictionary. % << /ren /renmatrix /pixs pixs /pixx size /pixy size /height size 2 mul 2 div 72 div /width size 2 mul 2 div 72 div /strictspec strictspec /loosespec loosespec /xdim xdim /xnom xnom /xmin xmin /xmax xmax /modunit halfx 2 mul /opt options >> _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /d3aqr dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER d3aqr-- % --BEGIN ENCODER gs1datamatrix-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput gs1process setanycolor fifocache rsecbinary render renmatrix datamatrix-- % --DESC: GS1 Data Matrix % --EXAM: (01)09521234543213(17)120508(10)ABCD1234(410)9501101020917 % --EXOP: % --RNDR: renmatrix % --FMLY: Supply Chain %%BeginResource: uk.co.terryburton.bwipp gs1datamatrix 0.0 2026052800 89031 85551 %%BeginData: 119 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 6 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /gs1process dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /datamatrix dup /uk.co.terryburton.bwipp findresource put begin /gs1datamatrix { 32 dict begin { /dontdraw false def /parse false def /dontlint false def /lintreqs true def /gssep false def /strictspec false def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def barcode length 4000 gt { /bwipp.gs1datamatrixinputTooLong (The input data is too long) //raiseerror exec } if /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def barcode /ai //gs1process exec /fncs exch def /vals exch def /ais exch def % % Create the datamatrix data using stack-based accumulation % /fnc1 -1 def mark fnc1 0 1 ais length 1 sub { /i exch def ais i get { } forall % Push AI characters vals i get { } forall % Push value characters i ais length 1 sub ne fncs i get and { gssep {29} {fnc1} ifelse % Push separator } if } for counttomark array astore /dmtx exch def pop % % Compose input to datamatrix % /barcode dmtx length 1 add 5 mul string def /j 0 def dmtx { dup fnc1 eq { pop barcode j (^FNC1) putinterval /j j 5 add def } { barcode exch j exch put /j j 1 add def } ifelse } forall /barcode barcode 0 j getinterval def % % Apply AST spec overrides and resolve physical specification % /gs1datamatrix ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec % % Get the result of encoding with datamatrix % options (parse) undef options (ast) undef options (mag) undef options (parsefnc) true put options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put /uk.co.terryburton.bwipp._dontdraw true def barcode options //datamatrix exec /args exch def args (opt) options put args _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /gs1datamatrix dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER gs1datamatrix-- % --BEGIN ENCODER gs1datamatrixrectangular-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput gs1process setanycolor fifocache rsecbinary render renmatrix datamatrix-- % --DESC: GS1 Data Matrix Rectangular % --EXAM: (01)09521234543213(17)120508(10)ABCD1234(410)9501101020917 % --EXOP: % --RNDR: renmatrix % --FMLY: Supply Chain %%BeginResource: uk.co.terryburton.bwipp gs1datamatrixrectangular 0.0 2026052800 89226 85839 %%BeginData: 120 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 6 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /gs1process dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /datamatrix dup /uk.co.terryburton.bwipp findresource put begin /gs1datamatrixrectangular { 32 dict begin { /parse false def /dontlint false def /lintreqs true def /dontdraw false def /gssep false def /strictspec false def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def barcode length 4000 gt { /bwipp.gs1datamatrixrectangularinputTooLong (The input data is too long) //raiseerror exec } if /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def barcode /ai //gs1process exec /fncs exch def /vals exch def /ais exch def % % Create the datamatrix data using stack-based accumulation % /fnc1 -1 def mark fnc1 0 1 ais length 1 sub { /i exch def ais i get { } forall % Push AI characters vals i get { } forall % Push value characters i ais length 1 sub ne fncs i get and { gssep {29} {fnc1} ifelse % Push separator } if } for counttomark array astore /dmtx exch def pop % % Compose input to datamatrix % /barcode dmtx length 1 add 5 mul string def /j 0 def dmtx { dup fnc1 eq { pop barcode j (^FNC1) putinterval /j j 5 add def } { barcode exch j exch put /j j 1 add def } ifelse } forall /barcode barcode 0 j getinterval def % % Apply AST spec overrides and resolve physical specification % /gs1datamatrixrectangular ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec % % Get the result of encoding with datamatrix % options (parse) undef options (ast) undef options (mag) undef options (parsefnc) true put options (format) (rectangle) put options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put /uk.co.terryburton.bwipp._dontdraw true def barcode options //datamatrix exec /args exch def args (opt) options put args _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /gs1datamatrixrectangular dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER gs1datamatrixrectangular-- % --BEGIN ENCODER gs1dldatamatrix-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput gs1process setanycolor fifocache rsecbinary render renmatrix datamatrix-- % --DESC: GS1 Digital Link Data Matrix % --EXAM: https://id.gs1.org/01/09521234543213/22/ABC%2D123?99=XYZ-987 % --EXOP: includetext % --RNDR: renmatrix % --FMLY: Supply Chain %%BeginResource: uk.co.terryburton.bwipp gs1dldatamatrix 0.0 2026052800 87578 84137 %%BeginData: 104 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 7 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /gs1process dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /datamatrix dup /uk.co.terryburton.bwipp findresource put begin /gs1dldatamatrix { 17 dict begin { /includetext false def /parse false def /dontlint false def /lintreqs true def /dontdraw false def /strictspec false def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Parse the input % /fncvals << /parse parse /parseonly true /parsefnc false >> def barcode fncvals //parseinput exec /barcode exch def barcode /dl //gs1process exec pop 0 get /val exch def 0 get /key exch def /hri key length val length add 2 add string def hri 0 40 put hri 1 key putinterval hri key length 1 add 41 put hri key length 2 add val putinterval % % Apply AST spec overrides and resolve physical specification % /gs1dldatamatrix ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec % % Get the result of encoding with datamatrix % options (parse) undef options (ast) undef options (mag) undef options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put /uk.co.terryburton.bwipp._dontdraw true def barcode options //datamatrix exec /args exch def args (opt) options put includetext { args (text1) hri put args (text1yoffset) -1.0 put args (text1font) /Helvetica put args (text1size) 5 put } if args _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /gs1dldatamatrix dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER gs1dldatamatrix-- % --BEGIN ENCODER gs1qrcode-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput gs1process setanycolor fifocache rsecbinary render renmatrix qrcode-- % --DESC: GS1 QR Code % --EXAM: (01)09521234543213(8200)http://www.abc.net(10)ABCD1234(410)9501101020917 % --EXOP: % --RNDR: renmatrix % --FMLY: Supply Chain %%BeginResource: uk.co.terryburton.bwipp gs1qrcode 0.0 2026052800 89005 85639 %%BeginData: 120 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 6 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /gs1process dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /qrcode dup /uk.co.terryburton.bwipp findresource put begin /gs1qrcode { 16 dict begin { /parse false def /dontlint false def /lintreqs true def /dontdraw false def /strictspec false def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /hdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def barcode length 4000 gt { /bwipp.gs1qrcodeinputTooLong (The input data is too long) //raiseerror exec } if /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def barcode /ai //gs1process exec /fncs exch def /vals exch def /ais exch def % % Create the qrcode data using stack-based accumulation % /fnc1 -1 def mark fnc1 0 1 ais length 1 sub { /i exch def ais i get { } forall % Push AI characters vals i get { } forall % Push value characters i ais length 1 sub ne fncs i get and { fnc1 % Push FNC1 separator } if } for counttomark array astore /qrc exch def pop % % Compose input to qrcode % /barcode qrc length 1 add 5 mul string def /j 0 def qrc { dup fnc1 eq { pop barcode j (^FNC1) putinterval /j j 5 add def } { barcode exch j exch put /j j 1 add def } ifelse } forall /barcode barcode 0 j getinterval def % % Apply AST spec overrides and resolve physical specification % /gs1qrcode ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec % % Get the result of encoding with qrcode % options (parse) undef options (ast) undef options (mag) undef options (parsefnc) true put options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (hdim) hdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put /uk.co.terryburton.bwipp._dontdraw true def barcode options //qrcode exec /args exch def args (opt) options put args _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /gs1qrcode dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER gs1qrcode-- % --BEGIN ENCODER gs1dlqrcode-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput gs1process setanycolor fifocache rsecbinary render renmatrix qrcode-- % --DESC: GS1 Digital Link QR Code % --EXAM: HTTPS://ID.GS1.ORG/01/09521234543213/22/ABC%2D123?99=XYZ-987 % --EXOP: includetext % --RNDR: renmatrix % --FMLY: Supply Chain %%BeginResource: uk.co.terryburton.bwipp gs1dlqrcode 0.0 2026052800 87558 84117 %%BeginData: 104 ASCII Lines currentglobal true setglobal /setpacking where {pop currentpacking true setpacking} if 7 dict dup /raiseerror dup /uk.co.terryburton.bwipp findresource put dup /processoptions dup /uk.co.terryburton.bwipp findresource put dup /parseinput dup /uk.co.terryburton.bwipp findresource put dup /gs1process dup /uk.co.terryburton.bwipp findresource put dup /render dup /uk.co.terryburton.bwipp findresource put dup /renmatrix dup /uk.co.terryburton.bwipp findresource put dup /qrcode dup /uk.co.terryburton.bwipp findresource put begin /gs1dlqrcode { 17 dict begin { /includetext false def /parse false def /dontlint false def /lintreqs true def /dontdraw false def /strictspec false def /propspec false def /loosespec false def /mag 1.0 def /xdim -1.0 def /ast (default) def /xnom -1.0 def /xmin -1.0 def /xmax -1.0 def null /apply //processoptions exec /options exch def /global_encoder_defaults //render exec /barcode exch def /_render dontdraw /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledontdraw known} {pop false} ifelse and /uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not def % % Parse the input % /fncvals << /parse parse /parseonly true /parsefnc false >> def barcode fncvals //parseinput exec /barcode exch def barcode /dl //gs1process exec pop 0 get /val exch def 0 get /key exch def /hri key length val length add 2 add string def hri 0 40 put hri 1 key putinterval hri key length 1 add 41 put hri key length 2 add val putinterval % % Apply AST spec overrides and resolve physical specification % /gs1dlqrcode ast /apply_ast //render exec not { //raiseerror exec } if /resolve_strictspec //render exec % % Get the result of encoding with qrcode % options (parse) undef options (ast) undef options (mag) undef options (strictspec) strictspec put options (loosespec) loosespec put options (xdim) xdim put options (xnom) xnom put options (xmin) xmin put options (xmax) xmax put /uk.co.terryburton.bwipp._dontdraw true def barcode options //qrcode exec /args exch def args (opt) options put includetext { args (text1) hri put args (text1yoffset) -4.0 put args (text1font) /Helvetica put args (text1size) 5 put } if args _render //renmatrix if } stopped {end stop} if end } [/barcode] {null def} forall bind def /gs1dlqrcode dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if setglobal %%EndData %%EndResource % --END ENCODER gs1dlqrcode-- % --BEGIN ENCODER gs1dotcode-- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput gs1process setanycolor fifocache rsecprime render renmatrix dotcode-- % --DESC: GS1 DotCode % --EXAM: (235)5vBZIF%!