[reportlab-users] Scaled Flowables consuming too much space in Platypus?

Dinu Gherman reportlab-users@reportlab.com
Mon, 16 Sep 2002 18:14:53 +0200


--Apple-Mail-17-198602396
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed

Robin Becker:

> well we made drawings into groups as that seemed quite sensible, but
> scaling a drawing doesn't affect the external dimensions only the
> contents which also seems quite sensible. The canvas is a fixed thing 
> so
> saying scale yourself is like telling an A4 to become A5. Indeed 
> scaling
> the reportlab canvas doesn't change the paper size.

Well well, putting the Drawing in a Group and passing that to Platypus
makes things even worse (probably because Groups are not Flowables)!
See attached file...

I still feel this is a drawback, because it seems natural to me to
make a Drawing and include a resized version of it into a story in
order to fit the frame width or whatever...

But then, maybe my sense of what is natural differs from others'.

Dinu

--
Dinu C. Gherman
......................................................................
"I never apologize for the United States of America, I don't care what
the facts are." (George Bush, Sr.)


Traceback (most recent call last):
   File "scalingbug2.py", line 31, in ?
     SimpleDocTemplate('scalingbug2.pdf').build(story)
   File 
"/usr/lib/python2.2/site-packages/reportlab/platypus/doctemplate.py", 
line 736, in build
     BaseDocTemplate.build(self,flowables)
   File 
"/usr/lib/python2.2/site-packages/reportlab/platypus/doctemplate.py", 
line 579, in build
     self.handle_flowable(flowables)
   File 
"/usr/lib/python2.2/site-packages/reportlab/platypus/doctemplate.py", 
line 482, in handle_flowable
     self.handle_keepWithNext(flowables)
   File 
"/usr/lib/python2.2/site-packages/reportlab/platypus/doctemplate.py", 
line 465, in handle_keepWithNext
     while i<n and flowables[i].getKeepWithNext(): i = i + 1
AttributeError: Group instance has no attribute 'getKeepWithNext'



--Apple-Mail-17-198602396
Content-Disposition: attachment;
	filename=scalingbug2.py
Content-Transfer-Encoding: 7bit
Content-Type: application/text;
	x-unix-mode=0644;
	x-mac-type=54455854;
	name="scalingbug2.py"

# scalingbug2.py

from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.platypus.doctemplate import SimpleDocTemplate
from reportlab.platypus.paragraph import Paragraph
from reportlab.platypus.flowables import Spacer
from reportlab.graphics.shapes import Drawing, Rect, Group

h2 = getSampleStyleSheet()['Heading1']

w, h = 100, 100
rect = Rect(0, 0, w, h, fillColor=colors.black)
d1 = Drawing(w, h)
d1.add(rect)

d2 = Drawing(w, h)
d2.add(rect)
g = Group()
g.add(d2)
g.scale(0.5, 0.5)

story = []
t = "Drawing not scaled - ok!"
story.append(Paragraph(t, h2))
story.append(d1)
story.append(Spacer(0, 100))
t = "Drawing scaled, but flowable area <i>not</i> scaled - not ok?"
story.append(Paragraph(t, h2))
story.append(g)

SimpleDocTemplate('scalingbug2.pdf').build(story)


--Apple-Mail-17-198602396
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed



--Apple-Mail-17-198602396--