@@ -70,27 +70,38 @@ public function write($pdf, $record) {
7070 }
7171
7272 foreach ($ record ->get ('fields ' ) as $ field ) {
73- // Write label and value on the same line
74- // Calculate label width with proportional character spacing
75- $ labelWidth = $ pdf ->GetStringWidth ($ field ['label ' ], 'freemono ' , '' , self ::LABEL_SIZE );
76- $ charCount = strlen ($ field ['label ' ]);
77- $ spacingPerChar = 0.5 ;
78- $ totalSpacing = $ charCount * $ spacingPerChar ;
79- $ adjustedWidth = $ labelWidth + $ totalSpacing ;
73+ if (!empty ($ field ['label ' ]) && $ field ['label ' ] !== "\u{200B}" ) {
74+ // Write label and value on the same line
75+ // Calculate label width with proportional character spacing
76+ $ labelWidth = $ pdf ->GetStringWidth ($ field ['label ' ], 'freemono ' , '' , self ::LABEL_SIZE );
77+ $ charCount = strlen ($ field ['label ' ]);
78+ $ spacingPerChar = 0.5 ;
79+ $ totalSpacing = $ charCount * $ spacingPerChar ;
80+ $ adjustedWidth = $ labelWidth + $ totalSpacing ;
8081
81- static ::writeText (
82- $ pdf , $ field ['label ' ],
83- $ currentX , $ currentY ,
84- 'freemono ' , 'B ' , self ::LABEL_SIZE , 'L ' ,
85- $ adjustedWidth , self ::LABEL_SIZE , true , 0 , $ spacingPerChar
86- );
82+ static ::writeText (
83+ $ pdf , $ field ['label ' ],
84+ $ currentX , $ currentY ,
85+ 'freemono ' , 'B ' , self ::LABEL_SIZE , 'L ' ,
86+ $ adjustedWidth , self ::LABEL_SIZE , true , 0 , $ spacingPerChar
87+ );
8788
88- static ::writeText (
89- $ pdf , $ field ['value ' ],
90- $ currentX + $ adjustedWidth + 2 , $ currentY ,
91- 'freemono ' , 'B ' , self ::FIELD_SIZE , 'L ' ,
92- $ usableWidth - $ adjustedWidth - 2 , self ::FIELD_SIZE , true , 0 , 0.3
93- );
89+ static ::writeText (
90+ $ pdf , $ field ['value ' ],
91+ $ currentX + $ adjustedWidth + 2 , $ currentY ,
92+ 'freemono ' , 'B ' , self ::FIELD_SIZE , 'L ' ,
93+ $ usableWidth - $ adjustedWidth - 2 , self ::FIELD_SIZE , true , 0 , 0.3
94+ );
95+ } else {
96+
97+ // Label is empty, so write value only.
98+ static ::writeText (
99+ $ pdf , $ field ['value ' ],
100+ $ currentX , $ currentY , // No offset
101+ 'freemono ' , 'B ' , self ::FIELD_SIZE , 'L ' ,
102+ $ usableWidth , self ::FIELD_SIZE , true , 0 , 0.3
103+ );
104+ }
94105
95106 $ currentY += max (self ::LABEL_SIZE , self ::FIELD_SIZE ) + self ::FIELD_MARGIN ;
96107 }
0 commit comments