Spaces:
Sleeping
Sleeping
samyak152002
commited on
Commit
•
b76b3d8
1
Parent(s):
a24b0c9
Update app.py
Browse files
app.py
CHANGED
@@ -3,15 +3,16 @@
|
|
3 |
import streamlit as st
|
4 |
import base64
|
5 |
from annotations import analyze_pdf
|
6 |
-
import tempfile
|
7 |
-
import os
|
8 |
|
9 |
def display_pdf(pdf_bytes):
|
10 |
-
"""Displays the PDF in the browser using an
|
11 |
if pdf_bytes:
|
|
|
12 |
base64_pdf = base64.b64encode(pdf_bytes).decode('utf-8')
|
13 |
-
pdf_display = f
|
14 |
-
|
|
|
|
|
15 |
else:
|
16 |
st.info("No annotated PDF to display.")
|
17 |
|
@@ -58,9 +59,12 @@ def main():
|
|
58 |
|
59 |
# Option to download the annotated PDF
|
60 |
if annotated_pdf:
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
64 |
|
65 |
if __name__ == "__main__":
|
66 |
main()
|
|
|
3 |
import streamlit as st
|
4 |
import base64
|
5 |
from annotations import analyze_pdf
|
|
|
|
|
6 |
|
7 |
def display_pdf(pdf_bytes):
|
8 |
+
"""Displays the PDF in the browser using an embed tag."""
|
9 |
if pdf_bytes:
|
10 |
+
# Encode the PDF to base64
|
11 |
base64_pdf = base64.b64encode(pdf_bytes).decode('utf-8')
|
12 |
+
pdf_display = f"""
|
13 |
+
<embed src="data:application/pdf;base64,{base64_pdf}" width="100%" height="800px" type="application/pdf">
|
14 |
+
"""
|
15 |
+
st.components.v1.html(pdf_display, height=800, width=700, scrolling=True)
|
16 |
else:
|
17 |
st.info("No annotated PDF to display.")
|
18 |
|
|
|
59 |
|
60 |
# Option to download the annotated PDF
|
61 |
if annotated_pdf:
|
62 |
+
st.download_button(
|
63 |
+
label="📥 Download Annotated PDF",
|
64 |
+
data=annotated_pdf,
|
65 |
+
file_name="annotated.pdf",
|
66 |
+
mime="application/pdf",
|
67 |
+
)
|
68 |
|
69 |
if __name__ == "__main__":
|
70 |
main()
|