Spaces:
Sleeping
Sleeping
Download pdf_processing.py from I-AdityaGoyal/NoteBot: direct link, hf CLI and curl.
- Browser
- Download file 431 Bytes
-
https://huggingface.co/spaces/I-AdityaGoyal/NoteBot/resolve/main/pdf_processing.py
- Command line
-
hf download hf://spaces/I-AdityaGoyal/NoteBot/pdf_processing.py
-
curl -L -o pdf_processing.py https://huggingface.co/spaces/I-AdityaGoyal/NoteBot/resolve/main/pdf_processing.py
431 Bytes
| import fitz # PyMuPDF | |
| def extract_text_from_pdf(pdf_path): | |
| try: | |
| pdf_document = fitz.open(pdf_path) | |
| text = "" | |
| for page_num in range(len(pdf_document)): | |
| page = pdf_document.load_page(page_num) | |
| text += page.get_text() | |
| pdf_document.close() | |
| return text | |
| except Exception as e: | |
| print(f"Error extracting text from PDF: {e}") | |
| return "" | |