Spaces:
Build error
Build error
Create report.py
Browse files
report.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fpdf import FPDF
|
| 2 |
+
|
| 3 |
+
def generate_pdf(results, overall_score, filename="ContractRiskReport.pdf"):
|
| 4 |
+
pdf = FPDF()
|
| 5 |
+
pdf.add_page()
|
| 6 |
+
pdf.set_font("Arial", size=12)
|
| 7 |
+
pdf.cell(200, 10, txt="Contract Risk Analysis Report", ln=True, align="C")
|
| 8 |
+
pdf.ln()
|
| 9 |
+
|
| 10 |
+
pdf.cell(200, 10, txt=f"Overall Risk Score: {overall_score:.2f}", ln=True)
|
| 11 |
+
|
| 12 |
+
for r in results:
|
| 13 |
+
pdf.set_text_color(255, 0, 0) if r['risk_level'] == "High" else pdf.set_text_color(0)
|
| 14 |
+
pdf.multi_cell(0, 10, f"[{r['risk_level']}] {r['clause']}")
|
| 15 |
+
|
| 16 |
+
pdf.output(filename)
|
| 17 |
+
return filename
|