[reportlab-users] Image flowable
ing. Francesco Boscarino
reportlab-users@reportlab.com
Wed, 18 Aug 2004 13:00:12 +0200
This is a multi-part message in MIME format.
------=_NextPart_000_0081_01C48523.4C1AA260
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi,
I was trying to layout a sort of newspaper with multiple frame =
holding text simulating newspaper columns and a frame to hold an image:
for frame in getAllFrames(article):
x =3D int(getFrameX(frame))
y =3D int(getFrameY(frame))
w =3D int(getFrameW(frame))
h =3D int(getFrameH(frame))
id =3D node+'_'+frame.parentNode.tagName
=
frames.append(Frame(x*mm,PAGE_HEIGHT-y*mm-h*mm,w*mm,h*mm,id=3Did))
foto =3D getFoto(article)
if (len(foto) > 0):
if (articolo.foto !=3D ""):
(x,y,w,h) =3D foto
=
frames.append(Frame(x*mm,PAGE_HEIGHT-y*mm-h*mm,w*mm,h*mm,id=3Dnode+'_foto=
'))
=
self.addImageToFrame(node+'_foto',articolo.foto,w*mm,h*mm)
=20
pageTemplate =3D =
PageTemplate(id=3D'main',frames=3Dframes,onPage=3Dself.myLaterPages,pages=
ize=3DA3)
doc =3D BaseDocTemplate('file.pdf',showBoundary=3D1)
doc.addPageTemplates(pageTemplate)
doc.build(self.Elements)
def addToFrame(self,id,txt):
self.Elements.append(FrameBreak(id))
self.Elements.append(Paragraph(txt,self.styles["Normal"]))
def addImageToFrame(self,id,foto,w,h):
#self.Elements.append(FrameBreak(id)) <--- with or without this =
behaves the same
self.Elements.append(Image(foto,w,h))
where articolo.foto holds the filename of the jpg image.
What I got is the pdf correctly generated but no image at all. I've =
installed PIL and I got no errors.
Any idea?
Regards
Francesco
------=_NextPart_000_0081_01C48523.4C1AA260
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1458" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> I was trying to =
layout a sort of=20
newspaper with multiple frame holding text simulating newspaper columns =
and a=20
frame to hold an image:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>for frame in=20
getAllFrames(article):<BR>  =
; =20
x =3D=20
int(getFrameX(frame))<BR> =
=20
y =3D=20
int(getFrameY(frame))<BR> =
=20
w =3D=20
int(getFrameW(frame))<BR> =
=20
h =3D=20
int(getFrameH(frame))<BR> =
=20
id =3D=20
node+'_'+frame.parentNode.tagName<BR> =
=20
frames.append(Frame(x*mm,PAGE_HEIGHT-y*mm-h*mm,w*mm,h*mm,id=3Did))<BR>&nb=
sp; =20
foto =3D=20
getFoto(article)<BR>  =
; =20
if (len(foto) >=20
0):<BR> =
=20
if (articolo.foto !=3D=20
""):<BR>  =
; =20
(x,y,w,h) =3D=20
foto<BR>  =
; =20
frames.append(Frame(x*mm,PAGE_HEIGHT-y*mm-h*mm,w*mm,h*mm,id=3Dnode+'_foto=
'))<BR> =
=20
self.addImageToFrame(node+'_foto',articolo.foto,w*mm,h*mm)<BR>  =
; =
=20
</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> =20
pageTemplate =3D=20
PageTemplate(id=3D'main',frames=3Dframes,onPage=3Dself.myLaterPages,pages=
ize=3DA3)<BR> =20
doc =3D=20
BaseDocTemplate('file.pdf',showBoundary=3D1)<BR> &=
nbsp; =20
doc.addPageTemplates(pageTemplate)<BR>  =
; =20
doc.build(self.Elements)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> </DIV>
<DIV><BR> def=20
addToFrame(self,id,txt):<BR> =20
self.Elements.append(FrameBreak(id))<BR> &nb=
sp; =20
self.Elements.append(Paragraph(txt,self.styles["Normal"]))</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> def=20
addImageToFrame(self,id,foto,w,h):<BR>  =
; =20
#self.Elements.append(FrameBreak(id)) <--- with or without=20
this behaves the same<BR> =
self.Elements.append(Image(foto,w,h))</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>where articolo.foto holds the filename =
of the jpg=20
image.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>What I got is the pdf correctly =
generated but no=20
image at all. I've installed PIL and I got no errors.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Any idea?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Regards</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Francesco</FONT></DIV></BODY></HTML>
------=_NextPart_000_0081_01C48523.4C1AA260--