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, 'freesans', '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', 'b', self::TITLE_SIZE, 'L', $usableWidth, self::TITLE_SIZE, true, 0 ); $currentY += self::TITLE_SIZE + self::TITLE_MARGIN; } $fields = $record->get('fields'); // Below rescales the size of the field box to fit, it feels like it could/should be abstracted one class above // to be usable on other labels but im unsure of how to implement that, since it uses a lot of private // constants. // Figure out how tall the label fields wants to be $fieldCount = count($fields); $usableHeight = $pa->h - self::TAG_SIZE // bottom tag text - self::BARCODE_MARGIN; // gap between fields and 1D $field_layout = Helper::labelFieldLayoutScaling( pdf: $pdf, fields: $fields, currentX: $currentX, usableWidth: $usableWidth, usableHeight: $usableHeight, baseLabelSize: self::LABEL_SIZE, baseFieldSize: self::FIELD_SIZE, baseFieldMargin: self::FIELD_MARGIN, baseLabelPadding: 1.5, baseGap: 1.5, maxScale: 1.8, labelFont: 'freesans', ); foreach ($fields as $field) { $labelText = rtrim($field['label'], ':') . ':'; static::writeText( $pdf, $labelText, $currentX, $currentY, 'freesans', '', $field_layout['labelSize'], 'L', $field_layout['labelWidth'], $field_layout['rowAdvance'], true, 0 ); static::writeText( $pdf, $field['value'], $field_layout['valueX'], $currentY, 'freemono', 'B', $field_layout['fieldSize'], 'L', $field_layout['valueWidth'], $field_layout['rowAdvance'], true, 0, 0.01 ); $currentY += $field_layout['rowAdvance']; } 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 ); } } }