fix:E-Sign PDF 폰트 크기 2배 확대, 왼쪽 정렬 기본값, 서명자 매핑 수정

- PdfSignatureService: 자동 폰트 크기 공식 2배(h*0.7→h*1.4), 기본 정렬 C→L
- text_align 필드 추가 (L/C/R 정렬 선택 가능)
- store()/buildVariableMap(): sign_order→role 기반 매핑으로 변경
  (signer_order 1=creator/갑/회사, 2=counterpart/을/파트너)
- template-fields: 가로 정렬 버튼 UI 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
김보곤
2026-02-13 18:07:31 +09:00
parent d5283099c4
commit 843e898f5f
5 changed files with 41 additions and 14 deletions

View File

@@ -168,7 +168,7 @@ private function overlayDate(Fpdi $pdf, EsignSignField $field, float $x, float $
$dateText = now()->format('Y-m-d');
}
$this->renderText($pdf, $dateText, $x, $y, $w, $h, $field->font_size);
$this->renderText($pdf, $dateText, $x, $y, $w, $h, $field->font_size, $field->text_align ?? 'L');
}
/**
@@ -181,7 +181,7 @@ private function overlayText(Fpdi $pdf, EsignSignField $field, float $x, float $
return;
}
$this->renderText($pdf, $text, $x, $y, $w, $h, $field->font_size);
$this->renderText($pdf, $text, $x, $y, $w, $h, $field->font_size, $field->text_align ?? 'L');
}
/**
@@ -193,29 +193,30 @@ private function overlayCheckbox(Fpdi $pdf, EsignSignField $field, float $x, flo
return;
}
$this->renderText($pdf, "\xe2\x9c\x93", $x, $y, $w, $h, $field->font_size); // ✓ (UTF-8)
$this->renderText($pdf, "\xe2\x9c\x93", $x, $y, $w, $h, $field->font_size, 'C'); // ✓ (UTF-8)
}
/**
* 텍스트를 지정 영역에 렌더링하는 공통 메서드.
*/
private function renderText(Fpdi $pdf, string $text, float $x, float $y, float $w, float $h, ?int $fieldFontSize = null): void
private function renderText(Fpdi $pdf, string $text, float $x, float $y, float $w, float $h, ?int $fieldFontSize = null, string $textAlign = 'L'): void
{
// 필드에 지정된 폰트 크기 우선, 없으면 영역 높이 기반 자동 산출
// 필드에 지정된 폰트 크기 우선, 없으면 영역 높이 기반 자동 산출 (2배 확대)
if ($fieldFontSize && $fieldFontSize >= 4) {
$fontSize = $fieldFontSize;
} else {
$fontSize = min($h * 0.7, 12);
if ($fontSize < 4) {
$fontSize = 4;
$fontSize = min($h * 1.4, 24);
if ($fontSize < 6) {
$fontSize = 6;
}
}
$pdf->SetFont($this->getKoreanFont(), '', $fontSize);
$pdf->SetTextColor(0, 0, 0);
// 텍스트를 영역 중앙에 배치
// 텍스트를 지정된 정렬 방식으로 배치 (L=왼쪽, C=가운데, R=오른쪽)
$align = in_array($textAlign, ['L', 'C', 'R']) ? $textAlign : 'L';
$pdf->SetXY($x, $y);
$pdf->Cell($w, $h, $text, 0, 0, 'C', false, '', 0, false, 'T', 'M');
$pdf->Cell($w, $h, $text, 0, 0, $align, false, '', 0, false, 'T', 'M');
}
}