[reportlab-users] BX page size bug?
blaize rhodes
blaize at pobox.com
Wed Dec 7 06:30:03 EST 2011
hi,
I noticed that the page sizes: B0, B1, B2, B3 page sizes look wrong
to me which may be a bug.
from reportlab.lib.pagesizes import B6, B5, B4, B3, B2, B1, B0
from reportlab.lib.units import cm
# from iso stds
std_sizes = (
(B0, 100.0, 141.4),
(B1, 70.7, 100.0),
(B2, 50.0, 70.7),
(B3, 35.3, 50.0),
(B4, 25.0, 35.3),
(B5, 17.6, 25.0),
(B6, 12.5, 17.6))
def approx_equal(u, v):
return abs(u - v) < 0.1
for i in range(len(std_sizes)):
b_page, std_w, std_h = std_sizes[i]
w, h = b_page
w, h = w/cm, h/cm
print("Page size B%i: %4.1f, %4.1f %4.1f, %4.1f %s" %
(i, w, h, std_w, std_h,
approx_equal(w, std_w) and approx_equal(h, std_h)))
that code (which is attached in case the mail does something weird to
whitespace) produces these results:
blaize at dogbert:~/proj/graph_paper$ python bsizes.py
Page size B0: 100.0, 141.2 100.0, 141.4 False
Page size B1: 141.2, 50.0 70.7, 100.0 False
Page size B2: 50.0, 70.6 50.0, 70.7 False
Page size B3: 70.6, 25.0 35.3, 50.0 False
Page size B4: 25.0, 35.3 25.0, 35.3 True
Page size B5: 17.6, 25.0 17.6, 25.0 True
Page size B6: 12.5, 17.6 12.5, 17.6 True
B1 and B3 seem way out and the rest (including B5 and B6) are not
exactly right.
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).
Thanks for providing such a well architected library to the public. I
find reportlab a joy to use.
cheers
blaize
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bsizes.py
Type: text/x-python
Size: 607 bytes
Desc: not available
Url : <http://two.pairlist.net/pipermail/reportlab-users/attachments/20111207/f1b3245e/attachment.py>
More information about the reportlab-users
mailing list