Function
extract_pdf_text
(pdf_path: Path, max_pages: int | None = None)
Source from the content-addressed store, hash-verified
| 1938 | |
| 1939 | |
| 1940 | def extract_pdf_text(pdf_path: Path, max_pages: int | None = None) -> str: |
| 1941 | if fitz is None: |
| 1942 | return "" |
| 1943 | doc = fitz.open(pdf_path) |
| 1944 | try: |
| 1945 | page_limit = len(doc) if max_pages is None else min(len(doc), max_pages) |
| 1946 | texts = [doc[i].get_text("text") for i in range(page_limit)] |
| 1947 | finally: |
| 1948 | doc.close() |
| 1949 | return "\n".join(texts) |
| 1950 | |
| 1951 | |
| 1952 | def is_plausible_pdf_title_line(line: str) -> bool: |
Tested by
no test coverage detected