2
# This file is part of GNU Enterprise.
4
# GNU Enterprise is free software; you can redistribute it
5
# and/or modify it under the terms of the GNU General Public
6
# License as published by the Free Software Foundation; either
7
# version 2, or (at your option) any later version.
9
# GNU Enterprise is distributed in the hope that it will be
10
# useful, but WITHOUT ANY WARRANTY; without even the implied
11
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12
# PURPOSE. See the GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public
15
# License along with program; see the file COPYING. If not,
16
# write to the Free Software Foundation, Inc., 59 Temple Place
17
# - Suite 330, Boston, MA 02111-1307, USA.
19
# Copyright 2004-2005 Free Software Foundation
26
Implements the USPS PostNet barcode spec
30
from Base import Barcode, InvalidBarcode
32
class PostNet(Barcode):
36
validLengths = [5,9,11]
39
# 1 = tall bar, 2=short bar, 0=space
55
lineWidth = 1.44 # points
56
lineHeight = 8.5 # (.125")
57
spaceWidth = 1.9 #1.66
60
# Stroke?, X Multiplier, Y Multiplier
61
'0': (False, 1, 1), # Spaces
62
'1': (True, 1, 1), # Tall bars
63
'2': (True, 1, .45) # Short bars
68
defaultIncludeText = False
70
# Calculate a Mod-10 check digit
71
def checkdigit(self, value):
78
cd = abs(10-divmod(v,10)[1])
84
if __name__ == '__main__':
88
def test(value, format, file):
90
postnet.generate(value,f, format)
93
# test('381072456','png','test1.png')
94
# test('381172459','tiff','test1.tif')
95
test('383759907','eps','postnet-1.eps')
96
test('12345','eps','postnet-2.eps')
97
test('12345678901','eps','postnet-3.eps')