curlkun commited on
Commit
09a7ec9
·
verified ·
1 Parent(s): 4fd6763

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -348,22 +348,23 @@ def add_no_diff_stamp_pdf(page):
348
  rect = fitz.Rect(rect_x, rect_y, rect_x + rect_w, rect_y + rect_h)
349
  page.draw_rect(rect, color=(1, 0, 0), width=1.5)
350
  try:
351
- # 「差異無し」センタリング(12pt ≒ 7px/文字 × 4文字 = 28px)
352
  text1_w = 4 * 12
 
353
  text2_w = len(ts) * 5
354
  page.insert_text(
355
- (rect_x + (rect_w - text1_w) / 2, rect_y + 14), "差異無し",
356
  fontfile=FONT_PATH, fontname=FONT_NAME,
357
  fontsize=12, color=(1, 0, 0),
358
  )
359
  page.insert_text(
360
- (rect_x + (rect_w - text2_w) / 2, rect_y + 28), ts,
361
  fontfile=FONT_PATH, fontname=FONT_NAME,
362
  fontsize=8, color=(1, 0, 0),
363
  )
364
  except Exception:
365
- page.insert_text((rect_x + 5, rect_y + 14), "NO DIFF", fontsize=12, color=(1, 0, 0))
366
- page.insert_text((rect_x + 5, rect_y + 28), ts, fontsize=8, color=(1, 0, 0))
367
 
368
  # ------------------------------------------------------------------ #
369
  # 左右見開きPDF生成
 
348
  rect = fitz.Rect(rect_x, rect_y, rect_x + rect_w, rect_y + rect_h)
349
  page.draw_rect(rect, color=(1, 0, 0), width=1.5)
350
  try:
351
+ # 「差異無し」センタリング
352
  text1_w = 4 * 12
353
+ # タイムスタンプ:センタリング位置から2文字分(8pt×2=16px)右にオフセット
354
  text2_w = len(ts) * 5
355
  page.insert_text(
356
+ (rect_x + (rect_w - text1_w) / 2, rect_y + 16), "差異無し",
357
  fontfile=FONT_PATH, fontname=FONT_NAME,
358
  fontsize=12, color=(1, 0, 0),
359
  )
360
  page.insert_text(
361
+ (rect_x + (rect_w - text2_w) / 2 + 16, rect_y + 30), ts,
362
  fontfile=FONT_PATH, fontname=FONT_NAME,
363
  fontsize=8, color=(1, 0, 0),
364
  )
365
  except Exception:
366
+ page.insert_text((rect_x + 5, rect_y + 16), "NO DIFF", fontsize=12, color=(1, 0, 0))
367
+ page.insert_text((rect_x + 5, rect_y + 30), ts, fontsize=8, color=(1, 0, 0))
368
 
369
  # ------------------------------------------------------------------ #
370
  # 左右見開きPDF生成