Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 18799 → Rev 18800

/trunk/Scribus/scribus/plugins/barcodegenerator/barcode.cpp
43,9 → 43,9
about->authors = QString::fromUtf8("Terry Burton - <tez@terryburton.co.uk>, Petr Van\xc4\x9bk <petr@scribus.info>");
about->shortDescription = tr("Scribus frontend for Pure PostScript Barcode Writer");
about->description = "Barcode Writer in Pure PostScript is an award-winning open source barcode maker, as used by NASA, that facilitates the printing of all major barcode symbologies entirely within level 2 PostScript, ideal for variable data printing. The complete process of generating printed barcodes is performed entirely within the printer (or print system) so that it is no longer the responsibility of your application or a library. There is no need for any barcode fonts and the flexibility offered by direct PostScript means you can avoid re-implementing barcode generator code, or migrating to new libraries, whenever your project language needs change.\nhttp://www.terryburton.co.uk/barcodewriter/";
about->version = "Backend: 2013-02-27";
about->version = "Backend: 2014-01-30";
// about->releaseDate
about->copyright = QString::fromUtf8("Backend: Copyright (c) 2004-2013 Terry Burton - tez@terryburton.co.uk\nFrontend: Copyright (c) 2005 Petr Van\xc4\x9bk - petr@scribus.info");
about->copyright = QString::fromUtf8("Backend: Copyright (c) 2004-2014 Terry Burton - tez@terryburton.co.uk\nFrontend: Copyright (c) 2005 Petr Van\xc4\x9bk - petr@scribus.info");
about->license = "Backend: MIT/X-Consortium, Frontend: GPL";
return about;
}
/trunk/Scribus/scribus/plugins/barcodegenerator/barcode.ps
1,12 → 1,8
%!PS-Adobe-2.0
%%Creator: Terry Burton
%%DocumentPaperSizes: a4
%%EndComments
 
% Barcode Writer in Pure PostScript - Version 2013-02-27
%!PS
% Barcode Writer in Pure PostScript - Version 2014-01-30
% http://www.terryburton.co.uk/barcodewriter/
%
% Copyright (c) 2004-2013 Terry Burton
% Copyright (c) 2004-2014 Terry Burton
%
% $Id$
%
34,28 → 30,49
% CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
% IN THE SOFTWARE.
 
% Uncomment this next line to allow these named resource
% definitions to remain resident within a printer's
% PostScript virtual machine so that the barcode generation
% capability persists between jobs.
 
% serverdict begin 0 exitserver
 
% --BEGIN TEMPLATE--
 
% --BEGIN PREAMBLE--
% --BEGIN RESOURCE preamble--
%%BeginResource: Category uk.co.terryburton.bwipp 0.0 2014013000 35431 31872
%%BeginData: 6 ASCII Lines
currentglobal
true setglobal
/Generic /Category findresource
dup length 1 add dict copy
dup /InstanceType /packedarraytype put
/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
% --END PREAMBLE--
%%EndData
%%EndResource
% --END RESOURCE preamble--
 
% --BEGIN RESOURCE raiseerror--
% --REQUIRES preamble--
%%BeginResource: uk.co.terryburton.bwipp raiseerror 0.0 2014013000 112041 44115
%%BeginData: 13 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
begin
/raiseerror {
$error exch /errorinfo exch put
$error exch /errorname exch put
$error /command null put
$error /newerror true put
handleerror quit
} bind def
/raiseerror dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END RESOURCE raiseerror--
 
% --BEGIN RENDERER renlinear--
% --REQUIRES preamble raiseerror--
%%BeginResource: uk.co.terryburton.bwipp renlinear 0.0 2014013000 80519 79841
%%BeginData: 237 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
begin
/renlinear {
 
98,10 → 115,10
/guardrightypos 0 def
/guardwidth 6 def
/guardheight 7 def
 
% Apply the renderer options and the user options
args {def} forall
opt {def} forall
opt {def} forall
 
/barcolor barcolor cvlit def
/textcolor textcolor cvlit def
130,7 → 147,7
/guardrightypos guardrightypos cvr def
/guardwidth guardwidth cvr def
/guardheight guardheight cvr def
 
% Create bar elements and put them into the bars array
/bars sbs length 1 add 2 idiv array def
/x 0.00 def /maxh 0 def
149,7 → 166,7
bars i 2 idiv -1 put % Dummy entry
} ifelse
} {
/d sbs i get spaceratio mul spaceratio sub 1 add def % d=digit*r-r+1
/d sbs i get spaceratio mul spaceratio sub 1 add def % d=digit*r-r+1
} ifelse
/x x d add def % x+=d
} for
180,16 → 197,16
x borderleft add borderright add 0 rlineto
0 maxh borderbottom add bordertop add rlineto
x borderleft add borderright add neg 0 rlineto
0 maxh borderbottom add bordertop add neg rlineto
0 maxh borderbottom add bordertop add neg rlineto
closepath
backgroundcolor (unset) ne { gsave backgroundcolor setanycolor fill grestore } if
backgroundcolor (unset) ne { gsave backgroundcolor setanycolor fill grestore } if
showborder {
gsave
bordercolor (unset) ne { bordercolor setanycolor } if
borderwidth setlinewidth stroke
grestore
} if
} if
 
% Display the bars for elements in the bars array
gsave
0 setlinecap
202,7 → 219,7
} ifelse
} forall
grestore
 
% Display the text for elements in the text array
textcolor (unset) ne { textcolor setanycolor } if
includetext {
211,8 → 228,8
txt {
{} forall
2 copy s ne exch fn ne or {
2 copy /s exch def /fn exch def
exch findfont exch scalefont setfont
2 copy /s exch def /fn exch def
exch findfont exch scalefont setfont
} {
pop pop
} ifelse
261,7 → 278,7
textyalign (center) eq { /textypos textyoffset maxh textascent sub 2 div add def } if
textxpos textypos moveto textgaps 0 tstr ashow
} ifelse
} if
} if
 
% Display the guard elements
guardwhitespace {
271,7 → 288,7
guardleftpos neg guardwidth add guardleftypos guardwidth 2 div add moveto
guardwidth neg guardheight -2 div rlineto
guardwidth guardheight -2 div rlineto
stroke
stroke
} if
guardrightpos 0 ne {
newpath
278,12 → 295,12
guardrightpos x add guardwidth sub guardrightypos guardheight 2 div add moveto
guardwidth guardheight -2 div rlineto
guardwidth neg guardheight -2 div rlineto
stroke
stroke
} if
} if
 
grestore
 
end
 
} bind def
290,11 → 307,17
/renlinear dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END RENDERER renlinear--
 
% --BEGIN RENDERER renmatrix--
% --REQUIRES preamble raiseerror--
%%BeginResource: uk.co.terryburton.bwipp renmatrix 0.0 2014013000 54629 54543
%%BeginData: 66 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
begin
/renmatrix {
 
333,23 → 356,23
currentpoint translate
width pixx div 72 mul height pixy div 72 mul scale
0 0 moveto pixx 0 lineto pixx pixy lineto 0 pixy lineto closepath
backgroundcolor (unset) ne { gsave backgroundcolor setanycolor fill grestore } if
backgroundcolor (unset) ne { gsave backgroundcolor setanycolor fill grestore } if
barcolor (unset) ne { barcolor setanycolor } if
/i 0 def
pixs {
/x i pixx mod def
/y pixy 1 sub i pixx idiv sub def
1 eq {
newpath
x y moveto
1 0 rlineto
0 1 rlineto
-1 0 rlineto
0 -1 rlineto
closepath fill
} if
/i i 1 add def
} forall
/xyget {pixx mul add get} bind def
newpath
0 1 pixs length 1 sub {
dup pixx mod /x exch def
pixx idiv /y exch def
pixs x y xyget 1 eq {
x pixy y sub 1 sub moveto
0 1 rlineto
1 0 rlineto
0 -1 rlineto
-1 0 rlineto
closepath
} if
} for
fill
grestore
 
end
358,11 → 381,17
/renmatrix dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END RENDERER renmatrix--
 
% --BEGIN RENDERER renmaximatrix--
% --REQUIRES preamble raiseerror--
%%BeginResource: uk.co.terryburton.bwipp renmaximatrix 0.0 2014013000 55933 55803
%%BeginData: 79 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
begin
/renmaximatrix {
 
370,20 → 399,44
 
/args exch def % We are given some arguments
 
% Default options
/barcolor (unset) def
/backgroundcolor (unset) def
 
% Apply the renderer options and the user options
args {def} forall
opt {def} forall
 
/barcolor barcolor cvlit def
/backgroundcolor backgroundcolor cvlit def
 
% Set RGB or CMYK color depending on length of given hex string
/setanycolor {
/anycolor exch def
anycolor length 6 eq {
(< >) 8 string copy dup 1 anycolor putinterval cvx exec {255 div} forall setrgbcolor
} if
anycolor length 8 eq {
(< >) 10 string copy dup 1 anycolor putinterval cvx exec {255 div} forall setcmykcolor
} if
} bind def
 
gsave
 
currentpoint translate
 
2.4945 dup scale % from 1pt to 1.88mm
 
0 0 moveto 30 0 lineto 30 29 lineto 0 29 lineto closepath
backgroundcolor (unset) ne { gsave backgroundcolor setanycolor fill grestore } if
barcolor (unset) ne { barcolor setanycolor } if
 
0.5 0.5774 translate
 
newpath
pixs {
dup
/x exch 30 mod def
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
395,8 → 448,9
0.5 0.2887 rlineto
0 0.5774 rlineto
-0.5 0.2887 rlineto
closepath fill
closepath
} forall
fill
 
% Plot the locator symbol
newpath 14 13.8576 0.5774 0 360 arc closepath
414,15 → 468,21
/renmaximatrix dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END RENDERER renmaximatrix--
 
% --BEGIN ENCODER ean5--
% --REQUIRES preamble raiseerror renlinear--
% --DESC: EAN-5 (5 digit addon)
% --EXAM: 90200
% --EXOP: includetext guardwhitespace
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp ean5 0.0 2014013000 64172 63771
%%BeginData: 135 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/ean5 {
438,8 → 498,8
/textsize 12 def
/textxoffset 0 def
/textyoffset (unset) def
/height 0.7 def
/height 0.7 def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
449,8 → 509,8
} loop
currentdict end /options exch def
} if
options {def} forall
options {def} forall
 
/textfont textfont cvlit def
/textsize textsize cvr def
/height height cvr def
460,7 → 520,17
} {
/textyoffset textyoffset cvr def
} ifelse
 
% 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
 
% Create an array containing the character mappings
/encs
[ (3211) (2221) (2122) (1411) (1132)
491,7 → 561,7
 
/sbs 31 string def
/txt 5 array def
 
0 1 4 {
/i exch def
 
545,15 → 615,21
/ean5 dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER ean5--
 
% --BEGIN ENCODER ean2--
% --REQUIRES preamble raiseerror renlinear--
% --DESC: EAN-2 (2 digit addon)
% --EXAM: 05
% --EXOP: includetext guardwhitespace
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp ean2 0.0 2014013000 62649 62505
%%BeginData: 120 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/ean2 {
570,7 → 646,7
/textxoffset 0 def
/textyoffset (unset) def
/height 0.7 def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
581,7 → 657,7
currentdict end /options exch def
} if
options {def} forall
 
/textfont textfont cvlit def
/textsize textsize cvr def
/height height cvr def
591,7 → 667,17
} {
/textyoffset textyoffset cvr def
} ifelse
 
% 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
 
% Create an array containing the character mappings
/encs
[ (3211) (2221) (2122) (1411) (1132)
607,7 → 693,7
 
/sbs 13 string def
/txt 2 array def
 
0 1 1 {
/i exch def
 
624,7 → 710,7
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
mirrormap i get 49 eq { % Reverse enc if 1 in this position in mirrormap
mirrormap i 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 {
661,16 → 747,21
/ean2 dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER ean2--
 
% --BEGIN ENCODER ean13--
% --SUGGESTS ean5 ean2--
% --REQUIRES preamble raiseerror renlinear ean5 ean2--
% --DESC: EAN-13
% --EXAM: 2071473968010
% --EXAM: 2112345678900
% --EXOP: includetext guardwhitespace
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp ean13 0.0 2014013000 87575 97526
%%BeginData: 215 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
711,7 → 802,7
/textxoffset textxoffset cvr def
/textyoffset textyoffset cvr def
/height height cvr def
/addongap addongap cvr def
/addongap addongap cvr def
addontextfont (unset) ne {/addontextfont addontextfont cvlit def} if
addontextsize (unset) ne {/addontextsize addontextsize cvr def} if
addontextxoffset (unset) ne {/addontextxoffset addontextxoffset cvr def} if
726,7 → 817,20
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
 
% Add checksum digit
/pad 13 string def
/checksum 0 def
740,6 → 844,11
} 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
762,7 → 871,7
 
/sbs 59 string def
/txt 13 array def
 
% Put the start character
sbs 0 encs 10 get putinterval
 
842,8 → 951,8
/bbs [bbs aload pop addcode (bbs) get {.075 add} forall] def
/txt [txt aload pop addcode (txt) get aload pop] def
/guardrightypos height 72 mul 6 sub def
} if
} if
 
% Return the arguments
<<
/ren //renlinear
865,16 → 974,21
/ean13 dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER ean13--
 
% --BEGIN ENCODER ean8--
% --SUGGESTS ean5 ean2--
% --REQUIRES preamble raiseerror renlinear ean5 ean2--
% --DESC: EAN-8
% --EXAM: 01335583
% --EXOP: includetext guardwhitespace height=0.5
% --EXAM: 02345673
% --EXOP: includetext guardwhitespace
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp ean8 0.0 2014013000 84797 91233
%%BeginData: 196 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
898,7 → 1012,7
/addontextsize (unset) def
/addontextxoffset (unset) def
/addontextyoffset (unset) def
 
% Parse the input options, either a string or a dict
options type /stringtype eq {
1 dict begin
909,7 → 1023,7
currentdict end /options exch def
} if
options {def} forall
 
/textfont textfont cvlit def
/textsize textsize cvr def
/textxoffset textxoffset cvr def
931,6 → 1045,19
/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
 
% Add checksum digit
/pad 8 string def
/checksum 0 def
944,10 → 1071,15
} 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
 
% Create an array containing the character mappings
/encs
[ (3211) (2221) (2122) (1411) (1132)
960,7 → 1092,7
 
/sbs 43 string def
/txt 8 array def
 
% Put the start character
sbs 0 encs 10 get putinterval
 
1026,7 → 1158,7
/bbs [bbs aload pop addcode (bbs) get {.075 add} forall] def
/txt [txt aload pop addcode (txt) get aload pop] def
/guardrightypos height 72 mul 6 sub def
} if
} if
 
% Return the arguments
<<
1050,16 → 1182,21
/ean8 dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER ean8--
 
% --BEGIN ENCODER upca--
% --SUGGESTS ean5 ean2--
% --REQUIRES preamble raiseerror renlinear ean5 ean2--
% --DESC: UPC-A
% --EXAM: 488581014973
% --EXAM: 416000336108
% --EXOP: includetext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp upca 0.0 2014013000 86287 96243
%%BeginData: 203 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
1077,7 → 1214,7
/textsize 12 def
/textxoffset -7 def
/textyoffset -4 def
/height 1 def
/height 1 def
/addongap 12 def
/addontextfont (unset) def
/addontextsize (unset) def
1093,7 → 1230,7
} loop
currentdict end /options exch def
} if
options {def} forall
options {def} forall
 
/textfont textfont cvlit def
/textsize textsize cvr def
1115,7 → 1252,20
pop
/addon () def
} ifelse
 
% 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
 
% Add checksum digit to barcode
/pad 12 string def % Create pad one bigger than barcode
/checksum 0 def
1129,6 → 1279,11
} 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-A 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
1219,7 → 1374,7
/bbs [bbs aload pop addcode (bbs) get {.075 add} forall] def
/txt [txt aload pop addcode (txt) get aload pop] def
/guardrightypos height 72 mul 6 sub def
} if
} if
 
% Return the arguments
<<
1242,16 → 1397,21
/upca dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER upca--
 
% --BEGIN ENCODER upce--
% --SUGGESTS ean5 ean2--
% --REQUIRES preamble raiseerror renlinear ean5 ean2--
% --DESC: UPC-E
% --EXAM: 00123457
% --EXOP: includetext height=0.4
% --EXOP: includetext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp upce 0.0 2014013000 94123 96978
%%BeginData: 237 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
1275,7 → 1435,7
/addontextsize (unset) def
/addontextxoffset (unset) def
/addontextyoffset (unset) def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
1286,7 → 1446,7
currentdict end /options exch def
} if
options {def} forall
 
/textfont textfont cvlit def
/textsize textsize cvr def
/textxoffset textxoffset cvr def
1298,11 → 1458,6
addontextxoffset (unset) ne {/addontextxoffset addontextxoffset cvr def} if
addontextyoffset (unset) ne {/addontextyoffset addontextyoffset cvr def} if
 
% Ensure 0 or 1 number systems
barcode 0 get dup 48 ne exch 49 ne and {
/barcode () def
} if
 
% Split off the addon
barcode ( ) search {
/barcode exch def
1313,6 → 1468,24
/addon () def
} ifelse
 
% 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
 
% Create an array containing the character mappings
/encs
[ (3211) (2221) (2122) (1411) (1132)
1359,6 → 1532,11
} 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-E 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
1396,7 → 1574,7
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
mirrormap i 1 sub get 49 eq { % Reverse enc if 1 in this position in mirrormap
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 {
1468,17 → 1646,21
/upce dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER upce--
 
% --BEGIN ENCODER isbn--
% --REQUIRES ean13--
% --SUGGESTS ean5 ean2--
% --REQUIRES preamble raiseerror renlinear ean5 ean2 ean13--
% --DESC: ISBN
% --EXAM: 978-1-56592-479 54495
% --EXAM: 978-1-56581-231-4 52250
% --EXOP: includetext guardwhitespace
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp isbn 0.0 2014013000 87301 87094
%%BeginData: 159 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
1496,9 → 1678,9
/isbntextxoffset (unset) def
/isbntextyoffset (unset) def
/height 1 def
/addongap 12 def
/addongap 12 def
/legacy false def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
1509,7 → 1691,7
currentdict end /options exch def
} if
options {def} forall
 
/isbntextfont isbntextfont cvlit def
/isbntextsize isbntextsize cvr def
isbntextxoffset (unset) ne {/isbntextxoffset isbntextxoffset cvr def} if
1526,7 → 1708,7
pop
/addon () def
} ifelse
 
% Convert ISBN-10 to ISBN-13
legacy not isbntxt length 13 le and {
/pad isbntxt length 4 add string def
1584,7 → 1766,7
 
% Convert ISBN digits to EAN-13
/barcode 12 string def
isbn length 9 eq {
isbn length 9 eq {
barcode 0 (978) putinterval
barcode 3 isbn putinterval
} {
1593,7 → 1775,7
 
% Append the addon
addon () ne {
12 addon length add 1 add string
12 addon length add 1 add string
dup 0 barcode putinterval
dup 12 ( ) putinterval
dup 13 addon putinterval
1602,7 → 1784,7
 
% Get the result of encoding with ean13
options (dontdraw) true put
options (addongap) addongap put
options (addongap) addongap put
/args barcode options //ean13 exec def
 
% Add the ISBN text
1630,22 → 1812,26
dontdraw not //renlinear if
 
end
 
} bind def
/isbn dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER isbn--
 
% --BEGIN ENCODER ismn--
% --REQUIRES ean13--
% --SUGGESTS ean5 ean2--
% --REQUIRES preamble raiseerror renlinear ean5 ean2 ean13--
% --DESC: ISMN
% --EXAM: 979-0-2600-0043
% --EXAM: 979-0-2605-3211-3
% --EXOP: includetext guardwhitespace
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp ismn 0.0 2014013000 85722 85534
%%BeginData: 145 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
1663,7 → 1849,7
/ismntextxoffset (unset) def
/ismntextyoffset (unset) def
/height 1 def
/addongap 12 def
/addongap 12 def
/legacy false def
 
% Parse the input options
1676,7 → 1862,7
currentdict end /options exch def
} if
options {def} forall
 
/ismntextfont ismntextfont cvlit def
/ismntextsize ismntextsize cvr def
ismntextxoffset (unset) ne {/ismntextxoffset ismntextxoffset cvr def} if
1683,7 → 1869,7
ismntextyoffset (unset) ne {/ismntextyoffset ismntextyoffset cvr def} if
/height height cvr def
/addongap addongap cvr def
 
% Split off the addon
ismntxt ( ) search {
/ismntxt exch def
1742,11 → 1928,11
/ismntxt pad def
 
% Convert ISMN digits to EAN-13
/barcode ismn 0 12 getinterval def
/barcode ismn 0 12 getinterval def
 
% Append the addon
addon () ne {
12 addon length add 1 add string
12 addon length add 1 add string
dup 0 barcode putinterval
dup 12 ( ) putinterval
dup 13 addon putinterval
1755,7 → 1941,7
 
% Get the result of encoding with ean13
options (dontdraw) true put
options (addongap) addongap put
options (addongap) addongap put
/args barcode options //ean13 exec def
 
% Add the ISMN text
1783,22 → 1969,26
dontdraw not //renlinear if
 
end
 
} bind def
/ismn dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER ismn--
 
% --BEGIN ENCODER issn--
% --REQUIRES ean13--
% --SUGGESTS ean2 ean5--
% --REQUIRES preamble raiseerror renlinear ean2 ean5 ean13--
% --DESC: ISSN
% --EXAM: 0317-8471 00 05
% --EXAM: 0317-8129 00 17
% --EXOP: includetext guardwhitespace
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp issn 0.0 2014013000 84110 83835
%%BeginData: 135 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
1816,7 → 2006,7
/issntextxoffset (unset) def
/issntextyoffset (unset) def
/height 1 def
/addongap 12 def
/addongap 12 def
 
% Parse the input options
options type /stringtype eq {
1828,7 → 2018,7
currentdict end /options exch def
} if
options {def} forall
 
/issntextfont issntextfont cvlit def
/issntextsize issntextsize cvr def
issntextxoffset (unset) ne {/issntextxoffset issntextxoffset cvr def} if
1835,7 → 2025,7
issntextyoffset (unset) ne {/issntextyoffset issntextyoffset cvr def} if
/height height cvr def
/addongap addongap cvr def
 
% Split off the ISSN
issntxt ( ) search {
/issntxt exch def
1881,7 → 2071,7
/issntxt pad def
 
% Convert ISSN digits to EAN-13
/barcode issn 0 7 getinterval def
/barcode issn 0 7 getinterval def
 
% Append the sequence variant
/barcode 12 string def
1891,7 → 2081,7
 
% Append the addon
addon () ne {
12 addon length add 1 add string
12 addon length add 1 add string
dup 0 barcode putinterval
dup 12 ( ) putinterval
dup 13 addon putinterval
1900,7 → 2090,7
 
% Get the result of encoding with ean13
options (dontdraw) true put
options (addongap) addongap put
options (addongap) addongap put
/args barcode options //ean13 exec def
 
% Add the ISSN text
1926,20 → 2116,26
dontdraw not //renlinear if
 
end
 
} bind def
/issn dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER issn--
 
% --BEGIN ENCODER code128--
% --REQUIRES preamble raiseerror renlinear--
% --DESC: Code 128
% --EXAM: Count01234567^FNC2!
% --EXOP: includetext parsefnc
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp code128 0.0 2014013000 125419 134999
%%BeginData: 421 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/code128 {
1995,7 → 2191,7
length j add /j exch def
/barcode msg 0 j getinterval def
exit
} ifelse
} ifelse
} loop
} if
 
2002,9 → 2198,9
/barlen barcode length def
 
% Special function characters
/sta -1 def /stb -2 def /stc -3 def
/swa -4 def /swb -5 def /swc -6 def
/fn1 -7 def /fn2 -8 def /fn3 -9 def
/sta -1 def /stb -2 def /stc -3 def
/swa -4 def /swb -5 def /swc -6 def
/fn1 -7 def /fn2 -8 def /fn3 -9 def
/fn4 -10 def /sft -11 def /stp -12 def
/lka -13 def /lkc -14 def % CC-A/B and CC-C linkage
 
2011,7 → 2207,7
% Character maps for each state
/charmaps [
% A B C A B C A B C
[ 32 32 (00) ] [ (!) (!) (01) ] [ (") (") (02) ] % 0-2
[ 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
2047,8 → 2243,8
[ 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
] def
] def
 
% Invert charmaps to give character to value maps for each state
/charvals [ 109 dict 109 dict 109 dict ] def
0 1 charmaps length 1 sub {
2057,7 → 2253,7
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
charvals j get exch i put
} for
} for
/seta charvals 0 get def
2085,7 → 2281,7
/text () def
} if
 
