[reportlab-users] Fwd: [reportlab-team] Fwd: PDF Imaging

Ramas Sami ramas at live.co.uk
Tue May 20 09:07:06 EDT 2014

Thanks Robin,
It worked very well, Thanks for your help and time.

Best Regards--Ramas

Date: Tue, 20 May 2014 13:37:13 +0100
From: robin at reportlab.com
To: reportlab-users at reportlab.com
Subject: [reportlab-users] Fwd: [reportlab-team] Fwd: PDF Imaging

Hi Ramas,
1) you are trying to mix platypus flowables (the Image object im) with direct 
drawing to the canvas.
The simplest way to do what you want is probably to use either of the canvas 
methods drawInlineImage or drawImage.
> HI Nick,
> Good Morning...
> *My code to get image into PDF file,*
> from reportlab.pdfgen import canvas
> from reportlab.lib.pagesizes import letter, A4, landscape
> from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Image
> from reportlab.graphics.shapes import *
> from reportlab.lib import colors
> from reportlab.graphics import renderPDF
> from reportlab.lib.enums import TA_CENTER
> from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
> from reportlab.lib.units import cm, inch
> def hello(c):
>     c.setFont('Times-Roman', 26)
>     c.drawString(100,800, "V-LIFE Monthly Report (May 2014)")
>     c.rect(10, 10, 575, 820)
>     c.rect(30,680,520,100)
>     im = Image("CompanyLogo.jpg")
>     im.hAlign = 'CENTER'
this is a platypus object, you can use it with a canvas if you are knowledgeable 
about the Flowable api. However, the easiest way to get an image onto a canvas 
is to use something like
see reportlab/pdfgen/canvas.py for more details of the available arguments.
>     print('Sucessfully done')
> c = canvas.Canvas("testPage.pdf")
> hello(c)
> c.showPage()
> c.save()

reportlab-users mailing list
reportlab-users at lists2.reportlab.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20140520/12be4394/attachment.html>

More information about the reportlab-users mailing list