fix: remove trailing spacers before PDF build to avoid blank last page
This commit is contained in:
@@ -278,7 +278,7 @@ def generate_pdf(plan_id, student_name, content, output_dir, rendered_report=Non
|
|||||||
return
|
return
|
||||||
c.saveState()
|
c.saveState()
|
||||||
try:
|
try:
|
||||||
c.setFont("Chinese", 14)
|
c.setFont("Chinese", 56)
|
||||||
# 浅灰色半透明
|
# 浅灰色半透明
|
||||||
c.setFillColor(colors.Color(0.6, 0.6, 0.6, alpha=0.25))
|
c.setFillColor(colors.Color(0.6, 0.6, 0.6, alpha=0.25))
|
||||||
# 旋转45度
|
# 旋转45度
|
||||||
@@ -290,5 +290,9 @@ def generate_pdf(plan_id, student_name, content, output_dir, rendered_report=Non
|
|||||||
pass
|
pass
|
||||||
c.restoreState()
|
c.restoreState()
|
||||||
|
|
||||||
|
# 移除末尾的空白元素(避免产生多余空白页)
|
||||||
|
while pdf.elements and isinstance(pdf.elements[-1], Spacer):
|
||||||
|
pdf.elements.pop()
|
||||||
|
|
||||||
doc.build(pdf.elements, onFirstPage=draw_watermark, onLaterPages=draw_watermark)
|
doc.build(pdf.elements, onFirstPage=draw_watermark, onLaterPages=draw_watermark)
|
||||||
return output_path
|
return output_path
|
||||||
@@ -8,5 +8,6 @@
|
|||||||
"model": "MiniMax-M2.7-highspeed",
|
"model": "MiniMax-M2.7-highspeed",
|
||||||
"temperature": 0.1,
|
"temperature": 0.1,
|
||||||
"prompt_template": "",
|
"prompt_template": "",
|
||||||
"api_key": "sk-cp-Mj6FHASGAcdc1IhpetY7z4lXCgbkoGAkMbViODPHiVdC-NerbqKRW8ZTCuFliDA9JukoB56ILEYUhDKH2QUJq-xt1ZYNStQ-HNgjRvXIq0H4gOgoxy26xuA"
|
"api_key": "sk-cp-Mj6FHASGAcdc1IhpetY7z4lXCgbkoGAkMbViODPHiVdC-NerbqKRW8ZTCuFliDA9JukoB56ILEYUhDKH2QUJq-xt1ZYNStQ-HNgjRvXIq0H4gOgoxy26xuA",
|
||||||
|
"watermark_text": "有音教育·艺超音乐培训"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user