Skip to content

Commit 0b6d810

Browse files
authored
FEAT: Add Label 5520 with 1D barcode - remove 2D barcode
FEAT: Add Label 5520 with 1D barcode - remove 2D barcode
1 parent 8c164d1 commit 0b6d810

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
3+
namespace App\Models\Labels\Sheets\Avery;
4+
5+
6+
class _5520_B extends _5520
7+
{
8+
private const BARCODE_SIZE = 0.20;
9+
private const BARCODE_MARGIN = 1.40;
10+
private const TAG_SIZE = 0.125;
11+
private const TITLE_SIZE = 0.140;
12+
private const TITLE_MARGIN = 0.025;
13+
private const LABEL_SIZE = 0.090;
14+
private const LABEL_MARGIN = -0.015;
15+
private const FIELD_SIZE = 0.150;
16+
private const FIELD_MARGIN = 0.012;
17+
18+
public function getUnit() { return 'in'; }
19+
20+
public function getLabelMarginTop() { return 0.06; }
21+
public function getLabelMarginBottom() { return 0.06; }
22+
public function getLabelMarginLeft() { return 0.06; }
23+
public function getLabelMarginRight() { return 0.06; }
24+
25+
public function getSupportAssetTag() { return false; }
26+
public function getSupport1DBarcode() { return true; }
27+
public function getSupport2DBarcode() { return false; }
28+
public function getSupportFields() { return 2; }
29+
public function getSupportLogo() { return false; }
30+
public function getSupportTitle() { return true; }
31+
32+
public function preparePDF($pdf) {}
33+
34+
public function write($pdf, $record) {
35+
$pa = $this->getLabelPrintableArea();
36+
37+
$currentX = $pa->x1;
38+
$currentY = $pa->y1;
39+
$usableWidth = $pa->w;
40+
$usableHeight = $pa->h;
41+
42+
if ($record->has('title')) {
43+
static::writeText(
44+
$pdf, $record->get('title'),
45+
$pa->x1, $pa->y1,
46+
'freesans', '', self::TITLE_SIZE, 'C',
47+
$pa->w, self::TITLE_SIZE, true, 0
48+
);
49+
$currentY += self::TITLE_SIZE + self::TITLE_MARGIN;
50+
$usableHeight -= self::TITLE_SIZE + self::TITLE_MARGIN;
51+
}
52+
53+
if ($record->has('barcode1d')) {
54+
static::write1DBarcode(
55+
$pdf, $record->get('barcode1d')->content, $record->get('barcode1d')->type,
56+
$pa->x1, $pa->y2 - self::BARCODE_SIZE,
57+
$usableWidth, self::BARCODE_SIZE
58+
);
59+
$usableHeight -= self::BARCODE_SIZE + self::BARCODE_MARGIN;
60+
}
61+
62+
foreach ($record->get('fields') as $field) {
63+
static::writeText(
64+
$pdf, $field['label'],
65+
$currentX, $currentY,
66+
'freesans', '', self::LABEL_SIZE, 'L',
67+
$usableWidth, self::LABEL_SIZE, true, 0
68+
);
69+
$currentY += self::LABEL_SIZE + self::LABEL_MARGIN;
70+
71+
static::writeText(
72+
$pdf, $field['value'],
73+
$currentX, $currentY,
74+
'freemono', 'B', self::FIELD_SIZE, 'L',
75+
$usableWidth, self::FIELD_SIZE, true, 0, 0.01
76+
);
77+
$currentY += self::FIELD_SIZE + self::FIELD_MARGIN;
78+
}
79+
80+
}
81+
}
82+
83+
84+
?>

0 commit comments

Comments
 (0)