samyak152002 commited on
Commit
d97dd70
·
verified ·
1 Parent(s): d9a6b52

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -6,7 +6,7 @@ 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"""
@@ -40,6 +40,12 @@ def main():
40
  else:
41
  st.success("Analysis complete!")
42
 
 
 
 
 
 
 
43
  # Display the annotated PDF
44
  st.subheader("📄 Annotated PDF")
45
  display_pdf(annotated_pdf)
@@ -58,13 +64,15 @@ def main():
58
  st.sidebar.success("No language issues found!")
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()
 
6
 
7
  def display_pdf(pdf_bytes):
8
  """Displays the PDF in the browser using an embed tag."""
9
+ if pdf_bytes and len(pdf_bytes) > 0:
10
  # Encode the PDF to base64
11
  base64_pdf = base64.b64encode(pdf_bytes).decode('utf-8')
12
  pdf_display = f"""
 
40
  else:
41
  st.success("Analysis complete!")
42
 
43
+ # Debugging: Show the size of annotated_pdf
44
+ if annotated_pdf and len(annotated_pdf) > 0:
45
+ st.write(f"Annotated PDF size: {len(annotated_pdf)} bytes")
46
+ else:
47
+ st.write("Annotated PDF is empty.")
48
+
49
  # Display the annotated PDF
50
  st.subheader("📄 Annotated PDF")
51
  display_pdf(annotated_pdf)
 
64
  st.sidebar.success("No language issues found!")
65
 
66
  # Option to download the annotated PDF
67
+ if annotated_pdf and len(annotated_pdf) > 0:
68
  st.download_button(
69
  label="📥 Download Annotated PDF",
70
  data=annotated_pdf,
71
  file_name="annotated.pdf",
72
  mime="application/pdf",
73
  )
74
+ else:
75
+ st.info("No annotated PDF available for download.")
76
 
77
  if __name__ == "__main__":
78
  main()