Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -49,41 +49,53 @@ def generate_pdf_report(summary: str, screenshots: List[str], log_results: List[
|
|
| 49 |
c = canvas.Canvas(pdf_path, pagesize=letter)
|
| 50 |
width, height = letter
|
| 51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
# Title Page
|
| 53 |
c.setFont("Helvetica", 16)
|
| 54 |
-
c.drawString(
|
|
|
|
| 55 |
c.showPage() # Create a new page
|
| 56 |
|
| 57 |
# Add Summary Text (New Page)
|
| 58 |
c.setFont("Helvetica", 12)
|
| 59 |
-
c.drawString(
|
| 60 |
-
|
|
|
|
|
|
|
| 61 |
c.showPage() # Create a new page
|
| 62 |
|
| 63 |
# Add Logs for Top 5 Images (New Page)
|
| 64 |
-
c.drawString(
|
| 65 |
-
y_position
|
| 66 |
for log in log_results[:5]: # Display top 5 logs
|
| 67 |
-
c.drawString(
|
| 68 |
-
y_position -=
|
|
|
|
| 69 |
c.showPage() # Create a new page
|
| 70 |
|
| 71 |
# Add Screenshots (Top 5 Images) (New Page)
|
| 72 |
-
c.drawString(
|
| 73 |
-
y_position -=
|
| 74 |
for screenshot in screenshots[:5]: # Limit to the top 5 images
|
| 75 |
-
c.drawImage(screenshot,
|
| 76 |
-
y_position -= 120
|
|
|
|
| 77 |
c.showPage() # Create a new page
|
| 78 |
|
| 79 |
# Add Chart Image (New Page)
|
| 80 |
-
c.drawString(
|
| 81 |
-
c.drawImage(chart_path,
|
|
|
|
| 82 |
c.showPage() # Create a new page
|
| 83 |
|
| 84 |
# Add Map Image (New Page)
|
| 85 |
-
c.drawString(
|
| 86 |
-
c.drawImage(map_path,
|
| 87 |
|
| 88 |
c.save()
|
| 89 |
|
|
|
|
| 49 |
c = canvas.Canvas(pdf_path, pagesize=letter)
|
| 50 |
width, height = letter
|
| 51 |
|
| 52 |
+
# Set starting position for content
|
| 53 |
+
margin_left = 72
|
| 54 |
+
margin_top = height - 72
|
| 55 |
+
line_height = 14 # Height of each line of text
|
| 56 |
+
y_position = margin_top
|
| 57 |
+
|
| 58 |
# Title Page
|
| 59 |
c.setFont("Helvetica", 16)
|
| 60 |
+
c.drawString(margin_left, y_position, "Drone Survey Analysis Report")
|
| 61 |
+
y_position -= 30 # Space below the title
|
| 62 |
c.showPage() # Create a new page
|
| 63 |
|
| 64 |
# Add Summary Text (New Page)
|
| 65 |
c.setFont("Helvetica", 12)
|
| 66 |
+
c.drawString(margin_left, y_position, "Summary:")
|
| 67 |
+
y_position -= line_height
|
| 68 |
+
c.drawString(margin_left, y_position, summary)
|
| 69 |
+
y_position -= 20 # Space after summary
|
| 70 |
c.showPage() # Create a new page
|
| 71 |
|
| 72 |
# Add Logs for Top 5 Images (New Page)
|
| 73 |
+
c.drawString(margin_left, y_position, "Log Results for Top 5 Images:")
|
| 74 |
+
y_position -= line_height
|
| 75 |
for log in log_results[:5]: # Display top 5 logs
|
| 76 |
+
c.drawString(margin_left, y_position, log)
|
| 77 |
+
y_position -= line_height
|
| 78 |
+
y_position -= 20 # Space after logs
|
| 79 |
c.showPage() # Create a new page
|
| 80 |
|
| 81 |
# Add Screenshots (Top 5 Images) (New Page)
|
| 82 |
+
c.drawString(margin_left, y_position, "Incident Screenshots:")
|
| 83 |
+
y_position -= line_height
|
| 84 |
for screenshot in screenshots[:5]: # Limit to the top 5 images
|
| 85 |
+
c.drawImage(screenshot, margin_left, y_position, width=150, height=100)
|
| 86 |
+
y_position -= 120 # Space after each image
|
| 87 |
+
y_position -= 20 # Space after images
|
| 88 |
c.showPage() # Create a new page
|
| 89 |
|
| 90 |
# Add Chart Image (New Page)
|
| 91 |
+
c.drawString(margin_left, y_position, "Detection Trend Chart:")
|
| 92 |
+
c.drawImage(chart_path, margin_left, y_position - 100, width=400, height=300)
|
| 93 |
+
y_position -= 300 # Space after chart
|
| 94 |
c.showPage() # Create a new page
|
| 95 |
|
| 96 |
# Add Map Image (New Page)
|
| 97 |
+
c.drawString(margin_left, y_position, "Issue Locations Map:")
|
| 98 |
+
c.drawImage(map_path, margin_left, y_position - 100, width=400, height=300)
|
| 99 |
|
| 100 |
c.save()
|
| 101 |
|