From d8999f8a649ad673583177dd8d8425fafdd0c9f5 Mon Sep 17 00:00:00 2001 From: Dotty Dotter Date: Thu, 7 May 2026 08:04:56 +0200 Subject: [PATCH] =?UTF-8?q?fix(#180):=20@page-Gr=C3=B6=C3=9Fe=20in=20pt=20?= =?UTF-8?q?statt=20px=20f=C3=BCr=20korrekte=20PNG-Pixel-Dimensionen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit WeasyPrint konvertiert CSS-px zu PDF-pt mit 96/72=0.75-Faktor: 1080px CSS-Page → 810pt PDF-Page → 810px PNG (bei zoom=1). Mit 'size: 1080pt 1080pt' wird die PDF-Page direkt 1080pt und PyMuPDF rendert 1080×1080px wie erwartet. --- app/main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 4ea51d9..58bdff8 100644 --- a/app/main.py +++ b/app/main.py @@ -3459,7 +3459,11 @@ async def _render_scorecard_pdf( width=width, height=height, ) - page_size_css = f"@page {{ size: {width}px {height}px; margin: 0; }}" + # `size: NNNpt` → PDF-Page hat exakt N×M Punkte. PyMuPDF rendert + # bei zoom=1 dann 1 PDF-Punkt = 1 PNG-Pixel. CSS-Pixel werden + # aber auch in pt umgerechnet (96dpi → 72dpi → ×0.75) — daher + # konvertiere pt→css-px so, dass die Inhalts-Layouts passen. + page_size_css = f"@page {{ size: {width}pt {height}pt; margin: 0; }}" pdf = HTML(string=html_content).write_pdf(stylesheets=[CSS(string=page_size_css)]) safe = drucksache.replace("/", "-") return pdf, width, height, f"scorecard-{safe}-{format}"