Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,23 +3,6 @@ from reportlab.lib.pagesizes import A4
|
|
| 3 |
from reportlab.pdfgen import canvas
|
| 4 |
import os
|
| 5 |
|
| 6 |
-
# List of courts in Pakistan
|
| 7 |
-
courts = [
|
| 8 |
-
"Supreme Court of Pakistan",
|
| 9 |
-
"Sindh High Court",
|
| 10 |
-
"Lahore High Court",
|
| 11 |
-
"Peshawar High Court",
|
| 12 |
-
"Balochistan High Court",
|
| 13 |
-
"Islamabad High Court",
|
| 14 |
-
"District & Sessions Court - Karachi",
|
| 15 |
-
"District & Sessions Court - Lahore",
|
| 16 |
-
"District & Sessions Court - Islamabad",
|
| 17 |
-
"District & Sessions Court - Quetta",
|
| 18 |
-
"District & Sessions Court - Peshawar",
|
| 19 |
-
"District & Sessions Court - Multan",
|
| 20 |
-
"District & Sessions Court - Faisalabad",
|
| 21 |
-
# Add all district courts here
|
| 22 |
-
]
|
| 23 |
|
| 24 |
# List of cities with courts
|
| 25 |
cities = [
|
|
@@ -37,9 +20,12 @@ def create_pdf(data):
|
|
| 37 |
|
| 38 |
# Header
|
| 39 |
c.setFont("Helvetica-Bold", 12)
|
| 40 |
-
c.drawString(50, height - 50, f"OFFICE OF THE {data['court_name']}
|
| 41 |
c.setFont("Helvetica", 10)
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
# To Section
|
| 45 |
c.drawString(50, height - 110, "To,")
|
|
@@ -48,60 +34,74 @@ def create_pdf(data):
|
|
| 48 |
|
| 49 |
# Subject
|
| 50 |
c.setFont("Helvetica-Bold", 11)
|
| 51 |
-
c.drawString(50, height - 180, "SUBJECT:")
|
| 52 |
c.setFont("Helvetica", 10)
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
f"INTIMATION REGARDING GRANT OF INTERIM PRE-ARREST BAIL TO ACCUSED IN CRL.BA NO. {data['case_no']}/2025, {data['case_name']}",
|
| 57 |
)
|
|
|
|
| 58 |
|
| 59 |
# Body
|
|
|
|
| 60 |
body = (
|
| 61 |
-
f"Whereas, the following named applicant/accused
|
| 62 |
-
f"
|
| 63 |
-
f"
|
| 64 |
-
f"
|
| 65 |
-
f"
|
| 66 |
-
f"to
|
| 67 |
-
f"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
)
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
|
|
|
| 73 |
|
| 74 |
# Applicant Information
|
| 75 |
c.setFont("Helvetica-Bold", 11)
|
| 76 |
-
c.drawString(50,
|
| 77 |
c.setFont("Helvetica", 10)
|
| 78 |
-
c.drawString(50,
|
| 79 |
|
| 80 |
# Footer
|
| 81 |
c.setFont("Helvetica", 10)
|
| 82 |
-
c.drawString(50,
|
| 83 |
-
c.
|
| 84 |
-
c.drawString(50,
|
| 85 |
-
c.drawString(50,
|
|
|
|
| 86 |
|
| 87 |
# Save the PDF
|
| 88 |
c.save()
|
| 89 |
return pdf_file
|
| 90 |
|
|
|
|
| 91 |
# Streamlit App
|
| 92 |
st.title("Court Order Generator")
|
| 93 |
|
| 94 |
# User Inputs
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
city = st.selectbox("Select City", cities)
|
| 97 |
case_no = st.text_input("Case Number")
|
| 98 |
-
date = st.
|
| 99 |
police_station = st.text_input("Police Station Name")
|
| 100 |
case_name = st.text_input("Case Details/Name")
|
| 101 |
-
order_date = st.
|
| 102 |
surety = st.number_input("Surety Amount (Rs.)", min_value=0, step=500)
|
| 103 |
-
next_date = st.
|
| 104 |
-
time = st.text_input("Hearing Time")
|
| 105 |
accused_name = st.text_input("Applicant/Accused Name")
|
| 106 |
|
| 107 |
# Generate PDF Button
|
|
|
|
| 3 |
from reportlab.pdfgen import canvas
|
| 4 |
import os
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
# List of cities with courts
|
| 8 |
cities = [
|
|
|
|
| 20 |
|
| 21 |
# Header
|
| 22 |
c.setFont("Helvetica-Bold", 12)
|
| 23 |
+
c.drawString(50, height - 50, f"OFFICE OF THE {data['court_name']}")
|
| 24 |
c.setFont("Helvetica", 10)
|
| 25 |
+
|
| 26 |
+
# Date on the left, City in the center
|
| 27 |
+
c.drawString(50, height - 70, f"Dated: {data['date']}")
|
| 28 |
+
c.drawCentredString(width / 2, height - 70, f"{data['city']}")
|
| 29 |
|
| 30 |
# To Section
|
| 31 |
c.drawString(50, height - 110, "To,")
|
|
|
|
| 34 |
|
| 35 |
# Subject
|
| 36 |
c.setFont("Helvetica-Bold", 11)
|
| 37 |
+
c.drawString(50, height - 180, "SUBJECT: ")
|
| 38 |
c.setFont("Helvetica", 10)
|
| 39 |
+
subject_text = (
|
| 40 |
+
f"INTIMATION REGARDING GRANT OF INTERIM PRE-ARREST BAIL TO ACCUSED "
|
| 41 |
+
f"IN CRL.BA NO. {data['case_no']}/2025, {data['case_name']}"
|
|
|
|
| 42 |
)
|
| 43 |
+
c.drawString(120, height - 180, subject_text)
|
| 44 |
|
| 45 |
# Body
|
| 46 |
+
c.setFont("Helvetica", 10)
|
| 47 |
body = (
|
| 48 |
+
f"Whereas, the following named applicant/accused {data['accused_name']} "
|
| 49 |
+
f"has filed a criminal bail before arrest application u/s 498-Cr.P.C before "
|
| 50 |
+
f"this Court through their advocate for the grant of pre-arrest bail in the "
|
| 51 |
+
f"above-noted case. After hearing parties and their counsel, this Court has granted "
|
| 52 |
+
f"interim pre-arrest bail to the applicant/accused vide order dated {data['order_date']}, "
|
| 53 |
+
f"subject to furnishing solvent surety in the sum of Rs.{data['surety']} only and P.R bond "
|
| 54 |
+
f"in like amount.\n\nThe applicant/accused has furnished the required surety, which was accepted "
|
| 55 |
+
f"by this Court. The applicant/accused is directed to appear before the trial court/join the investigation "
|
| 56 |
+
f"and they are further directed to attend this Court on {data['next_date']} for confirmation or otherwise.\n\n"
|
| 57 |
+
f"You are further directed to produce the police papers before this Court on {data['next_date']} at {data['time']} "
|
| 58 |
+
f"without fail."
|
| 59 |
)
|
| 60 |
+
text_lines = body.split("\n")
|
| 61 |
+
y = height - 220
|
| 62 |
+
for line in text_lines:
|
| 63 |
+
c.drawString(50, y, line)
|
| 64 |
+
y -= 20
|
| 65 |
|
| 66 |
# Applicant Information
|
| 67 |
c.setFont("Helvetica-Bold", 11)
|
| 68 |
+
c.drawString(50, y - 20, "NAME OF APPLICANT/ACCUSED:")
|
| 69 |
c.setFont("Helvetica", 10)
|
| 70 |
+
c.drawString(50, y - 40, f"{data['accused_name']}")
|
| 71 |
|
| 72 |
# Footer
|
| 73 |
c.setFont("Helvetica", 10)
|
| 74 |
+
c.drawString(50, y - 80, "Given under my hand and seal of this Court on this ____ day of January, 2025.")
|
| 75 |
+
c.setFont("Helvetica-Bold", 10)
|
| 76 |
+
c.drawString(50, y - 120, "By Order")
|
| 77 |
+
c.drawString(50, y - 140, "Office Superintendent")
|
| 78 |
+
c.drawString(50, y - 160, f"{data['court_name']}")
|
| 79 |
|
| 80 |
# Save the PDF
|
| 81 |
c.save()
|
| 82 |
return pdf_file
|
| 83 |
|
| 84 |
+
|
| 85 |
# Streamlit App
|
| 86 |
st.title("Court Order Generator")
|
| 87 |
|
| 88 |
# User Inputs
|
| 89 |
+
court_option = st.radio("Select Court Option", ["Select from List", "Enter Manually"])
|
| 90 |
+
|
| 91 |
+
if court_option == "Select from List":
|
| 92 |
+
court_name = st.selectbox("Select Court", ["Supreme Court of Pakistan", "High Court"] + cities)
|
| 93 |
+
else:
|
| 94 |
+
court_name = st.text_input("Enter Court Name Manually")
|
| 95 |
+
|
| 96 |
city = st.selectbox("Select City", cities)
|
| 97 |
case_no = st.text_input("Case Number")
|
| 98 |
+
date = st.text_input("Date (e.g., 02-01-2025)")
|
| 99 |
police_station = st.text_input("Police Station Name")
|
| 100 |
case_name = st.text_input("Case Details/Name")
|
| 101 |
+
order_date = st.text_input("Order Date (e.g., 02-01-2025)")
|
| 102 |
surety = st.number_input("Surety Amount (Rs.)", min_value=0, step=500)
|
| 103 |
+
next_date = st.text_input("Next Hearing Date (e.g., 08-01-2025)")
|
| 104 |
+
time = st.text_input("Hearing Time (e.g., 08:30 AM)")
|
| 105 |
accused_name = st.text_input("Applicant/Accused Name")
|
| 106 |
|
| 107 |
# Generate PDF Button
|