encoding (auto) eq {
encoding (auto) eq {
 
/fncvals <<
(FNC1) fn1
2096,7 → 2292,7
(LNKC) lkc
>> def
 
% Convert input into bytes accounting for FNC and LNK characters
% Convert input into bytes accounting for FNC and LNK characters
/msg barlen array def
/text barlen string def
/i 0 def /j 0 def {
2181,7 → 2377,7
% Does a-only come before b-only after given position and vice versa
/abeforeb {dup nextanotb exch get exch nextbnota exch get lt} bind def
/bbeforea {dup nextbnota exch get exch nextanotb exch get lt} bind def
 
/cws barcode length 2 mul 3 add array def
 
% Select start character
2203,11 → 2399,11
/cset (setc) def
exit
} if
0 abeforeb {
0 abeforeb {
sta enca
/cset (seta) def
exit
} if
exit
} if
stb enca
/cset (setb) def
exit
2214,14 → 2410,14
} loop
 
% Main encoding loop
/i 0 def {
/i 0 def {
i msglen eq {exit} if
 
i numsscr /nums exch def /nchars exch def
 
% Determine switches and shifts
{ % common exit
cset (seta) eq cset (setb) eq or nums 4 ge and
cset (seta) eq cset (setb) eq or nums 4 ge and
msg i get fn1 ne and {
nums 2 mod 0 eq {
swc cset (seta) eq {enca} {encb} ifelse
2235,9 → 2431,9
exit
} ifelse
} if
cset (setb) eq msg i get anotb and {
cset (setb) eq msg i get anotb and {
i msglen 1 sub lt {
i 1 add bbeforea {
i 1 add bbeforea {
sft encb
msg i get enca
/i i 1 add def
2271,7 → 2467,7
/cset (setb) def
exit
} if
 
% No switches or latches so encode
cset (seta) eq {
msg i get enca
2289,14 → 2485,14
/i i 1 add def
} {
msg i 2 getinterval encc
/i i 2 add def
/i i 2 add def
} ifelse
exit
} if
 
exit
} loop
 
} loop
/cws cws 0 j getinterval def
} if % auto encoding
2358,16 → 2554,21
/code128 dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER code128--
 
% --BEGIN ENCODER gs1-128--
% --REQUIRES code128--
% --REQUIRES preamble raiseerror renlinear code128--
% --DESC: GS1-128
% --EXAM: (01)95012345678903(3103)000123
% --EXOP: includetext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp gs1-128 0.0 2014013000 77354 80518
%%BeginData: 157 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
2387,7 → 2588,7
/height 0.5 def
/linkagea false def
/linkagec false def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
2403,10 → 2604,10
/textsize textsize cvr def
/textxoffset textxoffset cvr def
/textyoffset textyoffset cvr def
/height height cvr def
/height height cvr def
 
/text barcode def
 
% Expand ordinals of the form ^NNN to ASCII
/expand {
/in exch def
2424,10 → 2625,10
dup out exch j exch putinterval
length j add /j exch def
out 0 j getinterval exit
} ifelse
} ifelse
} loop
} bind def
 
% Parse out AIs
/ais [] def
/aival 2 dict def
2437,8 → 2638,8
(\)) search pop
exch pop
exch (\() search {
exch pop exch 3 1 roll
} {
exch pop exch 3 1 roll
} {
() 3 1 roll
} ifelse
[ ais aload pop counttomark 2 add index ] /ais exch def
2464,7 → 2665,7
10 2 string cvrs dup aifixed 3 1 roll put
} forall
 
% Create the code128 data
% Create the code128 data
/fnc1 -1 def
/c128 [ fnc1 ] def
0 1 ais length 1 sub {
2513,9 → 2714,9
args (textxalign) (center) put
args (opt) options put
args
 
dontdraw not //renlinear if
 
end
 
} bind def
2522,16 → 2723,21
/gs1-128 dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER gs1-128--
 
% --BEGIN ENCODER ean14--
% --REQUIRES code128--
% --REQUIRES preamble raiseerror renlinear code128--
% --DESC: GS1-14
% --EXAM: (01)04601234567893
% --EXOP: includetext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp ean14 0.0 2014013000 67271 66925
%%BeginData: 93 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
2549,7 → 2755,7
/textxoffset 0 def
/textyoffset -7 def
/height 1 def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
2565,24 → 2771,39
/textsize textsize cvr def
/textxoffset textxoffset cvr def
/textyoffset textyoffset cvr def
/height height cvr def
/height height cvr def
 
% Calculate EAN checksum and add to end of barcode
barcode length dup 17 eq exch 18 eq or
barcode 0 4 getinterval (\(01\)) eq and {
/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
18 string
dup 0 barcode 0 17 getinterval putinterval
dup 17 checksum 48 add put
/barcode exch def
/gtin barcode 4 14 getinterval def
% Validate the input
barcode 0 4 getinterval (\(01\)) ne {
/bwipp.ean14badAI (GS1-14 must begin with (01) application identifier) //raiseerror exec
} if
barcode length 17 ne barcode length 18 ne and {
/bwipp.ean14badLength (GS1-14 must be 13 or 14 digits) //raiseerror exec
} if
barcode 4 barcode length 4 sub getinterval {
dup 48 lt exch 57 gt or {
/bwipp.ean14badCharacter (GS1-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 GS1-14 check digit provided) //raiseerror exec
} if
} if
18 string
dup 0 barcode putinterval
dup 17 checksum 48 add put
/barcode exch def
/gtin barcode 4 14 getinterval def
 
% Compose input to code128
/text barcode def
/barcode 21 string def
2598,9 → 2819,9
args (textxalign) (center) put
args (opt) options put
args
 
dontdraw not //renlinear if
 
end
 
} bind def
2607,16 → 2828,21
/ean14 dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER ean14--
 
% --BEGIN ENCODER sscc18--
% --REQUIRES code128--
% --REQUIRES preamble raiseerror renlinear code128--
% --DESC: SSCC-18
% --EXAM: (00)006141411234567890
% --EXOP: includetext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp sscc18 0.0 2014013000 67283 66932
%%BeginData: 93 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
2634,7 → 2860,7
/textxoffset 0 def
/textyoffset -7 def
/height 1 def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
2650,24 → 2876,39
/textsize textsize cvr def
/textxoffset textxoffset cvr def
/textyoffset textyoffset cvr def
/height height cvr def
/height height cvr def
 
% Calculate EAN checksum and add to end of barcode
barcode length dup 21 eq exch 22 eq or
barcode 0 4 getinterval (\(00\)) eq and {
/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
22 string
dup 0 barcode 0 21 getinterval putinterval
dup 21 checksum 48 add put
/barcode exch def
/sscc barcode 4 18 getinterval def
% Validate the input
barcode 0 4 getinterval (\(00\)) ne {
/bwipp.sscc18badAI (SSCC-18 must begin with (00) application identifier) //raiseerror exec
} if
barcode length 21 ne barcode length 22 ne and {
/bwipp.sscc18badLength (SSCC-18 must be 17 or 18 digits) //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
} if
22 string
dup 0 barcode putinterval
dup 21 checksum 48 add put
/barcode exch def
/sscc barcode 4 18 getinterval def
 
% Compose input to code128
/text barcode def
/barcode 25 string def
2683,9 → 2924,9
args (textxalign) (center) put
args (opt) options put
args
 
dontdraw not //renlinear if
 
end
 
} bind def
2692,15 → 2933,21
/sscc18 dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER sscc18--
 
% --BEGIN ENCODER code39--
% --REQUIRES preamble raiseerror renlinear--
% --DESC: Code 39
% --EXAM: THIS IS CODE 39
% --EXOP: includetext includecheck includecheckintext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp code39 0.0 2014013000 68872 72176
%%BeginData: 141 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/code39 {
2711,7 → 2958,8
/barcode exch def % We are given a barcode string
 
/dontdraw false def
/includecheck false def % Enable/disable checkdigit
/includecheck false def
/validatecheck false def
/includetext false def
/includecheckintext false def
/hidestars false def
2719,7 → 2967,7
/textsize 10 def
/textyoffset -7 def
/height 1 def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
2730,12 → 2978,40
currentdict end /options exch def
} if
options {def} forall
 
/textfont textfont cvlit def
/textsize textsize cvr def
/textyoffset textyoffset cvr def
/height height cvr def
 
% Create a string of the available characters
/barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def
/charvals 43 dict def
0 1 42 {charvals exch dup barchars exch 1 getinterval exch put} for
 
% 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
 
/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 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
 
% Create an array containing the character mappings
/encs
[ (1113313111) (3113111131) (1133111131) (3133111111) (1113311131)
2749,21 → 3025,9
(1313111311) (1311131311) (1113131311) (1311313111)
] def
 
% Create a string of the available characters
/barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*) def
/sbs barlen includecheck {3} {2} ifelse add 10 mul string def
/txt barlen includecheck {3} {2} ifelse add array def
 
/barlen barcode length def % Length of the code
 
includecheck {
/sbs barlen 10 mul 30 add string def
/txt barlen 3 add array def
} {
/sbs barlen 10 mul 20 add string def
/txt barlen 2 add array def
} ifelse
 
/checksum 0 def
 
% Put the start character
sbs 0 encs 43 get putinterval
hidestars not {
2774,20 → 3038,13
 
0 1 barlen 1 sub {
/i exch def
% Lookup the encoding for the each barcode character
barcode i 1 getinterval 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 10 mul 10 add enc putinterval % Put encoded digit into sbs
/indx charvals barcode i 1 getinterval get def
sbs i 10 mul 10 add encs indx get putinterval
txt i 1 add [barcode i 1 getinterval i 1 add 16 mul textyoffset textfont textsize] put
/checksum checksum indx add def
} for
 
% Put the checksum and end characters
includecheck {
/checksum checksum 43 mod def
sbs barlen 10 mul 10 add encs checksum get putinterval
includecheckintext {
txt barlen 1 add [barchars checksum 1 getinterval barlen 1 add 16 mul textyoffset textfont textsize] put
2808,7 → 3065,7
txt barlen 1 add [() barlen 1 add 16 mul textyoffset textfont textsize] put
} ifelse
} ifelse
 
% Return the arguments
<<
/ren //renlinear
2829,16 → 3086,21
/code39 dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER code39--
 
% --BEGIN ENCODER code39ext--
% --REQUIRES code39--
% --REQUIRES preamble raiseerror renlinear code39--
% --DESC: Code 39 Extended
% --EXAM: Code39 Ext!
% --EXOP: includetext includecheck includecheckintext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp code39ext 0.0 2014013000 71391 71049
%%BeginData: 110 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
2881,10 → 3143,17
length j add /j exch def
/barcode msg 0 j getinterval def
exit
} ifelse
} ifelse
} loop
} if
 
% Validate the input
barcode 4 barcode length 4 sub getinterval {
128 ge {
/bwipp.code39extBadCharacter (Code 39 Extended must contain only ASCII characters) //raiseerror exec
} if
} forall
 
/barlen barcode length def
 
% Extended alphabet to non-extended alphabet
2939,16 → 3208,21
/code39ext dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER code39ext--
 
% --BEGIN ENCODER code32--
% --REQUIRES code39--
% --DESC: Italian PharmaCode
% --REQUIRES preamble raiseerror renlinear code39--
% --DESC: Italian Pharmacode
% --EXAM: 01234567
% --EXOP: includetext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp code32 0.0 2014013000 68024 67911
%%BeginData: 99 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
2983,15 → 3257,33
/textyoffset textyoffset cvr def
/height height cvr def
 
/text 10 string def
text 0 barcode 0 8 getinterval putinterval
% 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
text 8 0
% Calculate check digit
/checksum 0 def
0 1 7 {
dup text exch get 48 sub exch 1 and 1 add mul dup 9 gt {9 sub} if add
/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
10 mod 48 add put
/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 barcode cvrs def
3027,16 → 3319,21
/code32 dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER code32--
 
% --BEGIN ENCODER pzn--
% --REQUIRES code39--
% --REQUIRES preamble raiseerror renlinear code39--
% --DESC: Pharmazentralnummer (PZN)
% --EXAM: 123456
% --EXOP: includetext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp pzn 0.0 2014013000 68199 67907
%%BeginData: 100 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
3043,10 → 3340,10
/pzn {
 
20 dict begin
 
/options exch def % We are given an options string
/barcode exch def % We are given a barcode string
 
/dontdraw false def
/includetext false def % Enable/disable code32 text
/textfont /Courier def
3055,7 → 3352,7
/textxoffset 0 def
/height 1 def
/pzn8 false def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
3066,7 → 3363,7
currentdict end /options exch def
} if
options {def} forall
 
/textfont textfont cvlit def
/textsize textsize cvr def
/textyoffset textyoffset cvr def
3073,48 → 3370,82
/textxoffset textxoffset cvr def
/height height cvr def
 
/msg pzn8 {9} {8} ifelse string def
/msglen msg length def
msg 0 45 put
msg 1 barcode 0 msglen 2 sub getinterval putinterval
% calculate check digit
0
1 1 msglen 2 sub {dup msg exch get 48 sub exch pzn8 not {1 add} if mul add} for
11 mod 48 add
msg exch msglen 1 sub exch put
% 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
options (dontdraw) true put
/args msg options //code39 exec 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 textxoffset textyoffset textfont textsize] ] put
args (textxalign) (center) put
args (opt) options put
args
 
dontdraw not //renlinear if
 
end
 
} bind def
/pzn dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER pzn--
 
% --BEGIN ENCODER code93--
% --REQUIRES preamble raiseerror renlinear--
% --DESC: Code 93
% --EXAM: THIS IS CODE 93
% --EXOP: includetext includecheck
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp code93 0.0 2014013000 67695 70999
%%BeginData: 148 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/code93 {
3131,8 → 3462,8
/textsize 10 def
/textyoffset -7 def
/height 1 def
/parsefnc false def
/parsefnc false def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
3143,12 → 3474,12
currentdict end /options exch def
} if
options {def} forall
 
/textfont textfont cvlit def
/textsize textsize cvr def
/textyoffset textyoffset cvr def
/height height cvr def
 
/encs
[ (131112) (111213) (111312) (111411) (121113)
(121212) (121311) (111114) (131211) (141111)
3176,7 → 3507,7
(SFT+) sft4
>> def
 
% Convert input into bytes accounting for shift characters
% Convert input into bytes accounting for shift characters
/msg barlen array def
/i 0 def /j 0 def {
i barlen eq {exit} if
3205,12 → 3536,12
 
% Put the start character
sbs 0 encs 47 get putinterval
 
/checksum1 0 def /checksum2 0 def
0 1 msglen 1 sub {
/i exch def
% Lookup the encoding for the each barcode character
msg i get dup 0 lt {
msg i get dup 0 lt {
42 exch sub /indx exch def
/char ( ) def
} {
3237,7 → 3568,7
sbs msglen 6 mul 18 add encs 48 get putinterval
} {
% Put the end character
sbs msglen 6 mul 6 add encs 48 get putinterval
sbs msglen 6 mul 6 add encs 48 get putinterval
} ifelse
 
% Return the arguments
3260,16 → 3591,21
/code93 dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER code93--
 
% --BEGIN ENCODER code93ext--
% --REQUIRES code93--
% --REQUIRES preamble raiseerror renlinear code93--
% --DESC: Code 93 Extended
% --EXAM: Code93 Ext!
% --EXOP: includetext includecheck
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp code93ext 0.0 2014013000 71456 71250
%%BeginData: 114 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
3312,7 → 3648,7
length j add /j exch def
/barcode msg 0 j getinterval def
exit
} ifelse
} ifelse
} loop
} if
 
3320,7 → 3656,7
 
% Extended alphabet to non-extended alphabet
/extencs
[ (^SFT%U) (^SFT$A) (^SFT$B) (^SFT$C) (^SFT$D) (^SFT$E) (^SFT$F) (^SFT$G)
[ (^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)
3381,15 → 3717,21
/code93ext dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER code93ext--
 
% --BEGIN ENCODER interleaved2of5--
% --REQUIRES preamble raiseerror renlinear--
% --DESC: Interleaved 2 of 5 (ITF)
% --EXAM: 2401234567
% --EXOP: height=0.5 includecheck includetext includecheckintext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp interleaved2of5 0.0 2014013000 67355 70551
%%BeginData: 150 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/interleaved2of5 {
3407,7 → 3749,7
/textsize 10 def
/textyoffset -7 def
/height 1 def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
3418,12 → 3760,19
currentdict end /options exch def
} if
options {def} forall
 
/textfont textfont cvlit def
/textsize textsize cvr def
/textyoffset textyoffset cvr def
/height height cvr 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
 
/barlen barcode length def % Length of the code
 
% Prefix 0 to barcode if length is even and including checkdigit
3530,16 → 3879,21
/interleaved2of5 dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER interleaved2of5--
 
% --BEGIN ENCODER itf14--
% --REQUIRES interleaved2of5--
% --REQUIRES preamble raiseerror renlinear interleaved2of5--
% --DESC: ITF-14
% --EXAM: 04601234567893
% --EXOP: includetext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp itf14 0.0 2014013000 63664 66994
%%BeginData: 95 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
3551,13 → 3905,18
/barcode exch def % We are given a barcode string
 
/dontdraw false def
/includetext false def % Enable/disable text
/includetext false def
/includecheckintext true def
/textfont /Courier def
/textsize 10 def
/textxoffset 0 def
/textyoffset -7 def
/height 1 def
/textyoffset -10 def
/height 0.5 def
/showborder true def
/borderwidth 4 def
/borderleft 15 def
/borderright 15 def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
3573,30 → 3932,54
/textsize textsize cvr def
/textxoffset textxoffset cvr def
/textyoffset textyoffset cvr def
/height height cvr def
/height height cvr def
/borderwidth borderwidth cvr def
/borderleft borderleft cvr def
/borderright borderright cvr def
 
% Calculate EAN checksum and add to end of barcode
barcode length dup 13 eq exch 14 eq or {
/gtin barcode 0 13 getinterval 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
} if
14 string
dup 0 barcode putinterval
dup 13 checksum 48 add put
/barcode exch def
 
% Get the result of encoding with interleaved2of5
options (dontdraw) true put
options (showborder) true put
options (borderwidth) 4 put
options (borderleft) 15 put
options (borderright) 15 put
options (height) 0.5 put
options (includecheck) true put
options (includecheckintext) true put
options (textyoffset) -10 put
/args gtin options //interleaved2of5 exec def
options (showborder) showborder put
options (borderwidth) borderwidth put
options (borderleft) borderleft put
options (borderright) borderright put
options (height) height put
options (textyoffset) textyoffset put
options (includecheckintext) includecheckintext put
/args barcode options //interleaved2of5 exec def
 
args (opt) options put
args
 
dontdraw not //renlinear if
 
end
 
} bind def
3603,16 → 3986,21
/itf14 dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER itf14--
 
% --BEGIN ENCODER identcode--
% --REQUIRES interleaved2of5--
% --BEGIN ENCODER identcode--
% --REQUIRES preamble raiseerror renlinear interleaved2of5--
% --DESC: Deutsche Post Identcode
% --EXAM: 563102430313
% --EXOP: includetext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp identcode 0.0 2014013000 63813 67011
%%BeginData: 91 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
3630,7 → 4018,7
/textxoffset 0 def
/textyoffset -7 def
/height 1 def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
3646,22 → 4034,34
/textsize textsize cvr def
/textxoffset textxoffset cvr def
/textyoffset textyoffset cvr def
/height height cvr def
/height height cvr 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
barcode length dup 11 eq exch 12 eq or {
/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
12 string
dup 0 barcode 0 11 getinterval putinterval
dup 11 checksum 48 add put
/pad exch def
/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
/barcode pad def
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
3680,9 → 4080,9
args (textxalign) (center) put
args (opt) options put
args
 
dontdraw not //renlinear if
 
end
 
} bind def
3689,16 → 4089,21
/identcode dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER identcode--
 
% --BEGIN ENCODER leitcode--
% --REQUIRES interleaved2of5--
% --BEGIN ENCODER leitcode--
% --REQUIRES preamble raiseerror renlinear interleaved2of5--
% --DESC: Deutsche Post Leitcode
% --EXAM: 21348075016401
% --EXOP: includetext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp leitcode 0.0 2014013000 63805 67007
%%BeginData: 91 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
3716,7 → 4121,7
/textxoffset 0 def
/textyoffset -7 def
/height 1 def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
3732,22 → 4137,34
/textsize textsize cvr def
/textxoffset textxoffset cvr def
/textyoffset textyoffset cvr def
/height height cvr def
/height height cvr 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
barcode length dup 13 eq exch 14 eq or {
/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
14 string
dup 0 barcode 0 13 getinterval putinterval
dup 13 checksum 48 add put
/pad exch def
/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
/barcode pad def
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
3766,9 → 4183,9
args (textxalign) (center) put
args (opt) options put
args
 
dontdraw not //renlinear if
 
end
 
} bind def
3775,15 → 4192,21
/leitcode dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER leitcode--
 
% --BEGIN ENCODER databaromni--
% --REQUIRES preamble raiseerror renlinear renmatrix--
% --DESC: GS1 DataBar Omnidirectional
% --EXAM: (01)24012345678905
% --EXOP:
% --RNDR: renlinear renmatrix
%%BeginResource: uk.co.terryburton.bwipp databaromni 0.0 2014013000 116812 129140
%%BeginData: 418 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
3798,7 → 4221,7
/height 33 72 div def
/linkage false def
/format (omni) def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
3809,29 → 4232,37
currentdict end /options exch def
} if
options {def} forall
 
format (truncated) eq {/height 13 72 div def} if
/height height cvr def
 
% Strip the AI and optional check digit
barcode length dup 17 eq exch 18 eq or {
barcode 0 4 getinterval (\(01\)) eq {
/binval [
linkage {1} {0} ifelse
barcode 4 13 getinterval {48 sub} forall
] def
% Validate the input
barcode 0 4 getinterval (\(01\)) ne {
/bwipp.databaromniBadAI (GS1 DataBar Omnidirectional must begin with (01) application identifier) //raiseerror exec
} if
barcode length 17 ne barcode length 18 ne and {
/bwipp.databaromniBadLength (GS1 DataBar Omnidirectional must be 13 or 14 digits) //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
} if
} forall
 
% Calculate EAN checksum and add to end of barcode
% 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
} 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 0 17 getinterval putinterval
dup 0 barcode putinterval
dup 17 checksum 48 add put
/barcode exch def
 
3857,7 → 4288,7
} loop
exch pop exch pop
} bind def
 
/getRSSwidths {
/oe exch def
/el exch def
3868,7 → 4299,7
/mask 0 def
0 1 el 2 sub {
/bar exch def
/ew 1 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 {
3888,15 → 4319,20
val 0 lt {exit} if
/ew ew 1 add def
/mask mask 1 bar bitshift not and def
} loop
} loop
/val val sval add def
/nm nm ew sub def
out bar ew put
out bar ew put
} for
out el 1 sub nm put
out
} bind 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
3917,7 → 4353,7
/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
3985,7 → 4421,7
} 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
4008,7 → 4444,7
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
4015,7 → 4451,7
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
4029,7 → 4465,7
d3w {} forall
d4w {} forall
] def
 
/checkweights [
1 3 9 27 2 6 18 54
58 72 24 8 29 36 12 4
4042,13 → 4478,13
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
] def
 
/checksum 0 def
0 1 31 {
/i exch def
/checksum checksum widths i get checkweights i get mul add def
/checksum checksum widths i get checkweights i get mul add def
} for
/checksum checksum 79 mod def
/checksum checksum 79 mod def
checksum 8 ge {/checksum checksum 1 add def} if
checksum 72 ge {/checksum checksum 1 add def} if
/checklt checkwidths checksum 9 idiv 5 mul 5 getinterval def
4063,10 → 4499,10
format (omni) eq format (truncated) eq or { % linear
 
/sbs [
1 d1w {} forall checklt {} forall d2w {} forall
1 d1w {} forall checklt {} forall d2w {} forall
d4w {} forall checkrt {} forall d3w {} forall 1 1
] def
 
<<
/ren //renlinear
/sbs sbs
4076,19 → 4512,19
/textxalign (center)
/opt options
>>
 
dontdraw not //renlinear if
 
} { % 2D - stacked or stackedomni
 
/top [ 1 1 d1w {} forall checklt {} forall d2w {} forall 1 1 0 ] def
/bot [ 1 1 d4w {} forall checkrt {} forall d3w {} forall 1 1 0 ] def
/bot [ 1 1 d4w {} forall checkrt {} forall d3w {} forall 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
50 array astore /top exch def
0 2 24 {
/i exch def
bot i get {1} repeat
4114,7 → 4550,7
] def
/pixy pixs length 50 idiv def
} if
 
% Stacked omnidirectional
format (stackedomni) eq {
/sep1 [ top {1 exch sub} forall ] def
4164,7 → 4600,7
] def
/pixy pixs length 50 idiv def
} if
 
% Return the arguments
<<
/ren //renmatrix
4175,11 → 4611,11
/width 50 72 div
/opt options
>>
 
dontdraw not //renmatrix if
 
} ifelse
 
end
 
} bind def
4186,16 → 4622,21
/databaromni dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER databaromni--
 
% --BEGIN ENCODER databarstacked--
% --REQUIRES databaromni--
% --REQUIRES preamble raiseerror renlinear renmatrix databaromni--
% --DESC: GS1 DataBar Stacked
% --EXAM: (01)24012345678905
% --EXOP:
% --RNDR: renmatrix renlinear
% --RNDR: renmatrix
%%BeginResource: uk.co.terryburton.bwipp databarstacked 0.0 2014013000 72003 71808
%%BeginData: 73 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
4219,6 → 4660,36
} if
options {def} forall
 
% Validate the input
barcode 0 4 getinterval (\(01\)) ne {
/bwipp.databarstackedBadAI (GS1 DataBar Stacked must begin with (01) application identifier) //raiseerror exec
} if
barcode length 17 ne barcode length 18 ne and {
/bwipp.databarstackedBadLength (GS1 DataBar Stacked must be 13 or 14 digits) //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
 
% Get the result of encoding with databaromni with format=stacked
options (dontdraw) true put
options (format) (stacked) put
4227,7 → 4698,7
 
args (opt) options put
args
 
dontdraw not //renmatrix if
 
end
4236,16 → 4707,21
/databarstacked dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER databarstacked--
 
% --BEGIN ENCODER databarstackedomni--
% --REQUIRES databaromni--
% --REQUIRES preamble raiseerror renlinear renmatrix databaromni--
% --DESC: GS1 DataBar Stacked Omnidirectional
% --EXAM: (01)24012345678905
% --EXOP:
% --RNDR: renmatrix renlinear
% --RNDR: renmatrix
%%BeginResource: uk.co.terryburton.bwipp databarstackedomni 0.0 2014013000 72103 71888
%%BeginData: 73 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
4269,6 → 4745,36
} if
options {def} forall
 
% Validate the input
barcode 0 4 getinterval (\(01\)) ne {
/bwipp.databarstackedomniBadAI (GS1 DataBar Stacked Omnidirectional must begin with (01) application identifier) //raiseerror exec
} if
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 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
 
% Get the result of encoding with databaromni with format=stackedomni
options (dontdraw) true put
options (format) (stackedomni) put
4277,7 → 4783,7
 
args (opt) options put
args
 
dontdraw not //renmatrix if
 
end
4286,16 → 4792,21
/databarstackedomni dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER databarstackedomni--
 
% --BEGIN ENCODER databartruncated--
% --REQUIRES databaromni--
% --REQUIRES preamble raiseerror renlinear renmatrix databaromni--
% --DESC: GS1 DataBar Truncated
% --EXAM: (01)24012345678905
% --EXOP:
% --RNDR: renlinear renmatrix
%%BeginResource: uk.co.terryburton.bwipp databartruncated 0.0 2014013000 72029 71824
%%BeginData: 73 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
4319,6 → 4830,36
} if
options {def} forall
 
