Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -534,41 +534,10 @@ def display_pdf_preview(file_path, model_name):
|
|
| 534 |
|
| 535 |
st.markdown("---")
|
| 536 |
|
| 537 |
-
#
|
| 538 |
-
st.markdown(f'''
|
| 539 |
-
<div style="width: 100%; height: 900px; margin-top: 10px;">
|
| 540 |
-
<embed
|
| 541 |
-
src="{pdf_url}#toolbar=1&navpanes=0&scrollbar=1&view=FitH"
|
| 542 |
-
width="100%"
|
| 543 |
-
height="900px"
|
| 544 |
-
type="application/pdf"
|
| 545 |
-
style="border: 1px solid #444; border-radius: 8px;">
|
| 546 |
-
</div>
|
| 547 |
-
''', unsafe_allow_html=True)
|
| 548 |
-
|
| 549 |
-
# Fallback viewer options
|
| 550 |
-
st.markdown("---")
|
| 551 |
-
st.markdown("📄 **Alternative viewing options:**")
|
| 552 |
-
|
| 553 |
-
col1, col2, col3 = st.columns(3)
|
| 554 |
-
|
| 555 |
-
with col1:
|
| 556 |
-
st.markdown(f"[Open in new tab ↗]({pdf_url})")
|
| 557 |
-
|
| 558 |
-
with col2:
|
| 559 |
-
# PDF.js viewer as backup
|
| 560 |
-
pdf_js_url = f"https://mozilla.github.io/pdf.js/web/viewer.html?file={quote(pdf_url, safe='')}"
|
| 561 |
-
st.markdown(f"[Open with PDF viewer ↗]({pdf_js_url})")
|
| 562 |
-
|
| 563 |
-
with col3:
|
| 564 |
-
# Direct link
|
| 565 |
-
st.markdown(f"[Direct link]({pdf_url})")
|
| 566 |
-
|
| 567 |
-
# If embed doesn't work, show PDF.js viewer as backup
|
| 568 |
-
st.markdown("---")
|
| 569 |
st.markdown("🔍 **Backup viewer** (if PDF doesn't display above):")
|
| 570 |
|
| 571 |
-
# Use
|
| 572 |
import streamlit.components.v1 as components
|
| 573 |
components.iframe(
|
| 574 |
src=f"https://mozilla.github.io/pdf.js/web/viewer.html?file={quote(pdf_url, safe='')}",
|
|
|
|
| 534 |
|
| 535 |
st.markdown("---")
|
| 536 |
|
| 537 |
+
# Show backup viewer with PDF.js
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 538 |
st.markdown("🔍 **Backup viewer** (if PDF doesn't display above):")
|
| 539 |
|
| 540 |
+
# Use PDF.js viewer directly (most reliable for HuggingFace Spaces)
|
| 541 |
import streamlit.components.v1 as components
|
| 542 |
components.iframe(
|
| 543 |
src=f"https://mozilla.github.io/pdf.js/web/viewer.html?file={quote(pdf_url, safe='')}",
|