AzizWazir commited on
Commit
ecb38ba
·
verified ·
1 Parent(s): 9a256f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -9,8 +9,11 @@ def pdf_to_word(pdf_file):
9
  document = Document()
10
 
11
  for page in reader.pages:
12
- text = page.extract_text()
13
- document.add_paragraph(text)
 
 
 
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)