Skip to content

A free open source IT asset/license management system

applied to TZe_24mm_E

Godfrey M02c237404e85
diff --git a/app/Models/Labels/Tapes/Brother/TZe_241.php b/app/Models/Labels/Tapes/Brother/TZe_241.php
index b360099a97..97e0fbe542 100644
--- a/app/Models/Labels/Tapes/Brother/TZe_241.php
+++ b/app/Models/Labels/Tapes/Brother/TZe_241.php
@@ -57,8 +57,6 @@ class TZe_241 extends TZe_18mm
$fields = $record->get('fields') ?? [];
- $fieldCount = count($fields);
-
$field_layout = Helper::labelFieldLayoutScaling(
pdf: $pdf,
fields: $fields,
diff --git a/app/Models/Labels/Tapes/Brother/TZe_24mm_E.php b/app/Models/Labels/Tapes/Brother/TZe_24mm_E.php
index 6035f7640e..dbb2897ed0 100644
--- a/app/Models/Labels/Tapes/Brother/TZe_24mm_E.php
+++ b/app/Models/Labels/Tapes/Brother/TZe_24mm_E.php
@@ -2,6 +2,8 @@
namespace App\Models\Labels\Tapes\Brother;
+use App\Helpers\Helper;
+
class TZe_24mm_E extends TZe_24mm
{
private const BARCODE_MARGIN = 1.75;
@@ -71,49 +73,39 @@ class TZe_24mm_E extends TZe_24mm
}
$fields = $record->get('fields');
- // Figure out how tall the label fields wants to be
- $fieldCount = count($fields);
- $perFieldHeight = (self::LABEL_SIZE + self::LABEL_MARGIN)
- + (self::FIELD_SIZE + self::FIELD_MARGIN);
-
- $baseHeight = $fieldCount * $perFieldHeight;
- // If it doesn't fit in the available height, scale everything down
- $scale = 1.0;
- if ($baseHeight > $usableHeight && $baseHeight > 0) {
- $scale = $usableHeight / $baseHeight;
- }
-
- $labelSize = self::LABEL_SIZE * $scale;
- $fieldSize = self::FIELD_SIZE * $scale;
- $fieldMargin = self::FIELD_MARGIN * $scale;
-
- foreach ($fields as $field) {
- // Write label and value on the same line
- // Calculate label width with proportional character spacing
- $labelWidth = $pdf->GetStringWidth($field['label'], 'freesans', '', $labelSize);
- $charCount = strlen($field['label']);
- $spacingPerChar = 0.5;
- $totalSpacing = $charCount * $spacingPerChar;
- $adjustedWidth = $labelWidth + $totalSpacing;
-
- static::writeText(
- $pdf, $field['label'],
- $currentX, $currentY,
- 'freesans', 'B', $labelSize, 'L',
- $adjustedWidth, $labelSize, true, 0, $spacingPerChar
- );
-
- static::writeText(
- $pdf, $field['value'],
- $currentX + $adjustedWidth + 2, $currentY,
- 'freesans', 'B', $fieldSize, 'L',
- $usableWidth - $adjustedWidth - 2, $fieldSize, true, 0, 0.3
- );
- $currentY += max($labelSize, $fieldSize) +$fieldMargin;
- }
+ $field_layout = Helper::labelFieldLayoutScaling(
+ pdf: $pdf,
+ fields: $fields,
+ currentX: $currentX,
+ usableWidth: $usableWidth,
+ usableHeight: $usableHeight,
+ baseLabelSize: self::LABEL_SIZE,
+ baseFieldSize: self::FIELD_SIZE,
+ baseFieldMargin: self::FIELD_MARGIN,
+ baseLabelPadding: 1.5,
+ baseGap: 1.5,
+ maxScale: 1.8,
+ labelFont: 'freesans',
+ );
+
+ foreach ($fields as $field) {
+ static::writeText(
+ $pdf, $field['label'],
+ $currentX, $currentY,
+ 'freesans', '', $field_layout['labelSize'], 'L',
+ $field_layout['labelWidth'], $field_layout['rowAdvance'], true, 0
+ );
+
+ static::writeText(
+ $pdf, $field['value'],
+ $field_layout['valueX'], $currentY,
+ 'freemono', 'B', $field_layout['fieldSize'], 'L',
+ $field_layout['valueWidth'], $field_layout['rowAdvance'], true, 0, 0.01
+ );
+ $currentY += $field_layout['rowAdvance'];
+ }
-
if ($record->has('barcode1d')) {
static::write1DBarcode(
$pdf, $record->get('barcode1d')->content, $record->get('barcode1d')->type,