Re: Fwd: [reportlab-team] Fwd: PDF Imaging
Ramas Sami <[email protected]>
| Newsgroups | gmane.comp.python.reportlab.user |
|---|---|
| Message-ID | <[email protected]> |
Hi Robin, Thank you so much, It worked after I have changed to 'canvas.drawImage()'. It saved my day work. Thank you so much for your help and time, much appreciated. Best Regards--Ramas Date: Tue, 20 May 2014 13:37:13 +0100 From: [email protected] To: [email protected] 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 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() .......... _______________________________________________ reportlab-users mailing list [email protected] http://two.pairlist.net/mailman/listinfo/reportlab-users