% Validate the input
barcode 0 4 getinterval (\(01\)) ne {
/bwipp.databartruncatedBadAI (GS1 DataBar Truncated must begin with (01) application identifier) //raiseerror exec
} if
barcode length 17 ne barcode length 18 ne and {
/bwipp.databartruncatedBadLength (GS1 DataBar Truncated must be 13 or 14 digits) //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
 
% Get the result of encoding with databaromni with format=truncated
options (dontdraw) true put
options (format) (truncated) put
4327,7 → 4868,7
 
args (opt) options put
args
 
dontdraw not //renlinear if
 
end
4336,15 → 4877,21
/databartruncated dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER databartruncated--
 
% --BEGIN ENCODER databarlimited--
% --REQUIRES preamble raiseerror renlinear--
% --DESC: GS1 DataBar Limited
% --EXAM: (01)15012345678907
% --EXOP:
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp databarlimited 0.0 2014013000 86855 92952
%%BeginData: 276 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/databarlimited {
4368,37 → 4915,54
currentdict end /options exch def
} if
options {def} forall
 
/height height cvr def
 
% Strip the AI and optional check digit
barcode length dup 17 eq exch 18 eq or {
barcode 0 5 getinterval dup (\(01\)0) eq exch (\(01\)1) eq or {
/binval [
barcode 4 13 getinterval {48 sub} forall
] def
linkage {
/linkval [ 2 0 1 5 1 3 3 5 3 1 0 9 6 ] def
0 1 binval length 1 sub {
/i exch def
binval i binval i get linkval i get add put
} for
} if
% Validate the input
barcode 0 4 getinterval (\(01\)) ne {
/bwipp.databarlimitedBadAI (GS1 DataBar Limited must begin with (01) application identifier) //raiseerror exec
} if
barcode length 17 ne barcode length 18 ne and {
/bwipp.databarlimitedBadLength (GS1 DataBar Limited must be 13 or 14 digits) //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
} if
} forall
 
% Calculate EAN checksum and add to end of barcode
% 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
} 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 Limited check digit provided) //raiseerror exec
} if
} if
18 string
dup 0 barcode 0 17 getinterval putinterval
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 {
/linkval [ 2 0 1 5 1 3 3 5 3 1 0 9 6 ] def
0 1 binval length 1 sub {
/i exch def
binval i binval i get linkval i get add put
} for
} if
 
% Create the human readable text
/txt barcode length array def
0 1 barcode length 1 sub {
4421,7 → 4985,7
} loop
exch pop exch pop
} bind def
 
/getRSSwidths {
/oe exch def
/el exch def
4432,7 → 4996,7
/mask 0 def
0 1 el 2 sub {
/bar exch def
/ew 1 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 {
4452,15 → 5016,15
val 0 lt {exit} if
/ew ew 1 add def
/mask mask 1 bar bitshift not and def
} loop
} loop
/val val sval add def
/nm nm ew sub def
out bar ew put
out bar ew put
} for
out el 1 sub nm put
out
} bind def
 
0 1 11 {
/i exch def
binval i 1 add 2 copy get binval i get 2013571 mod 10 mul add put
4481,7 → 5045,7
/d1 d1 3 -1 roll 10 12 j sub exp cvi mul add def
} ifelse
} for
 
/tab267 [
183063 0 17 9 6 3 6538 28
820063 183064 13 13 5 4 875 728
4516,9 → 5080,9
/i i 8 add def
} loop
 
/d1wo d1 d1gs sub d1te idiv d1elo d1mwo 7 false getRSSwidths def
/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
/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
4539,7 → 5103,7
d1w {} forall
d2w {} forall
] def
 
/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
4560,7 → 5124,7
322 323
326 337
] def
 
/checksum 0 def
0 1 27 {
/i exch def
4577,11 → 5141,11
checkwidths i 2 mul swidths i get put
checkwidths i 2 mul 1 add bwidths i get put
} for
 
/sbs [
1 d1w {} forall checkwidths {} forall d2w {} forall 1 1
] def
 
% Return the arguments
<<
/ren //renlinear
4601,15 → 5165,21
/databarlimited dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER databarlimited--
 
% --BEGIN ENCODER databarexpanded--
% --REQUIRES preamble raiseerror renlinear renmatrix--
% --DESC: GS1 DataBar Expanded
% --EXAM: (01)95012345678903(3103)000123
% --EXOP:
% --RNDR: renlinear renmatrix
%%BeginResource: uk.co.terryburton.bwipp databarexpanded 0.0 2014013000 216579 225605
%%BeginData: 871 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
4624,8 → 5194,8
/height 34 72 div def
/format (expanded) def
/segments -1 def
/linkage false def
/linkage false def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
4636,7 → 5206,7
currentdict end /options exch def
} if
options {def} forall
 
/height height cvr def
/segments segments cvi def
 
4661,10 → 5231,10
dup out exch j exch putinterval
length j add /j exch def
out 0 j getinterval exit
} ifelse
} ifelse
} loop
} bind def
 
% Parse out AIs
/ais [] def
/aival 2 dict def
4674,8 → 5244,8
(\)) search pop
exch pop
exch (\() search {
exch pop exch 3 1 roll
} {
exch pop exch 3 1 roll
} {
() 3 1 roll
} ifelse
[ ais aload pop counttomark 2 add index ] /ais exch def
4682,19 → 5252,19
aival 3 1 roll expand put
} loop
pop
 
% Method selection
{ % common exit
 
% (01)9...(3103)...
ais length 2 eq {
ais 0 get (01) eq ais 1 get (3103) eq and {
ais 0 get (01) eq ais 1 get (3103) eq and {
aival (01) get 0 1 getinterval (9) eq aival (3103) get cvi 32767 le and {
(0100) false exit
(0100) false exit
} if
} if
} if
 
% (01)9...(3202)...
ais length 2 eq {
ais 0 get (01) eq ais 1 get (3202) eq and {
4703,7 → 5273,7
} if
} if
} if
 
% (01)9...(3203)...
ais length 2 eq {
ais 0 get (01) eq ais 1 get (3203) eq and {
4712,7 → 5282,7
} 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
4724,8 → 5294,8
} ifelse
ais 0 get (01) eq ai310x ai320x or and aibad not and {
ais length 3 eq {
aival (01) get 0 1 getinterval (9) eq
aival ais 1 get get cvi 99999 le and
aival (01) get 0 1 getinterval (9) eq
aival ais 1 get get cvi 99999 le and
aival ais 2 get get cvi 999999 le and {
ai310x ais 2 get (11) eq and { (0111000) false exit } if
ai320x ais 2 get (11) eq and { (0111001) false exit } if
4737,7 → 5307,7
ai320x ais 2 get (17) eq and { (0111111) false exit } if
} if
} {
aival (01) get 0 1 getinterval (9) eq
aival (01) get 0 1 getinterval (9) eq
aival ais 1 get get cvi 99999 le and {
ai310x { (0111000) false exit } if
ai320x { (0111001) false exit } if
4745,7 → 5315,7
} 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
4753,7 → 5323,7
aival (01) 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
4761,17 → 5331,17
aival (01) get 0 1 getinterval (9) eq { (01101) true exit } if
} if
} if
 
% (01)...
ais 0 get (01) eq { (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
4780,23 → 5350,23
2 copy 30 10 getinterval exch 9 3 getinterval cvi 2 10 string cvrs dup length 10 exch sub exch putinterval
exch pop
} bind 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
} bind 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
dup 3 -1 roll 2 2 index length string cvrs dup length 2 index length exch sub exch putinterval
} bind def
 
method (00) eq {
/cdf [] def
/gpf [] def
} if
 
method (1) eq {
/cdf aival (01) get 0 13 getinterval conv13to44 def
/cdf [ cdf {48 sub} forall ] def
4803,7 → 5373,7
/gpf [] def
/ais ais 1 ais length 1 sub getinterval def
} if
 
method (0100) eq {
/cdf 55 string def
cdf 0 aival (01) get 1 12 getinterval conv12to40 putinterval
4812,7 → 5382,7
/gpf [] def
/ais [] def
} if
 
method (0101) eq {
/cdf 55 string def
cdf 0 aival (01) get 1 12 getinterval conv12to40 putinterval
4826,7 → 5396,7
/gpf [] def
/ais [] def
} if
 
method length 7 eq {
/cdf 76 string def
cdf 0 aival (01) get 1 12 getinterval conv12to40 putinterval
4837,7 → 5407,7
aival ais 2 get 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
4 2 getinterval cvi add add
} {
38400
} ifelse
4846,7 → 5416,7
/gpf [] def
/ais [] def
} if
 
method (01100) eq {
/cdf 42 string def
cdf 0 aival (01) get 1 12 getinterval conv12to40 putinterval
4855,7 → 5425,7
/gpf [ aival ais 1 get get {} forall ] def
/ais ais 2 ais length 2 sub getinterval def
} if
 
method (01101) eq {
/cdf 52 string def
cdf 0 aival (01) get 1 12 getinterval conv12to40 putinterval
4865,7 → 5435,7
/gpf [ aival ais 1 get get dup length 3 sub 3 exch getinterval {} forall ] def
/ais ais 2 ais length 2 sub getinterval def
} if
 
% Variable length symbol field
gpfallow {
/vlf 2 array def
4892,20 → 5462,20
} forall
 
/fnc1 -1 def /lnumeric -2 def /lalphanumeric -3 def /liso646 -4 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
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
(0000000) 7 string copy dup 3 -1 roll 2 7 string cvrs
dup length 7 exch sub exch putinterval
} for
lalphanumeric (0000)
>> def
 
/alphanumeric <<
48 1 57 {dup 43 sub 5 tobin} for
fnc1 (01111)
4915,7 → 5485,7
lnumeric (000)
liso646 (00100)
>> def
 
/iso646 <<
48 1 57 {dup 43 sub 5 tobin} for
fnc1 (01111)
4930,7 → 5500,7
lnumeric (000)
lalphanumeric (00100)
>> def
 
% Append the remaining AI data
0 1 ais length 1 sub {
/i exch def
4952,16 → 5522,16
% 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
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
} ifelse
exch sub
} bind def
 
/encode {
dup /raw ne {exch get} {pop} ifelse
[ exch {48 sub} forall ]
4969,7 → 5539,7
gpfenc exch j exch putinterval
/j exch j add def
} bind 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
4978,7 → 5548,7
/i exch def
gpf i get
(00) 2 string copy
dup 0 gpf i get dup fnc1 eq {pop 94} if put
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
4996,7 → 5566,7
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
5003,10 → 5573,10
{ % 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
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 {
5015,7 → 5585,7
exit
} if
pop
lalphanumeric numeric encode
lalphanumeric numeric encode
/mode (alphanumeric) def
exit
} {
5032,13 → 5602,13
/i i 1 add def
exit
} { % C1.FNC1
2 string dup 0 gpf i get put dup 1 94 put numeric encode
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
5065,7 → 5635,7
/i i 1 add def
exit
} if
 
mode (iso646) eq {
gpf i get fnc1 eq {
fnc1 iso646 encode
5087,13 → 5657,13
/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
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
5105,16 → 5675,16
pad length 0 gt {
0 5 pad length 1 sub { % Fill with 00100
/i exch def
pad i [ 0 0 1 0 0 ] 0 pad length i sub 5 2 copy gt {exch} if pop getinterval putinterval
} for
pad i [ 0 0 1 0 0 ] 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
 
% Concatinate fields
/binval [
linkage {1} {0} ifelse
linkage {1} {0} ifelse
method {48 sub} forall
vlf aload pop
cdf aload pop
5122,7 → 5692,7
pad aload pop
] def
/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
5138,7 → 5708,7
} loop
exch pop exch pop
} bind def
 
/getRSSwidths {
/oe exch def
/el exch def
5149,7 → 5719,7
/mask 0 def
0 1 el 2 sub {
/bar exch def
/ew 1 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 {
5169,10 → 5739,10
val 0 lt {exit} if
/ew ew 1 add def
/mask mask 1 bar bitshift not and def
} loop
} loop
/val val sval add def
/nm nm ew sub def
out bar ew put
out bar ew put
} for
out el 1 sub nm put
out
5187,7 → 5757,7
] def
 
/dxw datalen array def
 
