diff --git a/engine/src/parser/pdfium_document.cpp b/engine/src/parser/pdfium_document.cpp index 15b1dd5..e62e472 100644 --- a/engine/src/parser/pdfium_document.cpp +++ b/engine/src/parser/pdfium_document.cpp @@ -2982,6 +2982,12 @@ std::expected PdfiumDocument::applyEdits(const std::string& e if (align == "right") x = columnLeft + (columnWidth - naturalW); else if (align == "center") x = columnLeft + (columnWidth - naturalW) / 2.0; } + // The line's TRUE starting x (after lineX/center/right). The caret layout below + // records this as x0 so the frontend places the caret on the actual glyphs. (It + // used to hardcode columnLeft, which only matched left-aligned lines — center/right + // headings then mismapped clicks. x0 is caret-only metadata; it does not affect + // glyph emission or the rendered page.) + const double lineStartX = x; for (size_t k = 0; k < lw.size(); ++k) { size_t wi = lw[k]; if (k > 0) { @@ -3026,7 +3032,7 @@ std::expected PdfiumDocument::applyEdits(const std::string& e x += words[wi].width; } layoutLines.push_back({ - {"baselineY", baselineY}, {"x0", columnLeft}, + {"baselineY", baselineY}, {"x0", lineStartX}, {"fontSize", lineFontSize > 0 ? lineFontSize : leading / 1.2}, {"text", lineText}, {"adv", adv}, }); diff --git a/frontend/src/lib/pdfiumEngine.ts b/frontend/src/lib/pdfiumEngine.ts index db0b17a..91ecd57 100644 --- a/frontend/src/lib/pdfiumEngine.ts +++ b/frontend/src/lib/pdfiumEngine.ts @@ -23,7 +23,7 @@ function getModule(): Promise { if (!modulePromise) { modulePromise = (async () => { try { - const V = '20260617b'; + const V = '20260617c'; const resp = await fetch(`/pdfium-engine.mjs?v=${V}`, { cache: 'no-store' }); if (!resp.ok) throw new Error(`pdfium-engine.mjs ${resp.status}`); const blobUrl = URL.createObjectURL(new Blob([await resp.text()], { type: 'text/javascript' }));