Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -271,18 +271,18 @@ def pdf_to_iframe(file):
|
|
| 271 |
pdf_bytes = f.read()
|
| 272 |
encoded = base64.b64encode(pdf_bytes).decode("utf-8")
|
| 273 |
return f"""
|
| 274 |
-
<
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
</div>
|
| 280 |
"""
|
| 281 |
except Exception as e:
|
| 282 |
return f"<p style='color:red;'>Failed to display PDF: {e}</p>"
|
| 283 |
|
| 284 |
|
| 285 |
|
|
|
|
| 286 |
# ---------- Gradio UI ----------
|
| 287 |
with gr.Blocks(theme=simple_theme, title=APP_TITLE) as interface:
|
| 288 |
gr.HTML(f"""
|
|
|
|
| 271 |
pdf_bytes = f.read()
|
| 272 |
encoded = base64.b64encode(pdf_bytes).decode("utf-8")
|
| 273 |
return f"""
|
| 274 |
+
<iframe
|
| 275 |
+
src="data:application/pdf;base64,{encoded}"
|
| 276 |
+
width="100%" height="80vh" <!-- dynamic height: 80% of viewport -->
|
| 277 |
+
style="border:1px solid #ccc;"
|
| 278 |
+
></iframe>
|
|
|
|
| 279 |
"""
|
| 280 |
except Exception as e:
|
| 281 |
return f"<p style='color:red;'>Failed to display PDF: {e}</p>"
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
+
|
| 286 |
# ---------- Gradio UI ----------
|
| 287 |
with gr.Blocks(theme=simple_theme, title=APP_TITLE) as interface:
|
| 288 |
gr.HTML(f"""
|