(pdf_bytes: bytes)
| 67 | |
| 68 | @staticmethod |
| 69 | def extract_text(pdf_bytes: bytes) -> str: |
| 70 | if fitz is None: |
| 71 | raise RuntimeError("PyMuPDF not installed") |
| 72 | doc = fitz.open(stream=pdf_bytes, filetype="pdf") |
| 73 | pages = [] |
| 74 | for i, page in enumerate(doc): |
| 75 | text = page.get_text("text") |
| 76 | if text.strip(): |
| 77 | pages.append(f"<!-- Page {i + 1} -->\n{text.strip()}") |
| 78 | doc.close() |
| 79 | return "\n\n---\n\n".join(pages) |
| 80 | |
| 81 | |
| 82 | KNOWN_PDF_URLS = { |