Added logic in sticker pdf service
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 17s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 21s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 24s
Laravel Pint / pint (pull_request) Successful in 2m43s
Laravel Larastan / larastan (pull_request) Failing after 5m28s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 17s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 21s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 24s
Laravel Pint / pint (pull_request) Successful in 2m43s
Laravel Larastan / larastan (pull_request) Failing after 5m28s
This commit is contained in:
@@ -1614,29 +1614,8 @@ class StickerPdfService
|
|||||||
$stickerHeight = (float) $template['height'];
|
$stickerHeight = (float) $template['height'];
|
||||||
$stickerId = $template['sticker_id'] ?? null;
|
$stickerId = $template['sticker_id'] ?? null;
|
||||||
|
|
||||||
// $gap = 5.0;
|
|
||||||
|
|
||||||
// $count = ($toSerial - $fromSerial) + 1;
|
|
||||||
|
|
||||||
// $totalHeight =
|
|
||||||
// ($stickerHeight * $count)
|
|
||||||
// +
|
|
||||||
// ($gap * ($count - 1));
|
|
||||||
|
|
||||||
$orientation = $stickerWidth > $stickerHeight ? 'L' : 'P';
|
$orientation = $stickerWidth > $stickerHeight ? 'L' : 'P';
|
||||||
|
|
||||||
// $pdf = new TCPDF(
|
|
||||||
// 'P',
|
|
||||||
// 'mm',
|
|
||||||
// [
|
|
||||||
// $stickerWidth,
|
|
||||||
// $stickerHeight
|
|
||||||
// ],
|
|
||||||
// true,
|
|
||||||
// 'UTF-8',
|
|
||||||
// false
|
|
||||||
// );
|
|
||||||
|
|
||||||
$pdf = new TCPDF($orientation, 'mm', [$stickerWidth, $stickerHeight], true, 'UTF-8', false);
|
$pdf = new TCPDF($orientation, 'mm', [$stickerWidth, $stickerHeight], true, 'UTF-8', false);
|
||||||
|
|
||||||
$pdf->setPrintHeader(false);
|
$pdf->setPrintHeader(false);
|
||||||
@@ -1714,6 +1693,18 @@ class StickerPdfService
|
|||||||
|
|
||||||
$pdf->SetFont($element['font'], '', $element['size']);
|
$pdf->SetFont($element['font'], '', $element['size']);
|
||||||
|
|
||||||
|
$font = $element['font'] ?? 'helvetica';
|
||||||
|
$fontSize = (float) ($element['size'] ?? 10);
|
||||||
|
|
||||||
|
// if (
|
||||||
|
// ($element['characteristics_type'] ?? '') == 'feed_address'
|
||||||
|
// && mb_strlen((string) $textValue) > 61
|
||||||
|
// ) {
|
||||||
|
// $fontSize = max(6, $fontSize - 2);
|
||||||
|
// }
|
||||||
|
|
||||||
|
$pdf->SetFont($font, '', $fontSize);
|
||||||
|
|
||||||
$x = (float) $element['x'];
|
$x = (float) $element['x'];
|
||||||
$y = $element['y'] + $currentY;
|
$y = $element['y'] + $currentY;
|
||||||
|
|
||||||
@@ -1737,7 +1728,22 @@ class StickerPdfService
|
|||||||
$x = $leftMargin;
|
$x = $leftMargin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if($stickerId == 'SelfPriming Monoblock Pump'){
|
||||||
|
$leftMargin = 10;
|
||||||
|
$rightMargin = 10;
|
||||||
|
|
||||||
|
$usableWidth = 85 - $leftMargin - $rightMargin; // 65mm
|
||||||
|
|
||||||
|
$textWidth = $pdf->GetStringWidth((string) $textValue);
|
||||||
|
|
||||||
|
// Center the address within the available width
|
||||||
|
$x = $leftMargin + (($usableWidth - $textWidth) / 2);
|
||||||
|
|
||||||
|
// Prevent the address from starting before the left margin
|
||||||
|
if ($textWidth > $usableWidth) {
|
||||||
|
$x = $leftMargin;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$pdf->Text($x, $y, (string) $textValue);
|
$pdf->Text($x, $y, (string) $textValue);
|
||||||
|
|||||||
Reference in New Issue
Block a user