0 1 datalen 1 sub {
 
/x exch def
5210,14 → 5780,14
/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 {
/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
5228,7 → 5798,7
dxw x dw put
 
} for
 
/finderwidths [
1 8 4 1 1 1 1 4 8 1
3 6 4 1 1 1 1 4 6 3
5263,7 → 5833,7
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
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
5292,11 → 5862,11
/widths [
dxw {{} forall} 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
/checksum checksum widths i get checkweightseq i get mul add def
} for
/checksum checksum 211 mod datalen 3 sub 211 mul add def
 
5315,7 → 5885,7
/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
/cw 8 array def
0 1 3 {
/i exch def
cw i 2 mul cwo i get put
5338,7 → 5908,7
0 1 segments 1 sub {
/pos exch r segments mul add def
pos datalen lt {
dxw pos get {} forall
dxw pos get {} forall
pos 2 mod 0 eq {fxw pos 2 idiv get {} forall} if
} if
} for
5395,7 → 5965,7
/finderpos [ % Finder pattern module positions
19 98 row length 13 sub {} for
68 98 row length 13 sub {} for
] def
] def
finderpos {
dup 14 add 1 exch {
/i exch def
5434,9 → 6004,9
% 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
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
seps exch numrows 1 sub exch put
 
% Middle separator pattern
/sep [ pixx 2 idiv 1 add { 0 1 } repeat ] 0 pixx getinterval def
5478,16 → 6048,21
/databarexpanded dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER databarexpanded--
 
% --BEGIN ENCODER databarexpandedstacked--
% --REQUIRES databarexpanded--
% --REQUIRES preamble raiseerror renlinear renmatrix databarexpanded--
% --DESC: GS1 DataBar Expanded Stacked
% --EXAM: (01)95012345678903(3103)000123
% --EXOP: segments=4
% --RNDR: renmatrix renlinear
% --RNDR: renlinear renmatrix
%%BeginResource: uk.co.terryburton.bwipp databarexpandedstacked 0.0 2014013000 63864 67228
%%BeginData: 43 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
5519,7 → 6094,7
 
args (opt) options put
args
 
dontdraw not //renmatrix if
 
end
5528,15 → 6103,21
/databarexpandedstacked dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER databarexpandedstacked--
 
% --BEGIN ENCODER pharmacode--
% --REQUIRES preamble raiseerror renlinear--
% --DESC: Pharmaceutical Binary Code
% --EXAM: 117480
% --EXOP: showborder
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp pharmacode 0.0 2014013000 61048 60895
%%BeginData: 91 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/pharmacode {
5550,7 → 6131,7
/height 8 2.835 mul 72 div def
/nwidth 0.5 2.835 mul def
/wwidth 1.5 2.835 mul def
/swidth 1.0 2.835 mul def
/swidth 1.0 2.835 mul def
 
% Parse the input options
options type /stringtype eq {
5562,12 → 6143,25
currentdict end /options exch def
} if
options {def} forall
 
/height height cvr def
/nwidth nwidth cvr def
/wwidth wwidth cvr def
/swidth swidth cvr 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
 
% Create the human readable text
/txt barcode length array def
0 1 barcode length 1 sub {
5575,7 → 6169,7
txt i [barcode i 1 getinterval 0 0 () 0] put
} for
 
% Convert the integer into the paramacode string
% 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
 
5612,15 → 6206,21
/pharmacode dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER pharmacode--
 
% --BEGIN ENCODER pharmacode2--
% --REQUIRES preamble raiseerror renlinear--
% --DESC: Two-track Pharmacode
% --EXAM: 117480
% --EXOP: includetext showborder
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp pharmacode2 0.0 2014013000 61615 61489
%%BeginData: 96 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/pharmacode2 {
5647,6 → 6247,19
 
/height height cvr 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
 
% Create the human readable text
/txt barcode length array def
0 1 barcode length 1 sub {
5660,7 → 6273,7
/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
5672,7 → 6285,7
/i i 1 sub def
} loop
/encstr encstr i 1 add 15 i sub getinterval def
 
% Generate the bar pattern
0 1 encstr length 1 sub {
/i exch def
5680,7 → 6293,7
bhs i bar [1 1 2] 5 -1 roll get mul put
bbs i [0 bar 0] 4 -1 roll get put
} for
 
% Return the arguments
<<
/ren //renlinear
5701,15 → 6314,21
/pharmacode2 dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER pharmacode2--
 
% --BEGIN ENCODER code2of5--
% --REQUIRES preamble raiseerror renlinear--
% --DESC: Code 25
% --EXAM: 01234567
% --EXOP: version=iata includetext includecheck includecheckintext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp code2of5 0.0 2014013000 69377 72456
%%BeginData: 150 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/code2of5 {
5721,6 → 6340,7
 
/dontdraw false def
/includecheck false def
/validatecheck false def
/includetext false def % Enable/disable text
/includecheckintext false def
/textfont /Courier def
5745,13 → 6365,36
/textyoffset textyoffset cvr def
/height height cvr def
 
% Validate input
barcode {
dup 48 lt exch 57 gt or {
/bwipp.code2of5badCharacter (Code 25 must contain only digits) //raiseerror exec
} if
} forall
 
/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
 
% Create an array containing the character mappings
<<
/versions <<
/industrial
[ (1111313111) (3111111131) (1131111131) (3131111111)
(1111311131) (3111311111) (1131311111) (1111113131)
(3111113111) (1131113111) (313111) (31113)
]
]
/iata
[ (1111313111) (3111111131) (1131111131) (3131111111)
(1111311131) (3111311111) (1131311111) (1111113131)
5769,8 → 6412,12
[ (113311) (311131) (131131) (331111) (113131) (313111)
(133111) (111331) (311311) (131311) (1111) (311)
]
>>
version get /encs exch def
>> def
versions version known not {
/bwipp.code2of5badVersion (Unrecognised Code 25 version) //raiseerror exec
} if
/encs versions version get def
 
/cs encs 0 get length def
/cw 0 encs 0 get {48 sub add} forall def
/ss encs dup length 2 sub get length def
5779,21 → 6426,11
% Create a string of the available characters
/barchars (0123456789) def
 
/barlen barcode length def % Length of the code
/sbs barlen includecheck {1 add} if cs mul ss add ss add string def
/txt barlen includecheck {1 add} if array def
 
includecheck {
/sbs barlen 1 add cs mul ss add ss add string def
/txt barlen 1 add array def
} {
/sbs barlen cs mul ss add ss add string def
/txt barlen array def
} ifelse
 
% Put the start character
sbs 0 encs 10 get putinterval
 
/checksum 0 def
 
0 1 barlen 1 sub {
/i exch def
% Lookup the encoding for the each barcode character
5804,16 → 6441,10
/enc encs indx get def % Get the indxth encoding
sbs i cs mul ss add enc putinterval % Put encoded digit into sbs
txt i [barcode i 1 getinterval i cw mul sw add textyoffset textfont textsize] put
barlen i sub 2 mod 0 eq {
/checksum checksum indx add def
} {
/checksum checksum indx 3 mul add def
} ifelse
} for
 
% Put the checksum and end characters
includecheck {
/checksum 10 checksum 10 mod sub 10 mod def
sbs barlen cs mul ss add encs checksum get putinterval
sbs barlen cs mul cs add ss add encs 11 get putinterval
includecheckintext {
5845,15 → 6476,21
/code2of5 dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER code2of5--
 
% --BEGIN ENCODER code11--
% --REQUIRES preamble raiseerror renlinear--
% --DESC: Code 11
% --EXAM: 0123456789
% --EXOP: includetext includecheck includecheckintext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp code11 0.0 2014013000 70769 73865
%%BeginData: 158 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/code11 {
5865,6 → 6502,7
 
/dontdraw false def
/includecheck false def
/validatecheck false def
/includetext false def
/includecheckintext false def
/textfont /Courier def
5871,7 → 6509,7
/textsize 10 def
/textyoffset -7 def
/height 1 def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
5882,12 → 6520,12
currentdict end /options exch def
} if
options {def} forall
 
/textfont textfont cvlit def
/textsize textsize cvr def
/textyoffset textyoffset cvr def
/height height cvr def
 
% Create an array containing the character mappings
/encs
[ (111131) (311131) (131131) (331111) (113131)
5897,55 → 6535,75
 
% Create a string of the available characters
/barchars (0123456789-) def
/charvals 11 dict def
0 1 10 {charvals exch dup barchars exch 1 getinterval exch put} for
 
/barlen barcode length def % Length of the code
% 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
 
includecheck {
barlen 10 ge {
/sbs barlen 6 mul 24 add string def
/txt barlen 2 add array def
/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 barchars checksum1 get ne {
/bwipp.code11badCheckDigit (Incorrect Code 11 check digit provided) //raiseerror exec
} if
} {
/sbs barlen 6 mul 18 add string def
/txt barlen 1 add array def
barcode barlen get barchars checksum1 get ne
barcode barlen 1 add get barchars checksum2 get ne or {
/bwipp.code11badCheckDigits (Incorrect Code 11 check digits provided) //raiseerror exec
} if
} ifelse
} {
/sbs barlen 6 mul 12 add string def
/txt barlen array def
} ifelse
/barcode barcode 0 barlen getinterval def
/includecheck true def
} if
 
/sbs barlen numchecks add 6 mul 12 add string def
/txt barlen numchecks add array def
 
% Put the start character
sbs 0 encs 11 get putinterval
 
/checksum1 0 def /checksum2 0 def
/xpos 8 def
0 1 barlen 1 sub {
/i exch def
% Lookup the encoding for the each barcode character
barcode i 1 getinterval 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 6 mul 6 add enc putinterval % Put encoded digit into sbs
/indx charvals barcode i 1 getinterval get def
/enc encs indx get def
sbs i 6 mul 6 add enc putinterval
txt i [barcode i 1 getinterval xpos textyoffset textfont textsize] put
0 1 5 { % xpos+=width of the character
/xpos exch enc exch get 48 sub xpos add def
} for
/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
 
% Put the checksum and end characters
includecheck {
/checksum1 checksum1 11 mod def
barlen 10 ge {
/checksum2 checksum2 checksum1 add 11 mod def
sbs barlen 6 mul 6 add encs checksum1 get putinterval
sbs barlen 6 mul 6 add encs checksum1 get putinterval
sbs barlen 6 mul 12 add encs checksum2 get putinterval
includecheckintext {
txt barlen [barchars checksum1 1 getinterval xpos textyoffset textfont textsize] put
/enc encs checksum1 get def
/enc encs checksum1 get def
0 1 5 { % xpos+=width of the character
/xpos exch enc exch get 48 sub xpos add def
} for
5956,7 → 6614,7
} ifelse
sbs barlen 6 mul 18 add encs 11 get putinterval
} {
sbs barlen 6 mul 6 add encs checksum1 get putinterval
sbs barlen 6 mul 6 add encs checksum1 get putinterval
includecheckintext {
txt barlen [barchars checksum1 1 getinterval xpos textyoffset textfont textsize] put
} {
5988,15 → 6646,21
/code11 dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER code11--
 
% --BEGIN ENCODER bc412--
% --REQUIRES preamble raiseerror renlinear--
% --DESC: BC412
% --EXAM: BC412
% --EXOP: semi includetext includecheckintext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp bc412 0.0 2014013000 66342 69616
%%BeginData: 148 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/bc412 {
6007,7 → 6671,8
/barcode exch def % We are given a barcode string
 
/dontdraw false def
/includecheck false def % Enable/disable checkdigit
/includecheck false def
/validatecheck false def
/includetext false def
/includecheckintext false def
/includestartstop false def
6016,7 → 6681,7
/textsize 10 def
/textyoffset -7 def
/height 1 def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
6027,17 → 6692,45
currentdict end /options exch def
} if
options {def} forall
 
/textfont textfont cvlit def
/textsize textsize cvr def
/textyoffset textyoffset cvr def
/height height cvr def
 
semi {
/includecheck true def
/includestartstop true def
} if
 
% Create a string of the available characters
/barchars (0R9GLVHA8EZ4NTS1J2Q6C7DYKBUIX3FWP5M) def
/charvals 35 dict def
0 1 34 {charvals exch dup barchars exch 1 getinterval exch put} for
 
% 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
 
/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 barchars checksum get ne {
/bwipp.bc412badCheckDigit (Incorrect BC412 check digit provided) //raiseerror exec
} if
/barcode barcode 0 barlen getinterval def
/includecheck true def
} if
 
% Create an array containing the character mappings
/encs
[ (11111115) (13111212) (11131113) (12111213) (12121311)
6050,11 → 6743,6
(12) (111)
] def
 
% Create a string of the available characters
/barchars (0R9GLVHA8EZ4NTS1J2Q6C7DYKBUIX3FWP5M) def
 
/barlen barcode length def % Length of the code
 
/sbs barlen 1 add 8 mul 5 add string def
includecheck {
/txt barlen 1 add array def
6072,24 → 6760,16
/txtpos 0 def
} ifelse
 
/checksum 0 def
0 1 barlen 1 sub {
/i exch def
% Lookup the encoding for the each barcode character
barcode i 1 getinterval 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 pos enc putinterval % Put encoded digit into sbs
/indx charvals barcode i 1 getinterval get def
sbs pos encs indx get putinterval
txt i [barcode i 1 getinterval i 12 mul txtpos add textyoffset textfont textsize] put
/checksum checksum indx add def
/pos pos 8 add def
} for
 
% Put the checksum
includecheck {
/checksum checksum 35 mod def
sbs pos encs checksum get putinterval
includecheckintext {
txt barlen [barchars checksum 1 getinterval barlen 12 mul txtpos add textyoffset textfont textsize] put
6097,16 → 6777,16
txt barlen [() barlen 12 mul txtpos add textyoffset textfont textsize] put
} ifelse
/pos pos 8 add def
} if
} if
 
% Put the stop character
includestartstop {
includestartstop {
sbs pos encs 36 get putinterval
/pos pos 2 add def
} if
 
% Return the arguments
/sbs sbs 0 pos getinterval def
/sbs sbs 0 pos getinterval def
<<
/ren //renlinear
/sbs [sbs {48 sub} forall]
6126,15 → 6806,21
/bc412 dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER bc412--
 
% --BEGIN ENCODER rationalizedCodabar--
% --DESC: Rationalized Codabar
% --REQUIRES preamble raiseerror renlinear--
% --DESC: Codabar
% --EXAM: A0123456789B
% --EXOP: includetext includecheck includecheckintext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp rationalizedCodabar 0.0 2014013000 71473 74381
%%BeginData: 156 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/rationalizedCodabar {
6145,7 → 6831,9
/barcode exch def % We are given a barcode string
 
/dontdraw false def
/altstartstop false def
/includecheck false def % Enable/disable checkdigit
/validatecheck false def
/includetext false def % Enable/disable text
/includecheckintext false def
/textfont /Courier def
6152,7 → 6840,7
/textsize 10 def
/textyoffset -7 def
/height 1 def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
6163,12 → 6851,12
currentdict end /options exch def
} if
options {def} forall
 
/textfont textfont cvlit def
/textsize textsize cvr def
/textyoffset textyoffset cvr def
/height height cvr def
 
% Create an array containing the character mappings
/encs
[ (11111331) (11113311) (11131131) (33111111) (11311311)
6178,46 → 6866,72
] def
 
% Create a string of the available characters
/barchars (0123456789-$:/.+ABCD) def
 
/barlen barcode length def % Length of the code
 
includecheck {
/sbs barlen 8 mul 8 add string def
/txt barlen 1 add array def
altstartstop {
/barchars (0123456789-$:/.+TN*E) def
} {
/sbs barlen 8 mul string def
/txt barlen array def
/barchars (0123456789-$:/.+ABCD) def
} ifelse
/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
 
/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
/txt barlen includecheck {1 add} if array def
 
/xpos 0 def
0 1 barlen 2 sub {
/i exch def
% Lookup the encoding for the each barcode character
barcode i 1 getinterval 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
/indx charvals barcode i 1 getinterval get def
/enc encs indx get def
sbs i 8 mul enc putinterval % Put encoded digit into sbs
txt i [barcode i 1 getinterval xpos textyoffset textfont textsize] put
0 1 7 { % xpos+=width of the character
/xpos exch enc exch get 48 sub xpos add def
} for
/checksum checksum indx add def
} for
 
% Find index of last character
barcode barlen 1 sub 1 getinterval barchars exch search
pop % Discard true leaving pre
length /indx exch def % indx is the length of pre
pop pop % Discard seek and post
 
% Put the checksum character and stop character
includecheck {
% Put the checksum character
/checksum checksum indx add def
/checksum 16 checksum 16 mod sub 16 mod def
sbs barlen 8 mul 8 sub encs checksum get putinterval
includecheckintext {
txt barlen 1 sub [barchars checksum 1 getinterval xpos textyoffset textfont textsize] put
6228,11 → 6942,13
/xpos exch encs checksum get exch get 48 sub xpos add def
} for
% Put the end character
/indx charvals barcode barlen 1 sub 1 getinterval get def
/enc encs indx get def % Get the indxth encoding
sbs barlen 8 mul enc putinterval % Put encoded digit into sbs
txt barlen [barcode barlen 1 sub 1 getinterval xpos textyoffset textfont textsize] put
} {
% Put the end character
/indx charvals barcode barlen 1 sub 1 getinterval get def
/enc encs indx get def % Get the indxth encoding
sbs barlen 8 mul 8 sub enc putinterval % Put encoded digit into sbs
txt barlen 1 sub [barcode barlen 1 sub 1 getinterval xpos textyoffset textfont textsize] put
6258,15 → 6974,21
/rationalizedCodabar dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER rationalizedCodabar--
 
% --BEGIN ENCODER onecode--
% --DESC: United States Postal Service Intelligent Mail
% --REQUIRES preamble raiseerror renlinear--
% --DESC: USPS Intelligent Mail
% --EXAM: 0123456709498765432101234567891
% --EXOP: barcolor=FF0000
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp onecode 0.0 2014013000 105187 108053
%%BeginData: 335 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/onecode {
6278,7 → 7000,7
 
/dontdraw false def
/height 0.15 def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
6289,11 → 7011,11
currentdict end /options exch def
} if
options {def} forall
 
/height height cvr def
 
/barlen barcode length def
 
% Create the human readable text
/txtdict <<
2 dup
6319,18 → 7041,18
/base exch def
/num exch def
num length 1 sub -1 1 {
/i exch def
/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
{ %loop - extend input as necessary
num 0 get base lt {exit} if
/num [0 num {} forall] def
/num [0 num {} forall] def
num 0 num 0 get num 1 get base idiv add put
num 1 num 1 get base mod put
} loop
% Trim leading zeros
/num [/i true def num {dup 0 eq i and {pop} {/i false def} ifelse} forall] def
/num [/i true def num {dup 0 eq i and {pop} {/i false def} ifelse} forall] def
num length 0 eq {/num [0] def} if
num
} bind def
6339,7 → 7061,7
2 copy length exch length
2 copy sub abs /offset exch def
lt {exch} if
/a exch def /b exch def
/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
6367,7 → 7089,7
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
bintmp bintmp length 1 sub 2 copy get 256 idiv put
} for
 
% Generation of 11-bit CRC on byte array
6375,7 → 7097,7
/dat bytes 0 get 5 bitshift def
6 {
fcs dat xor 1024 and 0 ne {
/fcs fcs 1 bitshift 3893 xor def
/fcs fcs 1 bitshift 3893 xor def
} {
/fcs fcs 1 bitshift def
} ifelse
6383,10 → 7105,10
/dat dat 1 bitshift def
} repeat
1 1 12 {
bytes exch get 3 bitshift /dat exch def
8 {
bytes exch get 3 bitshift /dat exch def
8 {
fcs dat xor 1024 and 0 ne {
/fcs fcs 1 bitshift 3893 xor def
/fcs fcs 1 bitshift 3893 xor def
} {
/fcs fcs 1 bitshift def
} ifelse
6408,7 → 7130,7
/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
} for
codewords i binval binval length 1 sub get b mod put
binval binval length 1 sub 2 copy get b idiv put
} for
6421,100 → 7143,100
 
% Conversion from codewords to characters
/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
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
] def
 
/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
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
] def
 
6522,7 → 7244,7
0 1 9 {
/i exch def
codewords i get dup 1286 le {
tab513 exch get
tab513 exch get
} {
tab213 exch 1287 sub get
} ifelse
6553,7 → 7275,7
4 7 7 5 0 12 1 11 2 9 9 0 6 8 5 3 3 10 8 2
] def
 
/bbs 65 array def
/bbs 65 array def
/bhs 65 array def
0 1 64 {
/i exch def
6565,18 → 7287,18
} if
dec not asc and {
bbs i 3 height mul 8 div put
bhs i 5 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
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
bhs i 8 height mul 8 div put
} if
} for
 
% Return the arguments
<<
/ren //renlinear
6599,15 → 7321,21
/onecode dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER onecode--
 
% --BEGIN ENCODER postnet--
% --DESC: United States Postal Service POSTNET
% --REQUIRES preamble raiseerror renlinear--
% --DESC: USPS POSTNET
% --EXAM: 01234
% --EXOP: includetext includecheckintext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp postnet 0.0 2014013000 67140 70346
%%BeginData: 140 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/postnet {
6619,12 → 7347,13
 
/dontdraw false def
/includetext false def % Enable/disable text
/validatecheck false def
/includecheckintext false def
/textfont /Courier def
/textsize 10 def
/textyoffset -7 def
/height 0.125 def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
6635,28 → 7364,39
currentdict end /options exch def
} if
options {def} forall
 
/textfont textfont cvlit def
/textsize textsize cvr def
/textyoffset textyoffset cvr def
/height height cvr def
/barlen barcode length def
 
% Ensure 5, 9 or 11 digits
barlen 5 lt {
/barlen -1 def % Error
} {
barlen 11 ge {
/barlen 11 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
barlen 10 eq {
/barlen 9 def
} forall
 
% Create a string of the available characters
/barchars (0123456789) def
 
/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 barchars checksum get ne {
/bwipp.postnetBadCheckDigit (Incorrect USPS POSTNET check digit provided) //raiseerror exec
} if
barlen 8 le {
/barlen 5 def
} if
} ifelse
/barcode barcode 0 barlen getinterval def
} if
 
% Create an array containing the character mappings
/encs
6665,9 → 7405,6
(5) (5)
] def
 
% Create a string of the available characters
/barchars (0123456789) def
 
/bhs barlen 5 mul 7 add array def
/txt barlen 1 add array def
 
6680,15 → 7417,9
} for
bhs 0 heights putinterval % Put encoded digit into sbs
 
/checksum 0 def
0 1 barlen 1 sub {
/i exch def
% Lookup the encoding for the each barcode character
barcode i 1 getinterval 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
/enc encs barcode i get 48 sub get def
/heights enc length array def
0 1 enc length 1 sub {
/j exch def
6696,11 → 7427,9
} for
bhs i 5 mul 1 add heights putinterval % Put encoded digit into sbs
txt i [barcode i 1 getinterval i 5 mul 1 add 3.312 mul textyoffset textfont textsize] put
/checksum checksum indx add def % checksum+=indx
} for
 
% Put the checksum character
/checksum 10 checksum 10 mod sub 10 mod def
/enc encs checksum get def
/heights enc length array def
0 1 enc length 1 sub {
6707,14 → 7436,14
/j exch def
heights j enc j 1 getinterval cvi height mul 5 div put
} for
bhs barlen 5 mul 1 add heights putinterval
bhs barlen 5 mul 1 add heights putinterval
 
includecheckintext {
txt barlen [barchars checksum 1 getinterval barlen 5 mul 1 add 3.312 mul textyoffset textfont textsize] put
} {
txt barlen [( ) barlen 5 mul 1 add 72 mul 25 div textyoffset textfont textsize] put
} ifelse
 
% Put end character
/enc encs 11 get def
/heights enc length array def
6722,7 → 7451,7
/j exch def
heights j enc j 1 getinterval cvi height mul 5 div put
} for
bhs barlen 5 mul 6 add heights putinterval
bhs barlen 5 mul 6 add heights putinterval
 
% Return the arguments
<<
6744,15 → 7473,21
/postnet dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER postnet--
 
% --BEGIN ENCODER planet--
% --DESC: United States Postal Service PLANET
% --REQUIRES preamble raiseerror renlinear--
% --DESC: USPS PLANET
% --EXAM: 01234567890
% --EXOP: includetext includecheckintext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp planet 0.0 2014013000 67000 70210
%%BeginData: 141 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/planet {
6764,12 → 7499,13
 
/dontdraw false def
/includetext false def % Enable/disable text
/validatecheck false def
/includecheckintext false def
/textfont /Courier def
/textsize 10 def
/textyoffset -7 def
/height 0.125 def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
6780,25 → 7516,41
currentdict end /options exch def
} if
options {def} forall
 
/textfont textfont cvlit def
/textsize textsize cvr def
/textyoffset textyoffset cvr def
/height height cvr def
/barlen barcode length def
 
% Ensure 11 or 13 digits
barlen 11 lt {
/barlen -1 def % Error
} {
barlen 13 ge {
/barlen 13 def
} {
/barlen 11 def
} ifelse
} ifelse
/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
 
% Create a string of the available characters
/barchars (0123456789) def
 
% 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 barchars checksum get ne {
/bwipp.planetBadCheckDigit (Incorrect USPS PLANET check digit provided) //raiseerror exec
} if
/barcode barcode 0 barlen getinterval def
} if
 
% Create an array containing the character mappings
/encs
[ (22555) (55522) (55252) (55225) (52552)
6806,9 → 7558,6
(5) (5)
] def
 
% Create a string of the available characters
/barchars (0123456789) def
 
/bhs barlen 5 mul 7 add array def
/txt barlen 1 add array def
 
6821,15 → 7570,9
} for
bhs 0 heights putinterval % Put encoded digit into sbs
 
/checksum 0 def
0 1 barlen 1 sub {
/i exch def
% Lookup the encoding for the each barcode character
barcode i 1 getinterval 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
/enc encs barcode i get 48 sub get def
/heights enc length array def
0 1 enc length 1 sub {
/j exch def
6837,11 → 7580,9
} for
bhs i 5 mul 1 add heights putinterval % Put encoded digit into sbs
txt i [barcode i 1 getinterval i 5 mul 1 add 3.312 mul textyoffset textfont textsize] put
/checksum checksum indx add def % checksum+=indx
} for
 
% Put the checksum character
/checksum 10 checksum 10 mod sub 10 mod def
/enc encs checksum get def
/heights enc length array def
0 1 enc length 1 sub {
6848,14 → 7589,14
/j exch def
heights j enc j 1 getinterval cvi height mul 5 div put
} for
bhs barlen 5 mul 1 add heights putinterval
bhs barlen 5 mul 1 add heights putinterval
 
includecheckintext {
txt barlen [barchars checksum 1 getinterval barlen 5 mul 1 add 3.312 mul textyoffset textfont textsize] put
} {
txt barlen [( ) barlen 5 mul 1 add 72 mul 25 div textyoffset textfont textsize] put
} ifelse
 
% Put end character
/enc encs 11 get def
/heights enc length array def
6863,7 → 7604,7
/j exch def
heights j enc j 1 getinterval cvi height mul 5 div put
} for
bhs barlen 5 mul 6 add heights putinterval
bhs barlen 5 mul 6 add heights putinterval
 
% Return the arguments
<<
6885,15 → 7626,21
/planet dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER planet--
 
% --BEGIN ENCODER royalmail--
% --DESC: Royal Mail 4 State Customer Code (RM4SCC)
% --REQUIRES preamble raiseerror renlinear--
% --DESC: Royal Mail 4 State Customer Code
% --EXAM: LE28HS9Z
% --EXOP: includetext includecheckintext barcolor=FF0000
% --EXOP: includetext barcolor=FF0000
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp royalmail 0.0 2014013000 67811 71080
%%BeginData: 145 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/royalmail {
6905,12 → 7652,13
 
/dontdraw false def
/includetext false def % Enable/disable text
/validatecheck false def
/includecheckintext false def
/textfont /Courier def
/textsize 10 def
/textyoffset -7 def
/height 0.175 def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
6921,63 → 7669,78
currentdict end /options exch def
} if
options {def} forall
 
/textfont textfont cvlit def
/textsize textsize cvr def
/textyoffset textyoffset cvr def
/height height cvr def
 
% Create a string of the available characters
/barchars (ZUVWXY501234B6789AHCDEFGNIJKLMTOPQRS) def
/charvals 36 dict def
0 1 35 {charvals exch dup barchars exch 1 getinterval exch put} for
 
% 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 barchars checksum get ne {
/bwipp.royalmailBadCheckDigit (Incorrect RM4SCC check digit provided) //raiseerror exec
} if
/barcode barcode 0 barlen getinterval def
} if
 
% Create an array containing the character mappings
/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)
[ (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)
] def
 
% Create a string of the available characters
/barchars (ZUVWXY501234B6789AHCDEFGNIJKLMTOPQRS) def
 
/barlen barcode length def
/encstr barlen 4 mul 6 add string def
/txt barlen 1 add array def
 
% Put start character
encstr 0 encs 36 get putinterval
/checksumrow 0 def
/checksumcol 0 def
 
0 1 barlen 1 sub {
/i exch def
% Lookup the encoding for the each barcode character
barcode i 1 getinterval 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
encstr i 4 mul 1 add enc putinterval
/indx charvals barcode i 1 getinterval get def
encstr i 4 mul 1 add encs indx get putinterval
txt i [barcode i 1 getinterval i 4 mul 1 add 3.312 mul textyoffset textfont textsize] put
/checksumrow checksumrow indx 6 idiv add def
/checksumcol checksumcol indx 6 mod add def
} for
 
% Put the checksum character
/checksum checksumrow 6 mod 6 mul checksumcol 6 mod add def
/enc encs checksum get def
encstr barlen 4 mul 1 add enc putinterval
encstr barlen 4 mul 1 add encs checksum get putinterval
includecheckintext {
txt barlen [barchars checksum 1 getinterval barlen 4 mul 1 add 3.312 mul textyoffset textfont textsize] put
} {
txt barlen [( ) barlen 4 mul 1 add 3.312 mul textyoffset textfont textsize] put
} ifelse
 
% Put end character
encstr barlen 4 mul 5 add encs 37 get putinterval
encstr barlen 4 mul 5 add encs 37 get putinterval
 
/bbs encstr length array def
/bbs encstr length array def
/bhs encstr length array def
0 1 encstr length 1 sub {
/i exch def
6999,7 → 7762,7
bhs i 8 height mul 8 div put
} if
} for
 
% Return the arguments
<<
/ren //renlinear
7020,15 → 7783,21
/royalmail dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER royalmail--
 
% --BEGIN ENCODER auspost--
% --REQUIRES preamble raiseerror renlinear--
% --DESC: AusPost 4 State Customer Code
% --EXAM: 5956439111ABA 9
% --EXOP: includetext custinfoenc=character
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp auspost 0.0 2014013000 78831 81870
%%BeginData: 202 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/auspost {
7045,7 → 7814,7
/textyoffset -7 def
/height 0.175 def
/custinfoenc (character) def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
7056,7 → 7825,7
currentdict end /options exch def
} if
options {def} forall
 
/textfont textfont cvlit def
/textsize textsize cvr def
/textyoffset textyoffset cvr def
7078,7 → 7847,7
 
% Create a string of the available characters
/barchars (ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz #) def
 
/barlen barcode length def
barcode 0 2 getinterval (11) eq {37} if
barcode 0 2 getinterval (45) eq {37} if
7092,20 → 7861,20
 
% Encode the FCC
0 1 1 {
/i exch def
/i exch def
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
/i exch def
encs barcode i 1 getinterval cvi 64 add get
encstr i 2 mul 2 add 3 2 roll putinterval
txt i 2 sub [barcode i 1 getinterval i 2 sub 2 mul 6 add 3.312 mul textyoffset textfont textsize] put
} for
% Encode the customer information
 
% Encode the customer information
custinfoenc (numeric) eq {
0 1 barlen 11 sub {
/i exch def
7112,37 → 7881,37
encs barcode i 10 add 1 getinterval cvi 64 add get
encstr i 2 mul 22 add 3 2 roll putinterval
txt i 8 add [barcode i 10 add 1 getinterval i 2 mul 22 add 3.312 mul textyoffset textfont textsize] put
} for
} for
/ciflen barlen 10 sub 2 mul def
} {
0 1 barlen 11 sub {
/i exch def
/i exch def
barcode i 10 add 1 getinterval barchars exch search
pop
length /indx exch def
pop pop
/enc encs indx get def
pop
length /indx exch def
pop pop
/enc encs indx get def
encstr i 3 mul 22 add enc putinterval
txt i 8 add [barcode i 10 add 1 getinterval i 3 mul 22 add 3.312 mul textyoffset textfont textsize] put
} for
} for
/ciflen barlen 10 sub 3 mul def
} ifelse
 
% Add any filler characters
22 ciflen add 1 encstr length 14 sub {
22 ciflen add 1 encstr length 14 sub {
encstr exch encs 75 get putinterval
} for
 
% Create the 64x64 Reed-Solomon table
/rstable 64 64 mul array def
rstable 0 [ 64 {0} repeat ] putinterval
rstable 64 [ 0 1 63 {} for ] putinterval
/prev 1 def
64 {
64 {
/next prev 1 bitshift def
next 64 and 0 ne {
/next next 67 xor def
} if
} if
0 1 63 {
/j exch def
/nextcell {rstable 64 next mul j add} def
7153,7 → 7922,7
} for
/prev next def
} repeat
 
% Calculate the Reed-Solomon codes for triples
/rscodes encstr length 16 sub 3 idiv 4 add array def
rscodes 0 [ 4 {0} repeat ] putinterval
7162,9 → 7931,9
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
encstr i 2 add 1 getinterval cvi add
put
} for
} for
rscodes length 5 sub -1 0 {
/i exch def
0 1 4 {
7180,12 → 7949,12
/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 encs 74 get putinterval
encstr encstr length 2 sub encs 74 get putinterval
 
/bbs encstr length array def
/bbs encstr length array def
/bhs encstr length array def
0 1 encstr length 1 sub {
/i exch def
7206,8 → 7975,8
bbs i 3 height mul 8 div put
bhs i 2 height mul 8 div put
} if
} for
} for
 
% Return the arguments
<<
/ren //renlinear
7228,15 → 7997,21
/auspost dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER auspost--
 
% --BEGIN ENCODER kix--
% --DESC: Royal Dutch TPG Post KIX 4-State Barcode
% --REQUIRES preamble raiseerror renlinear--
% --DESC: Royal Dutch TPG Post KIX
% --EXAM: 1231FZ13XHS
% --EXOP: includetext includecheckintext
% --EXOP: includetext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp kix 0.0 2014013000 63161 62955
%%BeginData: 111 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/kix {
7248,12 → 8023,11
 
/dontdraw false def
/includetext false def % Enable/disable text
/includecheckintext false def
/textfont /Courier def
/textsize 10 def
/textyoffset -7 def
/height 0.175 def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
7264,42 → 8038,46
currentdict end /options exch def
} if
options {def} forall
 
/textfont textfont cvlit def
/textsize textsize cvr def
/textyoffset textyoffset cvr def
/height height cvr def
 
% Create an array containing the character mappings
/encs
[ (0033) (0123) (0132) (1023) (1032) (1122)
(0213) (0303) (0312) (1203) (1212) (1302)
(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)
(2031) (2121) (2130) (3021) (3030) (3120)
(2211) (2301) (2310) (3201) (3210) (3300)
] def
 
% Create a string of the available characters
/barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ) def
/charvals 36 dict def
0 1 35 {charvals exch dup barchars exch 1 getinterval exch put} for
 
% 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
/encstr barlen 4 mul string def
/txt barlen array def
 
0 1 barlen 1 sub {
/i exch def
% Lookup the encoding for the each barcode character
barcode i 1 getinterval 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
encstr i 4 mul enc putinterval
/indx charvals barcode i 1 getinterval get def
encstr i 4 mul encs indx get putinterval
txt i [barcode i 1 getinterval i 4 mul 3.312 mul textyoffset textfont textsize] put
} for
 
/bbs encstr length array def
/bbs encstr length array def
/bhs encstr length array def
0 1 encstr length 1 sub {
/i exch def
7321,7 → 8099,7
bhs i 8 height mul 8 div put
} if
} for
 
% Return the arguments
<<
/ren //renlinear
7342,15 → 8120,21
/kix dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER kix--
 
% --BEGIN ENCODER japanpost--
% --REQUIRES preamble raiseerror renlinear--
% --DESC: Japan Post 4 State Customer Code
% --EXAM: 6540123789-A-K-Z
% --EXOP: includetext includecheckintext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp japanpost 0.0 2014013000 67972 71212
%%BeginData: 162 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/japanpost {
7367,7 → 8151,7
/textsize 10 def
/textyoffset -7 def
/height 0.175 def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
7378,17 → 8162,17
currentdict end /options exch def
} if
options {def} forall
 
/textfont textfont cvlit def
/textsize textsize cvr def
/textyoffset textyoffset cvr def
/height height cvr def
 
% Create an array containing the character mappings
% 0123456789- C1C2C3C4C5C6C7C8 ST EN
/encs
[ (300) (330) (312) (132) (321) (303) (123) (231) (213) (033) (030)
(120) (102) (210) (012) (201) (021) (003) (333)
(120) (102) (210) (012) (201) (021) (003) (333)
(31) (13)
] def
 
7395,7 → 8179,7
% Create a string of the available characters
/barchars (0123456789-ABCDEFGHIJKLMNOPQRSTUVWXYZ) def
/barlen barcode length def
 
/encstr 20 1 add 3 mul 4 add string def
/digits 20 array def
/txt barlen 1 add array def
7510,15 → 8294,21
/japanpost dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER japanpost--
 
% --BEGIN ENCODER msi--
% --REQUIRES preamble raiseerror renlinear--
% --DESC: MSI Modified Plessey
% --EXAM: 0123456789
% --EXOP: includetext includecheck includecheckintext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp msi 0.0 2014013000 73119 76565
%%BeginData: 139 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/msi {
7538,7 → 8328,7
/textsize 10 def
/textyoffset -7 def
/height 1 def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
7549,12 → 8339,12
currentdict end /options exch def
} if
options {def} forall
 
/textfont textfont cvlit def
/textsize textsize cvr def
/textyoffset textyoffset cvr def
/height height cvr def
 
