473,385 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

ReportLab - Frames - Images

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 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 bill(canvas, doc):
canvas.saveState()
canvas.restoreState()

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,bill)

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

Jan 15 '07 #1
2 7437
Chuck wrote:
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 to
the right of the text. The image always appears first and then the text
below on the next line.

Please help.

you'll get more help at the reportlab users list (see

http://two.pairlist.net/pipermail/reportlab-users/ )

Anyhow I got some output from your script, by making two changes

*************** CUT ***********************
from reportlab.pdfgen import *
...........
>
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%"))
change(1)
doc.append(flowables.HRFlowable(color="black", thickness=3, width="100%"))
>

pdf.build(doc,bill)
change(2)

pdf.build(doc)
>
run()
*************************** CUT ***********************************

I also had to change the name of the image to one on my system.

Hope this helps
--
Robin Becker
Jan 15 '07 #2
Thanks for the help. I made you changes but it still puts the picture
above the text, not beside the text.

I also found a user group at
http://news.gmane.org/gmane.comp.python.reportlab.user . It may be the
same. I have now posted there.

Chuck

Jan 16 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Robin Becker | last post by:
Version 1.18 of the ReportLab Toolkit has been released. This release will be the last to attempt to keep compatibility with Python 1.52 - 2.1. We will allow 2.2 specific features into the code in...
4
by: Active8 | last post by:
I did this once and can't remember how <blush> so I read the reportlab user guid. It says to unzip the reportlab archive - this is on w2k, BTW, with Python23 - to a directory and make a file...
1
by: Com Dot | last post by:
In a frameset, the menu frame has six buttons. I would like to use mouseOver on these buttons to make images change in another frame. Does anyone have a script or know of a working site where this...
25
by: Steal | last post by:
Hi at all I try to validate this page using the link: http://validator.w3.org/ but it return that this is not a valid HTML 4.01 page please where is it error? Steil <!DOCTYPE HTML PUBLIC...
10
by: AmyMC | last post by:
Hi, I've been buried in this project, which has a lot of pre-loaded images. The pages which have these images are frames.... and even with my best attempts to preload them all still most do not. ...
27
by: Murray R. Van Luyn | last post by:
Hi, Is using frames in a website as big an issue nowadays as it was maybe 5 or so years ago? I can remember that you used to have to have a frame site, as well as a non frame site for browsers...
0
by: norseman | last post by:
Daniel de Sousa Barros wrote: ================================================ Click Start/settings/control panel/system/advanced/settings(in \ performance area)/advanced/change set System...
16
by: Laszlo Nagy | last post by:
I need to create multi lingual invoices from reportlab. I think it is possible to use UTF 8 strings but there is a problem with the font. I could not find any free TTF font that can do latin1,...
0
by: Robin Becker | last post by:
Version 2.2 of the ReportLab open-source toolkit is out! You find downloads and src instructions at http://www.reportlab.org/downloads.html. Contributions ============= Thanks to everybody who...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.