| import requests | |
| import io | |
| from PyPDF2 import PdfReader | |
| def extract_pdf_content(url: str) -> str: | |
| try: | |
| pdf_bytes = requests.get(url, timeout=10).content | |
| pdf_file = io.BytesIO(pdf_bytes) | |
| reader = PdfReader(pdf_file) | |
| text = "" | |
| for page in reader.pages: | |
| text += page.extract_text() or "" | |
| return text.strip() | |
| except Exception as e: | |
| return f"PDF_ERROR: {str(e)}" | |