Update legal_document_analysis.py
Browse files
legal_document_analysis.py
CHANGED
@@ -395,7 +395,12 @@ def generate_pdf_analysis(document_text, summary, detected_clauses, hidden_oblig
|
|
395 |
pdf.set_font("Arial", 'I', 8)
|
396 |
pdf.cell(0, 10, f'Page {pdf.page_no()}', 0, 0, 'C')
|
397 |
|
398 |
-
|
|
|
|
|
|
|
|
|
|
|
399 |
|
400 |
# Function to handle chatbot interaction
|
401 |
def chatbot_query(user_input):
|
@@ -449,6 +454,7 @@ def send_feedback(feedback_content):
|
|
449 |
def send_pdf_via_email(pdf_buffer, recipient_email):
|
450 |
sender_email = os.getenv("SENDER_EMAIL")
|
451 |
password = os.getenv("EMAIL_PASS")
|
|
|
452 |
msg = MIMEMultipart()
|
453 |
msg['From'] = sender_email
|
454 |
msg['To'] = recipient_email
|
@@ -597,10 +603,7 @@ def display_legal_analysis_page():
|
|
597 |
|
598 |
# Download PDF Analysis Button
|
599 |
st.subheader("Download Analysis as PDF")
|
600 |
-
pdf_buffer =
|
601 |
-
pdf = generate_pdf_analysis(document_text, summary, detected_clauses, hidden_obligations, detected_risks, risk_assessment_matrix, risk_level_distribution, risks_by_type, stacked_bar_chart, risk_heatmap)
|
602 |
-
pdf.output(pdf_buffer, 'F')
|
603 |
-
pdf_buffer.seek(0)
|
604 |
|
605 |
# Add download button for PDF
|
606 |
st.download_button(
|
|
|
395 |
pdf.set_font("Arial", 'I', 8)
|
396 |
pdf.cell(0, 10, f'Page {pdf.page_no()}', 0, 0, 'C')
|
397 |
|
398 |
+
# Save PDF to a BytesIO object
|
399 |
+
pdf_buffer = io.BytesIO()
|
400 |
+
pdf.output(pdf_buffer, 'F') # Save to BytesIO
|
401 |
+
pdf_buffer.seek(0)
|
402 |
+
|
403 |
+
return pdf_buffer
|
404 |
|
405 |
# Function to handle chatbot interaction
|
406 |
def chatbot_query(user_input):
|
|
|
454 |
def send_pdf_via_email(pdf_buffer, recipient_email):
|
455 |
sender_email = os.getenv("SENDER_EMAIL")
|
456 |
password = os.getenv("EMAIL_PASS")
|
457 |
+
|
458 |
msg = MIMEMultipart()
|
459 |
msg['From'] = sender_email
|
460 |
msg['To'] = recipient_email
|
|
|
603 |
|
604 |
# Download PDF Analysis Button
|
605 |
st.subheader("Download Analysis as PDF")
|
606 |
+
pdf_buffer = generate_pdf_analysis(document_text, summary, detected_clauses, hidden_obligations, detected_risks, risk_assessment_matrix, risk_level_distribution, risks_by_type, stacked_bar_chart, risk_heatmap)
|
|
|
|
|
|
|
607 |
|
608 |
# Add download button for PDF
|
609 |
st.download_button(
|