fix: remove trailing spacers before PDF build to avoid blank last page

This commit is contained in:
hmo
2026-04-27 21:19:35 +08:00
parent 0898e2da8f
commit 8ae7def939
2 changed files with 7 additions and 2 deletions
+5 -1
View File
@@ -278,7 +278,7 @@ def generate_pdf(plan_id, student_name, content, output_dir, rendered_report=Non
return
c.saveState()
try:
c.setFont("Chinese", 14)
c.setFont("Chinese", 56)
# 浅灰色半透明
c.setFillColor(colors.Color(0.6, 0.6, 0.6, alpha=0.25))
# 旋转45度
@@ -290,5 +290,9 @@ def generate_pdf(plan_id, student_name, content, output_dir, rendered_report=Non
pass
c.restoreState()
# 移除末尾的空白元素(避免产生多余空白页)
while pdf.elements and isinstance(pdf.elements[-1], Spacer):
pdf.elements.pop()
doc.build(pdf.elements, onFirstPage=draw_watermark, onLaterPages=draw_watermark)
return output_path
+2 -1
View File
@@ -8,5 +8,6 @@
"model": "MiniMax-M2.7-highspeed",
"temperature": 0.1,
"prompt_template": "",
"api_key": "sk-cp-Mj6FHASGAcdc1IhpetY7z4lXCgbkoGAkMbViODPHiVdC-NerbqKRW8ZTCuFliDA9JukoB56ILEYUhDKH2QUJq-xt1ZYNStQ-HNgjRvXIq0H4gOgoxy26xuA"
"api_key": "sk-cp-Mj6FHASGAcdc1IhpetY7z4lXCgbkoGAkMbViODPHiVdC-NerbqKRW8ZTCuFliDA9JukoB56ILEYUhDKH2QUJq-xt1ZYNStQ-HNgjRvXIq0H4gOgoxy26xuA",
"watermark_text": "有音教育·艺超音乐培训"
}