husseinelsaadi commited on
Commit
8330d5a
·
1 Parent(s): cb47676
backend/services/report_generator.py CHANGED
@@ -348,7 +348,7 @@ def create_pdf_report(report_text: str) -> BytesIO:
348
  qa = report_data['qa_log'][i]
349
 
350
  # Check if we have space
351
- if y_pos < BOTTOM_MARGIN + 2:
352
  break
353
 
354
  # Question
@@ -385,10 +385,16 @@ def create_pdf_report(report_text: str) -> BytesIO:
385
  plt.close(fig)
386
 
387
  # === PAGE 2: REMAINING TRANSCRIPT ===
388
- if report_data['qa_log'] and len(report_data['qa_log']) > 3:
389
- _create_transcript_page(pdf, report_data['qa_log'][3:], A4_WIDTH, A4_HEIGHT,
390
- LEFT_MARGIN, RIGHT_MARGIN, TOP_MARGIN, BOTTOM_MARGIN,
391
- ACCENT_COLOR, TEXT_COLOR, start_index=4)
 
 
 
 
 
 
392
 
393
  buffer.seek(0)
394
  return buffer
 
348
  qa = report_data['qa_log'][i]
349
 
350
  # Check if we have space
351
+ if y_pos < BOTTOM_MARGIN + 2.2:
352
  break
353
 
354
  # Question
 
385
  plt.close(fig)
386
 
387
  # === PAGE 2: REMAINING TRANSCRIPT ===
388
+ if report_data['qa_log'] and len(report_data['qa_log']) > max_qa_on_page1:
389
+ _create_transcript_page(
390
+ pdf,
391
+ report_data['qa_log'][max_qa_on_page1:], # Continue from the next unanswered question
392
+ A4_WIDTH, A4_HEIGHT,
393
+ LEFT_MARGIN, RIGHT_MARGIN, TOP_MARGIN, BOTTOM_MARGIN,
394
+ ACCENT_COLOR, TEXT_COLOR,
395
+ start_index=max_qa_on_page1 + 1 # Correct numbering
396
+ )
397
+
398
 
399
  buffer.seek(0)
400
  return buffer