[reportlab-users] Page background image with Platypus?
Erik Wickstrom
erik at erikwickstrom.com
Fri Oct 5 15:57:35 EDT 2007
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))
# 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> 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
> > 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/20071005/fecda256/attachment.htm>
More information about the reportlab-users
mailing list