diff --git a/app/embeddings.py b/app/embeddings.py
index 894e6dc..117ea2b 100644
--- a/app/embeddings.py
+++ b/app/embeddings.py
@@ -649,7 +649,14 @@ def render_highlighted_page(programm_id: str, seite: int, query: str) -> Optiona
needle = (query or "").strip()[:200]
- src = fitz.open(str(pdf_path))
+ try:
+ 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:
if seite < 1 or seite > len(src):
return None, 0, False
@@ -689,7 +696,13 @@ def render_highlighted_page(programm_id: str, seite: int, query: str) -> Optiona
annot.update()
highlighted = bool(needle and rects)
- return src.tobytes(), target_page_idx + 1, highlighted
+ try:
+ 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:
src.close()
diff --git a/app/templates/index.html b/app/templates/index.html
index 7e59272..0497239 100644
--- a/app/templates/index.html
+++ b/app/templates/index.html
@@ -699,10 +699,10 @@
+ 📈 Auswertungen
📚 Quellen
🔍 Methodik
-
- 📈 Auswertungen
+