% Create an array containing the character mappings
/encs
[ (12121212) (12121221) (12122112) (12122121) (12211212)
7570,7 → 8360,7
 
/mod10 {
/code exch def
0 0 code {48 sub exch 10 mul add exch} forall pop 2 mul
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
7580,7 → 8370,7
/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
0 code length {3 1 roll mul add} repeat
11 mod 11 exch sub 11 mod
dup 10 eq badmod11 and {
pop code length 2 add string dup 0 code putinterval dup code length (10) putinterval
7592,7 → 8382,7
/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
0 code length {3 1 roll mul add} repeat
11 mod 11 exch sub 11 mod
dup 10 eq badmod11 and {
pop code length 2 add string dup 0 code putinterval dup code length (10) putinterval
7655,15 → 8445,21
/msi dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER msi--
 
% --BEGIN ENCODER plessey--
% --REQUIRES preamble raiseerror renlinear--
% --DESC: Plessey UK
% --EXAM: 01234ABCD
% --EXOP: includetext includecheckintext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp plessey 0.0 2014013000 69509 72964
%%BeginData: 146 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/plessey {
7675,6 → 8471,7
 
/dontdraw false def
/includetext false def % Enable/disable text
/validatecheck false def
/includecheckintext false def
/unidirectional false def
/textfont /Courier def
7681,7 → 8478,7
/textsize 10 def
/textyoffset -7 def
/height 1 def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
7692,47 → 8489,32
currentdict end /options exch def
} if
options {def} forall
 
/textfont textfont cvlit def
/textsize textsize cvr def
/textyoffset textyoffset cvr def
/height height cvr def
% Create an array containing the character mappings
/encs
[ (14141414) (32141414) (14321414) (32321414)
(14143214) (32143214) (14323214) (32323214)
(14141432) (32141432) (14321432) (32321432)
(14143232) (32143232) (14323232) (32323232)
(32321432) (541412323) (323)
] def
 
% Create a string of the available characters
/barchars (0123456789ABCDEF) def
/charvals 16 dict def
0 1 15 {charvals exch dup barchars exch 1 getinterval exch put} for
 
/barlen barcode length def % Length of the code
unidirectional {
/sbs barlen 8 mul 27 add string def
} {
/sbs barlen 8 mul 33 add string def
} ifelse
/txt barlen 2 add array def
% 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
 
/barlen barcode length validatecheck {2 sub} if def
 
% Calculate the checksums
/checkbits barlen 4 mul 8 add array def
checkbits barlen 4 mul [ 0 0 0 0 0 0 0 0 ] putinterval
 
% Put start character
sbs 0 encs 16 get putinterval
 
0 1 barlen 1 sub {
/i exch def
% Lookup the encoding for the each barcode character
barcode i 1 getinterval 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 8 mul 8 add enc putinterval % Put encoded digit into sbs
txt i [barcode i 1 getinterval i 20 mul 20 add textyoffset textfont textsize] put
/indx charvals barcode i 1 getinterval get def
checkbits i 4 mul [
indx 1 and
indx -1 bitshift 1 and
7740,8 → 8522,6
indx -3 bitshift
] putinterval
} for
 
% Checksum is last 8 bits of a CRC using a salt
/checksalt [ 1 1 1 1 0 1 0 0 1 ] def
0 1 barlen 4 mul 1 sub {
/i exch def
7752,17 → 8532,44
} for
} if
} for
 
% Calculate the value of the checksum digits
/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 barchars checksum1 get ne
barcode barlen 1 add get barchars checksum2 get ne or {
/bwipp.plesseyBadCheckDigits (Incorrect Plessey check digits provided) //raiseerror exec
} if
/barcode barcode 0 barlen getinterval def
} if
 
% Create an array containing the character mappings
/encs
[ (14141414) (32141414) (14321414) (32321414)
(14143214) (32143214) (14323214) (32323214)
(14141432) (32141432) (14321432) (32321432)
(14143232) (32143232) (14323232) (32323232)
(32321432) (541412323) (323)
] def
 
/sbs barlen 8 mul unidirectional {27} {33} ifelse add string def
/txt barlen 2 add array def
 
% Put start character
sbs 0 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 encs indx get putinterval
txt i [barcode i 1 getinterval i 20 mul 20 add textyoffset textfont textsize] put
} for
 
% Put the checksum characters
/checksum1 checkval 15 and def
/checksum2 checkval -4 bitshift def
sbs barlen 8 mul 8 add encs checksum1 get putinterval
sbs barlen 8 mul 16 add encs checksum2 get putinterval
includecheckintext {
7774,11 → 8581,7
} ifelse
 
% Put end character
unidirectional {
sbs barlen 8 mul 24 add encs 18 get putinterval
} {
sbs barlen 8 mul 24 add encs 17 get putinterval
} ifelse
sbs barlen 8 mul 24 add encs unidirectional {18} {17} ifelse get putinterval
 
% Return the arguments
<<
7800,15 → 8603,21
/plessey dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER plessey--
 
% --BEGIN ENCODER telepen--
% --REQUIRES preamble raiseerror renlinear--
% --DESC: Telepen
% --EXAM: 123456
% --EXOP: numeric includetext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp telepen 0.0 2014013000 70915 74443
%%BeginData: 173 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/telepen {
7860,7 → 8669,7
length j add /j exch def
/barcode msg 0 j getinterval def
exit
} ifelse
} ifelse
} loop
} if
 
7914,7 → 8723,7
{ % loop
i barlen eq {exit} if
numeric { % numeric mode: 00-99 & 0X-9X
barcode i get 16 gt {
barcode i get 16 gt {
/np barcode i 2 getinterval def
np 1 1 getinterval (X) eq { % X in even position amongst digits
/indx np 0 1 getinterval cvi 17 add def
7979,15 → 8788,21
/telepen dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER telepen--
 
% --BEGIN ENCODER posicode--
% --REQUIRES preamble raiseerror renlinear--
% --DESC: PosiCode
% --EXAM: ABC123
% --EXOP: version=b inkspread=-0.5 parsefnc includetext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp posicode 0.0 2014013000 113148 115762
%%BeginData: 389 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/posicode {
8048,7 → 8863,7
length j add /j exch def
/barcode msg 0 j getinterval def
exit
} ifelse
} ifelse
} loop
} if
 
8055,8 → 8870,8
/barlen barcode length def
 
% Special function characters
/la0 -1 def /la1 -2 def /la2 -3 def
/sf0 -4 def /sf1 -5 def /sf2 -6 def
/la0 -1 def /la1 -2 def /la2 -3 def
/sf0 -4 def /sf1 -5 def /sf2 -6 def
/fn1 -7 def /fn2 -8 def /fn3 -9 def /fn4 -10 def
 
% Character maps for each state
8064,7 → 8879,7
/normal
[
% 0 1 2 0 1 2 0 1 2
[ (0) (^) (') ] [ (1) (;) 27 ] [ (2) (<) 28 ] % 0-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
8097,8 → 8912,8
[ (X) -98 -98 ] [ (Y) -98 -98 ] [ (Z) -98 -98 ] % 33-35
[ (-) -98 -98 ] [ (.) -98 -98 ] % 36-37
]
>>
version (a) eq version (b) eq or {/normal} {/limited} ifelse get
>>
version (a) eq version (b) eq or {/normal} {/limited} ifelse get
/charmaps exch def
 
% Invert charmaps to give character to value maps for each state
8111,7 → 8926,7
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
charvals j get exch i put
} for
} for
/set0 charvals 0 get def
8134,7 → 8949,7
/text () def
} if
 
encoding (auto) eq {
encoding (auto) eq {
 
/fncvals <<
(FNC1) fn1
8143,7 → 8958,7
(FNC4) fn4
>> def
 
% Convert input into bytes accounting for FNC characters
% Convert input into bytes accounting for FNC characters
/msg barlen array def
/text barlen string def
/i 0 def /j 0 def {
8177,7 → 8992,7
/i 0 def /j 0 def /cset (set0) def
{
i msglen eq {exit} if
 
{ % common exit
 
% Read next two characters
8185,7 → 9000,7
/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 {
cset load char1 known {
char1 cset load enc
/i i 1 add def
exit
8197,7 → 9012,7
char1 set2 enc
/i i 1 add def
exit
} if
} if
 
% If char2 is also not in this set then latch else shift encode
cset load char2 known not {
8209,7 → 9024,7
/cset (set0) def
} ifelse
exit
} {
} {
cset (set0) eq {
sf1 cset load enc
char1 set1 enc
8216,7 → 9031,7
} {
sf0 cset load enc
char1 set0 enc
} ifelse
} ifelse
/i i 1 add def
exit
} ifelse
8223,7 → 9038,7
 
exit
} loop
 
} loop
/cws cws 0 j getinterval def
} if % auto encoding
8280,7 → 9095,7
/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 ]
[ 45 36 28 21 15 10 6 3 ]
[ 9 8 7 6 5 4 3 2 ]
[ 1 1 1 1 1 1 1 1 ]
] def
8293,7 → 9108,7
} if
/v v -1 bitshift def
/cw cw -1 bitshift def
} repeat
} repeat
} forall
/v v checkoffset add def
 
8301,7 → 9116,7
/v v 1023 and def
v 824 gt v 853 lt and {
/v v 292 add def
} if
} if
} {
/v v 1023 and 45 add def
} ifelse
8329,7 → 9144,7
} loop
20 0 1 4 {d exch get sub} for
d exch 5 exch put
version (b) eq version (limitedb) eq or {
version (b) eq version (limitedb) eq or {
/d [ d {1 add} forall ] def
} if
/cbs (111111111111) 12 string copy def
8340,8 → 9155,8
 
% 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
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
8374,15 → 9189,21
/posicode dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER posicode--
 
% --BEGIN ENCODER codablockf--
% --REQUIRES preamble raiseerror renmatrix--
% --DESC: Codablock F
% --EXAM: CODABLOCK F 34567890123456789010040digit
% --EXOP: columns=8
% --RNDR: renmatrix
%%BeginResource: uk.co.terryburton.bwipp codablockf 0.0 2014013000 139631 148959
%%BeginData: 512 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
begin
/codablockf {
8417,7 → 9238,7
/rowheight rowheight cvi def
/sepheight sepheight cvi def
 
columns 4 ge columns 62 le and
columns 4 ge columns 62 le and
rows 2 ge rows 44 le and rows -1 eq or and {/c columns def} if
 
% Parse ordinals of the form ^NNN to ASCII
8437,13 → 9258,13
length j add /j exch def
/barcode msg 0 j getinterval def
exit
} ifelse
} ifelse
} loop
} if
 
/barlen barcode length def
 
% Convert input into bytes accounting for FNC characters
% Convert input into bytes accounting for FNC characters
/swa -1 def /swb -2 def /swc -3 def /sft -4 def
/fn1 -5 def /fn2 -6 def /fn3 -7 def /fn4 -8 def
/sta -9 def /stp -10 def
8451,7 → 9272,7
% Character maps for each state
/charmaps [
% A B C A B C A B C
[ 32 32 (00) ] [ (!) (!) (01) ] [ (") (") (02) ] % 0-2
[ 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
8487,7 → 9308,7
[ swc swc (99) ] [ swb fn4 swb ] [ fn4 swa swa ] % 99-101
[ fn1 fn1 fn1 ] [ sta sta sta ] [ stp stp stp ] % 102-104
] def
 
% Invert charmaps to give character to value maps for each state
/charvals [ 105 dict 105 dict 105 dict ] def
0 1 charmaps length 1 sub {
8496,13 → 9317,13
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
charvals j get exch i put
} for
} for
/seta charvals 0 get def
/setb charvals 1 get def
/setc charvals 2 get def
 
/fncvals <<
(FNC1) fn1
(FNC2) fn2
8606,7 → 9427,7
 
/i 0 def /j 0 def /r 1 def
/lastrow false def {
 
lastrow {exit} if
 
% Add start character and code subset selector
8623,11 → 9444,11
/cset (setc) def
exit
} if
i abeforeb {
i abeforeb {
sft enca
/cset (seta) def
exit
} if
exit
} if
swb enca
/cset (setb) def
exit
8639,12 → 9460,12
/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
 
% Determine switches and shifts
{ % common exit
cset (seta) eq cset (setb) eq or nums 4 ge and
cset (seta) eq cset (setb) eq or nums 4 ge and
msg i get fn1 ne and {
nums 2 mod 0 eq
rem 3 ge and {
8679,10 → 9500,10
exit
} if
} if
cset (setb) eq msg i get anotb and
rem 2 ge and {
cset (setb) eq msg i get anotb and
rem 2 ge and {
i msglen 1 sub lt {
i 1 add bbeforea {
i 1 add bbeforea {
sft encb
msg i get enca
/i i 1 add def
8726,7 → 9547,7
/i i 1 add def
exit
} if
 
% No switches or latches so try to encode
cset (seta) eq seta msg i get known and
rem 1 ge and {
8747,7 → 9568,7
/i i 1 add def
} {
msg i 2 getinterval encc
/i i 2 add def
/i i 2 add def
} ifelse
exit
} if
8783,7 → 9604,7
26 1 63 {} for
] def
/cmap [ 0 1 85 {} for ] def
 
% Add symbol check characters to last row
/chkmsg msglen array def
/j 0 def
8848,7 → 9669,7
/sbs [
cws i c 5 add mul c 5 add getinterval {
encs exch get {48 sub} forall
} forall
} forall
] def
mark
0 sbs {1 index 1 eq {{0}} {{1}} ifelse repeat} forall
8872,7 → 9693,7
rowheight {rowbits r 1 sub get aload pop} repeat
symwid sepheight mul {1} repeat
] def
 
% Return the arguments
<<
/ren //renmatrix
8892,15 → 9713,21
/codablockf dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER codablockf--
 
% --BEGIN ENCODER code16k--
% --REQUIRES preamble raiseerror renmatrix--
% --DESC: Code 16K
% --EXAM: Abcd-1234567890-wxyZ
% --EXOP:
% --RNDR: renmatrix
%%BeginResource: uk.co.terryburton.bwipp code16k 0.0 2014013000 159804 175815
%%BeginData: 710 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
begin
/code16k {
8957,16 → 9784,16
length j add /j exch def
/barcode msg 0 j getinterval def
exit
} ifelse
} ifelse
} loop
} if
 
/barlen barcode length def
 
% Convert input into bytes accounting for FNC characters
/swa -1 def /swb -2 def /swc -3 def
/sa1 -4 def /sb1 -5 def /sc1 -6 def
/sa2 -7 def /sb2 -8 def /sc2 -9 def
% Convert input into bytes accounting for FNC characters
/swa -1 def /swb -2 def /swc -3 def
/sa1 -4 def /sb1 -5 def /sc1 -6 def
/sa2 -7 def /sb2 -8 def /sc2 -9 def
/pad -10 def /sb3 -11 def /sc3 -12 def
/fn1 -13 def /fn2 -14 def /fn3 -15 def /fn4 -16 def
 
8973,7 → 9800,7
% Character maps for each state
/charmaps [
% A B C A B C A B C
[ 32 32 (00) ] [ (!) (!) (01) ] [ (") (") (02) ] % 0-2
[ 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
9009,8 → 9836,8
[ 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
] def
] def
 
% Invert charmaps to give character to value maps for each state
/charvals [ 109 dict 109 dict 109 dict ] def
0 1 charmaps length 1 sub {
9019,7 → 9846,7
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
charvals j get exch i put
} for
} for
/seta charvals 0 get def
9042,7 → 9869,7
/text () def
} if
 
encoding (auto) eq {
encoding (auto) eq {
 
/fncvals <<
(FNC1) fn1
9068,7 → 9895,7
} loop
/msg msg 0 j getinterval def
/msglen msg length def
 
% Determine digit runlength and characters from given position
/numsscr {
/n 0 def /s 0 def
9130,9 → 9957,9
% Does a-only come before b-only after given position and vice versa
/abeforeb {dup nextanotb exch get exch nextbnota exch get lt} bind def
/bbeforea {dup nextbnota exch get exch nextanotb exch get lt} bind def
 
/cws barcode length 2 mul 3 add array def
 
% Select mode and encode first characters
/i 0 def /j 0 def
{ % common exit
9140,7 → 9967,7
pos -1 ne {
% encode one and two
cws 0 pos 10 idiv 1 sub put
cws 1 pos 10 mod 1 sub put
cws 1 pos 10 mod 1 sub put
/j 2 def
/cset (setb) def
/mode 7 def
9192,7 → 10019,7
/i 1 def
exit
} if
% b . 3+ odd nums => c sb2 encode
% 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
9228,9 → 10055,9
 
{ % Encode remainder
i msglen eq {exit} if
 
i numsscr /nums exch def /nchars exch def
 
% Determine switches and shifts
{ % common exit
cset (seta) eq {
9264,7 → 10091,7
} if
% 4 nums . a => sc2 encode
i msglen 4 sub lt {
nums 4 eq
nums 4 eq
seta msg i 4 add get known and {
sc2 enca
2 {
9273,7 → 10100,7
/i i 1 add def
} {
msg i 2 getinterval encc
/i i 2 add def
/i i 2 add def
} ifelse
} repeat
exit
9280,8 → 10107,8
} if
} if
% 6 nums . a => sc3 encode
i msglen 6 sub lt {
nums 6 eq
i msglen 6 sub lt {
nums 6 eq
seta msg i 6 add get known and {
sc3 enca
3 {
9320,7 → 10147,7
} if
% anotb . anotb . bnota before anotb => sa2 encode
i msglen 2 sub lt {
msg i get anotb
msg i get anotb
msg i 1 add get anotb and
i 2 add bbeforea and {
sa2 encb
9379,7 → 10206,7
% otherwise => encode
msg i get encb
/i i 1 add def
exit
exit
} if
cset (setc) eq {
% 2+ nums => encode
9441,7 → 10268,7
} if
% b . b . b . 2+ even nums => sb3 encode
i msglen 3 sub lt {
setb msg i get known
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 {
9450,7 → 10277,7
msg i 1 add get encb
msg i 2 add get encb
/i i 3 add def
exit
exit
} if
} if
% anotb before bnota => swa
9466,13 → 10293,13
} if
exit
} loop
 
} loop
/cws cws 0 j getinterval def
} if % auto encoding
 
% Basic metrics for the each symbol
% r dcws
% r dcws
/metrics [
[ 2 7 ]
[ 3 12 ]
9512,9 → 10339,9
/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
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
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
 
9539,7 → 10366,7
] def
 
% Start/stop character encodings
/startencs [
/startencs [
(3211) (2221) (2122) (1411) (1132) (1231) (1114) (3112)
(3211) (2221) (2122) (1411) (1132) (1231) (1114) (3112)
] def
9556,7 → 10383,7
} {
/stopencs stopencseven def
} ifelse
 
% Derive the bits for each row
/rowbits r array def
0 1 r 1 sub {
9567,7 → 10394,7
1
cws i 5 mul 5 getinterval {
encs exch get {48 sub} forall
} forall
} forall
stopencs i get {48 sub} forall
1
] def
9588,7 → 10415,7
rowheight {rowbits r 1 sub get aload pop} repeat
81 sepheight mul {1} repeat
] def
 
% Return the arguments
<<
/ren //renmatrix
9608,15 → 10435,21
/code16k dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER code16k--
 
% --BEGIN ENCODER code49--
% --REQUIRES preamble raiseerror renmatrix--
% --DESC: Code 49
% --EXAM: MULTIPLE ROWS IN CODE 49
% --EXOP:
% --RNDR: renmatrix
%%BeginResource: uk.co.terryburton.bwipp code49 0.0 2014013000 274315 290531
%%BeginData: 1076 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
begin
/code49 {
9669,13 → 10502,13
length j add /j exch def
/barcode msg 0 j getinterval def
exit
} ifelse
} ifelse
} loop
} if
 
/barlen barcode length def
 
% Convert input into bytes accounting for FNC characters
% Convert input into bytes accounting for FNC characters
/s1 -1 def /s2 -2 def /fn1 -3 def /fn2 -4 def /fn3 -5 def /ns -6 def
/fncvals <<
(FNC1) fn1
9714,9 → 10547,9
/charvals 49 dict def
0 1 48 {
/i exch def
charmap i get
charmap i get
dup type /stringtype eq {0 get} if % convert string to ASCII if required
charvals exch i put
charvals exch i put
} for
 
% Shifted character encodings
9799,17 → 10632,17
/method (alpha) def /i -1 def /j -1 def
 
% Handle start for each mode
mode 0 eq mode 1 eq or {/method (alpha) def /i 0 def /j 0 def} if
mode 0 eq mode 1 eq or {/method (alpha) def /i 0 def /j 0 def} if
mode 2 eq {/method (numeric) def /i 0 def /j 0 def} if
mode 3 eq {
/posval [
/posval [
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
17 27 37 47 57 67 77
18 28 38 48 58 68 78 88
19 29 39 49 59 69 79 89 99
] def
cws 0 0 1 43 {dup posval exch get pos ne {pop} if} for 1 add put
9849,7 → 10682,7
/cws cws 0 j getinterval def
 
% Basic metrics for the each symbol
% r dcws
% r dcws
/metrics [
[ 2 9 ]
[ 3 16 ]
9883,7 → 10716,7
0 1 r 2 sub {
/i exch def
/cc cws j 7 getinterval def
ccs i 8 mul cc putinterval
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
9906,7 → 10739,7
/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
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
9922,10 → 10755,10
/wr1 lastrow 0 get 49 mul lastrow 1 get add def
 
% wr2 check character
cr7 weighty 0 get mul weighty calccheck add
cr7 weighty 0 get mul weighty calccheck add
wr1 weighty r 4 mul 3 sub get mul add
2401 mod dup /wr2 exch def
dup 49 idiv exch 49 mod 2 array astore
dup 49 idiv exch 49 mod 2 array astore
lastrow 2 3 -1 roll putinterval
 
% wr3 check character
9933,7 → 10766,7
wr1 weightx r 4 mul 3 sub get mul add
wr2 weightx r 4 mul 2 sub get mul add
2401 mod
dup 49 idiv exch 49 mod 2 array astore
dup 49 idiv exch 49 mod 2 array astore
lastrow 4 3 -1 roll putinterval
 
% Place last row check character
10690,15 → 11523,21
/code49 dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER code49--
 
% --BEGIN ENCODER channelcode--
% --REQUIRES preamble raiseerror renlinear--
% --DESC: Channel Code
% --EXAM: 3493
% --EXOP: height=0.5 includetext
% --EXOP: height=0.5 includetext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp channelcode 0.0 2014013000 70159 73500
%%BeginData: 149 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/channelcode {
10713,7 → 11552,7
/includetext false def
/includecheck false def
/height 1 def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
10726,20 → 11565,20
options {def} forall
 
/height height cvr def
/barlen barcode length def
 
barlen 2 ge barlen 7 le and {
/channels barlen 1 add def
% Validate the input
barcode length 2 lt barcode length 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 [ 26 292 3493 44072 576688 7742862 ] barcode length 2 sub get gt {
/bwipp.channelcodeTooBig (The Channel Code value is too big for the number of channels) //raiseerror exec
} if
 
% Determine finder
shortfinder {
/finder [ 1 1 1 1 1 ] def
} {
/finder [ 1 1 1 1 1 1 1 1 1 ] def
} ifelse
 
/nextb {
dup
dup s exch get exch
10756,13 → 11595,13
dup 3 index le {
b 2 index 4 index put
value target eq {
/out [
/out [
3 1 10 {dup s exch get exch b exch get} for
] 0 chan 2 mul getinterval def
] 0 chan 2 mul getinterval def
} if
/value value 1 add def
} if
} ifelse
} ifelse
pop pop pop pop
} bind def
 
10785,14 → 11624,19
out
} bind def
 
/barlen barcode length def
 
% Determine finder
/finder shortfinder { [ 1 1 1 1 1 ] } { [ 1 1 1 1 1 1 1 1 1 ] } ifelse def
 
% Encode the main data
/data barcode cvi channels encode def
/data barcode cvi barlen 1 add encode def
 
% Determine check data
/check [] def
includecheck {
/mod23 [
[] [] []
[] []
[ 13 12 4 9 3 1 ]
[ 13 2 12 3 18 16 4 1 ]
[ 11 16 17 8 20 4 10 2 5 1 ]
10799,7 → 11643,7
[ 1 4 16 18 3 12 2 8 9 13 6 1 ]
[ 20 16 22 13 15 12 5 4 8 9 21 3 7 1 ]
[ 2 6 18 8 1 3 9 4 12 13 16 2 6 18 8 1 ]
] channels get def
] barlen get def
0
0 1 data length 1 sub {
dup data exch get 1 sub exch mod23 exch get mul add
10840,15 → 11684,21
/channelcode dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER channelcode--
 
% --BEGIN ENCODER flattermarken--
% --REQUIRES preamble raiseerror renlinear--
% --DESC: Flattermarken
% --EXAM: 12345
% --EXOP: inkspread=-0.25
% --EXAM: 11099
% --EXOP: inkspread=-0.25 showborder borderleft=0 borderright=0
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp flattermarken 0.0 2014013000 59859 59663
%%BeginData: 93 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/flattermarken {
10865,6 → 11715,13
/textyoffset -7 def
/height 0.3 def
 
% Validate the input
barcode {
dup 48 lt exch 57 gt or {
/bwipp.flattermarkenBadCharacter (Flattermarken must contain only digits) //raiseerror exec
} if
} forall
 
% Parse the input options
options type /stringtype eq {
1 dict begin
10881,6 → 11738,13
/textyoffset textyoffset cvr def
/height height cvr def
 
% Validate the input
barcode {
dup 48 lt exch 57 gt or {
/bwipp.flattermarkenBadCharacter (Flattermarken must contain only digits) //raiseerror exec
} if
} forall
 
% Create an array containing the character mappings
/encs
[ (0018) (0117) (0216) (0315) (0414) (0513) (0612) (0711) (0810)
10925,15 → 11789,21
/flattermarken dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER flattermarken--
 
% --BEGIN ENCODER raw--
% --DESC: Raw bar space succession for custom symbologies
% --REQUIRES preamble raiseerror renlinear--
% --DESC: Custom 1D symbology
% --EXAM: 331132131313411122131311333213114131131221323
% --EXOP: height=0.5
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp raw 0.0 2014013000 55565 55558
%%BeginData: 52 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/raw {
10941,7 → 11811,7
20 dict begin % Confine variables to local scope
 
/options exch def % We are given an option string
/sbs exch def % We are given a barcode string
/barcode exch def % We are given a barcode string
 
/dontdraw false def
/height 1 def
10959,12 → 11829,19
 
/height height cvr def
 
% Validate input
barcode {
dup 49 lt exch 57 gt or {
/bwipp.rawBadCharacter (Raw must contain only digits 1 to 9) //raiseerror exec
} if
} forall
 
% Return the arguments
<<
/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]
/sbs [barcode {48 sub} forall]
/bhs [barcode length 1 add 2 idiv {height} repeat]
/bbs [barcode length 1 add 2 idiv {0} repeat]
/opt options
>>
 
10976,15 → 11853,21
/raw dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER raw--
 
% --BEGIN ENCODER daft--
% --DESC: Raw DAFT succession for custom 4 state symbologies
% --REQUIRES preamble raiseerror renlinear--
% --DESC: Custom 4 state symbology
% --EXAM: FATDAFTDAD
% --EXOP:
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp daft 0.0 2014013000 58923 58681
%%BeginData: 76 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/daft {
11010,6 → 11893,12
 
/height height cvr def
 
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
 
/bbs barlen array def
11052,15 → 11941,21
/daft dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER daft--
 
% --BEGIN ENCODER symbol--
% --REQUIRES preamble raiseerror renlinear--
% --DESC: Miscellaneous symbols
% --EXAM: fima
% --EXOP: backgroundcolor=DD000011
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp symbol 0.0 2014013000 58527 58256
%%BeginData: 72 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
begin
/symbol {
11083,30 → 11978,36
} if
options {def} forall
 
barcode (fima) eq {
/sbs [2.25 2.25 2.25 11.25 2.25 11.25 2.25 2.25 2.25] def
/bhs [.625 .625 .625 .625 .625] def
/bbs [0 0 0 0 0] def
} if
/symbols <<
/fima {
/sbs [2.25 2.25 2.25 11.25 2.25 11.25 2.25 2.25 2.25] def
/bhs [.625 .625 .625 .625 .625] def
/bbs [0 0 0 0 0] def
} bind
/fimb {
/sbs [2.25 6.75 2.25 2.25 2.25 6.25 2.25 2.25 2.25 6.75 2.25] def
/bhs [.625 .625 .625 .625 .625 .625] def
/bbs [0 0 0 0 0 0] def
} bind
/fimc {
/sbs [2.25 2.25 2.25 6.75 2.25 6.75 2.25 6.75 2.25 2.25 2.25] def
/bhs [.625 .625 .625 .625 .625 .625] def
/bbs [0 0 0 0 0 0] def
} bind
/fimd {
/sbs [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] def
/bhs [.625 .625 .625 .625 .625 .625 .625] def
/bbs [0 0 0 0 0 0 0] def
} bind
>> def
 
barcode (fimb) eq {
/sbs [2.25 6.75 2.25 2.25 2.25 6.25 2.25 2.25 2.25 6.75 2.25] def
/bhs [.625 .625 .625 .625 .625 .625] def
/bbs [0 0 0 0 0 0] def
% Valiate input
symbols barcode known not {
/bwipp.symbolUnknownSymbol (Unknown symbol name provided) //raiseerror exec
} if
 
barcode (fimc) eq {
/sbs [2.25 2.25 2.25 6.75 2.25 6.75 2.25 6.75 2.25 2.25 2.25] def
/bhs [.625 .625 .625 .625 .625 .625] def
/bbs [0 0 0 0 0 0] def
} if
barcode (fimd) eq {
/sbs [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] def
/bhs [.625 .625 .625 .625 .625 .625 .625] def
/bbs [0 0 0 0 0 0 0] def
} if
symbols barcode get exec
 
% Return the arguments
<<
/ren //renlinear
11124,15 → 12025,21
/symbol dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER symbol--
 
% --BEGIN ENCODER pdf417--
% --REQUIRES preamble raiseerror renmatrix--
% --DESC: PDF417
% --EXAM: This is PDF417
% --EXOP:
% --RNDR: renmatrix
%%BeginResource: uk.co.terryburton.bwipp pdf417 0.0 2014013000 138777 141653
%%BeginData: 505 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
begin
/pdf417 {
11185,7 → 12092,7
length j add /j exch def
/barcode msg 0 j getinterval def
exit
} ifelse
} ifelse
} loop
} if
 
11208,7 → 12115,7
datcws 0 924 put
} {
/datcws barlen 6 idiv 5 mul barlen 6 mod add 1 add array def
datcws 0 901 put
datcws 0 901 put
} ifelse
 
% Rebase groups of 6 bytes splitting into 3 byte chunks
11216,8 → 12123,8
/i exch def
/msbs [ barcode i 6 mul 3 getinterval {} forall ] def
/mscs [
msbs aload pop exch 256 mul add exch 65536 mul add
3 {dup 900 mod exch 900 idiv} repeat
msbs aload pop exch 256 mul add exch 65536 mul add
3 {dup 900 mod exch 900 idiv} repeat
] def
/lsbs [barcode i 6 mul 3 add 3 getinterval {} forall] def
/lscs [
11228,21 → 12135,21
lscs 0 get mscs 0 get 316 mul add
cws 4 2 index 900 mod put
900 idiv lscs 1 get add mscs 0 get 641 mul add mscs 1 get 316 mul add
cws 3 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
cws 3 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
cws 2 2 index 900 mod put
900 idiv lscs 3 get add mscs 1 get 20 mul add mscs 2 get 641 mul add
cws 1 2 index 900 mod put
900 idiv mscs 2 get 20 mul add
cws 0 3 -1 roll 900 mod put
datcws i 5 mul 1 add cws putinterval
datcws i 5 mul 1 add cws putinterval
} for
 
% Add the remaining bytes to the end of the codewords
/rem barlen 6 mod def
rem 0 ne {
datcws datcws length rem sub
[ barcode barlen rem sub rem getinterval {} forall ]
datcws datcws length rem sub
[ barcode barlen rem sub rem getinterval {} forall ]
putinterval
} if
 
11305,12 → 12212,12
% Generate the coefficients
/coeffs [ 1 k {0} repeat ] def
1 1 k {
/i exch def
/i exch def
coeffs i coeffs i 1 sub get put
i 1 sub -1 1 {
/j exch def
coeffs j coeffs j 1 sub get coeffs j get rsalog i get rsprod add 929 mod put
} for
} for
coeffs 0 coeffs 0 get rsalog i get rsprod put
} for
/coeffs coeffs 0 coeffs length 1 sub getinterval def
11635,15 → 12542,21
/pdf417 dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER pdf417--
 
% --BEGIN ENCODER micropdf417--
% --REQUIRES preamble raiseerror renmatrix--
% --DESC: MicroPDF417
% --EXAM: MicroPDF417
% --EXOP:
% --RNDR: renmatrix
%%BeginResource: uk.co.terryburton.bwipp micropdf417 0.0 2014013000 149010 154988
%%BeginData: 585 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
begin
/micropdf417 {
11696,7 → 12609,7
length j add /j exch def
/barcode msg 0 j getinterval def
exit
} ifelse
} ifelse
} loop
} if
 
11719,7 → 12632,7
datcws 0 924 put
} {
/datcws barlen 6 idiv 5 mul barlen 6 mod add 1 add array def
datcws 0 901 put
datcws 0 901 put
} ifelse
 
