1+ <?php
2+
3+ namespace App \Models \Labels \Tapes \Dymo ;
4+
5+
6+ class LabelWriter_11354 extends LabelWriter
7+ {
8+ private const BARCODE1D_HEIGHT = 3.00 ;
9+ private const BARCODE_MARGIN = 1.80 ;
10+ private const TAG_SIZE = 2.80 ;
11+ private const TITLE_SIZE = 2.80 ;
12+ private const TITLE_MARGIN = 0.50 ;
13+ private const FIELD_SIZE = 2.80 ;
14+ private const FIELD_MARGIN = 0.15 ;
15+
16+ public function getUnit ()
17+ {
18+ return 'mm ' ;
19+ }
20+ public function getWidth ()
21+ {
22+ return 57 ;
23+ }
24+ public function getHeight ()
25+ {
26+ return 32 ;
27+ }
28+ public function getSupportAssetTag ()
29+ {
30+ return true ;
31+ }
32+ public function getSupport1DBarcode ()
33+ {
34+ return true ;
35+ }
36+ public function getSupport2DBarcode ()
37+ {
38+ return true ;
39+ }
40+ public function getSupportFields ()
41+ {
42+ return 5 ;
43+ }
44+ public function getSupportLogo ()
45+ {
46+ return false ;
47+ }
48+ public function getSupportTitle ()
49+ {
50+ return true ;
51+ }
52+ public function preparePDF ($ pdf )
53+ {
54+ }
55+
56+ public function write ($ pdf , $ record )
57+ {
58+ $ pa = $ this ->getPrintableArea ();
59+
60+ $ currentX = $ pa ->x1 ;
61+ $ currentY = $ pa ->y1 ;
62+ $ usableWidth = $ pa ->w ;
63+ $ usableHeight = $ pa ->h ;
64+
65+ // Wide 1D barcode on top
66+ if ($ record ->has ('barcode1d ' )) {
67+ static ::write1DBarcode (
68+ $ pdf , $ record ->get ('barcode1d ' )->content , $ record ->get ('barcode1d ' )->type ,
69+ $ currentX , $ currentY , $ usableWidth , self ::BARCODE1D_HEIGHT
70+ );
71+ $ currentY += self ::BARCODE1D_HEIGHT + self ::BARCODE_MARGIN ;
72+ $ usableHeight -= self ::BARCODE1D_HEIGHT + self ::BARCODE_MARGIN ;
73+ }
74+
75+ // 2D Barcode in left column
76+ if ($ record ->has ('barcode2d ' )) {
77+ $ barcodeSize = $ usableHeight - self ::TAG_SIZE ;
78+
79+ static ::writeText (
80+ $ pdf , $ record ->get ('tag ' ),
81+ $ currentX , $ pa ->y2 - self ::TAG_SIZE ,
82+ 'freesans ' , 'b ' , self ::TAG_SIZE , 'C ' ,
83+ $ barcodeSize , self ::TAG_SIZE , true , 0
84+ );
85+ static ::write2DBarcode (
86+ $ pdf , $ record ->get ('barcode2d ' )->content , $ record ->get ('barcode2d ' )->type ,
87+ $ currentX , $ currentY ,
88+ $ barcodeSize , $ barcodeSize
89+ );
90+ $ currentX += $ barcodeSize + self ::BARCODE_MARGIN ;
91+ $ usableWidth -= $ barcodeSize + self ::BARCODE_MARGIN ;
92+ }
93+
94+ // Right column
95+ if ($ record ->has ('title ' )) {
96+ static ::writeText (
97+ $ pdf , $ record ->get ('title ' ),
98+ $ currentX , $ currentY ,
99+ 'freesans ' , 'b ' , self ::TITLE_SIZE , 'L ' ,
100+ $ usableWidth , self ::TITLE_SIZE , true , 0
101+ );
102+ $ currentY += self ::TITLE_SIZE + self ::TITLE_MARGIN ;
103+ }
104+
105+ foreach ($ record ->get ('fields ' ) as $ field ) {
106+ static ::writeText (
107+ $ pdf , (($ field ['label ' ]) ? $ field ['label ' ].' ' : '' ) . $ field ['value ' ],
108+ $ currentX , $ currentY ,
109+ 'freesans ' , '' , self ::FIELD_SIZE , 'L ' ,
110+ $ usableWidth , self ::FIELD_SIZE , true , 0 , 0.3
111+ );
112+ $ currentY += self ::FIELD_SIZE + self ::FIELD_MARGIN ;
113+ }
114+ }
115+
116+ }
0 commit comments