Yaswanth56 commited on
Commit
2d3085d
·
verified ·
1 Parent(s): f768b0c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -15
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(72, height - 72, "Drone Survey Analysis Report")
 
55
  c.showPage() # Create a new page
56
 
57
  # Add Summary Text (New Page)
58
  c.setFont("Helvetica", 12)
59
- c.drawString(72, height - 72, "Summary:")
60
- c.drawString(72, height - 92, summary)
 
 
61
  c.showPage() # Create a new page
62
 
63
  # Add Logs for Top 5 Images (New Page)
64
- c.drawString(72, height - 72, "Log Results for Top 5 Images:")
65
- y_position = height - 92
66
  for log in log_results[:5]: # Display top 5 logs
67
- c.drawString(72, y_position, log)
68
- y_position -= 15
 
69
  c.showPage() # Create a new page
70
 
71
  # Add Screenshots (Top 5 Images) (New Page)
72
- c.drawString(72, y_position - 20, "Incident Screenshots:")
73
- y_position -= 40
74
  for screenshot in screenshots[:5]: # Limit to the top 5 images
75
- c.drawImage(screenshot, 72, y_position, width=150, height=100)
76
- y_position -= 120
 
77
  c.showPage() # Create a new page
78
 
79
  # Add Chart Image (New Page)
80
- c.drawString(72, y_position - 20, "Detection Trend Chart:")
81
- c.drawImage(chart_path, 72, y_position - 100, width=400, height=300)
 
82
  c.showPage() # Create a new page
83
 
84
  # Add Map Image (New Page)
85
- c.drawString(72, y_position - 140, "Issue Locations Map:")
86
- c.drawImage(map_path, 72, y_position - 240, width=400, height=300)
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