% Rebase groups of 6 bytes splitting into 3 byte chunks
11727,8 → 12640,8
/i exch def
/msbs [ barcode i 6 mul 3 getinterval {} forall ] def
/mscs [
msbs aload pop exch 256 mul add exch 65536 mul add
3 {dup 900 mod exch 900 idiv} repeat
msbs aload pop exch 256 mul add exch 65536 mul add
3 {dup 900 mod exch 900 idiv} repeat
] def
/lsbs [barcode i 6 mul 3 add 3 getinterval {} forall] def
/lscs [
11739,21 → 12652,21
lscs 0 get mscs 0 get 316 mul add
cws 4 2 index 900 mod put
900 idiv lscs 1 get add mscs 0 get 641 mul add mscs 1 get 316 mul add
cws 3 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
cws 3 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
cws 2 2 index 900 mod put
900 idiv lscs 3 get add mscs 1 get 20 mul add mscs 2 get 641 mul add
cws 1 2 index 900 mod put
900 idiv mscs 2 get 20 mul add
cws 0 3 -1 roll 900 mod put
datcws i 5 mul 1 add cws putinterval
datcws i 5 mul 1 add cws putinterval
} for
 
% Add the remaining bytes to the end of the codewords
/rem barlen 6 mod def
rem 0 ne {
datcws datcws length rem sub
[ barcode barlen rem sub rem getinterval {} forall ]
datcws datcws length rem sub
[ barcode barlen rem sub rem getinterval {} forall ]
putinterval
} if
 
11869,12 → 12782,12
% Generate the coefficients
/coeffs [ 1 k {0} repeat ] def
1 1 k {
/i exch def
/i exch def
coeffs i coeffs i 1 sub get put
i 1 sub -1 1 {
/j exch def
coeffs j coeffs j 1 sub get coeffs j get rsalog i get rsprod add 929 mod put
} for
} for
coeffs 0 coeffs 0 get rsalog i get rsprod put
} for
/coeffs coeffs 0 coeffs length 1 sub getinterval def
12226,15 → 13139,21
/micropdf417 dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER micropdf417--
 
% --BEGIN ENCODER datamatrix--
% --REQUIRES preamble raiseerror renmatrix--
% --DESC: Data Matrix
% --EXAM: This is Data Matrix!
% --EXOP: rows=32 columns=32
% --RNDR: renmatrix
%%BeginResource: uk.co.terryburton.bwipp datamatrix 0.0 2014013000 137811 150247
%%BeginData: 559 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
begin
/datamatrix {
12247,6 → 13166,7
/dontdraw false def
/columns 0 def
/rows 0 def
/prefix () def
/encoding (ascii) def
/raw false def
/parse false def
12283,17 → 13203,29
length j add /j exch def
/barcode msg 0 j getinterval def
exit
} ifelse
} ifelse
} loop
} if
 
/premaps <<
/FNC1 [ 232 ] /PROG [ 234 ] /MAC5 [ 236 ] /MAC6 [ 237 ]
() []
>> def
premaps prefix known {
/precws premaps prefix get def
} {
/bwipp.datamatrixBadPrefix (The prefix for Data Matrix must be FNC1, PROG, MAC5 or MAC6) //raiseerror exec
} ifelse
 
/prelen precws length def
/barlen barcode length def
 
raw {/encoding (raw) def} if
 
encoding (raw) eq {
/cws barlen array def
/i 0 def /j 0 def
/cws barlen prelen add array def
cws 0 precws putinterval
/i 0 def /j prelen def
{ % loop
i barlen eq {exit} if
/cw barcode i 1 add 3 getinterval cvi def
12330,8 → 13262,9
/msg msg 0 j getinterval def
/msglen msg length def
 
/cws msglen 2 mul array def
/i 0 def /j 0 def
/cws msglen 2 mul prelen add array def
cws 0 precws putinterval
/i 0 def /j prelen def
{ % loop
i msglen eq {exit} if
/char msg i get def
12363,6 → 13296,119
/cws cws 0 j getinterval def
} if
 
/base40 false def % Used for size optimization
encoding (c40) eq encoding (text) eq encoding (x12) eq or or {
% Pathological case : 8-bit chars encode to 4 base-40 values
% plus extra 2 for possible nul-pading
/b40 barlen 4 mul 2 add array def
/base40 true def
 
% Maps are encoded as static strings with the base-40 value in
% the right 6-bits and the shift-state in the two left bits.
% The value 255 indicates an invalid mapping (x12 only).
encoding (c40) eq {
/mode 230 def
/8bit true def
/charmap <
404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f
03808182838485868788898a8b8c8d8e0405060708090a0b0c0d8f9091929394
950e0f101112131415161718191a1b1c1d1e1f2021222324252627969798999a
c0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedf
> def
} if
 
encoding (text) eq {
/mode 239 def
/8bit true def
/charmap <
404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f
03808182838485868788898a8b8c8d8e0405060708090a0b0c0d8f9091929394
95c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9da969798999a
c00e0f101112131415161718191a1b1c1d1e1f2021222324252627dbdcdddedf
> def
} if
 
encoding (x12) eq {
/mode 238 def
/8bit false def
/parsefnc false def
/charmap <
ffffffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffff
03ffffffffffffffffff01ffffffffff0405060708090a0b0c0dffffffff02ff
ff0e0f101112131415161718191a1b1c1d1e1f2021222324252627ffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
> def
} if
 
/i 0 def /j 0 def
{ % loop
i barlen ge {exit} if
/char barcode i get def
% ^FNC1
parsefnc char 94 eq and i barlen 4 sub lt and {
barcode i 5 getinterval (^FNC1) eq {
b40 j [ 1 27 ] putinterval % set-2, FNC1
/char -1 def
/i i 5 add def
/j j 2 add def
} if
} if
 
% Replace ^^ with ^
parsefnc char 94 eq and i barlen 1 sub lt and {
barcode i 1 add get 94 eq {
/i i 1 add def
} if
} if
8bit char 127 gt and {
/char char 127 and def
b40 j [ 1 30 ] putinterval % set-2, high-bit
/j j 2 add def
} if
char 0 ge char 127 le and {
charmap char get
dup 255 ne {
dup -6 bitshift 1 sub
dup 0 ge {
b40 j 3 -1 roll put
/j j 1 add def
} {
pop
} ifelse
63 and b40 j 3 -1 roll put
/j j 1 add def
} {
/bwipp.datamatrixBadX12character (Invalid character for Data Matrix X12 encoding) //raiseerror exec
} ifelse
/i i 1 add def
} if
} loop
 
% Nul-pad to full triples
{ % loop
j 3 mod 0 eq { exit } if
b40 j 0 put
/j j 1 add def
} loop
 
% Convert triples to 2 bytes
/b40len j def
/cws b40len 3 div 2 mul prelen add 1 add cvi array def
cws 0 precws putinterval
cws prelen mode put
/i 0 def /j prelen 1 add def
{ % loop
i b40len eq { exit } if
cws j [
b40 i get 1600 mul b40 i 1 add get 40 mul add b40 i 2 add get add 1 add
dup -8 bitshift
exch 255 and
] putinterval
/i i 3 add def
/j j 2 add def
} loop
} if
 
% Basic metrics for the each symbol
% rows cols regh regv rscw rsbl
/metrics [
12372,7 → 13418,7
[ 14 14 1 1 10 1 ]
[ 16 16 1 1 12 1 ]
[ 18 18 1 1 14 1 ]
[ 20 20 1 1 18 1 ]
[ 20 20 1 1 18 1 ]
[ 22 22 1 1 20 1 ]
[ 24 24 1 1 24 1 ]
[ 26 26 1 1 28 1 ]
12425,6 → 13471,11
/i i 1 add def
} loop
 
% C40/TEXT/X12 size optimization - do not emit the unlatch unless we pad
base40 cws length ncws lt and {
/cws [ cws {} forall 254 ] def
} if
 
% Extend cws to ncws codewords by addition of pseudo-randomised pad characters
cws length ncws lt {
/datlen cws length def
12447,11 → 13498,11
} {
i 7 le {/cwbsize 156 def} {/cwbsize 155 def} ifelse
} ifelse
/cwb cwbsize array def
/cwb cwbsize array def
0 1 cwbsize 1 sub {
/j exch def
cwb j cws j rsbl mul i add get put
} for
} for
cwbs i cwb put
ecbs i [ rscw rsbl idiv {0} repeat ] put
} for
12463,7 → 13514,7
 
% Function to calculate the product in the field
/rsprod {
2 copy 0 ne exch 0 ne and {
2 copy 0 ne exch 0 ne and {
rslog exch get exch rslog exch get add 255 mod rsalog exch get
} {
pop pop 0
12473,12 → 13524,12
% Generate the coefficients
/coeffs [ 1 rscw rsbl idiv {0} repeat ] def
1 1 rscw rsbl idiv {
/i exch def
/i exch def
coeffs i coeffs i 1 sub get put
i 1 sub -1 1 {
/j exch def
coeffs j coeffs j 1 sub get coeffs j get rsalog i get rsprod xor put
} for
} for
coeffs 0 coeffs 0 get rsalog i get rsprod put
} for
/coeffs coeffs 0 coeffs length 1 sub getinterval def
12489,13 → 13540,13
/cwb cwbs i get def
/ecb ecbs i get def
0 1 cwb length 1 sub {
/t exch cwb exch get ecb 0 get xor def
/t exch cwb exch get ecb 0 get xor def
ecb length 1 sub -1 0 {
/j exch def
/p ecb length j sub 1 sub def
ecb p t coeffs j get rsprod put
j 0 gt { ecb p ecb p 1 add get ecb p get xor put } if
} for
} for
} for
} for
 
12514,9 → 13565,9
% Place the codewords into the matrix
/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
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
12542,7 → 13593,7
{ 2 copy exch 1 sub exch } bind { 2 copy 2 sub } bind
{ 2 copy 1 sub } bind { 2 copy } bind
] def
 
/dmc1 [
{ mrows 1 sub 0 } bind { mrows 1 sub 1 } bind
{ mrows 1 sub 2 } bind { 0 mcols 2 sub } bind
12549,7 → 13600,7
{ 0 mcols 1 sub } bind { 1 mcols 1 sub } bind
{ 2 mcols 1 sub } bind { 3 mcols 1 sub } bind
] def
 
/dmc2 [
{ mrows 3 sub 0 } bind { mrows 2 sub 0 } bind
{ mrows 1 sub 0 } bind { 0 mcols 4 sub } bind
12556,7 → 13607,7
{ 0 mcols 3 sub } bind { 0 mcols 2 sub } bind
{ 0 mcols 1 sub } bind { 1 mcols 1 sub } bind
] def
 
/dmc3 [
{ mrows 3 sub 0 } bind { mrows 2 sub 0 } bind
{ mrows 1 sub 0 } bind { 0 mcols 2 sub } bind
12563,7 → 13614,7
{ 0 mcols 1 sub } bind { 1 mcols 1 sub } bind
{ 2 mcols 1 sub } bind { 3 mcols 1 sub } bind
] def
 
/dmc4 [
{ mrows 1 sub 0 } bind { mrows 1 sub mcols 1 sub } bind
{ 0 mcols 3 sub } bind { 0 mcols 2 sub } bind
12625,8 → 13676,8
/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 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
12637,7 → 13688,7
/cwpos cwpos 1 add def
} if
} for
} if
} if
} for
 
% Return the arguments
12659,15 → 13710,21
/datamatrix dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER datamatrix--
 
% --BEGIN ENCODER qrcode--
% --REQUIRES preamble raiseerror renmatrix--
% --DESC: QR Code
% --EXAM: http://www.terryburton.co.uk/barcodewriter/
% --EXOP: eclevel=M
% --RNDR: renmatrix
%%BeginResource: uk.co.terryburton.bwipp qrcode 0.0 2014013000 245432 260692
%%BeginData: 934 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
begin
/qrcode {
12713,7 → 13770,7
length j add /j exch def
/barcode msg 0 j getinterval def
exit
} ifelse
} ifelse
} loop
} if
 
12725,7 → 13782,7
% Convert from input into message bitstream
raw {/encoding (raw) def} if
encoding (raw) eq {
/msgbits barcode def
/msgbits barcode def
} {
 
% Symbol capacities
12800,9 → 13857,9
/H [ 4 8 15 21 27 36 39 52 60 74 % 1-H - 10-H
85 96 109 120 136 154 173 191 208 235 % 11-H - 20-H
248 270 284 315 330 365 385 405 430 457 % 21-H - 30-H
486 518 553 590 605 647 673 701 750 784 ] % 31-H - 40-H
>>
>> def
486 518 553 590 605 647 673 701 750 784 ] % 31-H - 40-H
>>
>> def
 
% M1 M2 M3 M4 M1 M2 M3 M4 M1 M2 M3 M4 M1 M2 M3 M4
/microcaps <<
12814,7 → 13871,7
>>
/byte <<
/L [ -1 -1 9 15 ] /M [ -1 -1 7 13 ] /Q [ -1 -1 -1 9 ] /H [ -1 -1 -1 -1 ]
>>
>>
/kanji <<
/L [ -1 -1 6 9 ] /M [ -1 -1 4 8 ] /Q [ -1 -1 -1 5 ] /H [ -1 -1 -1 -1 ]
>>
12854,7 → 13911,7
/M3 [ 5 4 4 3 ]
/M4 [ 6 5 5 4 ]
1 1 9 { 2 string 10 exch cvrs cc1to9 } for
10 1 26 { 2 string 10 exch cvrs cc10to26 } for
10 1 26 { 2 string 10 exch cvrs cc10to26 } for
27 1 40 { 2 string 10 exch cvrs cc27to40 } for
>> def
 
12921,7 → 13978,7
/i exch def
(00000000) 8 string copy
dup in i get cvi
2 8 string cvrs dup length 8 exch sub exch putinterval
2 8 string cvrs dup length 8 exch sub exch putinterval
out i 8 mul 3 -1 roll putinterval
} for
out
12993,12 → 14050,12
% Set the control character data for the version
/mid mids version get encvals encoding get get def
/cclen cclens version get encvals encoding get get def
 
% Create the bitstream as mode_id character_count encoded_data
/enc barcode encs encoding get load exec def
(0000000000000000) 0 cclen getinterval cclen string copy
(0000000000000000) 0 cclen getinterval cclen string copy
dup barlen encoding (kanji) eq {2 idiv} if cvi
2 cclen string cvrs dup length cclen exch sub exch putinterval
2 cclen string cvrs dup length cclen exch sub exch putinterval
/cc exch def
/msgbits mid length cclen add enc length add string def
msgbits 0 mid putinterval
13009,7 → 14066,7
 
% Lookup the most appropriate symbol specification
/metrics [
% format vers size align modules error codewords error correction blocks
% format vers size align modules error codewords error correction blocks
% L M Q H L1 L2 M1 M2 Q1 Q2 H1 H2
[ (micro) (M1) 11 98 99 36 [ 2 99 99 99 ] [ 1 0 -1 -1 -1 -1 -1 -1 ] ]
[ (micro) (M2) 13 98 99 80 [ 5 6 99 99 ] [ 1 0 1 0 -1 -1 -1 -1 ] ]
13106,7 → 14163,7
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
13114,12 → 14171,12
/padstrs [ (11101100) (00010001) ] def
/padnum 0 def
msgbits length 8 div ceiling 8 mul cvi 8 dmod lc4b {5} {1} ifelse sub {
pad exch padstrs padnum get putinterval
pad exch padstrs padnum get putinterval
/padnum padnum 1 add 2 mod def
} for
 
% Evaluate the padded message into codewords
/cws dcws array def
/cws dcws array def
0 1 cws length 1 sub {
/c exch def
/bpcw 8 def
13129,9 → 14186,9
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
} for
cws c cw put
} for
} for
 
% Calculate the log and anti-log tables
/rsalog [ 1 255 { dup 2 mul dup 256 ge {285 xor} if } repeat ] def
13140,7 → 14197,7
 
% Function to calculate the product in the field
/rsprod {
2 copy 0 ne exch 0 ne and {
2 copy 0 ne exch 0 ne and {
rslog exch get exch rslog exch get add 255 mod rsalog exch get
} {
pop pop 0
13150,12 → 14207,12
% Generate the coefficients for the Reed-Solomon algorithm
/coeffs [ 1 ecpb {0} repeat ] def
0 1 ecpb 1 sub {
/i exch def
/i exch def
coeffs i 1 add coeffs i get put
i -1 1 {
/j exch def
coeffs j coeffs j 1 sub get coeffs j get rsalog i get rsprod xor put
} for
} for
coeffs 0 coeffs 0 get rsalog i get rsprod put
} for
/coeffs coeffs 0 coeffs length 1 sub getinterval def
13189,7 → 14246,7
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
13211,7 → 14268,7
/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
13219,7 → 14276,7
pad pad length 1 sub 0 put
/cws pad def
} if
 
% Fixups for the short final data byte in M1 and M3 symbols
lc4b {
dcws 1 sub 1 ncws 2 sub {
13233,7 → 14290,7
% Create the bitmap
/pixs [ size size mul {-1} repeat ] def
/qmv {size mul add} bind def
 
% Finder patterns
/fpat [
[ 1 1 1 1 1 1 1 0 ]
13257,7 → 14314,7
} if
} for
} for
 
% Alignment patterns
/algnpat [
[ 1 1 1 1 1 ]
13282,7 → 14339,7
i 4 putalgnpat
4 i putalgnpat
} for
asp2 2 sub asp3 asp2 sub size 9 sub {
asp2 2 sub asp3 asp2 sub size 9 sub {
/x exch def
asp2 2 sub asp3 asp2 sub size 9 sub {
/y exch def
13289,7 → 14346,7
x y putalgnpat
} for
} for
 
% Timing patterns
format (full) eq {
8 1 size 9 sub {
13304,7 → 14361,7
pixs 0 i qmv i 1 add 2 mod put
} for
} ifelse
 
% Format information modules
format (full) eq {
/formatmap [
13324,7 → 14381,7
formatmap {
{ {} forall qmv pixs exch 0 put } forall
} forall
 
% Version information modules
size 45 ge {
/versionmap [
13344,15 → 14401,15
versionmap {
{ {} forall qmv pixs exch 0 put } forall
} forall
 
% Solitary dark module in full symbols
format (full) eq {
pixs 8 size 8 sub qmv 1 put
} if
 
% Calculate the mask patterns
format (full) eq {
/maskfuncs [
/maskfuncs [
{add 2 mod} bind
{exch pop 2 mod} bind
{pop 3 mod} bind
13363,7 → 14420,7
{2 copy mul 3 mod 3 1 roll add 2 mod add 2 mod} bind
] def
} {
/maskfuncs [
/maskfuncs [
{exch pop 2 mod} bind
{2 idiv exch 3 idiv add 2 mod} bind
{mul dup 2 mod exch 3 mod add 2 mod} bind
13378,7 → 14435,7
/j exch def
0 1 size 1 sub {
/i exch def
i j maskfuncs m get exec 0 eq
i j 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
13385,7 → 14442,7
} for
masks m mask put
} for
 
% Walk the symbol placing the bitstream
/posx size 1 sub def
/posy size 1 sub def
13404,7 → 14461,7
/posx posx 1 sub def
} {
/col 1 def
/posx posx 1 add def
/posx posx 1 add def
/posy posy dir add def
posy 0 lt posy size ge or { % Turn around at top and bottom
/dir dir -1 mul def
13440,7 → 14497,7
} for
scr1 scr3
} bind def
 
% Evaluation algorithm for full symbols
/evalfull {
/sym exch def
13450,7 → 14507,7
/lastpairs size array def
/thispairs size array def
/sizeadd1 size 1 add def
0 1 size 1 sub {
0 1 size 1 sub {
/i exch def
 
% Runlength encode (light, dark, light, ...) and evaluate each column
13465,10 → 14522,10
 
% Runlength encode (light, dark, light, ...) and evaluate each row
/symrow sym i size mul size getinterval def
mark 0 0
symrow {
mark 0 0
symrow {
exch 1 index eq {exch 1 add exch} {1 exch} ifelse
} forall
} forall
pop
rle 0 counttomark 2 sub getinterval astore
evalfulln1n3 n3 add /n3 exch def n1 add /n1 exch def
13489,14 → 14546,14
} if
 
} for
% Score dark/light imbalance
 
% Score dark/light imbalance
/dark 0 sym {add} forall def
/n4 dark 100 mul size dup mul div 50 sub abs 5 div cvi 10 mul def
 
n1 n2 add n3 add n4 add
} bind def
 
% Evaluation algorithm for micro symbols
/evalmicro {
/sym exch def
13512,7 → 14569,7
dkbot 16 mul dkrhs add neg
} ifelse
} bind def
 
% Evaluate the masked symbols to find the most suitable
/bestscore 999999999 def
0 1 masks length 1 sub {
13527,20 → 14584,20
} {
masksym evalmicro /score exch def
} ifelse
score bestscore lt {
score bestscore lt {
/bestsym masksym def
/bestmaskval m def
/bestscore score def
} if
} if
} for
/pixs bestsym def
 
% Add the format information
format (full) eq {
/fmtvals [
16#5412 16#5125 16#5e7c 16#5b4b 16#45f9 16#40ce 16#4f97 16#4aa0
16#5412 16#5125 16#5e7c 16#5b4b 16#45f9 16#40ce 16#4f97 16#4aa0
16#77c4 16#72f3 16#7daa 16#789d 16#662f 16#6318 16#6c41 16#6976
16#1689 16#13be 16#1ce7 16#19d0 16#0762 16#0255 16#0d0c 16#083b
16#1689 16#13be 16#1ce7 16#19d0 16#0762 16#0255 16#0d0c 16#083b
16#355f 16#3068 16#3f31 16#3a06 16#24b4 16#2183 16#2eda 16#2bed
] def
/ecid (MLHQ) eclevel search pop length exch pop exch pop def
13561,14 → 14618,14
pixs exch {} forall qmv fmtval 14 i sub neg bitshift 1 and put
} forall
} for
 
% Add the version information
size 45 ge {
/vervals [
16#07c94 16#085bc 16#09a99 16#0a4d3 16#0bbf6 16#0c762 16#0d847
16#0e60d 16#0f928 16#10b78 16#1145d 16#12a17 16#13532 16#149a6
16#15683 16#168c9 16#177ec 16#18ec4 16#191e1 16#1afab 16#1b08e
16#1cc1a 16#1d33f 16#1ed75 16#1f250 16#209d5 16#216fd 16#228ba
16#07c94 16#085bc 16#09a99 16#0a4d3 16#0bbf6 16#0c762 16#0d847
16#0e60d 16#0f928 16#10b78 16#1145d 16#12a17 16#13532 16#149a6
16#15683 16#168c9 16#177ec 16#18ec4 16#191e1 16#1afab 16#1b08e
16#1cc1a 16#1d33f 16#1ed75 16#1f250 16#209d5 16#216fd 16#228ba
16#2379f 16#24b0b 16#2542e 16#26a64 16#27541 16#28c69
] def
/verval vervals size 17 sub 4 idiv 7 sub get def
13599,15 → 14656,21
/qrcode dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER qrcode--
 
% --BEGIN ENCODER maxicode--
% --REQUIRES preamble raiseerror 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
%%BeginResource: uk.co.terryburton.bwipp maxicode 0.0 2014013000 129420 134959
%%BeginData: 564 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renmaximatrix dup /uk.co.terryburton.bwipp findresource put
begin
/maxicode {
13653,10 → 14716,10
length j add /j exch def
/barcode msg 0 j getinterval def
exit
} ifelse
} ifelse
} loop
} if
 
/msg barcode def
/msglen msg length def
 
13666,7 → 14729,7
% Normalise messages that begin with a field identifier [)>RS01GSyy
msg 0 7 getinterval <5b293e1e30311d> eq {
/fid msg 0 9 getinterval def
/msg msg 9 msglen 9 sub getinterval def
/msg msg 9 msglen 9 sub getinterval def
} {
/fid () def
} ifelse
13679,7 → 14742,7
 
% Prepend the field identifier
msg length fid length add string dup
0 fid putinterval dup
0 fid putinterval dup
fid length msg putinterval
/msg exch def
/msglen msg length def
13690,10 → 14753,10
/eci -1 def /pad -2 def /ns -3 def
/la -4 def /lb -5 def
/sa -6 def /sb -7 def /sc -8 def /sd -9 def /se -10 def
/sa2 -11 def /sa3 -12 def
/sa2 -11 def /sa3 -12 def
/lkc -13 def /lkd -14 def /lke -15 def
/pd2 -16 def /pd3 -17 def
/pd2 -16 def /pd3 -17 def
 
% Character maps for each state
/charmaps [
% A B C D E
13706,7 → 14769,7
[ (F) (f) 198 230 6 ] % 6
[ (G) (g) 199 231 7 ] % 7
[ (H) (h) 200 232 8 ] % 8
[ (I) (i) 201 233 9 ] % 9
[ (I) (i) 201 233 9 ] % 9
[ (J) (j) 202 234 10 ] % 10
[ (K) (k) 203 235 11 ] % 11
[ (L) (l) 204 236 12 ] % 12
13761,8 → 14824,8
[ sd sd sd lkd sd ] % 61
[ se se se se lke ] % 62
[ lb la lb lb lb ] % 63
] def
] def
 
% 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 charmaps length 1 sub {
13771,7 → 14834,7
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
charvals j get exch i put
} for
} for
/seta charvals 0 get def
13792,15 → 14855,15
} for
/nseq nseq 0 msglen getinterval def
 
