[reportlab-users] Frames, Logo images, and text

Chuck watsocd at gmail.com
Mon Jan 15 19:02:26 EST 2007


I have been trying all day to get this to work. My complete code is below. I
can get my text into the PDF, I can get my image in the PDF. What I can't get
to work is frames so that the image (logo) appears directly to the right of the
text. The image always appears first and then the text below on the next line.

Please help.


Chuck


*************** CUT ***********************
from reportlab.pdfgen import *


from reportlab.platypus import *


from reportlab.lib.units import inch
from reportlab.platypus import SimpleDocTemplate
from reportlab.platypus import flowables
from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER,
TA_JUSTIFY


from reportlab.lib.pagesizes import letter


#precalculate some basics
top_margin = letter[1] - inch
bottom_margin = inch
left_margin = inch
right_margin = letter[0] - inch
frame_width = right_margin - left_margin


def run():
doc = []
from reportlab.lib.styles import ParagraphStyle
from reportlab.platypus import Image


pdf = SimpleDocTemplate('bill2.pdf', pagesize = letter)


#need a style
normal = ParagraphStyle('normal')


doc.append(Image("pic.jpg", 100, 71)) #Logo


para = Paragraph("Some text1", normal)
doc.append(para)
para = Paragraph("Some text2", normal)
doc.append(para)
para = Paragraph("Some text3", normal)
doc.append(para)
para = Paragraph("Some text4", normal)
doc.append(para)
para = Paragraph(" ", normal)
doc.append(para)
doc.append(HRFlowable(color="black", thickness=3, width="100%"))


pdf.build(doc)


run()
*************************** CUT ***********************************




More information about the reportlab-users mailing list