From 2777ac96cc51223352fb384a015781ebb71bdb98 Mon Sep 17 00:00:00 2001 From: U-H-T <> Date: Thu, 23 May 2024 11:10:23 +0200 Subject: [PATCH] add logo support for Brother TZe24mm labels --- .../Labels/Tapes/Brother/TZe_24mm_B.php | 105 ++++++++++++++++++ .../Labels/Tapes/Brother/TZe_24mm_C.php | 77 +++++++++++++ 2 files changed, 182 insertions(+) create mode 100644 app/Models/Labels/Tapes/Brother/TZe_24mm_B.php create mode 100644 app/Models/Labels/Tapes/Brother/TZe_24mm_C.php diff --git a/app/Models/Labels/Tapes/Brother/TZe_24mm_B.php b/app/Models/Labels/Tapes/Brother/TZe_24mm_B.php new file mode 100644 index 0000000000..cedf5e0cbd --- /dev/null +++ b/app/Models/Labels/Tapes/Brother/TZe_24mm_B.php @@ -0,0 +1,105 @@ +getPrintableArea(); + + $currentX = $pa->x1; + $currentY = $pa->y1; + $usableWidth = $pa->w; + $usableHeight = $pa->h; + + $barcodeSize = $pa->h - self::TAG_SIZE; + + if ($record->has('barcode2d')) { + static::writeText( + $pdf, $record->get('tag'), + $pa->x1, $pa->y2 - self::TAG_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, + 'freemono', 'b', self::TAG_SIZE, 'R', + $usableWidth, self::TAG_SIZE, true, 0 + ); + } + + $usableWidth -= self::LOGO_MAX_WIDTH - self::LOGO_MARGIN; + + 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; + } + + $currentX += $usableWidth + (self::LOGO_MARGIN/2); + + if ($record->has('logo')) { + $logoSize = static::writeImage( + $pdf, $record->get('logo'), + $currentX, $pa->y1, + self::LOGO_MAX_WIDTH, $usableHeight, + 'L', 'T', 300, true, false, 0 + ); + $currentX += $logoSize[0] + self::LOGO_MARGIN; + $usableWidth -= $logoSize[0] + self::LOGO_MARGIN; + } + } +} diff --git a/app/Models/Labels/Tapes/Brother/TZe_24mm_C.php b/app/Models/Labels/Tapes/Brother/TZe_24mm_C.php new file mode 100644 index 0000000000..65b3676bfc --- /dev/null +++ b/app/Models/Labels/Tapes/Brother/TZe_24mm_C.php @@ -0,0 +1,77 @@ +getPrintableArea(); + + $currentX = $pa->x1; + $currentY = $pa->y1; + $usableWidth = $pa->w; + $usableHeight = $pa->h; + + $barcodeSize = $pa->h - self::TAG_SIZE; + + if ($record->has('barcode2d')) { + static::writeText( + $pdf, $record->get('tag'), + $pa->x1, $pa->y2 - self::TAG_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, + 'freemono', 'b', self::TAG_SIZE, 'R', + $usableWidth, self::TAG_SIZE, true, 0 + ); + } + + $usableWidth -= self::LOGO_MAX_WIDTH - self::LOGO_MARGIN; + + $currentX += $usableWidth - (self::LOGO_MARGIN/2); + + if ($record->has('logo')) { + $logoSize = static::writeImage( + $pdf, $record->get('logo'), + $currentX, $pa->y1, + self::LOGO_MAX_WIDTH, $usableHeight, + 'L', 'T', 300, true, false, 0 + ); + $currentX += $logoSize[0] + self::LOGO_MARGIN; + $usableWidth -= $logoSize[0] + self::LOGO_MARGIN; + } + } +}