473,289 Members | 1,808 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,289 software developers and data experts.

Report Lab Image Flowable Issue ..

I'm try to generate a report that will span multiple pages and have
dynamic content using python reportlab. I have no issues with regards
to generating images and then using p.drawInlineImage(signup_img,
100,150) to draw them onto the canvas.

The problem that i have comes when i try to create flowables so that
my layout can span multiple pages. The images themselves never
actually show up on the page ...

# Import pdf
generator
from cStringIO import StringIO
from reportlab.pdfgen import canvas
from reportlab.pdfgen.canvas import Canvas
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib.units import inch
from reportlab.platypus import Paragraph, Frame
from PIL import Image

# Create the HttpResponse object with the appropriate PDF
headers.
response = HttpResponse(mimetype='application/pdf')
response['Content-Disposition'] = 'attachment;
filename=somefilename.pdf'

buffer = StringIO()

styles = getSampleStyleSheet()
styleN = styles['Normal']
styleH = styles['Heading1']
story = []

#add some
flowables
story.append(Paragraph("This is a Heading",styleH))
story.append(Paragraph("""This is a paragraph in <img src='http://
images.google.com/intl/en_ALL/images/images_hp.gif' width='200'
height='200' /style"\
"",styleN))

c = Canvas(buffer)
f = Frame(inch, inch, 6*inch, 9*inch, showBoundary=1)
f.addFromList(story,c)
c.save()

# Get the value of the StringIO buffer and write it to the
response.
pdf = buffer.getvalue()
buffer.close()
response.write(pdf)

This should generate a pdf with the google image in it no ? The pdf
gets generated but no image comes out.

When I try the other option of using image flowables, I get only an
error. The reportlab docs example shows an Image flowable being called
like ... Image("lj8100.jpg") .... but when i try to call the object
directly i get an error which suggests that i should use Image.new or
Image.open to call the object ...

# Create image from /tmp
im = Image("/tmp/car_dealership.jpg", width=2*inch, height=2*inch)
im.hAlign = 'CENTER'

#add some
flowables
story.append(Paragraph("This is a Heading",styleH))
story.append(Image(im))

TypeError: 'module' object is not callable for the im = Image( ....)

When i try to feed the image manually ...

interest_image = interests_barchart(request)
im = Image.open(StringIO(interest_image.content))

#add some
flowables
story.append(Paragraph("This is a Heading",styleH))
story.append(im)

I get ... AttributeError: getSpaceBefore ... which seems to suggest
that im isn't a flowable ...

Can anyone help pls ?
Jun 27 '08 #1
1 5633
dbee wrote:
I'm try to generate a report that will span multiple pages and have
dynamic content using python reportlab. I have no issues with regards
to generating images and then using p.drawInlineImage(signup_img,
100,150) to draw them onto the canvas.

The problem that i have comes when i try to create flowables so that
my layout can span multiple pages. The images themselves never
actually show up on the page ...
.......

I think you should ask this on the reportlab users list which you can
find at http://two.pairlist.net/pipermail/reportlab-users/

As for your specific problem perhaps you should start with some simple
examples.
--
Robin Becker
Jun 27 '08 #2

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

Similar topics

0
by: Jacky11 | last post by:
Hi everyone, I have spent several hours on this topic, and I still don't have the right solution. However, you guys can accomplish in 5 minutes much more then I can accomplish in 5 hours. :-)...
6
by: Roger | last post by:
I have a report with a image displaying our company logo if I create an snapshot of this report, it appears to create an 'snp' file, but nothing is stored in the folder I tried both linked and...
6
by: Salad | last post by:
Hi: I have a Bill of Lading template from the printer that I saved as a BMP. I created a new report and in the report's picture property told it the BMP file name. It brought the image in just...
0
by: BATISTA | last post by:
Hi , I am working in c# with crystal report XI. I read an example about dynamic image location .. 1) In that we have a xml xchema file with two fields n amed country--datatype is string,...
0
by: BATISTA | last post by:
Hi I have to program in C# such that I have to add a button to the form , and create a crystal report, by getting source from the xml schema file(.xsd file) with two fields namely...
0
by: Chris | last post by:
I finally got my report to be recongized, that login issue is terrible. Using VS.NET 2003, created report inside of it. Now when I attempt to display the report is blank (missing data, though I can...
13
by: salad | last post by:
Hi Guys: I was stuck. I needed to send a report to a file. My beautiful report(s) in Access were going to require loss of formatting with RTFs, a PITA in WordMailMerge, sending it as a text...
11
by: Ryan | last post by:
I am writing a VB (2005) program that will allow the user to fill out and print a form. The form input is stored in a database (SQL 2005) to be retrieved/viewed/printed later. The form is...
2
by: smorrison64 | last post by:
I have a form that is coded to open a File Dialog boc to pick a picture to display on that particular item on a subform. My form is not based on query, but rather two separate tables (one primary,...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.