Label Definition

Defined under the namespace Scandit.Datacapture.Label

LabelDefinition
class LabelDefinition

Added in version 7.2.0

A configuration that defines labels and their relevant fields for Smart Label Capture to recognize and extract during scans. Label definitions provide flexible data extraction from specific label layouts without custom coding, enabling structured data extraction from diverse label types.

Label definitions support two primary approaches:

  • Pre-built Labels - Includes predefined configurations for common label types (price labels, VIN labels, 7-segment displays)

  • Custom Labels - Allows creating unique label definitions using custom barcode and text fields

Key configuration options for custom fields:

  • patterns - Regular expressions to identify target strings

  • dataTypePatterns - Context-identifying keywords for field recognition

  • symbologies - Specific barcode types to match

  • isOptional - Determines field requirement status

Pre-built field categories include:

  • Barcode Fields - Serial number, part number, IMEI

  • Price/Weight Fields - Unit price, total price, weight

  • Date/Text Fields - Packing date, expiry date

You can create label definitions in three ways:

name
get name(): string

Added in version 7.2.0

The name of the label definition.

fields
get fields(): LabelFieldDefinition[]

Added in version 7.2.0

The fields of the label definition.

createVinLabelDefinition(name)
static createVinLabelDefinition(name: string): Promise<LabelDefinition>

Added in version 7.4.0

Creates a predefined label definition for scanning Vehicle Identification Numbers (VIN). VIN codes are 17-character alphanumeric serial numbers that can appear as either text or barcodes on vehicles.

const vinLabel = await LabelDefinition.createVinLabelDefinition("vehicle_vin");

This factory method returns a label definition with two optional fields:

  • text - An optional text field for scanning VIN codes in text format with pattern [A-Z0-9]{17}

  • barcode - An optional barcode field for scanning VIN codes in barcode format (QR, Code 39, or Data Matrix symbologies) with pattern [A-Z0-9]{17}

createPriceCaptureDefinition(name)
static createPriceCaptureDefinition(name: string): Promise<LabelDefinition>

Added in version 7.4.0

Creates a predefined label definition for scanning price labels on retail products. This factory method is designed for price checking scenarios where both barcode and price text need to be captured from product labels.

This factory method returns a label definition with two fields:

  • SKU - A mandatory barcode field for scanning Symbology.EAN13UPCA and Symbology.Code128.

  • priceText - An optional text field for scanning price text using specialized price label recognition with pattern \\d+.

You can easily disable one of the symbologies of the barcode field by changing global mode settings. For example, to disable Symbology.Code128 one can do this:

Note

To use this label definition, make sure to import the PriceCapture library.

builder()
static builder(): LabelDefinitionBuilder

Added in version 7.2.0

Create a new label definition builder.