Skip to content

Commit 432422f

Browse files
committed
fix(PhpNativeHandler): reduce line height to 1.0 to match JSignPdf spacing
JSignPdf renders description text with baseline-to-baseline equal to the font size (leading factor 1.0). PhpNative was using 1.2, producing 20% extra space between lines and a visually inconsistent stamp. Set the factor to 1.0 for both the description block and the signer-name block. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 6db83c3 commit 432422f

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/Handler/SignEngine/PhpNativeHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ private function buildXObject(int $width, int $height, string $renderMode): Sign
275275
$parsed = trim((string)($textData['parsed'] ?? ''));
276276

277277
$descFontSize = (float)($textData['templateFontSize'] ?? $this->signatureTextService->getTemplateFontSize());
278-
$descLineHeight = $descFontSize * 1.2;
278+
$descLineHeight = $descFontSize * 1.0;
279279
$leftPadding = max(2.0, $descFontSize * 0.15);
280280

281281
$isDescriptionOnly = $renderMode === SignerElementsService::RENDER_MODE_DESCRIPTION_ONLY;
@@ -295,7 +295,7 @@ private function buildXObject(int $width, int $height, string $renderMode): Sign
295295
$leftHalfW = (float)$width / 2.0;
296296
$nameLines = $this->wrapTextForPdf($commonName, $leftHalfW - $leftPadding * 2, $nameFontSize);
297297
$nameLineCount = count($nameLines);
298-
$totalNameHeight = $nameLineCount * $nameFontSize * 1.2;
298+
$totalNameHeight = $nameLineCount * $nameFontSize * 1.0;
299299
$nameStartY = ((float)$height + $totalNameHeight) / 2.0 - $nameFontSize;
300300
$nameStartY = max(0.0, $nameStartY);
301301
$nameY = $nameStartY;
@@ -310,7 +310,7 @@ private function buildXObject(int $width, int $height, string $renderMode): Sign
310310
$stream .= sprintf("%.2F %.2F Td\n", $nameX, $nameY);
311311
$stream .= sprintf("(%s) Tj\n", $escaped);
312312
$stream .= "ET\n";
313-
$nameY -= $nameFontSize * 1.2;
313+
$nameY -= $nameFontSize * 1.0;
314314
}
315315
}
316316
}

0 commit comments

Comments
 (0)