From 43e6ed2da908acbcae77cd4aa6146a1fc60dbad3 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Fri, 31 Aug 2018 12:35:28 +0200 Subject: [PATCH] Check-in list PDF: Deal with very long questions and answers --- src/pretix/plugins/checkinlists/exporters.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/pretix/plugins/checkinlists/exporters.py b/src/pretix/plugins/checkinlists/exporters.py index 5fadfd52c0..0884143a32 100644 --- a/src/pretix/plugins/checkinlists/exporters.py +++ b/src/pretix/plugins/checkinlists/exporters.py @@ -164,8 +164,15 @@ class PDFCheckinList(ReportlabExportMixin, BaseCheckinList): ], ] + headrowstyle = self.get_style() + headrowstyle.fontName = 'OpenSansBd' for q in questions: - tdata[0].append(str(q.question)) + txt = str(q.question) + p = Paragraph(txt, headrowstyle) + while p.wrap(colwidths[len(tdata[0])], 5000)[1] > 30 * mm: + txt = txt[:len(txt) - 50] + "..." + p = Paragraph(txt, headrowstyle) + tdata[0].append(p) cqs = Checkin.objects.filter( position_id=OuterRef('pk'), @@ -227,7 +234,12 @@ class PDFCheckinList(ReportlabExportMixin, BaseCheckinList): for a in op.answers.all(): acache[a.question_id] = str(a) for q in questions: - row.append(Paragraph(acache.get(q.pk, ''), self.get_style())) + txt = acache.get(q.pk, '') + p = Paragraph(txt, self.get_style()) + while p.wrap(colwidths[len(row)], 5000)[1] > 50 * mm: + txt = txt[:len(txt) - 50] + "..." + p = Paragraph(txt, self.get_style()) + row.append(p) if op.order.status != Order.STATUS_PAID: tstyledata += [ ('BACKGROUND', (2, len(tdata)), (2, len(tdata)), '#990000'),