[reportlab-users] Page background image with Platypus?
Erik Wickstrom
erik at erikwickstrom.com
Mon Oct 8 17:06:42 EDT 2007
I've try fiddling with the size parameters. The largest I can get is with
about a 2 inch border around the image of blank page. My text is also not
"layering" on top of the background image, it's being pushed onto the next
page instead.
The actual dimensions of the image are 8.5x11 inches, so it should fit
perfectly.
Is there anything else I can try?
Thanks!
Erik
On 10/6/07, Stephan Diehl <stephan.diehl at gmx.net> wrote:
>
> Erik Wickstrom wrote:
> > I tried your suggestion, but it just seems to throw more errors. Here
> > is a snipet of my code:
> >
> > from cStringIO import StringIO
> > from reportlab.lib.styles import getSampleStyleSheet
> > from reportlab.platypus import *
> > from reportlab.platypus.flowables import KeepInFrame
> > from reportlab.platypus import Image
> > from reportlab.pdfgen import canvas
> > from reportlab.lib.pagesizes import letter, portrait, landscape
> > from reportlab.lib.units import inch
> > ......
> > ......
> > from reportlab.rl_config import defaultPageSize
> >
> > (MAXWIDTH, MAXHEIGHT) = defaultPageSize
> >
> > image = Image('/root/journal/gazette/paper1.png')
> > elements.append (KeepInFrame(MAXWIDTH, MAXHEIGHT, image))
> ^^^^^^
>
> I believe this line should be
> elements.append (KeepInFrame(MAXWIDTH, MAXHEIGHT, [image]))
>
> Have you tested with different MAX sizes? Maybe it needs to be smaller
> than the page size (I'm guessing here). My guess would be that it can't
> be larger than the space that would be filled with text, if it were text.
>
> And, by the way, I'm using reportlab from svn repository.
>
> > # Create two 'Paragraph' Flowables and add them to our 'elements'
> > elements.append(Paragraph("The Platypus", styles['Heading1']))
> > elements.append(Paragraph("Very <i>Special</i>!", styles['Normal']))
> >
> > # Write the document to disk
> > doc.build(elements)
> >
> > Am I using KeepInFrame incorrectly?
> >
> > Thanks!
> > Erik
> >
> > On 10/5/07, *Stephan Diehl* <stephan.diehl at gmx.net
> > <mailto:stephan.diehl at gmx.net>> wrote:
> >
> > Erik Wickstrom wrote:
> > > Hi,
> > >
> > > I'm trying to use an image as a background for my pdf. The image
> is
> > > large enough to cover the page. It seems to work fine when
> printing
> > > straight to the canvas with " p.drawImage
> > > ('/root/journal/gazette/paper1.png', 0, 0, width=None,
> height=None,
> > > mask=None)" but I need to use Platypus.
> > >
> >
> > [...]
> > > 671. raise LayoutError(ident)
> > >
> > > LayoutError at /gazette/test/
> > > Flowable <Image at -0x4950c374 frame=normal
> > > filename=/root/journal/gazette/paper1.png> too large on page 2
> > >
> > > What am I doing wrong?
> >
> > you can embed this into a 'KeepInFrame' object
> > for example
> >
> > from reportlab.platypus.flowables import KeepInFrame
> > from reportlab.platuyps import Image
> >
> > [ ...some code... ]
> >
> > image = Image(<... whatever ...>)
> > story.append(KeepInFrame(MAXWIDTH, MAXHEIGHT, [image])
> >
> > this will scale you image in such a way that it's not larger than
> > MAXWIDTH, MAXHEIGHT.
> >
> > Hope that helps
> >
> > Stephan
> >
> >
> > >
> > > Thanks!
> > > Erik
> > > |
> > >
> > >
> > >
> >
> ------------------------------------------------------------------------
> >
> > >
> > > _______________________________________________
> > > reportlab-users mailing list
> > > reportlab-users at reportlab.com <mailto:
> reportlab-users at reportlab.com>
> > > http://two.pairlist.net/mailman/listinfo/reportlab-users
> >
> > _______________________________________________
> > reportlab-users mailing list
> > reportlab-users at reportlab.com <mailto:reportlab-users at reportlab.com>
> > http://two.pairlist.net/mailman/listinfo/reportlab-users
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > reportlab-users mailing list
> > reportlab-users at reportlab.com
> > http://two.pairlist.net/mailman/listinfo/reportlab-users
>
> _______________________________________________
> reportlab-users mailing list
> reportlab-users at reportlab.com
> http://two.pairlist.net/mailman/listinfo/reportlab-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20071008/0997790d/attachment.html>
More information about the reportlab-users
mailing list