[reportlab-users] PDF File corrupt

Robin Becker robin at reportlab.com
Fri Dec 4 10:20:14 EST 2009


Dani, thanks for the code, but I think we need to have a sample image that
actually causes a problem. I see nothing objectionable here, but we have seen
jpegs that cause a problem. Presumably SUBTITLE is the name of a file.
--
Robin Becker

Dani Reguera wrote:

> Here is the code:

>

> from reportlab.pdfgen import canvas

> from reportlab.lib.pagesizes import landscape,A4

> from reportlab.pdfgen.textobject import PDFTextObject

> from reportlab.lib.colors import HexColor

> from reportlab.pdfbase import pdfmetrics

>

> mycanvas = canvas.Canvas(SUBTITLE,pagesize=landscape(A4))

>

> mycanvas.drawImage(styles['credits']['path'],int(styles['credits']['x'])*mm,int(styles['credits']['y'])*mm,width=int(styles['credits']['width'])*mm,height=int(styles['credits']['height'])*mm,

> mask='auto')

>

> kk = canvas.textobject.PDFTextObject(mycanvas)

> kk.setTextOrigin(x=0*mm,y=0*mm)

> kk.textOut(text)

>

> mycanvas.drawRightString(x*mm,y*mm,text)

>

> mycanvas.showPage()

> mycanvas.save()

>

..........


More information about the reportlab-users mailing list