[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>&nbsp;&nbsp;&nbsp; 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>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>for frame in=20
getAllFrames(article):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
x =3D=20
int(getFrameX(frame))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
y =3D=20
int(getFrameY(frame))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
w =3D=20
int(getFrameW(frame))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
h =3D=20
int(getFrameH(frame))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
id =3D=20
node+'_'+frame.parentNode.tagName<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
frames.append(Frame(x*mm,PAGE_HEIGHT-y*mm-h*mm,w*mm,h*mm,id=3Did))<BR>&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
foto =3D=20
getFoto(article)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;=20
if (len(foto) &gt;=20
0):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;=20
if (articolo.foto !=3D=20
""):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
(x,y,w,h) =3D=20
foto<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
frames.append(Frame(x*mm,PAGE_HEIGHT-y*mm-h*mm,w*mm,h*mm,id=3Dnode+'_foto=
'))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
self.addImageToFrame(node+'_foto',articolo.foto,w*mm,h*mm)<BR>&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;=20
</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
pageTemplate =3D=20
PageTemplate(id=3D'main',frames=3Dframes,onPage=3Dself.myLaterPages,pages=
ize=3DA3)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
doc =3D=20
BaseDocTemplate('file.pdf',showBoundary=3D1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;=20
doc.addPageTemplates(pageTemplate)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;=20
doc.build(self.Elements)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;</DIV>
<DIV><BR>&nbsp;&nbsp;&nbsp; def=20
addToFrame(self,id,txt):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
self.Elements.append(FrameBreak(id))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;=20
self.Elements.append(Paragraph(txt,self.styles["Normal"]))</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; def=20
addImageToFrame(self,id,foto,w,h):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;=20
#self.Elements.append(FrameBreak(id))&nbsp; &lt;--- with or without=20
this&nbsp;behaves the same<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =

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>&nbsp;</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&nbsp; and I got no errors.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Any idea?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</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--