From eba1f03363a2ee1dc37532a1552a1617d3ed373e Mon Sep 17 00:00:00 2001 From: aHVzY2g <25596663+aHVzY2g@users.noreply.github.com> Date: Fri, 3 Jan 2025 11:10:44 +0100 Subject: [PATCH 1/3] Added: TZe_24mm_D.php modified TZe_24mm_A that includes 1D code New label format for TZe_24mm that includes all fields of TZe_24mm_A with the addition of the 1D code at the bottom of the label. --- .../Labels/Tapes/Brother/TZe_24mm_D.php | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 app/Models/Labels/Tapes/Brother/TZe_24mm_D.php diff --git a/app/Models/Labels/Tapes/Brother/TZe_24mm_D.php b/app/Models/Labels/Tapes/Brother/TZe_24mm_D.php new file mode 100644 index 0000000000..5b18d7f9fb --- /dev/null +++ b/app/Models/Labels/Tapes/Brother/TZe_24mm_D.php @@ -0,0 +1,99 @@ +getPrintableArea(); + + $currentX = $pa->x1; + $currentY = $pa->y1; + $usableWidth = $pa->w; + + // Reserve space at bottom for 1D barcode + $usableHeight = $pa->h - self::BARCODE1D_SIZE; + $barcodeSize = $usableHeight - self::TAG_SIZE; + + if ($record->has('barcode2d')) { + static::writeText( + $pdf, $record->get('tag'), + $pa->x1, $pa->y2 - self::TAG_SIZE - self::BARCODE1D_SIZE, + 'freemono', 'b', self::TAG_SIZE, 'C', + $barcodeSize, self::TAG_SIZE, true, 0 + ); + static::write2DBarcode( + $pdf, $record->get('barcode2d')->content, $record->get('barcode2d')->type, + $currentX, $currentY, + $barcodeSize, $barcodeSize + ); + $currentX += $barcodeSize + self::BARCODE_MARGIN; + $usableWidth -= $barcodeSize + self::BARCODE_MARGIN; + } else { + static::writeText( + $pdf, $record->get('tag'), + $pa->x1, $pa->y2 - self::TAG_SIZE - self::BARCODE1D_SIZE, + 'freemono', 'b', self::TAG_SIZE, 'R', + $usableWidth, self::TAG_SIZE, true, 0 + ); + } + + if ($record->has('title')) { + static::writeText( + $pdf, $record->get('title'), + $currentX, $currentY, + 'freesans', '', self::TITLE_SIZE, 'L', + $usableWidth, self::TITLE_SIZE, true, 0 + ); + $currentY += self::TITLE_SIZE + self::TITLE_MARGIN; + } + + foreach ($record->get('fields') as $field) { + static::writeText( + $pdf, $field['label'], + $currentX, $currentY, + 'freesans', '', self::LABEL_SIZE, 'L', + $usableWidth, self::LABEL_SIZE, true, 0, 0 + ); + $currentY += self::LABEL_SIZE + self::LABEL_MARGIN; + + static::writeText( + $pdf, $field['value'], + $currentX, $currentY, + 'freemono', 'B', self::FIELD_SIZE, 'L', + $usableWidth, self::FIELD_SIZE, true, 0, 0.3 + ); + $currentY += self::FIELD_SIZE + self::FIELD_MARGIN; + } + + // Add C128 barcode at the bottom + if ($record->has('barcode1d')) { + static::write1DBarcode( + $pdf, $record->get('barcode1d')->content, $record->get('barcode1d')->type, + $pa->x1, $pa->y2 - self::BARCODE1D_SIZE, + $pa->w, self::BARCODE1D_SIZE + ); + } + } +} From 907f0553d4c146ac6cd27df8e6b6d1f2f139f0cd Mon Sep 17 00:00:00 2001 From: Marlon Spangenberg Date: Mon, 13 Jan 2025 12:14:30 +0100 Subject: [PATCH 2/3] moved label value into the same line, changed label font to freemono --- .../Labels/Tapes/Brother/TZe_24mm_D.php | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/app/Models/Labels/Tapes/Brother/TZe_24mm_D.php b/app/Models/Labels/Tapes/Brother/TZe_24mm_D.php index 5b18d7f9fb..947c23d5d4 100644 --- a/app/Models/Labels/Tapes/Brother/TZe_24mm_D.php +++ b/app/Models/Labels/Tapes/Brother/TZe_24mm_D.php @@ -10,8 +10,8 @@ class TZe_24mm_D extends TZe_24mm private const TITLE_MARGIN = 0.50; private const LABEL_SIZE = 2.00; private const LABEL_MARGIN = - 0.35; - private const FIELD_SIZE = 3.20; - private const FIELD_MARGIN = 0.15; + private const FIELD_SIZE = 2.00; + private const FIELD_MARGIN = 0.35; private const BARCODE1D_SIZE = 3.00; // Size for the C128 barcode at bottom public function getUnit() { return 'mm'; } @@ -19,7 +19,7 @@ class TZe_24mm_D extends TZe_24mm public function getSupportAssetTag() { return true; } public function getSupport1DBarcode() { return true; } public function getSupport2DBarcode() { return true; } - public function getSupportFields() { return 3; } + public function getSupportFields() { return 4; } public function getSupportLogo() { return false; } public function getSupportTitle() { return true; } @@ -70,21 +70,29 @@ class TZe_24mm_D extends TZe_24mm } foreach ($record->get('fields') as $field) { + // Write label and value on the same line + // Calculate label width with proportional character spacing + $labelWidth = $pdf->GetStringWidth($field['label'], 'freemono', '', self::LABEL_SIZE); + $charCount = strlen($field['label']); + $spacingPerChar = 0.5; + $totalSpacing = $charCount * $spacingPerChar; + $adjustedWidth = $labelWidth + $totalSpacing; + static::writeText( $pdf, $field['label'], $currentX, $currentY, - 'freesans', '', self::LABEL_SIZE, 'L', - $usableWidth, self::LABEL_SIZE, true, 0, 0 + 'freemono', 'B', self::LABEL_SIZE, 'L', + $adjustedWidth, self::LABEL_SIZE, true, 0, $spacingPerChar ); - $currentY += self::LABEL_SIZE + self::LABEL_MARGIN; static::writeText( $pdf, $field['value'], - $currentX, $currentY, + $currentX + $adjustedWidth + 2, $currentY, 'freemono', 'B', self::FIELD_SIZE, 'L', - $usableWidth, self::FIELD_SIZE, true, 0, 0.3 + $usableWidth - $adjustedWidth - 2, self::FIELD_SIZE, true, 0, 0.3 ); - $currentY += self::FIELD_SIZE + self::FIELD_MARGIN; + + $currentY += max(self::LABEL_SIZE, self::FIELD_SIZE) + self::FIELD_MARGIN; } // Add C128 barcode at the bottom From 0c4fc56b80a00c3f7e241ff1ac10863ad4c071f5 Mon Sep 17 00:00:00 2001 From: Marlon Spangenberg Date: Mon, 13 Jan 2025 12:20:56 +0100 Subject: [PATCH 3/3] increased label/field size to 2.5, reduced supported fields to 3 --- app/Models/Labels/Tapes/Brother/TZe_24mm_D.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Models/Labels/Tapes/Brother/TZe_24mm_D.php b/app/Models/Labels/Tapes/Brother/TZe_24mm_D.php index 947c23d5d4..5ecd86c977 100644 --- a/app/Models/Labels/Tapes/Brother/TZe_24mm_D.php +++ b/app/Models/Labels/Tapes/Brother/TZe_24mm_D.php @@ -8,9 +8,9 @@ class TZe_24mm_D extends TZe_24mm private const TAG_SIZE = 2.80; private const TITLE_SIZE = 2.80; private const TITLE_MARGIN = 0.50; - private const LABEL_SIZE = 2.00; + private const LABEL_SIZE = 2.50; private const LABEL_MARGIN = - 0.35; - private const FIELD_SIZE = 2.00; + private const FIELD_SIZE = 2.50; private const FIELD_MARGIN = 0.35; private const BARCODE1D_SIZE = 3.00; // Size for the C128 barcode at bottom @@ -19,7 +19,7 @@ class TZe_24mm_D extends TZe_24mm public function getSupportAssetTag() { return true; } public function getSupport1DBarcode() { return true; } public function getSupport2DBarcode() { return true; } - public function getSupportFields() { return 4; } + public function getSupportFields() { return 3; } public function getSupportLogo() { return false; } public function getSupportTitle() { return true; }