From d8d31bab51ef6985a21ace83e9f8794c7d11c4ad Mon Sep 17 00:00:00 2001 From: Richard Schreiber Date: Fri, 3 Feb 2023 11:59:43 +0100 Subject: [PATCH] PDF-Export: limit pagesize precision in badges nup-placement (#3085) --- src/pretix/plugins/badges/exporters.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/pretix/plugins/badges/exporters.py b/src/pretix/plugins/badges/exporters.py index 8c5f067695..4b0a7a2726 100644 --- a/src/pretix/plugins/badges/exporters.py +++ b/src/pretix/plugins/badges/exporters.py @@ -36,6 +36,7 @@ import json import logging from collections import OrderedDict from datetime import datetime, time, timedelta +from decimal import Decimal from io import BytesIO from typing import Tuple @@ -221,17 +222,17 @@ def render_pdf(event, positions, opt): di = i % badges_per_page if di == 0: nup_page = nup_pdf.add_blank_page( - width=opt['pagesize'][0], - height=opt['pagesize'][1], + width=Decimal('%.5f' % (opt['pagesize'][0])), + height=Decimal('%.5f' % (opt['pagesize'][1])), ) tx = opt['margins'][3] + (di % opt['cols']) * opt['offsets'][0] ty = opt['margins'][2] + (opt['rows'] - 1 - (di // opt['cols'])) * opt['offsets'][1] page.add_transformation(Transformation().translate(tx, ty)) page.mediabox = RectangleObject(( - page.mediabox.left.as_numeric() + tx, - page.mediabox.bottom.as_numeric() + ty, - page.mediabox.right.as_numeric() + tx, - page.mediabox.top.as_numeric() + ty + Decimal('%.5f' % (page.mediabox.left.as_numeric() + tx)), + Decimal('%.5f' % (page.mediabox.bottom.as_numeric() + ty)), + Decimal('%.5f' % (page.mediabox.right.as_numeric() + tx)), + Decimal('%.5f' % (page.mediabox.top.as_numeric() + ty)) )) page.trimbox = page.mediabox nup_page.merge_page(page)