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):
|
||||
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
|
||||
c.saveState()
|
||||
try:
|
||||
@@ -284,8 +287,9 @@ def generate_pdf(plan_id, student_name, content, output_dir, rendered_report=Non
|
||||
c.rotate(45)
|
||||
# 绘制水印文字(居中)
|
||||
c.drawCentredString(0, 0, watermark_text)
|
||||
except Exception:
|
||||
pass # 字体问题则跳过水印
|
||||
print(f"[WATERMARK] Drawn: {watermark_text}")
|
||||
except Exception as e:
|
||||
print(f"[WATERMARK] Error: {e}")
|
||||
c.restoreState()
|
||||
|
||||
doc.build(pdf.elements, onFirstPage=draw_watermark, onLaterPages=draw_watermark)
|
||||
|
||||
Reference in New Issue
Block a user