From 91d2ff35734fd1ab3ce90c4c5ef25ea2b801a3f2 Mon Sep 17 00:00:00 2001 From: DJP Date: Mon, 20 Oct 2025 16:33:47 -0400 Subject: [PATCH] Fix coordinate origin - remove Y-axis flipping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: Markers still misaligned after DPI scaling Cause: pdfplumber uses top-left origin, I was flipping Y incorrectly Fix: Remove Y-flip - both pdfplumber and SVG use top-left (0,0) Coordinate Systems: - pdfplumber: (0,0) = top-left, y increases DOWN - SVG: (0,0) = top-left, y increases DOWN - Standard PDF: (0,0) = bottom-left, y increases UP Since pdfplumber already gives us top-left coords, just scale, don't flip! Now: x_pixel = x_pdf × scale, y_pixel = y_pdf × scale 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- index.html | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index cc30d8d..b061ebf 100644 --- a/index.html +++ b/index.html @@ -1344,17 +1344,18 @@ pageIssues.forEach((issue, index) => { const coords = issue.coordinates; - // Scale PDF coordinates to image pixels - // PDF coordinates are bottom-left origin, need to flip Y and scale + // Scale coordinates from PDF points to image pixels + // pdfplumber uses top-left origin (0,0 = top-left), same as SVG + // So NO Y-flipping needed, just scale! const x0 = coords.x0 * scaleFactor; + const y0 = coords.y0 * scaleFactor; // coords.y0 is 'top' from pdfplumber const x1 = coords.x1 * scaleFactor; - const y0 = imgHeight - (coords.y1 * scaleFactor); // Flip Y - const y1 = imgHeight - (coords.y0 * scaleFactor); // Flip Y + const y1 = coords.y1 * scaleFactor; // coords.y1 is 'bottom' from pdfplumber const width = x1 - x0; const height = y1 - y0; - console.log(`Issue ${index + 1}: PDF coords (${coords.x0}, ${coords.y0}) → Screen (${x0.toFixed(0)}, ${y0.toFixed(0)}), size: ${width.toFixed(0)}x${height.toFixed(0)}`); + console.log(`Issue ${index + 1}: PDF (${coords.x0}, ${coords.y0}, ${coords.x1}, ${coords.y1}) → Pixels (${x0.toFixed(0)}, ${y0.toFixed(0)}, ${x1.toFixed(0)}, ${y1.toFixed(0)}), size: ${width.toFixed(0)}x${height.toFixed(0)}`); // Color based on severity let strokeColor, fillColor;