473,890 Members | 1,191 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.pdfge n import *

from reportlab.platy pus import *

from reportlab.lib.u nits import inch
from reportlab.platy pus import SimpleDocTempla te
from reportlab.platy pus import flowables
from reportlab.lib.e nums import TA_LEFT, TA_RIGHT, TA_CENTER,
TA_JUSTIFY

from reportlab.lib.p agesizes 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.saveStat e()
canvas.restoreS tate()

def run():
doc = []
from reportlab.lib.s tyles import ParagraphStyle
from reportlab.platy pus import Image

pdf = SimpleDocTempla te('bill2.pdf', pagesize = letter)

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

doc.append(Imag e("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(HRFl owable(color="b lack", thickness=3, width="100%"))
pdf.build(doc,b ill)

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

Jan 15 '07 #1
2 7517
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.pdfge n import *
...........
>
pdf = SimpleDocTempla te('bill2.pdf', pagesize = letter)

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

doc.append(Imag e("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(HRFl owable(color="b lack", thickness=3, width="100%"))
change(1)
doc.append(flow ables.HRFlowabl e(color="black" , thickness=3, width="100%"))
>

pdf.build(doc,b ill)
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
1423
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 future. There will be a branch called ReportLab_1_18_PRE22. So that enthusiasts can maintain it if required. Main changes since ReportLab 1.18: - Bug & leak fixes. - improvements to pyRXP which can now be used in 16bit mode.
4
5396
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 called reportlab.pth in the pythod dir. The only line in this file is supposed to be the path to the reportlib dir. Then I'm instructed to open the ... ok I'll close and reopen ... the python cmd line interpreter and type import reportlab
1
1862
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 is used? Any help is appreciated. Thanks, Com
25
43739
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 "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <html> <head>
10
1695
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. Some use more than one image and the flicker is obvious. Below is how I am loading them, and it doesn't matter if I use URL referenced images or locally, (i.e. ./image1.gif) <script> pic1= new Image;
27
3983
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 that didn't support the framed version. I wonder whether newer browsers have fixed that problem, and I can now use frames without fear? Regards, Murray R. Van Luyn.
0
1468
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 managed size on click SET box to right of above line click positives (OK APPLY etc.) all way out, system will probably reboot
16
8664
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, latin2, arabic, chinese and other languages at the same time. Is there a single font that is able to handle these languages? (Most of our invoices will be for EN, FR, DE, HU, SK, CZ, RO but some of them needs to be in Chinese.) Thanks, Laszlo
0
863
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 has contributed to the open-source toolkit in the run-up to the 2.2 release, whether by reporting bugs, sending patches, or contributing to the reportlab-users mailing list. Thanks especially to the following people, who contributed code that has...
0
9978
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9820
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11227
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8016
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7169
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5848
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6041
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4676
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.