Fix coordinate origin - remove Y-axis flipping

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 <noreply@anthropic.com>
This commit is contained in:
DJP 2025-10-20 16:33:47 -04:00
parent 2952731bd6
commit 91d2ff3573

View file

@ -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;