[reportlab-users] Float flowable to bottom of page
    Adrian Klaver 
    adrian.klaver at gmail.com
       
    Thu Feb  4 09:58:06 EST 2010
    
    
  
On Thursday 04 February 2010 6:30:52 am Robin Becker wrote:
> On 03/02/2010 21:59, James Lance wrote:
>
> OK this code appears a bit better in that you don't need to work out the
> height of the flowables before doing stuff
>
> #############################################
> from reportlab.platypus.flowables import KeepTogether, Spacer, _listWrapOn,
> _flowableSublist, PageBreak
> from reportlab.platypus.doctemplate import FrameBreak
> class FloatToEnd(KeepTogether):
>      '''
>      Float some flowables to the end of the current frame
>      '''
>      def __init__(self,flowables,maxHeight=None,brk='frame'):
>          self._content = _flowableSublist(flowables)
>          self._maxHeight = maxHeight
>          self._state = 0
>          self._brk = brk
>
>      def wrap(self,aW,aH):
>          return aW,aH+1  #force a split
>
>      def _makeBreak(self,h):
>          if self._brk=='page':
>              return PageBreak()
>          else:
>              return FrameBreak
I have been following along and I think I understand what is going on, except 
for above. I know this is test for the type of break, but where does that come 
into play? Also should it not be PageBreak?
>
>      def split(self,aW,aH):
>          dims = []
>          W,H = _listWrapOn(self._content,aW,self.canv,dims=dims)
>          if self._state==0:
>              if H<aH:
>                  return [Spacer(aW,aH-H)]+self._content
>              else:
>                  S = self
>                  S._state = 1
>                  return [self._makeBreak(aH), S]
>          else:
>              if H>aH: return self._content
>              return [Spacer(aW,aH-H)]+self._content
>
-- 
Adrian Klaver
adrian.klaver at gmail.com
    
    
More information about the reportlab-users
mailing list