Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -34,7 +34,9 @@ def encode_file(uploaded_file):
|
|
34 |
file_bytes = uploaded_file.getvalue()
|
35 |
|
36 |
if uploaded_file.type == "application/pdf":
|
37 |
-
|
|
|
|
|
38 |
if not images:
|
39 |
raise ValueError("Failed to convert PDF to image")
|
40 |
img_byte_arr = BytesIO()
|
@@ -87,7 +89,9 @@ def process_document():
|
|
87 |
|
88 |
# Generate preview
|
89 |
if uploaded_file.type == "application/pdf":
|
90 |
-
|
|
|
|
|
91 |
st.session_state.doc_preview = images[0]
|
92 |
else:
|
93 |
st.session_state.doc_preview = Image.open(uploaded_file)
|
|
|
34 |
file_bytes = uploaded_file.getvalue()
|
35 |
|
36 |
if uploaded_file.type == "application/pdf":
|
37 |
+
# Specify the path to poppler binaries
|
38 |
+
poppler_path = "/usr/bin" # Adjust this path if necessary
|
39 |
+
images = convert_from_bytes(file_bytes, first_page=1, last_page=1, poppler_path=poppler_path)
|
40 |
if not images:
|
41 |
raise ValueError("Failed to convert PDF to image")
|
42 |
img_byte_arr = BytesIO()
|
|
|
89 |
|
90 |
# Generate preview
|
91 |
if uploaded_file.type == "application/pdf":
|
92 |
+
# Specify the path to poppler binaries
|
93 |
+
poppler_path = "/usr/bin" # Adjust this path if necessary
|
94 |
+
images = convert_from_bytes(uploaded_file.getvalue(), first_page=1, last_page=1, poppler_path=poppler_path)
|
95 |
st.session_state.doc_preview = images[0]
|
96 |
else:
|
97 |
st.session_state.doc_preview = Image.open(uploaded_file)
|