RFID Tag Item
The RFIDTagItem Class
A RFIDTagItem – represented by the Neodynamic.SDK.Printing.RFIDTagItem class – lets you encode an RFID tag as part of a label. You create it by specifying the basic properties such as the data to encode and its format (ASCII, Hexadecimal or EPC). For Zebra ZPL printers you can also choose the tag type, the memory bank and starting block, set the access and kill passwords, and lock memory.
The RFIDTagItem has no visual representation: it has no Width/Height and nothing is drawn for it. Its X and Y are not used to generate the RFID commands, and it does not appear when the label is exported to an image or a document. It only produces printer commands.
Note
RFID tags are supported for ZPL and Fingerprint/Direct Protocol printers only. For other programming languages (EPL, PCL, etc.) the item generates no commands and is ignored. The printer must be RFID-enabled and loaded with RFID media. Tag type, memory bank, starting block, number of bytes, passwords and the lock options are available for ZPL only. See Fingerprint support.
Quick Start
ThermalLabel tLabel = new ThermalLabel(UnitType.Inch, 4, 3);
RFIDTagItem rfidTag = new RFIDTagItem();
rfidTag.DataFormat = RFIDTagDataFormat.ASCII; // default value
rfidTag.DataToEncode = "My Data";
tLabel.Items.Add(rfidTag);
See Printing the samples for how to send the label to the printer.
Main Properties
Data
| Property | Description |
|---|---|
DataFormat |
How DataToEncode is interpreted: ASCII (default), Hexadecimal or EPC. |
DataToEncode |
The data to write into the tag. Its format depends on DataFormat. Default is an empty string. |
EPCDataStructure |
Only for DataFormat = EPC. Describes the partitions of the EPC as TOTAL-BITS,PARTITION1-BITS,...,PARTITIONn-BITS, e.g. 96,8,3,3,20,24,38. |
DataField |
Binds DataToEncode to a field of the data source (see Data binding and expressions). |
ZPL only
| Property | Description |
|---|---|
TagType |
The RFID tag type. Default is Default, which keeps the printer's current setting. See the table below. |
StartingBlock |
The block number where the writing starts. Default is -1 (not specified: the printer default is used). |
NumberOfBytes |
The number of bytes to write. Default is 0 (not specified). |
MemoryBank |
The Gen 2 memory bank, as a string: "0" Reserved, "1" EPC, "2" TID, "3" User. Default is empty (not specified). |
AccessPassword |
The tag's access password. Default is empty. |
KillPassword |
The tag's kill password. Default is empty. |
LockMemoryBank |
Locks or unlocks the passwords and the EPC/User memory banks. |
PermaLockMemorySection |
Permanently locks sections of the user memory. |
For the complete list of members, see the API Reference.
Tag types
RFIDTagType |
Description |
|---|---|
Default |
Do not change the tag type configured in the printer. |
None |
No tag type. |
EPCClass0 |
EPC Class 0 |
EPCClass0Plus |
EPC Class 0 Plus |
EPCClass164bit |
EPC Class 1, 64 bit |
EPCClass196bit |
EPC Class 1, 96 bit |
UCODEEPC119 |
UCODE EPC 1.19 |
ImpinjClass0Plus |
Impinj Class 0 Plus |
ISO1800006A |
ISO 18000-06A |
EPCClass1Gen2 |
EPC Class 1 Gen 2 |
ISO1800006B |
ISO 18000-06B |
Lock options
LockMemoryBank and PermaLockMemorySection do nothing unless their Apply property is true.
LockMemoryBank – each of KillPassword, AccessPassword, EPCMemoryBank and USERMemoryBank takes an RFIDLockValue:
RFIDLockValue |
Meaning |
|---|---|
None |
Leave it as is (nothing is sent for that field). Default. |
Lock |
Lock |
Unlock |
Unlock |
Open |
Permanently unlock |
Protected |
Permanently lock |
PermaLockMemorySection – StartingSection (default 0) and NumberOfSections (default 0) define the sections of user memory to lock permanently.
Warning
Permanent locks (Open, Protected and PermaLockMemorySection) cannot be undone on the tag. Test with a few tags first.
How the data is encoded
DataFormat |
DataToEncode |
Example |
|---|---|---|
ASCII |
Plain text | My Data |
Hexadecimal |
Hexadecimal digits, two per byte | 4D792044617461 |
EPC |
The value of each partition of EPCDataStructure, separated by commas (a period . is also accepted) |
16,3,5,78742,146165,1234567891 |
For EPC data, EPCDataStructure is required and each partition value must fit in the bits assigned to it. In 96,8,3,3,20,24,38 the first number is the total (96 bits) and the rest are the partitions (8 + 3 + 3 + 20 + 24 + 38 = 96), so DataToEncode has six values.
Printing the samples
All samples below only change the label. Use the following code to print any of them:
VB.NET
'Create a WindowsPrintJob object
Using pj As New WindowsPrintJob()
'Create PrinterSettings object
Dim myPrinter As New PrinterSettings()
myPrinter.Communication.CommunicationType = CommunicationType.USB
myPrinter.Dpi = 203
myPrinter.ProgrammingLanguage = ProgrammingLanguage.ZPL
myPrinter.PrinterName = "Zebra ZD500R"
'Set PrinterSettings to WindowsPrintJob
pj.PrinterSettings = myPrinter
'Print ThermalLabel object...
pj.Print(tLabel)
End Using
C#
//Create a WindowsPrintJob object
using (WindowsPrintJob pj = new WindowsPrintJob())
{
//Create PrinterSettings object
PrinterSettings myPrinter = new PrinterSettings();
myPrinter.Communication.CommunicationType = CommunicationType.USB;
myPrinter.Dpi = 203;
myPrinter.ProgrammingLanguage = ProgrammingLanguage.ZPL;
myPrinter.PrinterName = "Zebra ZD500R";
//Set PrinterSettings to WindowsPrintJob
pj.PrinterSettings = myPrinter;
//Print ThermalLabel object...
pj.Print(tLabel);
}
RFIDTagItem Samples
- Example #1: Encoding ASCII data
- Example #2: Encoding Hexadecimal data
- Example #3: Encoding EPC data
- Example #4: Writing to a specific memory bank and block
- Example #5: Writing passwords and locking memory
Example #1: Encoding ASCII data
VB.NET
'Define a ThermalLabel object and set unit to inch and label size
Dim tLabel As New ThermalLabel(UnitType.Inch, 4, 3)
tLabel.GapLength = 0.2
'Define a RFIDTagItem object
Dim rfidTag As New RFIDTagItem()
'Set data type...
rfidTag.DataFormat = RFIDTagDataFormat.ASCII
'Set data to encode...
rfidTag.DataToEncode = "My Data"
'Add items to ThermalLabel object...
tLabel.Items.Add(rfidTag)
C#
//Define a ThermalLabel object and set unit to inch and label size
ThermalLabel tLabel = new ThermalLabel(UnitType.Inch, 4, 3);
tLabel.GapLength = 0.2;
//Define a RFIDTagItem object
RFIDTagItem rfidTag = new RFIDTagItem();
//Set data type...
rfidTag.DataFormat = RFIDTagDataFormat.ASCII;
//Set data to encode...
rfidTag.DataToEncode = "My Data";
//Add items to ThermalLabel object...
tLabel.Items.Add(rfidTag);
Example #2: Encoding Hexadecimal data
VB.NET
'Define a ThermalLabel object and set unit to inch and label size
Dim tLabel As New ThermalLabel(UnitType.Inch, 4, 3)
tLabel.GapLength = 0.2
'Define a RFIDTagItem object
Dim rfidTag As New RFIDTagItem()
'Set data type...
rfidTag.DataFormat = RFIDTagDataFormat.Hexadecimal
'Set data to encode...
rfidTag.DataToEncode = "4D792044617461" 'My Data
'Add items to ThermalLabel object...
tLabel.Items.Add(rfidTag)
C#
//Define a ThermalLabel object and set unit to inch and label size
ThermalLabel tLabel = new ThermalLabel(UnitType.Inch, 4, 3);
tLabel.GapLength = 0.2;
//Define a RFIDTagItem object
RFIDTagItem rfidTag = new RFIDTagItem();
//Set data type...
rfidTag.DataFormat = RFIDTagDataFormat.Hexadecimal;
//Set data to encode...
rfidTag.DataToEncode = "4D792044617461"; //My Data
//Add items to ThermalLabel object...
tLabel.Items.Add(rfidTag);
Example #3: Encoding EPC data
VB.NET
'Define a ThermalLabel object and set unit to inch and label size
Dim tLabel As New ThermalLabel(UnitType.Inch, 4, 3)
tLabel.GapLength = 0.2
'Define a RFIDTagItem object
Dim rfidTag As New RFIDTagItem()
'Set data type...
rfidTag.DataFormat = RFIDTagDataFormat.EPC
'Set the EPC Data Structure
'TOTAL-BITS,PARTITION1-BITS,PARTITION2-BITS,...,PARTITIONn-BITS
rfidTag.EPCDataStructure = "96,8,3,3,20,24,38"
'Set data to encode...
rfidTag.DataToEncode = "16,3,5,78742,146165,1234567891"
'Add items to ThermalLabel object...
tLabel.Items.Add(rfidTag)
C#
//Define a ThermalLabel object and set unit to inch and label size
ThermalLabel tLabel = new ThermalLabel(UnitType.Inch, 4, 3);
tLabel.GapLength = 0.2;
//Define a RFIDTagItem object
RFIDTagItem rfidTag = new RFIDTagItem();
//Set data type...
rfidTag.DataFormat = RFIDTagDataFormat.EPC;
//Set the EPC Data Structure
//TOTAL-BITS,PARTITION1-BITS,PARTITION2-BITS,...,PARTITIONn-BITS
rfidTag.EPCDataStructure = "96,8,3,3,20,24,38";
//Set data to encode...
rfidTag.DataToEncode = "16,3,5,78742,146165,1234567891";
//Add items to ThermalLabel object...
tLabel.Items.Add(rfidTag);
Example #4: Writing to a specific memory bank and block
This example encodes 4 bytes of hexadecimal data, starting at block 3 of the Gen 2 EPC memory bank (bank 1).
VB.NET
'Define a ThermalLabel object and set unit to inch and label size
Dim tLabel As New ThermalLabel(UnitType.Inch, 4, 3)
tLabel.GapLength = 0.2
'Define a RFIDTagItem object
Dim rfidTag As New RFIDTagItem()
'Set Tag Type
rfidTag.TagType = RFIDTagType.EPCClass1Gen2
'Set num of bytes
rfidTag.NumberOfBytes = 4
'Set data type
rfidTag.DataFormat = RFIDTagDataFormat.Hexadecimal
'Set starting block
rfidTag.StartingBlock = 3
'Set mem bank
rfidTag.MemoryBank = "1"
'Set data to encode...
rfidTag.DataToEncode = "11223344"
'Add items to ThermalLabel object...
tLabel.Items.Add(rfidTag)
C#
//Define a ThermalLabel object and set unit to inch and label size
ThermalLabel tLabel = new ThermalLabel(UnitType.Inch, 4, 3);
tLabel.GapLength = 0.2;
//Define a RFIDTagItem object
RFIDTagItem rfidTag = new RFIDTagItem();
//Set Tag Type
rfidTag.TagType = RFIDTagType.EPCClass1Gen2;
//Set num of bytes
rfidTag.NumberOfBytes = 4;
//Set data type
rfidTag.DataFormat = RFIDTagDataFormat.Hexadecimal;
//Set starting block
rfidTag.StartingBlock = 3;
//Set mem bank
rfidTag.MemoryBank = "1";
//Set data to encode...
rfidTag.DataToEncode = "11223344";
//Add items to ThermalLabel object...
tLabel.Items.Add(rfidTag);
Example #5: Writing passwords and locking memory
This example encodes 12 bytes of hexadecimal data in the user memory bank (bank 3), writes 12345678 as the access password and 11223344 as the kill password, permanently locks 6 sections of the user memory, locks the kill and access passwords, and permanently unlocks the EPC memory.
Important
Passwords are written using the item's DataFormat, so set it to Hexadecimal (8 hex digits for each password) when you use AccessPassword or KillPassword.
VB.NET
'Define a ThermalLabel object and set unit to inch and label size
Dim tLabel As New ThermalLabel(UnitType.Inch, 4, 3)
tLabel.GapLength = 0.2
'Define a RFIDTagItem object
Dim rfidTag As New RFIDTagItem()
'Set num of bytes
rfidTag.NumberOfBytes = 12
'Set data type
rfidTag.DataFormat = RFIDTagDataFormat.Hexadecimal
'Set starting block
rfidTag.StartingBlock = 0
'Set mem bank (3 = User)
rfidTag.MemoryBank = "3"
'Set data to encode...
rfidTag.DataToEncode = "112233445566778899001122"
'Set Access Password
rfidTag.AccessPassword = "12345678"
'Set Kill Password
rfidTag.KillPassword = "11223344"
'Set PermaLock Memory Section
rfidTag.PermaLockMemorySection.Apply = True
rfidTag.PermaLockMemorySection.StartingSection = 0
rfidTag.PermaLockMemorySection.NumberOfSections = 6
'Set Lock Memory Bank
rfidTag.LockMemoryBank.Apply = True
rfidTag.LockMemoryBank.KillPassword = RFIDLockValue.Lock
rfidTag.LockMemoryBank.AccessPassword = RFIDLockValue.Lock
rfidTag.LockMemoryBank.EPCMemoryBank = RFIDLockValue.Open
'Add items to ThermalLabel object...
tLabel.Items.Add(rfidTag)
C#
//Define a ThermalLabel object and set unit to inch and label size
ThermalLabel tLabel = new ThermalLabel(UnitType.Inch, 4, 3);
tLabel.GapLength = 0.2;
//Define a RFIDTagItem object
RFIDTagItem rfidTag = new RFIDTagItem();
//Set num of bytes
rfidTag.NumberOfBytes = 12;
//Set data type
rfidTag.DataFormat = RFIDTagDataFormat.Hexadecimal;
//Set starting block
rfidTag.StartingBlock = 0;
//Set mem bank (3 = User)
rfidTag.MemoryBank = "3";
//Set data to encode...
rfidTag.DataToEncode = "112233445566778899001122";
//Set Access Password
rfidTag.AccessPassword = "12345678";
//Set Kill Password
rfidTag.KillPassword = "11223344";
//Set PermaLock Memory Section
rfidTag.PermaLockMemorySection.Apply = true;
rfidTag.PermaLockMemorySection.StartingSection = 0;
rfidTag.PermaLockMemorySection.NumberOfSections = 6;
//Set Lock Memory Bank
rfidTag.LockMemoryBank.Apply = true;
rfidTag.LockMemoryBank.KillPassword = RFIDLockValue.Lock;
rfidTag.LockMemoryBank.AccessPassword = RFIDLockValue.Lock;
rfidTag.LockMemoryBank.EPCMemoryBank = RFIDLockValue.Open;
//Add items to ThermalLabel object...
tLabel.Items.Add(rfidTag);
Data binding and expressions
The data to encode can come from a data source. Set DataField to the field name and the value replaces DataToEncode for each label; DataFieldFormatString can be used to format it. DataFormat still applies, so the field must contain valid ASCII, hexadecimal or EPC data.
RFIDTagItem rfidTag = new RFIDTagItem();
rfidTag.DataFormat = RFIDTagDataFormat.Hexadecimal;
rfidTag.DataField = "tagId";
The item also supports Expression, which can build the data to encode from other fields or variables.
Fingerprint support
For Fingerprint printers only these properties are used: DataFormat, DataToEncode and EPCDataStructure.
- ASCII and Hexadecimal data are written to the tag data field.
- EPC requires
EPCDataStructure, and its total must be96or64bits (the string must start with96or64). Any other value, or an empty structure, generates no RFID commands. TagType,StartingBlock,NumberOfBytes,MemoryBank, the passwords and the lock options are ignored.
Common mistakes
- Printing on a non-ZPL / non-Fingerprint printer. The item is silently ignored.
- EPC without
EPCDataStructure.DataFormat = EPCneeds the structure; the number of values inDataToEncodemust match the number of partitions. - Hexadecimal data with an odd number of digits or with a length that does not match
NumberOfBytes. - Expecting something on the image. The item is not drawn in previews or image exports.
- More than one RFIDTagItem per label. A label carries a single tag; use one item.
- Locking before testing. Permanent locks are irreversible.