Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,8 +9,11 @@ def pdf_to_word(pdf_file):
|
|
9 |
document = Document()
|
10 |
|
11 |
for page in reader.pages:
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
14 |
|
15 |
word_file = BytesIO()
|
16 |
document.save(word_file)
|
|
|
9 |
document = Document()
|
10 |
|
11 |
for page in reader.pages:
|
12 |
+
if page.extract_text(): # Ensure text is extracted
|
13 |
+
text = page.extract_text()
|
14 |
+
document.add_paragraph(text)
|
15 |
+
else:
|
16 |
+
document.add_paragraph("[This page contains non-extractable content or images]")
|
17 |
|
18 |
word_file = BytesIO()
|
19 |
document.save(word_file)
|