Spaces:
Running
Running
File size: 396 Bytes
47b5f0c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import io
import os
from fastapi import UploadFile
import pdfplumber
class ExtractTextFeature:
@staticmethod
async def extract_text_from_pdf(file: UploadFile) -> str:
content = await file.read()
with pdfplumber.open(io.BytesIO(content)) as pdf:
text = ""
for page in pdf.pages:
text += page.extract_text()
return text
|