Download modules/pdfExtractor.py from Kurian07/RAG_LLM: direct link, hf CLI and curl.
- Browser
- Download file 585 Bytes
-
https://huggingface.co/spaces/Kurian07/RAG_LLM/resolve/main/modules/pdfExtractor.py
- Command line
-
hf download hf://spaces/Kurian07/RAG_LLM/modules/pdfExtractor.py
-
curl -L -o pdfExtractor.py https://huggingface.co/spaces/Kurian07/RAG_LLM/resolve/main/modules/pdfExtractor.py
585 Bytes
| import os | |
| import pymupdf4llm | |
| class PdfConverter: | |
| def __init__(self, pdf_file): | |
| self.pdf_file = pdf_file | |
| self.md_text = None | |
| def convert_to_markdown(self): | |
| self.md_text = pymupdf4llm.to_markdown(self.pdf_file) | |
| return self.md_text | |
| def save_markdown(self, output_file): | |
| with open(output_file, 'w') as file: | |
| file.write(self.md_text) | |
| # Example usage | |
| # pdf_file = os.path.join(os.getcwd(), "pdfs", "test.pdf") | |
| # converter = PdfConverter(pdf_file) | |
| # text = converter.convert_to_markdown() | |
| # print(text) |