[reportlab-users] Finding space left

Tomasz Świderski contact at tomaszswiderski.com
Tue Feb 16 17:01:48 EST 2010


I need similar Table functionality to generate tax records. Each page
must contain 3 sums: sum of values from previous pages, sum of values
from current page and total sum (prev + curr). Since I do not know
exactly where table will split, I need to be able to repeat bottom rows
(containing sums) and compute sum values on runtime.


To do so I needed to completely rewrite split mechanism. Current Table
implementation splits data on each Table split. So if Table need to
split on n-th row, it will divide data into 2 parts: data[:n] and
data[n:].


To be able to compute values on runtime, each part of Table needs access
to all data. So I decided to use different split mechanism. Instead of
dividing data, each part contains all data + information which rows are
visible (active) in this part of Table. After two days of work I have
working implementation of my method. It passes old_tables_test so it is
probably backward compatible with old implementation. My implementation
also allows to repeat rows from bottom. It is still work in progress but
I should have final version tomorrow. I am also attaching what I managed
to do so far with demonstration of bottom repeatable rows.


This method should also speed things up because data do not change on
split. For example old implementation needed to recompute span ranges
after each split. Since data do not change in my method, we can reuse
span ranges, no split ranges and many more.


I still need to implement computing values on runtime. It should be easy
now, because each Table part have access to all data. I will probably
use callable classes. Callable will be asked to evaluate on draw time.
It will have access to all data, information which rows are visible and
it's own position in data, so it will be able to do advanced
computations on table's data. Callable classes can cache results from
previous calls so computing partial sums should be fast. That's why I
prefer callable classes over simple functions ;)

Best Regards,
Tomasz Świderski


P.S. Since reportlab.2.4 supports only Python2.4+ why Flowables are
still old style classes? I'm missing properties from new style
classes :( It would be much easier to implement complex flowables like
Table with properties.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tables.py
Type: text/x-python
Size: 60301 bytes
Desc: not available
Url : <http://two.pairlist.net/pipermail/reportlab-users/attachments/20100216/f142b4ff/attachment-0002.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_platypus_tables.py
Type: text/x-python
Size: 36691 bytes
Desc: not available
Url : <http://two.pairlist.net/pipermail/reportlab-users/attachments/20100216/f142b4ff/attachment-0003.py>


More information about the reportlab-users mailing list