Update app.py
Browse files
app.py
CHANGED
@@ -98,6 +98,7 @@ def app2():
|
|
98 |
hy.markdown(" ")
|
99 |
|
100 |
hy.subheader("NER from Pdf Reports")
|
|
|
101 |
with hy.form(key="pdf_form"):
|
102 |
ce, c1, ce, c2, c3 = hy.columns([0.07, 1, 0.07, 4, 1.5])
|
103 |
with c1:
|
@@ -152,37 +153,21 @@ def app2():
|
|
152 |
print("No Entities Extracted!!!")
|
153 |
|
154 |
temp_dir = tempfile.TemporaryDirectory()
|
155 |
-
document.save(tempfile.gettempdir()+"/annott.pdf")
|
156 |
-
|
157 |
-
|
158 |
-
with c2:
|
159 |
-
st.markdown("""
|
160 |
-
<embed src="https://drive.google.com/viewerng/
|
161 |
-
viewer?embedded=true&url=https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf" width="800" height="800">
|
162 |
-
""", unsafe_allow_html=True)
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
with open((tempfile.gettempdir()+"/annott.pdf"),"rb") as f:
|
167 |
-
base64_pdf = base64.b64encode(f.read()).decode('utf-8')
|
168 |
-
#pdf_display = f'<embed src="data:application/pdf;base64,{base64_pdf}" width="800" height="800" type="application/pdf">'
|
169 |
-
pdf_display = f'<iframe src="data:application/pdf;base64,{base64_pdf}" width="800" height="800" type="application/pdf"></iframe>'
|
170 |
-
st.markdown(pdf_display, unsafe_allow_html=True)
|
171 |
-
|
172 |
-
|
173 |
|
174 |
-
|
175 |
except Exception as e:
|
176 |
print("Error occured: {}".format(e))
|
177 |
raise e
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
|
|
186 |
|
187 |
#with open((tempfile.gettempdir()+"/annott.pdf"),"rb") as f:
|
188 |
# base64_pdf = base64.b64encode(f.read()).decode('utf-8')
|
|
|
98 |
hy.markdown(" ")
|
99 |
|
100 |
hy.subheader("NER from Pdf Reports")
|
101 |
+
counter = 0
|
102 |
with hy.form(key="pdf_form"):
|
103 |
ce, c1, ce, c2, c3 = hy.columns([0.07, 1, 0.07, 4, 1.5])
|
104 |
with c1:
|
|
|
153 |
print("No Entities Extracted!!!")
|
154 |
|
155 |
temp_dir = tempfile.TemporaryDirectory()
|
156 |
+
document.save(tempfile.gettempdir()+"/annott.pdf")
|
157 |
+
counter+=1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
|
|
|
159 |
except Exception as e:
|
160 |
print("Error occured: {}".format(e))
|
161 |
raise e
|
162 |
+
|
163 |
+
if counter !=0:
|
164 |
+
with open((tempfile.gettempdir()+"/annott.pdf"), "rb") as pdf_file:
|
165 |
+
PDFbyte = pdf_file.read()
|
166 |
+
|
167 |
+
hy.download_button(label="Download Annotated PDF",
|
168 |
+
data=PDFbyte,
|
169 |
+
file_name="annotated.pdf",
|
170 |
+
mime='application/octet-stream')
|
171 |
|
172 |
#with open((tempfile.gettempdir()+"/annott.pdf"),"rb") as f:
|
173 |
# base64_pdf = base64.b64encode(f.read()).decode('utf-8')
|