fix: [esign] 운영서버 PDF 미리보기 필드값 누락 수정
- TCPDF K_PATH_FONTS를 storage/fonts/tcpdf/로 설정하여 vendor 쓰기 권한 문제 해결 - 사전 생성된 Pretendard 폰트 정의 파일 포함 (런타임 생성 불필요) - downloadDocument() 에러 로깅 상세화 (trace 포함)
This commit is contained in:
@@ -665,7 +665,11 @@ public function downloadDocument(string $token): StreamedResponse|JsonResponse
|
||||
$pdfService = new PdfSignatureService;
|
||||
$filePath = $pdfService->generatePreview($contract);
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('미리보기 PDF 생성 실패, 원본 제공', ['error' => $e->getMessage()]);
|
||||
Log::error('미리보기 PDF 생성 실패, 원본 제공', [
|
||||
'contract_id' => $contract->id,
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString(),
|
||||
]);
|
||||
$filePath = $contract->original_file_path;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,21 @@ class PdfSignatureService
|
||||
{
|
||||
private ?string $koreanFontName = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// TCPDF 클래스 로드 전에 K_PATH_FONTS를 쓰기 가능한 디렉토리로 설정
|
||||
// (운영서버에서 vendor/tecnickcom/tcpdf/fonts/ 쓰기 권한 없는 문제 방지)
|
||||
if (! defined('K_PATH_FONTS')) {
|
||||
$tcpdfFontsDir = dirname(__DIR__, 3).'/storage/fonts/tcpdf/';
|
||||
if (is_dir($tcpdfFontsDir)) {
|
||||
define('K_PATH_FONTS', $tcpdfFontsDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pretendard 한글 폰트를 등록하고 폰트 이름을 반환한다.
|
||||
* PDF 문서와 동일한 폰트로 필드 텍스트를 렌더링하여 일관성을 유지한다.
|
||||
* 사전 생성된 폰트 정의 파일이 storage/fonts/tcpdf/에 있으면 바로 사용한다.
|
||||
*/
|
||||
private function getKoreanFont(): string
|
||||
{
|
||||
@@ -22,11 +34,21 @@ private function getKoreanFont(): string
|
||||
return $this->koreanFontName;
|
||||
}
|
||||
|
||||
// 1순위: 프로젝트 내장 Pretendard (로컬/서버 공통)
|
||||
$fontPath = storage_path('fonts/Pretendard-Regular.ttf');
|
||||
// 사전 생성된 폰트 정의 파일이 K_PATH_FONTS에 있으면 바로 사용
|
||||
if (defined('K_PATH_FONTS') && file_exists(K_PATH_FONTS.'pretendard.php')) {
|
||||
$this->koreanFontName = 'pretendard';
|
||||
|
||||
return $this->koreanFontName;
|
||||
}
|
||||
|
||||
// 폴백: TTF에서 런타임 생성 시도
|
||||
$fontPath = storage_path('fonts/Pretendard-Regular.ttf');
|
||||
if (file_exists($fontPath)) {
|
||||
$this->koreanFontName = \TCPDF_FONTS::addTTFfont($fontPath, 'TrueTypeUnicode', '', 96);
|
||||
try {
|
||||
$this->koreanFontName = \TCPDF_FONTS::addTTFfont($fontPath, 'TrueTypeUnicode', '', 96);
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('TCPDF 한글 폰트 등록 실패', ['error' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->koreanFontName ?: 'helvetica';
|
||||
|
||||
13
storage/fonts/tcpdf/helvetica.php
Normal file
13
storage/fonts/tcpdf/helvetica.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
// TCPDF FONT FILE DESCRIPTION
|
||||
$type='core';
|
||||
$name='Helvetica';
|
||||
$up=-100;
|
||||
$ut=50;
|
||||
$dw=513;
|
||||
$diff='';
|
||||
$enc='';
|
||||
$desc=array('Flags'=>32,'FontBBox'=>'[-166 -225 1000 931]','ItalicAngle'=>0,'Ascent'=>931,'Descent'=>-225,'Leading'=>0,'CapHeight'=>718,'XHeight'=>523,'StemV'=>88,'StemH'=>76,'AvgWidth'=>513,'MaxWidth'=>1015,'MissingWidth'=>513);
|
||||
$cw=array(0=>500,1=>500,2=>500,3=>500,4=>500,5=>500,6=>500,7=>500,8=>500,9=>500,10=>500,11=>500,12=>500,13=>500,14=>500,15=>500,16=>500,17=>500,18=>500,19=>500,20=>500,21=>500,22=>500,23=>500,24=>500,25=>500,26=>500,27=>500,28=>500,29=>500,30=>500,31=>500,32=>278,33=>278,34=>355,35=>556,36=>556,37=>889,38=>667,39=>191,40=>333,41=>333,42=>389,43=>584,44=>278,45=>333,46=>278,47=>278,48=>556,49=>556,50=>556,51=>556,52=>556,53=>556,54=>556,55=>556,56=>556,57=>556,58=>278,59=>278,60=>584,61=>584,62=>584,63=>556,64=>1015,65=>667,66=>667,67=>722,68=>722,69=>667,70=>611,71=>778,72=>722,73=>278,74=>500,75=>667,76=>556,77=>833,78=>722,79=>778,80=>667,81=>778,82=>722,83=>667,84=>611,85=>722,86=>667,87=>944,88=>667,89=>667,90=>611,91=>278,92=>278,93=>277,94=>469,95=>556,96=>333,97=>556,98=>556,99=>500,100=>556,101=>556,102=>278,103=>556,104=>556,105=>222,106=>222,107=>500,108=>222,109=>833,110=>556,111=>556,112=>556,113=>556,114=>333,115=>500,116=>278,117=>556,118=>500,119=>722,120=>500,121=>500,122=>500,123=>334,124=>260,125=>334,126=>584,127=>500,128=>655,129=>500,130=>222,131=>278,132=>333,133=>1000,134=>556,135=>556,136=>333,137=>1000,138=>667,139=>250,140=>1000,141=>500,142=>611,143=>500,144=>500,145=>222,146=>221,147=>333,148=>333,149=>350,150=>556,151=>1000,152=>333,153=>1000,154=>500,155=>250,156=>938,157=>500,158=>500,159=>667,160=>278,161=>278,162=>556,163=>556,164=>556,165=>556,166=>260,167=>556,168=>333,169=>737,170=>370,171=>448,172=>584,173=>333,174=>737,175=>333,176=>606,177=>584,178=>350,179=>350,180=>333,181=>556,182=>537,183=>278,184=>333,185=>350,186=>365,187=>448,188=>869,189=>869,190=>879,191=>556,192=>667,193=>667,194=>667,195=>667,196=>667,197=>667,198=>1000,199=>722,200=>667,201=>667,202=>667,203=>667,204=>278,205=>278,206=>278,207=>278,208=>722,209=>722,210=>778,211=>778,212=>778,213=>778,214=>778,215=>584,216=>778,217=>722,218=>722,219=>722,220=>722,221=>667,222=>666,223=>611,224=>556,225=>556,226=>556,227=>556,228=>556,229=>556,230=>896,231=>500,232=>556,233=>556,234=>556,235=>556,236=>251,237=>251,238=>251,239=>251,240=>556,241=>556,242=>556,243=>556,244=>556,245=>556,246=>556,247=>584,248=>611,249=>556,250=>556,251=>556,252=>556,253=>500,254=>555,255=>500);
|
||||
|
||||
// --- EOF ---
|
||||
BIN
storage/fonts/tcpdf/pretendard.ctg.z
Normal file
BIN
storage/fonts/tcpdf/pretendard.ctg.z
Normal file
Binary file not shown.
15
storage/fonts/tcpdf/pretendard.php
Normal file
15
storage/fonts/tcpdf/pretendard.php
Normal file
File diff suppressed because one or more lines are too long
BIN
storage/fonts/tcpdf/pretendard.z
Normal file
BIN
storage/fonts/tcpdf/pretendard.z
Normal file
Binary file not shown.
Reference in New Issue
Block a user