pktpaulie commited on
Commit
28adf7a
·
verified ·
1 Parent(s): 2d5b92f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -311,10 +311,21 @@ def display_doc_as_image2(pdf_path):
311
 
312
  def display_doc_as_image3(pdf_path):
313
  try:
314
- images = convert_from_path(pdf_path, size=800)
315
- display(Image.fromarray(images[0]))
 
 
 
 
 
 
316
  except Exception as e:
317
  st.error(f"Failed to display image: {str(e)}")
 
 
 
 
 
318
 
319
  def display_doc_as_image1(pdf_path):
320
  try:
 
311
 
312
  def display_doc_as_image3(pdf_path):
313
  try:
314
+ # Convert PDF to images
315
+ images = []
316
+ for i in range(1): # Assuming only one page
317
+ img = Image.open(BytesIO(open(pdf_path, 'rb').read()))
318
+ images.append(img)
319
+
320
+ # Display the first page
321
+ display(images[0])
322
  except Exception as e:
323
  st.error(f"Failed to display image: {str(e)}")
324
+ # try:
325
+ # images = convert_from_path(pdf_path, size=800)
326
+ # display(Image.fromarray(images[0]))
327
+ # except Exception as e:
328
+ # st.error(f"Failed to display image: {str(e)}")
329
 
330
  def display_doc_as_image1(pdf_path):
331
  try: