debug: add watermark debug logging
This commit is contained in:
@@ -272,7 +272,10 @@ def generate_pdf(plan_id, student_name, content, output_dir, rendered_report=Non
|
|||||||
|
|
||||||
# 水印函数(每页都绘制)
|
# 水印函数(每页都绘制)
|
||||||
def draw_watermark(c, doc):
|
def draw_watermark(c, doc):
|
||||||
if not watermark_text or not CHINESE_FONT_OK:
|
if not watermark_text:
|
||||||
|
return
|
||||||
|
if not CHINESE_FONT_OK:
|
||||||
|
print(f"[WATERMARK] Skipping watermark - CHINESE_FONT_OK=False, FONT_PATH={FONT_PATH}")
|
||||||
return
|
return
|
||||||
c.saveState()
|
c.saveState()
|
||||||
try:
|
try:
|
||||||
@@ -284,8 +287,9 @@ def generate_pdf(plan_id, student_name, content, output_dir, rendered_report=Non
|
|||||||
c.rotate(45)
|
c.rotate(45)
|
||||||
# 绘制水印文字(居中)
|
# 绘制水印文字(居中)
|
||||||
c.drawCentredString(0, 0, watermark_text)
|
c.drawCentredString(0, 0, watermark_text)
|
||||||
except Exception:
|
print(f"[WATERMARK] Drawn: {watermark_text}")
|
||||||
pass # 字体问题则跳过水印
|
except Exception as e:
|
||||||
|
print(f"[WATERMARK] Error: {e}")
|
||||||
c.restoreState()
|
c.restoreState()
|
||||||
|
|
||||||
doc.build(pdf.elements, onFirstPage=draw_watermark, onLaterPages=draw_watermark)
|
doc.build(pdf.elements, onFirstPage=draw_watermark, onLaterPages=draw_watermark)
|
||||||
|
|||||||
Reference in New Issue
Block a user