Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -83,10 +83,11 @@ def analyze_requirement(requirement):
|
|
| 83 |
}
|
| 84 |
|
| 85 |
# Function to generate a PDF report
|
| 86 |
-
def
|
| 87 |
pdf = FPDF()
|
| 88 |
pdf.add_page()
|
| 89 |
-
|
|
|
|
| 90 |
# Add watermark
|
| 91 |
pdf.set_font("Arial", 'B', 50)
|
| 92 |
pdf.set_text_color(230, 230, 230) # Light gray color for watermark
|
|
@@ -113,15 +114,21 @@ def generate_pdf(req_text, req_type, domain, stakeholders, defects, rewrite):
|
|
| 113 |
pdf.cell(200, 10, txt=f"Report Generated on: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}", ln=True, align='C')
|
| 114 |
pdf.ln(10) # Add some space
|
| 115 |
|
| 116 |
-
|
| 117 |
-
pdf.
|
| 118 |
-
pdf.multi_cell(
|
| 119 |
-
pdf.
|
| 120 |
-
pdf.multi_cell(
|
| 121 |
-
pdf.multi_cell(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
-
|
| 124 |
-
|
|
|
|
| 125 |
|
| 126 |
# Custom CSS for professional styling
|
| 127 |
st.markdown("""
|
|
@@ -248,16 +255,24 @@ def main():
|
|
| 248 |
""", unsafe_allow_html=True)
|
| 249 |
|
| 250 |
# PDF Report Section
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
|
| 262 |
# Footer
|
| 263 |
st.markdown("---")
|
|
|
|
| 83 |
}
|
| 84 |
|
| 85 |
# Function to generate a PDF report
|
| 86 |
+
def generate_pdf_report(results):
|
| 87 |
pdf = FPDF()
|
| 88 |
pdf.add_page()
|
| 89 |
+
pdf.set_font("Arial", size=12)
|
| 90 |
+
|
| 91 |
# Add watermark
|
| 92 |
pdf.set_font("Arial", 'B', 50)
|
| 93 |
pdf.set_text_color(230, 230, 230) # Light gray color for watermark
|
|
|
|
| 114 |
pdf.cell(200, 10, txt=f"Report Generated on: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}", ln=True, align='C')
|
| 115 |
pdf.ln(10) # Add some space
|
| 116 |
|
| 117 |
+
# Add requirement details
|
| 118 |
+
pdf.set_font("Arial", 'B', 14)
|
| 119 |
+
pdf.multi_cell(200, 10, txt=f"Requirement R{i}: {result['Requirement']}", align='L')
|
| 120 |
+
pdf.set_font("Arial", size=12)
|
| 121 |
+
pdf.multi_cell(200, 10, txt=f"Type: {result['Type']}", align='L')
|
| 122 |
+
pdf.multi_cell(200, 10, txt=f"Domain: {result['Domain']}", align='L')
|
| 123 |
+
pdf.multi_cell(200, 10, txt=f"Stakeholders: {result['Stakeholders']}", align='L')
|
| 124 |
+
pdf.multi_cell(200, 10, txt=f"Defects: {result['Defects']}", align='L')
|
| 125 |
+
pdf.multi_cell(200, 10, txt=f"Rewritten: {result['Rewritten']}", align='L')
|
| 126 |
+
pdf.multi_cell(200, 10, txt="-" * 50, align='L')
|
| 127 |
+
pdf.ln(5) # Add some space between requirements
|
| 128 |
|
| 129 |
+
pdf_output = "requirements_report.pdf"
|
| 130 |
+
pdf.output(pdf_output)
|
| 131 |
+
return pdf_output
|
| 132 |
|
| 133 |
# Custom CSS for professional styling
|
| 134 |
st.markdown("""
|
|
|
|
| 255 |
""", unsafe_allow_html=True)
|
| 256 |
|
| 257 |
# PDF Report Section
|
| 258 |
+
st.subheader("π€ Generate Report")
|
| 259 |
+
with st.container():
|
| 260 |
+
col1, col2 = st.columns([3, 2])
|
| 261 |
+
with col1:
|
| 262 |
+
st.info("π‘ Click below to generate a comprehensive PDF report with all analysis details")
|
| 263 |
+
with col2:
|
| 264 |
+
if st.button("π Generate PDF Report", type="secondary", use_container_width=True):
|
| 265 |
+
with st.spinner("Generating PDF..."):
|
| 266 |
+
pdf_report = generate_pdf_report(st.session_state.results)
|
| 267 |
+
with open(pdf_report, "rb") as f:
|
| 268 |
+
st.download_button(
|
| 269 |
+
label="β¬οΈ Download Full Report",
|
| 270 |
+
data=f,
|
| 271 |
+
file_name="Requirement_Analysis_Report.pdf",
|
| 272 |
+
mime="application/pdf",
|
| 273 |
+
use_container_width=True,
|
| 274 |
+
type="primary"
|
| 275 |
+
)
|
| 276 |
|
| 277 |
# Footer
|
| 278 |
st.markdown("---")
|