MCPcopy Create free account
hub / github.com/917Dhj/DeepPaperNote / extract_pdf_text

Function extract_pdf_text

scripts/common.py:1940–1949  ·  view source on GitHub ↗
(pdf_path: Path, max_pages: int | None = None)

Source from the content-addressed store, hash-verified

1938
1939
1940def 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
1952def is_plausible_pdf_title_line(line: str) -> bool:

Callers 1

mainFunction · 0.90

Calls 3

openMethod · 0.45
get_textMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected