[reportlab-users] how to "shrink to fit page "?

Robin Becker robin at reportlab.com
Fri Jan 6 03:54:55 EST 2006


Emmanuel Viennet wrote:
> Hello,
> 
> I'm new to reportlab and use it to generate documents from Zope.
> Very easy to use, nice doc, congratulations !
> 
> One question: I generate rather long table, but don't care if it's
> printed *small*. What is the best way to generate a doc that will 
> always "fit the page" ?
> I'm looking for some kind of automatic scaling (shrink to fit page ?)
> 
> 
> Thank you for your advices
> Emmanuel
> 
.....
a relatively new flowable, KeepInFrame, in the latest svn is designed 
for this purpose.


so you would do something like

story.append(KeepInFrame(maxWidth,maxHeight,content,mode='shrink'))

maxWidth/maxHeight can be left at 0 and then remaining space in the 
frame will be usable. The list content holds the flowables to be kep in 
the current frame. The mode argument describes the overflow action

error		raise an error in the normal way
continue	ignore ie just draw it and report maxWidth, maxHeight
shrink		shrinkToFit
truncate	fit as much as possible

The hard part is knowing where the KeepInFrame will occur; normally you 
would put it at the start of a new frame; that way you know you're not 
trying to squash your giant table into the last inch of a column.

-- 
Robin Becker



More information about the reportlab-users mailing list