% Encode the message from ASCII to codewords
% Encode the message from ASCII to codewords
/prefixinset {
0 {
2 copy exch length ge {exit} if
2 copy exch length ge {exit} if
2 copy get 3 index exch known {1 add} {exit} ifelse
} loop
exch pop exch pop
} bind def
 
/enc {
exch get out exch j exch put
/j j 1 add def
13818,7 → 14881,7
exit
} if
{ % not a loop but common exit point
 
% If 9 numerals available then use NS
nseq i get 9 ge {
msg i 9 getinterval cvi 4 { dup 63 and exch -6 bitshift } repeat cset load ns get
13828,19 → 14891,19
/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 {
cset load char1 known {
char1 cset load enc
/i i 1 add def
exit
} if
 
% For switching from A to B
cset (seta) eq setb char1 known and {
setb char2 known {
13853,7 → 14916,7
} 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 def
13866,7 → 14929,7
sa2 setb enc
char1 seta enc
char2 seta enc
/i i 2 add def
/i i 2 add def
} if
p 3 eq {
sa3 setb enc
13873,7 → 14936,7
char1 seta enc
char2 seta enc
char3 seta enc
/i i 3 add def
/i i 3 add def
} if
p 4 ge {
la setb enc
13881,24 → 14944,24
} if
exit
} if
 
% If character is in A or B then directly latch
seta char1 known {
la cset load enc
/cset (seta) def
exit
} if
} if
setb char1 known {
lb cset load enc
/cset (setb) def
exit
} if
} if
 
% Determine which one of sets C, D or E the character is in
setc char1 known {/setx (setc) def /sx sc def /lkx lkc def} if
setd char1 known {/setx (setd) def /sx sd def /lkx lkd def} if
sete char1 known {/setx (sete) def /sx se def /lkx 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 def
p 1 eq {
13925,20 → 14988,20
p 4 ge {
sx cset load enc
lkx setx load enc
/cset setx def
/cset setx def
} if
 
exit
} loop % out
} loop
/encmsg out 0 j getinterval def
/padval cset load pad get def
/padval cset load pad get def
 
% Prefix the encoded message with the structured append insert
/sami [] def
sam -1 ne {
/sami 2 array def
sami 0 seta pad get put
sami 0 seta pad get put
sami 1 sam 10 idiv 1 sub 8 mul sam 10 mod 1 sub add put
} if
/encmsg [ sami aload pop encmsg aload pop ] def
13957,8 → 15020,8
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
/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 {
13985,7 → 15048,7
 
% Evaluate the structured carrier message as codewords
/pri [ 0 0 0 0 0 0 0 0 0 0 ] def
0 1 59 {
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
14080,9 → 15143,9
 
% Concatinate the data into final codewords
/codewords [
pri aload pop
pri aload pop
pri 10 rscodes aload pop
sec aload pop
sec aload pop
secchk aload pop
] def
 
14096,49 → 15159,49
 
% Maps modules to pixels in the grid
/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
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
] def
 
14169,15 → 15232,21
/maxicode dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER maxicode--
 
% --BEGIN ENCODER azteccode--
% --REQUIRES preamble raiseerror renmatrix--
% --DESC: Aztec Code
% --EXAM: This is Aztec Code
% --EXOP: format=full
% --RNDR: renmatrix
%%BeginResource: uk.co.terryburton.bwipp azteccode 0.0 2014013000 135811 148610
%%BeginData: 408 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
begin
/azteccode {
14206,7 → 15275,7
currentdict end /options exch def
} if
options {def} forall
 
/layers layers cvi def
/eclevel eclevel cvr def
/ecaddchars ecaddchars cvi def
14228,13 → 15297,13
length j add /j exch def
/barcode msg 0 j getinterval def
exit
} ifelse
} ifelse
} loop
} if
 
% Convert from input into message bitstream
/msgbits () def
format (rune) ne raw and {/msgbits barcode def} if
/msgbits () def
format (rune) ne raw and {/msgbits barcode def} if
format (rune) ne raw not and { % Simple autoencoder from input to bitstream using byte mode only
 
% Determine the character count
14256,13 → 15325,13
msgbits 5 cc putinterval
0 1 barlen 1 sub {
/i exch def
(00000000) 8 string copy dup barcode i get cvi 2 8 string cvrs dup length 8 exch sub exch putinterval
(00000000) 8 string copy dup barcode i get cvi 2 8 string cvrs dup length 8 exch sub exch putinterval
msgbits 5 cclen add i 8 mul add 3 -1 roll putinterval
} for
 
} if
 
% Lookup the most appropriate symbol specification
% Lookup the most appropriate symbol specification
/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 ]
14288,12 → 15357,12
/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
msgbits length 0 eq {/numecw 0 def} if % Error correction codewords
/numdcw ncws numecw sub def % Data codewords
/okay true def
format (unset) ne format frmt ne and {/okay false def} if
readerinit icap 1 ne and {/okay false def} if
layers -1 ne layers mlyr 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
/i i 1 add def
14313,8 → 15382,8
/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
% Concatinate the bits
12 string dup 0 cwb putinterval
% Concatinate the bits
12 string dup 0 cwb putinterval
dup bpcw 1 sub cwf putinterval
0 bpcw getinterval
/cwb exch def
14330,9 → 15399,9
/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
/m m bpcw add def
/c c 1 add def
} loop
} loop
/cws cws 0 c getinterval def
 
% Reed-Solomon algorithm
14360,12 → 15429,12
% Generate the coefficients
/coeffs [ 1 rsnc {0} repeat ] def
1 1 rsnc {
/i exch def
/i exch def
coeffs i coeffs i 1 sub get put
i 1 sub -1 1 {
/j exch def
coeffs j coeffs j 1 sub get coeffs j get rsalog i get rsprod xor put
} for
} for
coeffs 0 coeffs 0 get rsalog i get rsprod put
} for
 
14373,11 → 15442,11
/nd rscws length def
/rscws [ rscws {} forall rsnc {0} repeat 0 ] def
0 1 nd 1 sub {
/k exch rscws exch get rscws nd get xor def
/k exch rscws exch get rscws nd get xor def
0 1 rsnc 1 sub {
/j exch def
/j exch def
rscws nd j add rscws nd j add 1 add get k coeffs rsnc j sub 1 sub get rsprod xor put
} for
} for
} for
 
% Return all but the last codeword
14395,11 → 15464,11
mode 2#0000000011110000 and -4 bitshift
mode 2#0000000000001111 and
] def
/mode mode 6 16 19 rscodes def
/mode mode 6 16 19 rscodes 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
readerinit {/mode mode 2#00100000 or def} if
/mode [
mode 2#11110000 and -4 bitshift
mode 2#00001111 and
14419,16 → 15488,16
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
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
/rsparams [
[] [] [] [] [] []
[ 64 67 ] % 6-bit codewords
[] [] [] [] [] []
[ 64 67 ] % 6-bit codewords
[]
[ 256 301 ] % 8-bit codewords
[]
[]
[ 1024 1033 ] % 10-bit codewords
[]
[ 4096 4201 ] % 12-bit codewords
14435,16 → 15504,16
] def
/cws cws ncws cws length sub rsparams bpcw get {} forall rscodes def
format (full) eq {
/databits layers layers mul 16 mul layers 112 mul add string def
/databits layers layers mul 16 mul layers 112 mul add string def
} {
/databits layers layers mul 16 mul layers 88 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 {
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
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
 
% Move to a point in the cartesian plane centered on the bullseye
14457,7 → 15526,7
/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
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
14481,7 → 15550,7
% 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
/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
 
14511,7 → 15580,7
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
} for
/j 0 def
0 1 npixs length 1 sub {
/i exch def
14546,7 → 15615,7
 
% Mode ring
format (full) eq {
/modemap [
/modemap [
[-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]
14583,15 → 15652,21
/azteccode dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER azteccode--
 
% --BEGIN ENCODER codeone--
% --REQUIRES preamble raiseerror renmatrix--
% --DESC: Code One
% --EXAM: Code One
% --EXOP: version=B
% --RNDR: renmatrix
%%BeginResource: uk.co.terryburton.bwipp codeone 0.0 2014013000 104659 110857
%%BeginData: 328 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
begin
/codeone {
14638,7 → 15713,7
length j add /j exch def
/barcode msg 0 j getinterval def
exit
} ifelse
} ifelse
} loop
} if
 
14717,7 → 15792,7
/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
/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
14741,11 → 15816,11
/ecbs rsbl array def % Array of error correction blocks
0 1 rsbl 1 sub {
/i exch def
/cwb dcpb array def
/cwb dcpb array def
0 1 dcpb 1 sub {
/j exch def
cwb j cws j rsbl mul i add get put
} for
} for
cwbs i cwb put
} for
 
14757,7 → 15832,7
/rslog gf array def
1 1 gf-1 {dup rsalog exch get exch rslog 3 1 roll put} for
/rsprod {
2 copy 0 ne exch 0 ne and {
2 copy 0 ne exch 0 ne and {
rslog exch get exch rslog exch get add gf-1 mod rsalog exch get
} {
pop pop 0
14767,12 → 15842,12
% Generate the coefficients for the Reed-Solomon algorithm
/coeffs [ 1 ecpb {0} repeat ] def
0 1 ecpb 1 sub {
/i exch def
/i exch def
coeffs i 1 add coeffs i get put
i -1 1 {
/j exch def
coeffs j coeffs j 1 sub get coeffs j get rsalog i get rsprod xor put
} for
} for
coeffs 0 coeffs 0 get rsalog i get rsprod put
} for
/coeffs coeffs 0 coeffs length 1 sub getinterval def
14831,14 → 15906,14
 
% Centre pattern
/artifact [
{cols {0} repeat} bind
{cols {1} repeat} bind
{0 cols 2 sub {1} repeat 0} bind
{0 1 cols 4 sub {0} repeat 1 0} bind
{cols 1 sub 2 idiv {-1} repeat 1 cols 1 sub 2 idiv {-1} repeat} bind
{cols 1 sub 2 idiv {-1} repeat 0 cols 1 sub 2 idiv {-1} repeat} bind
{1 cols 2 sub {0} repeat 1} bind
{1 0 cols 4 sub {1} repeat 0 1} bind
{cols {0} repeat} bind
{cols {1} repeat} bind
{0 cols 2 sub {1} repeat 0} bind
{0 1 cols 4 sub {0} repeat 1 0} bind
{cols 1 sub 2 idiv {-1} repeat 1 cols 1 sub 2 idiv {-1} repeat} bind
{cols 1 sub 2 idiv {-1} repeat 0 cols 1 sub 2 idiv {-1} repeat} bind
{1 cols 2 sub {0} repeat 1} bind
{1 0 cols 4 sub {1} repeat 0 1} bind
] def
/cpat <<
/A (121343)
14852,7 → 15927,7
/S (56661278)
/T (5666666666127878)
>> vers 0 1 getinterval get def
pixs 0 rows cpat length sub 2 idiv mmv
pixs 0 rows cpat length sub 2 idiv mmv
[ cpat {artifact exch 49 sub get exec} forall ] putinterval
 
% Risers
14864,7 → 15939,7
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
pixs cols j sub 2 sub rows i sub 1 sub mmv
3 -1 roll putinterval
} {pop} ifelse
} for
14917,22 → 15992,27
/codeone dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER codeone--
 
% --BEGIN ENCODER gs1-cc--
% --REQUIRES micropdf417 pdf417--
% --REQUIRES preamble raiseerror renmatrix micropdf417 pdf417--
% --DESC: GS1 Composite 2D Component
% --EXAM: (01)95012345678903(3103)000123
% --EXOP: ccversion=b cccolumns=4
% --RNDR: renmatrix
%%BeginResource: uk.co.terryburton.bwipp gs1-cc 0.0 2014013000 191363 193686
%%BeginData: 650 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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 {
 
20 dict begin % Confine variables to local scope
 
/options exch def % We are given an option string
14943,7 → 16023,7
/cccolumns -1 def
/lintype () def
/linwidth -1 def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
14954,7 → 16034,7
currentdict end /options exch def
} if
options {def} forall
 
/cccolumns cccolumns cvi def
/linwidth linwidth cvi def
 
14974,7 → 16054,7
/databarlimited 3
/databarexpanded 4
/databarexpandedstacked 4
>> lintype get /cccolumns exch def
>> lintype get /cccolumns exch def
} if
 
% Expand ordinals of the form ^NNN to ASCII
14994,10 → 16074,10
dup out exch j exch putinterval
length j add /j exch def
out 0 j getinterval exit
} ifelse
} ifelse
} loop
} bind def
 
% Parse out AIs
/ais [] def
/aival 2 dict def
15007,8 → 16087,8
(\)) search pop
exch pop
exch (\() search {
exch pop exch 3 1 roll
} {
exch pop exch 3 1 roll
} {
() 3 1 roll
} ifelse
[ ais aload pop counttomark 2 add index ] /ais exch def
15015,13 → 16095,13
aival 3 1 roll expand put
} loop
pop
 
% Method selection
/isupper {dup 65 ge exch 90 le and} bind def % A-Z
/isnum0 {dup 48 ge exch 57 le and} bind def % 0-9
/isnum1 {dup 49 ge exch 57 le and} bind 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 {
15064,7 → 16144,7
 
% Freeform
-1 (0) exit
 
} loop
/method exch def
/npre exch def
15073,9 → 16153,9
 
/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
dup 3 -1 roll 2 2 index length string cvrs dup length 2 index length exch sub exch putinterval
} bind def
 
/alpha <<
65 1 90 {dup 65 sub 5 tobin} for
48 1 57 {dup 4 add 6 tobin} for
15085,16 → 16165,16
/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
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
(0000000) 7 string copy dup 3 -1 roll 2 7 string cvrs
dup length 7 exch sub exch putinterval
} for
lalphanumeric (0000)
>> def
 
/alphanumeric <<
48 1 57 {dup 43 sub 5 tobin} for
fnc1 (01111)
15104,7 → 16184,7
lnumeric (000)
liso646 (00100)
>> def
 
/iso646 <<
48 1 57 {dup 43 sub 5 tobin} for
fnc1 (01111)
15125,7 → 16205,7
aival ais 0 get 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
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
15166,12 → 16246,12
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
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
ais1 (21) eq ais1 (8004) eq or {
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
15182,7 → 16262,7
/aval exch def
} {
pop /aval -1 def
} ifelse
} 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
15191,7 → 16271,7
dup length 4 exch sub exch putinterval
[ exch {48 sub} forall ] /abits exch def
/cdf [
cdf aload pop
cdf aload pop
nbits aload pop
abits aload pop
] def
15217,12 → 16297,12
/out in length 6 mul array def
/j 0 def
0 1 in length 1 sub {
in exch get encs exch get
in exch get encs exch get
dup [ exch {48 sub} forall ] out exch j exch putinterval
length j add /j exch def
} for
/cdf [
cdf aload pop
cdf aload pop
out 0 j getinterval aload pop
] def
/gpf [] def
15327,7 → 16407,7
} {
/ccversion -1 def
} ifelse
} ifelse
} ifelse
used rembits
} if
} bind def
15348,7 → 16428,7
/i exch def
gpf i get
(00) 2 string copy
dup 0 gpf i get dup fnc1 eq {pop 94} if put
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
15366,7 → 16446,7
nextiso646only i nextiso646only i 1 add get 1 add put
} ifelse
} for
 
% Encode the general purpose field
/gpfenc 8296 array def
/i 0 def /j 0 def
15373,10 → 16453,10
{ % 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
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 {
15385,7 → 16465,7
exit
} if
pop
lalphanumeric numeric encode
lalphanumeric numeric encode
/mode (alphanumeric) def
exit
} {
15402,13 → 16482,13
/i i 1 add def
exit
} { % C1.FNC1
2 string dup 0 gpf i get put dup 1 94 put numeric encode
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
15435,7 → 16515,7
/i i 1 add def
exit
} if
 
mode (iso646) eq {
gpf i get fnc1 eq {
fnc1 iso646 encode
15457,7 → 16537,7
/i i 1 add def
exit
} if
 
} loop
} loop
/gpf gpfenc 0 j getinterval def
15467,8 → 16547,8
pad length 0 gt {
0 5 pad length 1 sub { % Fill with 00100
/i exch def
pad i [ 0 0 1 0 0 ] 0 pad length i sub 5 2 copy gt {exch} if pop getinterval putinterval
} for
pad i [ 0 0 1 0 0 ] 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
15495,8 → 16575,8
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 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
/cws [ 28 {0} repeat ] def
15521,7 → 16601,7
/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
} for
/b b bsl add def
/c c csl add def
} loop
15574,17 → 16654,21
/gs1-cc dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER gs1-cc--
 
% --BEGIN ENCODER ean13composite--
% --REQUIRES ean13 micropdf417 pdf417 gs1-cc--
% --SUGGESTS ean5 ean2--
% --REQUIRES preamble raiseerror renlinear renmatrix ean5 ean2 ean13 micropdf417 pdf417 gs1-cc--
% --DESC: EAN-13 Composite
% --EXAM: 2112345678900|(99)1234-abcd
% --EXOP: includetext
% --RNDR: renlinear renmatrix
%%BeginResource: uk.co.terryburton.bwipp ean13composite 0.0 2014013000 88474 88426
%%BeginData: 72 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
2 dict
1 dict
dup /raiseerror 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 /renlinear dup /uk.co.terryburton.bwipp findresource put
15598,7 → 16682,7
/barcode exch def
 
/dontdraw false def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
15654,17 → 16738,21
/ean13composite dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER ean13composite--
 
% --BEGIN ENCODER ean8composite--
% --REQUIRES ean8 micropdf417 pdf417 gs1-cc--
% --SUGGESTS ean5 ean2--
% --REQUIRES preamble raiseerror renlinear renmatrix ean5 ean2 ean8 micropdf417 pdf417 gs1-cc--
% --DESC: EAN-8 Composite
% --EXAM: 02345673|(21)A12345678
% --EXOP: includetext
% --RNDR: renlinear renmatrix
%%BeginResource: uk.co.terryburton.bwipp ean8composite 0.0 2014013000 85295 92184
%%BeginData: 75 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
2 dict
1 dict
dup /raiseerror 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 /renlinear dup /uk.co.terryburton.bwipp findresource put
15678,7 → 16766,7
/barcode exch def
 
/dontdraw false def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
15737,17 → 16825,21
/ean8composite dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER ean8composite--
 
% --BEGIN ENCODER upcacomposite--
% --REQUIRES upca micropdf417 pdf417 gs1-cc--
% --SUGGESTS ean5 ean2--
% --REQUIRES preamble raiseerror renlinear renmatrix ean5 ean2 upca micropdf417 pdf417 gs1-cc--
% --DESC: UPC-A Composite
% --EXAM: 416000336108|(99)1234-abcd
% --EXOP: includetext
% --RNDR: renlinear renmatrix
%%BeginResource: uk.co.terryburton.bwipp upcacomposite 0.0 2014013000 84946 91835
%%BeginData: 72 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
2 dict
dup /raiseerror 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 /renlinear dup /uk.co.terryburton.bwipp findresource put
15761,7 → 16853,7
/barcode exch def
 
/dontdraw false def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
15817,17 → 16909,21
/upcacomposite dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER upcacomposite--
 
% --BEGIN ENCODER upcecomposite--
% --REQUIRES upce micropdf417 pdf417 gs1-cc--
% --SUGGESTS ean5 ean2--
% --REQUIRES preamble raiseerror renlinear renmatrix ean5 ean2 upce micropdf417 pdf417 gs1-cc--
% --DESC: UPC-E Composite
% --EXAM: 00123457|(15)021231
% --EXOP: includetext
% --RNDR: renlinear renmatrix
%%BeginResource: uk.co.terryburton.bwipp upcecomposite 0.0 2014013000 85900 89258
%%BeginData: 87 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
2 dict
dup /raiseerror 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 /renlinear dup /uk.co.terryburton.bwipp findresource put
15841,7 → 16937,7
/barcode exch def
 
/dontdraw false def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
15869,7 → 16965,7
0 1 49 {0} repeat 1 0
1 0 49 {0} repeat 0 1
0 1 49 {0} repeat 1 0
]
]
/pixx 53
/pixy 3
/height 6 72 div
15912,16 → 17008,21
/upcecomposite dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER upcecomposite--
 
% --BEGIN ENCODER databaromnicomposite--
% --REQUIRES databaromni micropdf417 pdf417 gs1-cc--
% --REQUIRES preamble raiseerror renlinear renmatrix databaromni micropdf417 pdf417 gs1-cc--
% --DESC: GS1 DataBar Omnidirectional Composite
% --EXAM: (01)03612345678904|(11)990102
% --EXOP:
% --RNDR: renlinear renmatrix
%%BeginResource: uk.co.terryburton.bwipp databaromnicomposite 0.0 2014013000 85295 88703
%%BeginData: 100 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
2 dict
dup /raiseerror 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 /renlinear dup /uk.co.terryburton.bwipp findresource put
15935,7 → 17036,7
/barcode exch def
 
/dontdraw false def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
16019,16 → 17120,21
/databaromnicomposite dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER databaromnicomposite--
 
% --BEGIN ENCODER databarstackedcomposite--
% --REQUIRES databaromni databarstacked micropdf417 pdf417 gs1-cc--
% --REQUIRES preamble raiseerror renlinear renmatrix databaromni databarstacked micropdf417 pdf417 gs1-cc--
% --DESC: GS1 DataBar Stacked Composite
% --EXAM: (01)03412345678900|(17)010200
% --EXOP:
% --RNDR: renlinear renmatrix
%%BeginResource: uk.co.terryburton.bwipp databarstackedcomposite 0.0 2014013000 91237 87360
%%BeginData: 96 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
2 dict
dup /raiseerror 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 /renmatrix dup /uk.co.terryburton.bwipp findresource put
16041,7 → 17147,7
/barcode exch def
 
/dontdraw false def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
16122,16 → 17228,21
/databarstackedcomposite dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER databarstackedcomposite--
 
