Why does this indefinite character appear when doing a line break in reportlab pdf of django and how to remove it?

时间:2019-04-23 15:08:31

标签: python django reportlab

Two months ago I tried to make a PDF report with ReportLab in Django and everything worked fine until we started managing text areas. When you make a line break in HTML and it is shown in PDF, the following undefined character appears:

Duro■
dasfgq■
asg■
asgag

I have already tried to find solutions, both in Spanish OS and in English OS and I really do not know what else I can do.

Here are some links that I found and try to use but seeing that I do not use paragraphs, I do not know how to handle it in tables:

reportlab issue with line breaks using XPreformatted - additionall question mark printed

Why does this character ▯ appear?

def tabla(self, participante_id, pdf,y):
        try:
            participante = Participante.objects.get(id=participante_id)
        except Participante.DoesNotExist:
            participante=False
        datosnew = Despedida.objects.filter(participante=participante)
        a = 200
        for despi in datosnew:
            a += 200
            y -= 140
            encabezados = ('Sesión', 'Fecha')
            detalles = [(despi.sesion, despi.fecha)]
            encabezados1 = ('¿Qué significa para mi despedirme?:',)
            detalles1 = [(despi.despedida1,)]
            encabezados2 = ('¿Qué duele de las despedidas?:',)
            detalles2 = [(despi.despedida2,)]
            encabezados3 = ('¿Qué hago cuando no quiero despedirme?:',)
            detalles3 = [(despi.despedida3,)]
            encabezados4 = ('Menciona 5 cosas, personas o etapas de las que te costó despedirte',)
            detalles4 = [(despi.despedida4,)]

detalle_orden = Table([encabezados2] + detalles2,colWidths=[18 * cm,16 * cm,])
detalle_orden.setStyle(TableStyle(
    [
    #La primera fila(encabezados) va a estar centrada
    ('ALIGN',(0,0),(0,0),'LEFT'),
    #Los bordes de todas las celdas serán de color negro y con un grosor de 1
    #El tamaño de las letras de cada una de las celdas será de 10
    ('FONTSIZE', (0, 0), (-1, -1), 10),
    ('BACKGROUND', (0, 1), (0, 1), '#e9ecef'),
    ]
))
detalle_orden.wrapOn(pdf, 800, 600)
    #Definimos la coordenada donde se dibujará la tabla
detalle_orden.drawOn(pdf, 60,y-40)

I just want to remove those characters since the line break works correctly. Thank you for your attention

0 个答案:

没有答案
相关问题