tahirsher commited on
Commit
3cf9170
1 Parent(s): 0fa729c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -22,11 +22,14 @@ def fetch_pdf_text_from_github(urls):
22
  response = requests.get(url)
23
  if response.status_code == 200:
24
  pdf_file = BytesIO(response.content)
25
- pdf_reader = PdfReader(pdf_file)
26
- for page in pdf_reader.pages:
27
- page_text = page.extract_text()
28
- if page_text:
29
- text += page_text
 
 
 
30
  else:
31
  st.error(f"Failed to fetch PDF from URL: {url}")
32
  return text
 
22
  response = requests.get(url)
23
  if response.status_code == 200:
24
  pdf_file = BytesIO(response.content)
25
+ try:
26
+ pdf_reader = PdfReader(pdf_file)
27
+ for page in pdf_reader.pages:
28
+ page_text = page.extract_text()
29
+ if page_text:
30
+ text += page_text
31
+ except Exception as e:
32
+ st.error(f"Failed to read PDF from URL {url}: {e}")
33
  else:
34
  st.error(f"Failed to fetch PDF from URL: {url}")
35
  return text