Skip to content

Instantly share code, notes, and snippets.

@zsarge
Created February 11, 2025 17:02
Show Gist options
  • Save zsarge/43c8e149cb743afb19fefd129a8656b0 to your computer and use it in GitHub Desktop.
Save zsarge/43c8e149cb743afb19fefd129a8656b0 to your computer and use it in GitHub Desktop.
SnipeIT modified label for Norse IoT. This has the barcode and our text.
<?php
namespace App\Models\Labels\Tapes\Brother;
class TZe_12mm_A extends TZe_12mm
{
// this file lives at /var/www/html/snipeit/app/Models/Labels/Tapes/Brother/TZe_12mm_A.php
private const BARCODE_SIZE = 5.00;
private const BARCODE_MARGIN = 0.60;
private const TEXT_SIZE_MOD = 1.00;
public function getUnit() { return 'mm'; }
public function getHeight() { return 15.00; }
public function getWidth() { return 50.0; }
public function getSupportAssetTag() { return true; }
public function getSupport1DBarcode() { return true; }
public function getSupport2DBarcode() { return false; }
public function getSupportFields() { return 1; }
public function getSupportLogo() { return false; }
public function getSupportTitle() { return false; }
public function preparePDF($pdf) {}
public function write($pdf, $record) {
$pa = $this->getPrintableArea();
if ($record->has('barcode1d')) {
static::write1DBarcode(
$pdf, $record->get('barcode1d')->content, $record->get('barcode1d')->type,
$pa->x1, $pa->y1, $pa->w, self::BARCODE_SIZE
);
}
$currentY = $pa->y1 + self::BARCODE_SIZE + self::BARCODE_MARGIN;
$usableHeight = $pa->h - self::BARCODE_SIZE - self::BARCODE_MARGIN;
$fontSize = $usableHeight + self::TEXT_SIZE_MOD;
$tagWidth = $pa->w / 3;
$fieldWidth = $pa->w / 3 * 2;
static::writeText(
$pdf, "Norse IoT",
$pa->x1, $currentY,
'freemono', 'b', $fontSize, 'L',
$tagWidth + 5.00, $usableHeight, true, 0, 0
);
static::writeText(
$pdf, $record->get('tag'),
$pa->x1 + ($tagWidth), $currentY,
'freemono', 'b', $fontSize, 'R',
$fieldWidth, $usableHeight, true, 0, 0
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment