A free open source IT asset/license management system
<?php
namespace App\Models\Labels\Tapes\Dymo;
class LabelWriter_30252 extends LabelWriter
{
private const BARCODE_MARGIN = 1.80;
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_MARGIN = -0.35;
private const FIELD_SIZE = 3.20;
private const FIELD_MARGIN = 0.15;
public function getUnit()
{
return 'mm';
}
public function getWidth()
{
return 96.52;
}
public function getSupportAssetTag()
{
return true;
}
public function getSupport1DBarcode()
{
return true;
}
public function getSupport2DBarcode()
{
return true;
}
public function getSupportFields()
{
return 3;
}
public function getSupportLogo()
{
return false;
}
public function getSupportTitle()
{
return true;
}
protected function getContentEditorConfig(): array
{
return [
'barcode_size' => self::TAG_SIZE,
'barcode_margin' => self::BARCODE_MARGIN,
'barcode1D_v_align' => 'B',
'barcode1D_placement' => 'text_column',
'barcode_2d_size' => $this->getPrintableArea()->h - self::TAG_SIZE,
'barcode2D_h_align' => 'L',
'barcode2D_v_align' => 'T',
'tag_font_size' => self::TAG_SIZE,
'tag_alignment' => 'C',
'tag_position_mode' => 'under_barcode',
'tag_font' => 'freemono',
'title_font_size' => self::TITLE_SIZE,
'title_margin' => self::TITLE_MARGIN,
'title_font' => 'freesans',
'field_label_font_size' => self::LABEL_SIZE,
'field_label_margin' => self::LABEL_MARGIN,
'field_label_font' => 'freesans',
'field_value_font_size' => self::FIELD_SIZE,
'field_value_margin' => self::FIELD_MARGIN,
'field_value_font' => 'freemono',
'text_render_mode' => 'vertical_stack',
];
}
public function write($pdf, $record)
{
$pa = $this->getPrintableArea();
$currentX = $pa->x1;
$currentY = $pa->y1;
$usableWidth = $pa->w;
$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;
}
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;
}
if ($record->has('barcode1d')) {
static::write1DBarcode(
$pdf, $record->get('barcode1d')->content, $record->get('barcode1d')->type,
$currentX, $barcodeSize + self::BARCODE_MARGIN, $usableWidth - self::TAG_SIZE, self::TAG_SIZE
);
}
}
}