Fwd: [reportlab-team] Fwd: PDF Imaging

Robin Becker <[email protected]>
Newsgroups gmane.comp.python.reportlab.user
Message-ID <[email protected]>
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

        c.drawImage("CompanyLogo.jpg",10,10,520,100)

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()

..........
Attached Message Part (text/plain, 179 B)
_______________________________________________
reportlab-team mailing list
[email protected]
http://lists.reportlab.com/cgi-bin/mailman/listinfo/reportlab-team
CompanyLogo.jpg (image/jpeg, 2.6 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.