[reportlab-users] BX page size bug?

Tim Roberts timr at probo.com
Wed Dec 7 14:19:49 EST 2011


blaize rhodes wrote:

> I noticed that the page sizes: B0, B1, B2, B3 page sizes look wrong

> to me which may be a bug.


This is a good catch. If you look at the code in pagesizes.py, the
pattern for the B constants is different than the pattern for the A
constants for B1 and B3, and that's reflected in the erroneous values
you show.


> It'd probably be better to just use the mm dimensions from the standard

> rather than the geometric properties of the ISO standards to get the

> dimensions (I suspect).


That's a tough call, and mostly a style question. The ISO spec allows
+/- 1.5mm, and the numbers (except for B1 and B3) are within that
tolerance. However, the definition in the spec is that B0 is 1 x
sqrt(2) meters, and the others in the series are derived by cutting the
larger dimension in half. So, a clever but purist approach might be
something like this:

import math
from reportlab.lib.units import mm

def gen(*base):
if base[0] > base[1]:
base = (base[1],base[0])
while 1:
yield tuple(int(k)*mm for k in base)
base = (base[1]/2, base[0])

g = gen(1000.0,1000.0*math.sqrt(2))
B0 = g.next()
B1 = g.next()
B2 = g.next()
B3 = g.next()
B4 = g.next()
B5 = g.next()

g = gen(841,1189)
A0 = g.next()
A1 = g.next()
A2 = g.next()
A3 = g.next()
A4 = g.next()
A5 = g.next()

--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the reportlab-users mailing list