Help with PDF creation

22 views
Skip to first unread message

Tiziano da Cunha

unread,
Jan 15, 2024, 7:40:33 AMJan 15
to reportlab-users
Good morning, I'm trying to create a pdf and I don't know how to put together the code. Context: the pdf has 2 squares, one for acquirers and the other for transferors, it would need the square below (transferors) to depend on the square above (acquirers). Likewise, if more data is added to the squares, they have to increase their size and also decrease their size. For example, if the acquirers square has 2 data, the transferors square has to go down one place. I insert the code of what I tried to do:
            # Datos de los adquirientes
            adquirientes_y = height - 346-(10 * num_adquirientes)
            c.rect(57.5, adquirientes_y, width - 85, 45 + (num_adquirientes * 10), stroke=1, fill=0)
            c.drawImage(r"C:\Users\*\Documents\Desarrollo\ceta\ceta-api\app\routers\v1_0\barra-gris.jpg", 72, height-336,(width-220)/0.79, (width-165)/30) #valores fijos
           
            subrayado_negrita(c, "DATOS DE LOS ADQUIRENTES", 70, height - 312)
            c.rect(71, height-336, width -118, 15, stroke=1, fill=0) #valores fijos
            c.setFont("Helvetica", 10)
            c.drawString(82, height - 332, "CUIT / CUIL / CDI")
            c.drawString(178, height - 332, "Apellido y Nombre o Denominación")
            c.drawString(428, height - 332, "Porcentaje de Titularidad")

            for i, a in enumerate(cert.listAdquirientes):
                nombre_adquiriente = obtener_nombre(session, a.cuit, 'adquirente')
                c.drawString(88, height - 350 - i * 20, f"{int(a.cuit)}")
                c.drawString(178, height - 350 - i * 20, f"{nombre_adquiriente}")
                c.drawString(508, height - 350 - i * 20, f"{float(a.adquirencia)}%")

           
            # Datos de los transferentes
            transferentes_y = adquirientes_y - 55 - (10 * num_transferentes)
            c.rect(57.5, transferentes_y, width - 85, 45 + (num_transferentes * 10), stroke=1, fill=0)
            c.drawImage(r"C:\Users\*\Documents\Desarrollo\ceta\ceta-api\app\routers\v1_0\barra-gris.jpg", 72, height - 391 - (10 * num_adquirientes), (width - 220) / 0.79, (width - 165) / 30)
            subrayado_negrita(c, "DATOS DE LOS TRANSFERENTES", 70, height - 370 - (10 * num_adquirientes))
            c.rect(71, height - 391 - (10 * num_adquirientes), width - 118, 15, stroke=1, fill=0)
            c.setFont("Helvetica", 10)
            c.drawString(82, height - 387 - (10 * num_adquirientes), "CUIT / CUIL / CDI")
            c.drawString(178, height - 387 - (10 * num_adquirientes), "Apellido y Nombre o Denominación")
            c.drawString(428, height - 387 - (10 * num_adquirientes), "Porcentaje Transferido")

            for i, t in enumerate(cert.listTransferentes):
                nombre_transferente = obtener_nombre(session, t.cuit, 'transferente')
                c.drawString(88, height - 405 - (10 * num_adquirientes) - i * 20, f"{int(t.cuit)}")
                c.drawString(176, height - 405 - (10 * num_adquirientes) - i * 20, f"{nombre_transferente}")
                c.drawString(508, height - 405 - (10 * num_adquirientes) - i * 20, f"{float(t.titularidad)}%")

           
           
Ícono de validado por la comunidad

Tiziano da Cunha

unread,
Jan 15, 2024, 7:41:20 AMJan 15
to reportlab-users
Insert demo image
Reply all
Reply to author
Forward
0 new messages