Fix: CDU-PDF AssertionError Fallback + Kopfzeile vereinheitlicht + Fehler-Debug
This commit is contained in:
parent
916b0ca643
commit
14140571d8
@ -649,7 +649,14 @@ def render_highlighted_page(programm_id: str, seite: int, query: str) -> Optiona
|
|||||||
|
|
||||||
needle = (query or "").strip()[:200]
|
needle = (query or "").strip()[:200]
|
||||||
|
|
||||||
|
try:
|
||||||
src = fitz.open(str(pdf_path))
|
src = fitz.open(str(pdf_path))
|
||||||
|
except Exception:
|
||||||
|
# Manche PDFs (z.B. CDU Grundsatzprogramm 2007) lassen sich nicht
|
||||||
|
# mit PyMuPDF öffnen. Fallback: Original-PDF ohne Highlighting.
|
||||||
|
logger.exception("render_highlighted_page: kann %s nicht öffnen", pdf_path.name)
|
||||||
|
return pdf_path.read_bytes(), seite, False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if seite < 1 or seite > len(src):
|
if seite < 1 or seite > len(src):
|
||||||
return None, 0, False
|
return None, 0, False
|
||||||
@ -689,7 +696,13 @@ def render_highlighted_page(programm_id: str, seite: int, query: str) -> Optiona
|
|||||||
annot.update()
|
annot.update()
|
||||||
|
|
||||||
highlighted = bool(needle and rects)
|
highlighted = bool(needle and rects)
|
||||||
|
try:
|
||||||
return src.tobytes(), target_page_idx + 1, highlighted
|
return src.tobytes(), target_page_idx + 1, highlighted
|
||||||
|
except (AssertionError, Exception):
|
||||||
|
# PyMuPDF kann manche PDFs nicht serialisieren (z.B. CDU 2007).
|
||||||
|
# Fallback: Original-PDF ohne Annotations zurückgeben.
|
||||||
|
logger.warning("render_highlighted_page: tobytes() failed für %s, sende Original", pdf_path.name)
|
||||||
|
return pdf_path.read_bytes(), target_page_idx + 1, False
|
||||||
finally:
|
finally:
|
||||||
src.close()
|
src.close()
|
||||||
|
|
||||||
|
|||||||
@ -699,10 +699,10 @@
|
|||||||
<button class="mode-btn active" onclick="showMode('browse')">📋 Durchsuchen</button>
|
<button class="mode-btn active" onclick="showMode('browse')">📋 Durchsuchen</button>
|
||||||
<button class="mode-btn" onclick="showMode('tags')">🏷️ Tags</button>
|
<button class="mode-btn" onclick="showMode('tags')">🏷️ Tags</button>
|
||||||
<button class="mode-btn" onclick="showMode('upload')">📤 Prüfen</button>
|
<button class="mode-btn" onclick="showMode('upload')">📤 Prüfen</button>
|
||||||
|
<a href="/auswertungen" class="mode-btn" style="text-decoration: none;">📈 Auswertungen</a>
|
||||||
<a href="/quellen" class="mode-btn" style="text-decoration: none;">📚 Quellen</a>
|
<a href="/quellen" class="mode-btn" style="text-decoration: none;">📚 Quellen</a>
|
||||||
<a href="/methodik" class="mode-btn" style="text-decoration: none;">🔍 Methodik</a>
|
<a href="/methodik" class="mode-btn" style="text-decoration: none;">🔍 Methodik</a>
|
||||||
<button id="auth-btn" class="mode-btn" style="border:none;cursor:pointer;font-size:0.85rem;">🔑 Anmelden</button>
|
<button id="auth-btn" class="mode-btn" style="border:none;cursor:pointer;">🔑 Anmelden</button>
|
||||||
<a href="/auswertungen" class="mode-btn" style="text-decoration: none;">📈 Auswertungen</a>
|
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user