% --BEGIN ENCODER databarstackedomnicomposite--
% --REQUIRES databaromni databarstackedomni micropdf417 pdf417 gs1-cc--
% --REQUIRES preamble raiseerror renlinear renmatrix databaromni databarstackedomni micropdf417 pdf417 gs1-cc--
% --DESC: GS1 DataBar Stacked Omnidirectional Composite
% --EXAM: (01)03612345678904|(11)990102
% --EXOP:
% --RNDR: renlinear renmatrix
%%BeginResource: uk.co.terryburton.bwipp databarstackedomnicomposite 0.0 2014013000 91313 87432
%%BeginData: 96 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
2 dict
dup /raiseerror 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 /renmatrix dup /uk.co.terryburton.bwipp findresource put
16144,7 → 17255,7
/barcode exch def
 
/dontdraw false def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
16225,16 → 17336,21
/databarstackedomnicomposite dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER databarstackedomnicomposite--
 
% --BEGIN ENCODER databartruncatedcomposite--
% --REQUIRES databaromni databartruncated micropdf417 pdf417 gs1-cc--
% --REQUIRES preamble raiseerror renlinear renmatrix databaromni databartruncated micropdf417 pdf417 gs1-cc--
% --DESC: GS1 DataBar Truncated Composite
% --EXAM: (01)03612345678904|(11)990102
% --EXOP:
% --RNDR: renlinear renmatrix
%%BeginResource: uk.co.terryburton.bwipp databartruncatedcomposite 0.0 2014013000 92307 88414
%%BeginData: 100 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
2 dict
dup /raiseerror 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 /renlinear dup /uk.co.terryburton.bwipp findresource put
16248,7 → 17364,7
/barcode exch def
 
/dontdraw false def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
16332,16 → 17448,21
/databartruncatedcomposite dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER databartruncatedcomposite--
 
% --BEGIN ENCODER databarlimitedcomposite--
% --REQUIRES databarlimited micropdf417 pdf417 gs1-cc--
% --REQUIRES preamble raiseerror renlinear renmatrix databarlimited micropdf417 pdf417 gs1-cc--
% --DESC: GS1 DataBar Limited Composite
% --EXAM: (01)03512345678907|(21)abcdefghijklmnopqrstuv
% --EXOP:
% --RNDR: renlinear renmatrix
%%BeginResource: uk.co.terryburton.bwipp databarlimitedcomposite 0.0 2014013000 85160 81541
%%BeginData: 79 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
2 dict
dup /raiseerror 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 /renlinear dup /uk.co.terryburton.bwipp findresource put
16355,7 → 17476,7
/barcode exch def
 
/dontdraw false def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
16406,8 → 17527,8
>> //renmatrix exec
 
% Plot the 2D part
comp options //gs1-cc exec
dup (pixx) get 72 exch sub 1 rmoveto
comp options //gs1-cc exec
dup (pixx) get 72 exch sub 1 rmoveto
//renmatrix exec
 
grestore
16418,16 → 17539,21
/databarlimitedcomposite dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER databarlimitedcomposite--
 
% --BEGIN ENCODER databarexpandedcomposite--
% --REQUIRES databarexpanded micropdf417 pdf417 gs1-cc--
% --REQUIRES preamble raiseerror renlinear renmatrix databarexpanded micropdf417 pdf417 gs1-cc--
% --DESC: GS1 DataBar Expanded Composite
% --EXAM: (01)93712345678904(3103)001234|(91)1A2B3C4D5E
% --EXOP:
% --RNDR: renlinear renmatrix
%%BeginResource: uk.co.terryburton.bwipp databarexpandedcomposite 0.0 2014013000 88262 84615
%%BeginData: 98 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
2 dict
dup /raiseerror 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 /renlinear dup /uk.co.terryburton.bwipp findresource put
16441,7 → 17567,7
/barcode exch def
 
/dontdraw false def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
16501,7 → 17627,7
[ % Finder pattern module positions
18 98 bot length 13 sub {} for
69 98 bot length 13 sub {} for
] {sepfinder} forall
] {sepfinder} forall
0 linheight rmoveto <<
/ren //renmatrix
/pixs sep
16523,16 → 17649,21
/databarexpandedcomposite dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER databarexpandedcomposite--
 
% --BEGIN ENCODER databarexpandedstackedcomposite--
% --REQUIRES databarexpanded databarexpandedstacked micropdf417 pdf417 gs1-cc--
% --REQUIRES preamble raiseerror renlinear renmatrix databarexpanded databarexpandedstacked micropdf417 pdf417 gs1-cc--
% --DESC: GS1 DataBar Expanded Stacked Composite
% --EXAM: (01)00012345678905(10)ABCDEF|(21)12345678
% --EXOP: segments=4
% --EXOP: segments=4
% --RNDR: renmatrix renlinear
%%BeginResource: uk.co.terryburton.bwipp databarexpandedstackedcomposite 0.0 2014013000 87600 90536
%%BeginData: 95 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
2 dict
dup /raiseerror 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 /renmatrix dup /uk.co.terryburton.bwipp findresource put
16545,7 → 17676,7
/barcode exch def
 
/dontdraw false def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
16602,7 → 17733,7
[ % Finder pattern module positions
19 98 bot length 13 sub {} for
70 98 bot length 13 sub {} for
] {sepfinder} forall
] {sepfinder} forall
0 linheight rmoveto <<
/ren //renmatrix
/pixs sep
16625,16 → 17756,21
/databarexpandedstackedcomposite dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER databarexpandedstackedcomposite--
 
% --BEGIN ENCODER gs1-128composite--
% --REQUIRES code128 gs1-128 micropdf417 pdf417 gs1-cc--
% --REQUIRES preamble raiseerror renlinear renmatrix code128 gs1-128 micropdf417 pdf417 gs1-cc--
% --DESC: GS1-128 Composite
% --EXAM: (00)030123456789012340|(02)13012345678909(37)24(10)1234567ABCDEFG
% --EXOP: ccversion=c
% --RNDR: renlinear renmatrix
%%BeginResource: uk.co.terryburton.bwipp gs1-128composite 0.0 2014013000 88527 91356
%%BeginData: 100 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
2 dict
dup /raiseerror 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 /renlinear dup /uk.co.terryburton.bwipp findresource put
16648,7 → 17784,7
/barcode exch def
 
/dontdraw false def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
16683,7 → 17819,7
options (lintype) (gs1-128) put
options (linwidth) linwidth put
comp options //gs1-cc exec /compsym exch def
compsym (pixx) get 99 eq {(a)} {(c)} ifelse /linktype exch def
compsym (pixx) get 99 eq {(a)} {(c)} ifelse /linktype exch def
 
% Plot linear part
linktype (a) eq {
16719,7 → 17855,7
/x s p sub 1 sub 11 mul 10 add p 0 eq {2 add} if 99 sub def
x 1 rmoveto
} {
-7 1 rmoveto
-7 1 rmoveto
} ifelse
 
compsym //renmatrix exec
16732,16 → 17868,21
/gs1-128composite dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER gs1-128composite--
 
% --BEGIN ENCODER gs1datamatrix--
% --REQUIRES datamatrix--
% --REQUIRES preamble raiseerror renmatrix datamatrix--
% --DESC: GS1 Data Matrix
% --EXAM: (01)03453120000011(17)120508(10)ABCD1234(410)9501101020917
% --EXOP:
% --RNDR: renmatrix
%%BeginResource: uk.co.terryburton.bwipp gs1datamatrix 0.0 2014013000 74757 77843
%%BeginData: 134 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
16753,7 → 17894,7
/barcode exch def % We are given a barcode string
 
/dontdraw false def
 
% Parse the input options
options type /stringtype eq {
1 dict begin
16782,10 → 17923,10
dup out exch j exch putinterval
length j add /j exch def
out 0 j getinterval exit
} ifelse
} ifelse
} loop
} bind def
 
% Parse out AIs
/ais [] def
/aival 2 dict def
16795,8 → 17936,8
(\)) search pop
exch pop
exch (\() search {
exch pop exch 3 1 roll
} {
exch pop exch 3 1 roll
} {
() 3 1 roll
} ifelse
[ ais aload pop counttomark 2 add index ] /ais exch def
16822,7 → 17963,7
10 2 string cvrs dup aifixed 3 1 roll put
} forall
 
% Create the datamatrix data
% Create the datamatrix data
/fnc1 -1 def
/dmtx [ fnc1 ] def
0 1 ais length 1 sub {
16864,9 → 18005,9
 
args (opt) options put
args
 
dontdraw not //renmatrix if
 
end
 
} bind def
16873,16 → 18014,21
/gs1datamatrix dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER gs1datamatrix--
 
% --BEGIN ENCODER hibccode39--
% --REQUIRES code39--
% --REQUIRES preamble raiseerror renlinear code39--
% --DESC: HIBC Code 39
% --EXAM: A123BJC5D6E71
% --EXOP: includetext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp hibccode39 0.0 2014013000 67484 67295
%%BeginData: 92 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
16898,6 → 18044,7
/textsize 10 def
/textyoffset -7 def
/textxoffset 0 def
/validatecheck false def
 
% Parse the input options
options type /stringtype eq {
16915,25 → 18062,37
/textyoffset textyoffset cvr def
/textxoffset textxoffset cvr def
 
/barlen barcode length def
 
% Create a string of the available characters
/barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def
/charvals 43 dict def
0 1 42 {charvals exch dup barchars exch 1 getinterval exch put} for
 
/barcode barlen 2 add string dup 1 barcode putinterval def
barcode 0 43 put
% Validate the input
0 1 barcode length 1 sub {
barcode exch 1 getinterval charvals exch known not {
/bwipp.hibccode39badCharacter (HIBC Code 39 must contain only digits, capital letters, spaces and the symbols -.$/+%) //raiseerror exec
} if
} for
 
/barlen barcode length validatecheck {1 sub} if def
 
/checksum 0 def
0 1 barlen {
/i exch def
% Lookup the encoding for the each barcode character
barcode i 1 getinterval barchars exch search
pop % Discard true leaving pre
length /indx exch def % indx is the length of pre
pop pop % Discard seek and post
/checksum checksum indx add def
0 1 barlen 1 sub {
barcode exch 1 getinterval charvals exch get
checksum add /checksum exch def
} for
barcode barlen 1 add barchars checksum 43 mod get put
/checksum checksum 43 mod def
validatecheck {
barcode barlen get barchars checksum get ne {
/bwipp.hibccode39badCheckDigit (Incorrect HIBC Code 39 check digit provided) //raiseerror exec
} if
/barcode barcode 0 barlen getinterval def
} if
 
/barcode barlen 2 add string dup 1 barcode putinterval def
barcode 0 43 put
barcode barlen 1 add barchars checksum get put
 
/text barlen 4 add string def
text 0 42 put
text 1 barcode putinterval
16943,6 → 18102,7
% Get the result of encoding with code39
options (dontdraw) true put
options (includecheck) false put
options (validatecheck) false put
/args barcode options //code39 exec def
 
args (txt) [ [text textxoffset textyoffset textfont textsize] ] put
16949,7 → 18109,7
args (textxalign) (center) put
args (opt) options put
args
 
dontdraw not //renlinear if
 
end
16958,16 → 18118,21
/hibccode39 dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER hibccode39--
 
% --BEGIN ENCODER hibccode128--
% --REQUIRES code128--
% --REQUIRES preamble raiseerror renlinear code128--
% --DESC: HIBC Code 128
% --EXAM: A123BJC5D6E71
% --EXOP: includetext
% --RNDR: renlinear
%%BeginResource: uk.co.terryburton.bwipp hibccode128 0.0 2014013000 67387 67050
%%BeginData: 91 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
16983,6 → 18148,7
/textsize 10 def
/textyoffset -7 def
/textxoffset 0 def
/validatecheck false def
 
% Parse the input options
options type /stringtype eq {
17000,25 → 18166,37
/textyoffset textyoffset cvr def
/textxoffset textxoffset cvr def
 
/barlen barcode length def
 
% Create a string of the available characters
/barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def
/charvals 43 dict def
0 1 42 {charvals exch dup barchars exch 1 getinterval exch put} for
 
/barcode barlen 2 add string dup 1 barcode putinterval def
barcode 0 43 put
% Validate the input
0 1 barcode length 1 sub {
barcode exch 1 getinterval charvals exch known not {
/bwipp.hibccode128badCharacter (HIBC Code 128 must contain only digits, capital letters, spaces and the symbols -.$/+%) //raiseerror exec
} if
} for
 
/barlen barcode length validatecheck {1 sub} if def
 
/checksum 0 def
0 1 barlen {
/i exch def
% Lookup the encoding for the each barcode character
barcode i 1 getinterval barchars exch search
pop % Discard true leaving pre
length /indx exch def % indx is the length of pre
pop pop % Discard seek and post
/checksum checksum indx add def
0 1 barlen 1 sub {
barcode exch 1 getinterval charvals exch get
checksum add /checksum exch def
} for
barcode barlen 1 add barchars checksum 43 mod get put
/checksum checksum 43 mod def
validatecheck {
barcode barlen get barchars checksum get ne {
/bwipp.hibccode128badCheckDigit (Incorrect HIBC Code 128 check digit provided) //raiseerror exec
} if
/barcode barcode 0 barlen getinterval def
} if
 
/barcode barlen 2 add string dup 1 barcode putinterval def
barcode 0 43 put
barcode barlen 1 add barchars checksum get put
 
/text barlen 4 add string def
text 0 42 put
text 1 barcode putinterval
17027,6 → 18205,7
 
% Get the result of encoding with code128
options (dontdraw) true put
options (validatecheck) false put
/args barcode options //code128 exec def
 
args (txt) [ [text textxoffset textyoffset textfont textsize] ] put
17033,7 → 18212,7
args (textxalign) (center) put
args (opt) options put
args
 
dontdraw not //renlinear if
 
end
17042,16 → 18221,21
/hibccode128 dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER hibccode128--
 
% --BEGIN ENCODER hibcdatamatrix--
% --REQUIRES datamatrix--
% --REQUIRES preamble raiseerror renmatrix datamatrix--
% --DESC: HIBC Data Matrix
% --EXAM: A123BJC5D6E71
% --EXOP:
% --RNDR: renmatrix
%%BeginResource: uk.co.terryburton.bwipp hibcdatamatrix 0.0 2014013000 65062 64700
%%BeginData: 74 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
17063,6 → 18247,7
/barcode exch def % We are given a barcode string
 
/dontdraw false def
/validatecheck false def
 
% Parse the input options
options type /stringtype eq {
17075,32 → 18260,45
} if
options {def} forall
 
/barlen barcode length def
 
% Create a string of the available characters
/barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def
/charvals 43 dict def
0 1 42 {charvals exch dup barchars exch 1 getinterval exch put} for
 
/barcode barlen 2 add string dup 1 barcode putinterval def
barcode 0 43 put
% Validate the input
0 1 barcode length 1 sub {
barcode exch 1 getinterval charvals exch known not {
/bwipp.hibcdatamatrixBadCharacter (HIBC Data Matrix must contain only digits, capital letters, spaces and the symbols -.$/+%) //raiseerror exec
} if
} for
 
/barlen barcode length validatecheck {1 sub} if def
 
/checksum 0 def
0 1 barlen {
/i exch def
% Lookup the encoding for the each barcode character
barcode i 1 getinterval barchars exch search
pop % Discard true leaving pre
length /indx exch def % indx is the length of pre
pop pop % Discard seek and post
/checksum checksum indx add def
0 1 barlen 1 sub {
barcode exch 1 getinterval charvals exch get
checksum add /checksum exch def
} for
barcode barlen 1 add barchars checksum 43 mod get put
/checksum checksum 43 mod def
validatecheck {
barcode barlen get barchars checksum get ne {
/bwipp.hibcdatamatrixBadCheckDigit (Incorrect HIBC Data Matrix check digit provided) //raiseerror exec
} if
/barcode barcode 0 barlen getinterval def
} if
 
/barcode barlen 2 add string dup 1 barcode putinterval def
barcode 0 43 put
barcode barlen 1 add barchars checksum get put
 
% Get the result of encoding with datamatrix
options (dontdraw) true put
options (validatecheck) false put
/args barcode options //datamatrix exec def
 
args (opt) options put
args
 
dontdraw not //renmatrix if
 
end
17109,16 → 18307,21
/hibcdatamatrix dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER hibcdatamatrix--
 
% --BEGIN ENCODER hibcpdf417--
% --REQUIRES pdf417--
% --REQUIRES preamble raiseerror renmatrix pdf417--
% --DESC: HIBC PDF417
% --EXAM: A123BJC5D6E71
% --EXOP:
% --RNDR: renmatrix
%%BeginResource: uk.co.terryburton.bwipp hibcpdf417 0.0 2014013000 61955 65229
%%BeginData: 78 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
17131,6 → 18334,7
 
/dontdraw false def
/columns 2 def
/validatecheck false def
 
% Parse the input options
options type /stringtype eq {
17145,33 → 18349,46
 
/columns columns cvi def
 
/barlen barcode length def
 
% Create a string of the available characters
/barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def
/charvals 43 dict def
0 1 42 {charvals exch dup barchars exch 1 getinterval exch put} for
 
/barcode barlen 2 add string dup 1 barcode putinterval def
barcode 0 43 put
% Validate the input
0 1 barcode length 1 sub {
barcode exch 1 getinterval charvals exch known not {
/bwipp.hibcpdf417BadCharacter (HIBC PDF417 must contain only digits, capital letters, spaces and the symbols -.$/+%) //raiseerror exec
} if
} for
 
/barlen barcode length validatecheck {1 sub} if def
 
/checksum 0 def
0 1 barlen {
/i exch def
% Lookup the encoding for the each barcode character
barcode i 1 getinterval barchars exch search
pop % Discard true leaving pre
length /indx exch def % indx is the length of pre
pop pop % Discard seek and post
/checksum checksum indx add def
0 1 barlen 1 sub {
barcode exch 1 getinterval charvals exch get
checksum add /checksum exch def
} for
barcode barlen 1 add barchars checksum 43 mod get put
/checksum checksum 43 mod def
validatecheck {
barcode barlen get barchars checksum get ne {
/bwipp.hibcpdf417BadCheckDigit (Incorrect HIBC PDF417 check digit provided) //raiseerror exec
} if
/barcode barcode 0 barlen getinterval def
} if
 
/barcode barlen 2 add string dup 1 barcode putinterval def
barcode 0 43 put
barcode barlen 1 add barchars checksum get put
 
% Get the result of encoding with pdf417
options (dontdraw) true put
options (columns) columns put
options (validatecheck) false put
/args barcode options //pdf417 exec def
 
args (opt) options put
args
 
dontdraw not //renmatrix if
 
end
17180,16 → 18397,21
/hibcpdf417 dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER hibcpdf417--
 
% --BEGIN ENCODER hibcmicropdf417--
% --REQUIRES micropdf417--
% --REQUIRES preamble raiseerror renmatrix micropdf417--
% --DESC: HIBC MicroPDF417
% --EXAM: A123BJC5D6E71
% --EXOP:
% --RNDR: renmatrix
%%BeginResource: uk.co.terryburton.bwipp hibcmicropdf417 0.0 2014013000 65525 65160
%%BeginData: 78 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
dup /micropdf417 dup /uk.co.terryburton.bwipp findresource put
begin
17202,6 → 18424,7
 
/dontdraw false def
/columns 2 def
/validatecheck false def
 
% Parse the input options
options type /stringtype eq {
17216,33 → 18439,46
 
/columns columns cvi def
 
/barlen barcode length def
 
% Create a string of the available characters
/barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def
/charvals 43 dict def
0 1 42 {charvals exch dup barchars exch 1 getinterval exch put} for
 
/barcode barlen 2 add string dup 1 barcode putinterval def
barcode 0 43 put
% Validate the input
0 1 barcode length 1 sub {
barcode exch 1 getinterval charvals exch known not {
/bwipp.hibcmicropdf417BadCharacter (HIBC MicroPDF417 must contain only digits, capital letters, spaces and the symbols -.$/+%) //raiseerror exec
} if
} for
 
/barlen barcode length validatecheck {1 sub} if def
 
/checksum 0 def
0 1 barlen {
/i exch def
% Lookup the encoding for the each barcode character
barcode i 1 getinterval barchars exch search
pop % Discard true leaving pre
length /indx exch def % indx is the length of pre
pop pop % Discard seek and post
/checksum checksum indx add def
0 1 barlen 1 sub {
barcode exch 1 getinterval charvals exch get
checksum add /checksum exch def
} for
barcode barlen 1 add barchars checksum 43 mod get put
/checksum checksum 43 mod def
validatecheck {
barcode barlen get barchars checksum get ne {
/bwipp.hibcmicropdf417BadCheckDigit (Incorrect HIBC MicroPDF417 check digit provided) //raiseerror exec
} if
/barcode barcode 0 barlen getinterval def
} if
 
/barcode barlen 2 add string dup 1 barcode putinterval def
barcode 0 43 put
barcode barlen 1 add barchars checksum get put
 
% Get the result of encoding with micropdf417
options (dontdraw) true put
options (columns) columns put
options (validatecheck) false put
/args barcode options //micropdf417 exec def
 
args (opt) options put
args
 
dontdraw not //renmatrix if
 
end
17251,16 → 18487,21
/hibcmicropdf417 dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER hibcmicropdf417--
 
% --BEGIN ENCODER hibcqrcode--
% --REQUIRES qrcode--
% --REQUIRES preamble raiseerror renmatrix qrcode--
% --DESC: HIBC QR Code
% --EXAM: A123BJC5D6E71
% --EXOP:
% --RNDR: renmatrix
%%BeginResource: uk.co.terryburton.bwipp hibcqrcode 0.0 2014013000 65682 65326
%%BeginData: 74 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror 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
17272,6 → 18513,7
/barcode exch def % We are given a barcode string
 
/dontdraw false def
/validatecheck false def
 
% Parse the input options
options type /stringtype eq {
17284,32 → 18526,45
} if
options {def} forall
 
/barlen barcode length def
 
% Create a string of the available characters
/barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def
/charvals 43 dict def
0 1 42 {charvals exch dup barchars exch 1 getinterval exch put} for
 
/barcode barlen 2 add string dup 1 barcode putinterval def
barcode 0 43 put
% Validate the input
0 1 barcode length 1 sub {
barcode exch 1 getinterval charvals exch known not {
/bwipp.hibcqrcodeBadCharacter (HIBC QR Code must contain only digits, capital letters, spaces and the symbols -.$/+%) //raiseerror exec
} if
} for
 
/barlen barcode length validatecheck {1 sub} if def
 
/checksum 0 def
0 1 barlen {
/i exch def
% Lookup the encoding for the each barcode character
barcode i 1 getinterval barchars exch search
pop % Discard true leaving pre
length /indx exch def % indx is the length of pre
pop pop % Discard seek and post
/checksum checksum indx add def
0 1 barlen 1 sub {
barcode exch 1 getinterval charvals exch get
checksum add /checksum exch def
} for
barcode barlen 1 add barchars checksum 43 mod get put
/checksum checksum 43 mod def
validatecheck {
barcode barlen get barchars checksum get ne {
/bwipp.hibcqrcodeBadCheckDigit (Incorrect HIBC QR Code check digit provided) //raiseerror exec
} if
/barcode barcode 0 barlen getinterval def
} if
 
/barcode barlen 2 add string dup 1 barcode putinterval def
barcode 0 43 put
barcode barlen 1 add barchars checksum get put
 
% Get the result of encoding with qrcode
options (dontdraw) true put
options (validatecheck) false put
/args barcode options //qrcode exec def
 
args (opt) options put
args
 
dontdraw not //renmatrix if
 
end
17318,16 → 18573,21
/hibcqrcode dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER hibcqrcode--
 
% --BEGIN ENCODER hibccodablockf--
% --REQUIRES codablockf--
% --REQUIRES preamble raiseerror renmatrix codablockf--
% --DESC: HIBC Codablock F
% --EXAM: A123BJC5D6E71
% --EXOP:
% --RNDR: renmatrix
%%BeginResource: uk.co.terryburton.bwipp hibccodablockf 0.0 2014013000 64938 64908
%%BeginData: 74 ASCII Lines
/setpacking where {pop currentpacking true setpacking} if
1 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
dup /codablockf dup /uk.co.terryburton.bwipp findresource put
begin
17339,6 → 18599,7
/barcode exch def % We are given a barcode string
 
/dontdraw false def
/validatecheck false def
 
% Parse the input options
options type /stringtype eq {
17351,32 → 18612,45
} if
options {def} forall
 
/barlen barcode length def
 
% Create a string of the available characters
/barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def
/charvals 43 dict def
0 1 42 {charvals exch dup barchars exch 1 getinterval exch put} for
 
/barcode barlen 2 add string dup 1 barcode putinterval def
barcode 0 43 put
% Validate the input
0 1 barcode length 1 sub {
barcode exch 1 getinterval charvals exch known not {
/bwipp.codablockfBadCharacter (HIBC Codablock F must contain only digits, capital letters, spaces and the symbols -.$/+%) //raiseerror exec
} if
} for
 
/barlen barcode length validatecheck {1 sub} if def
 
/checksum 0 def
0 1 barlen {
/i exch def
% Lookup the encoding for the each barcode character
barcode i 1 getinterval barchars exch search
pop % Discard true leaving pre
length /indx exch def % indx is the length of pre
pop pop % Discard seek and post
/checksum checksum indx add def
0 1 barlen 1 sub {
barcode exch 1 getinterval charvals exch get
checksum add /checksum exch def
} for
barcode barlen 1 add barchars checksum 43 mod get put
/checksum checksum 43 mod def
validatecheck {
barcode barlen get barchars checksum get ne {
/bwipp.hibccodablockfBadCheckDigit (Incorrect HIBC Codablock F check digit provided) //raiseerror exec
} if
/barcode barcode 0 barlen getinterval def
} if
 
/barcode barlen 2 add string dup 1 barcode putinterval def
barcode 0 43 put
barcode barlen 1 add barchars checksum get put
 
% Get the result of encoding with codablockf
options (dontdraw) true put
options (validatecheck) false put
/args barcode options //codablockf exec def
 
args (opt) options put
args
 
dontdraw not //renmatrix if
 
end
17385,6 → 18659,8
/hibccodablockf dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
%%EndData
%%EndResource
% --END ENCODER hibccodablockf--
 
% --END TEMPLATE--