Problemas con Reportlab

hidura hidura en gmail.com
Jue Dic 13 05:22:07 CET 2007


Buenas noches lista,

Me encuentro generando un reporte en Reportlab y he tenido una desgracia
cada vez que pasa de las 16 filas el reporte debe generar una segunda pagina
para poder continuar pero en vez de generame la otra pagina me da un error
fatal y no hace nada si pudieran darme una mano se los agradeceria aqui pego
el fuente del reporte para que lo vean y me digan todo esta bien indexado
solo es cuando se genera la segunda pagina que explota



    # -*- coding: utf-8 -*



### Import Modules

from obje import con
db = con()
from reportlab.pdfgen import canvas
from reportlab.lib.units import inch
from reportlab.lib.pagesizes import letter,landscape
import os
import datetime
import time

###Define With and Height for the page (This does not set the page
properties)

ancho=8.50
largo=11


#def __init__(idfactu):
def cotiz(cotiza):

    cotiza.setTitle ("Cotización")
            #Draw Header Strings
    cotiza.setFont("Helvetica", 40)
    cotiza.drawString(2*inch, 10*inch, "Ocean Blue")
    cotiza.setFont("Helvetica", 12)
    cotiza.drawString(2*inch, 9.7*inch, "Direccion")
    cotiza.drawString(2*inch, 9.4*inch, "Telefono")
    cotiza.drawString(2*inch, 9.1*inch, "RNC")
    idfactu=91
        ## Obtener los datos del cliente

    cr = db.source()
    cr.execute("SELECT cliente FROM cotiz WHERE(id='%s')" % idfactu)
    c = cr.fetch()[0]
    clien = c[0]
    cr.execute("SELECT nombre FROM clientes WHERE(id='%s')" % clien)
    nomc = cr.fetch()[0]
    nombcli = nomc[0]
    cr.execute("SELECT direccion FROM clientes WHERE(id='%s')" % clien)
    dire = cr.fetch()[0]
    direc = dire[0]
    cr.execute("SELECT telefono FROM clientes WHERE(id='%s')" % clien)
    te = cr.fetch()[0]
    tel = te[0]
    cr.execute("SELECT celular FROM clientes WHERE(id='%s')" % clien)
    ce = cr.fetch()[0]
    cel = ce[0]
    cr.close()
            #Draw Clients Data
    cotiza.drawString(1.48*inch, 8.45*inch, "%s" % nombcli)
    cotiza.drawString(1.60*inch, 8.25*inch, "%s" % direc[0:12])
    cotiza.drawString(0.75*inch, 8.05*inch, "%s" % direc[12:])
    cotiza.drawString(1.55*inch, 7.75*inch, "%s" % tel)
    cotiza.drawString(1.55*inch, 7.50*inch, "%s" % cel)
    cotiza.setFont("Helvetica", 26)
    cotiza.drawRightString(7.5*inch, 9.5*inch, "Cotizacion")

            #Draw Square and Strings for the Client Data
    cotiza.rect(0.5*inch, 7.2*inch, 3.5*inch, 1.5*inch)
    cotiza.setFont("Helvetica", 12)
    cotiza.drawString(0.75*inch, 8.45*inch, "Cliente.:")
    cotiza.drawString(0.75*inch, 8.25*inch, "Direccion.:")
    cotiza.drawString(0.75*inch, 7.75*inch, "Tel.:")
    cotiza.drawString(0.75*inch, 7.50*inch, "Movil.:")

            #Draw Gridline for the Schema; and Signature Lines
    cotiza.grid([0.5*inch, 1.5*inch, 5*inch, 8*inch], [6.8*inch, 6.5*inch,
1*inch])
    cotiza.line(6.5*inch, 6.8*inch, 6.5*inch, 2*inch)
    cotiza.rect(5*inch, 1.00*inch, 3*inch, 0.25*inch)
    cotiza.rect(5*inch, 1.25*inch, 3*inch, 0.25*inch)
    cotiza.rect(5*inch, 1.50*inch, 3*inch, 0.25*inch)
    cotiza.rect(5*inch, 1.75*inch, 3*inch, 0.25*inch)

    cotiza.line(1*inch, 0.5*inch, 3.5*inch, 0.5*inch)
    cotiza.line(4.5*inch, 0.5*inch, 7.0*inch, 0.5*inch)

            #Draw Strings Inside The Schema
    cotiza.setFont("Helvetica", 12)
    cotiza.drawCentredString(1*inch, 6.6*inch, "Cantidad")
    cotiza.drawCentredString(3.25*inch, 6.6*inch, "Descripcion")
    cotiza.drawCentredString(5.75*inch, 6.6*inch, "Precio")
    cotiza.drawCentredString(7.25*inch, 6.6*inch, "Total")
    cotiza.drawString(5.05*inch, 1.82*inch, "Sub-Total:")
    cotiza.drawString(5.05*inch, 1.57*inch, "Impuestos:")
    cotiza.drawString(5.05*inch, 1.32*inch, "Otros:")
    cotiza.drawString(5.05*inch, 1.07*inch, "Total:")

#Obtener los productos de dicha cotizacion

    pos_y = 6.50
    cr = db.source()
    cr.execute("SELECT id FROM cotiz_productos WHERE(id_cotiz='%s')"%
idfactu)
    r = cr.ntuples
    w = cr.fetch(r)
    cuent_line = 0
    for i in range(0,r):
        t = w[i]
        q = t[0]
        pos_y = pos_y-0.25
        cr.execute("SELECT cantidad FROM cotiz_productos WHERE(id='%s')"% q)
        ca = cr.fetch()[0]
        cant = ca[0]
        cotiza.drawString(1*inch, pos_y*inch, "%s" % cant)
        cr.execute("SELECT producto FROM cotiz_productos WHERE(id='%s')"% q)
        idp = cr.fetch()[0]
        idpr = idp[0]
        cr.execute("SELECT nombre FROM productos WHERE(id='%s')"% idpr)
        no = cr.fetch()[0]
        nombr = no[0]
        cotiza.drawString(1.75*inch, pos_y*inch, "%s" % nombr)
        cr.execute("SELECT precio_vent FROM productos WHERE(id='%s')"% idpr)
        pc = cr.fetch()[0]
        prec = pc[0]
        cotiza.drawString(5.10*inch, pos_y*inch, "RD$%s.00" % prec)
        total = float(cant)*float(prec)
        cotiza.drawString(6.60*inch, pos_y*inch, "RD$%s0" % total)
        if (i >= 16):
            cotiza.showPage()
            cotiz (cotiza)
            cotiza.setFont("Helvetica", 40)
            pos_y= pos_y -10


cotiza = canvas.Canvas("Cotizacion.pdf", pagesize=(ancho*inch, largo*inch))
cotiz(cotiza)
cotiza.showPage()
cotiza.save()
os.system("evince Cotizacion.pdf")



-- 
Hidura
_______________________________________________
Lista de correo Python-es 
http://listas.aditel.org/listinfo/python-es
FAQ: http://listas.aditel.org/faqpyes





Más información sobre la lista de distribución Python-es