How to Read an RFID Tag ID and Print It as Text and QR Code — PGL and TSPL Programming Guide for Printronix and TSC Printers

Printronix PGL & TSC TSPL — RFID Programming Guide

How to Read an RFID Tag ID and Print It as Text and QR Code on the Same Label

A practical programming guide for T6000e, T8000, T4000, T800, MB241 and Alpha RFID printers — using Printronix PGL and TSC TSPL to read the tag’s existing EPC, store it in a dynamic variable, and print it as both human-readable text and a scannable QR code on the same label, in a single pass.

Who this guide is for: Developers, IT managers and systems integrators integrating RFID label printing into WMS, ERP or asset tracking systems. This guide uses native printer language commands — no middleware, no label design software required. You send the commands directly to port 9100 over TCP/IP or serial. Code examples are based on validated official documentation and real-world implementations.

Why Read the Tag ID and Print It?

When an RFID label is printed and encoded, the printer writes a unique EPC (Electronic Product Code) to the tag’s memory. In most workflows this is sufficient. But there are real operational scenarios where you also need the encoded EPC to appear visibly on the label — as human-readable text and as a QR code:

🏭 IT Asset Management

Print an RFID tag on a laptop or server. A technician can scan the QR code with any phone camera to retrieve the asset URL, while the EPC in text allows manual entry if the RFID reader is unavailable.

📺 Verification Labels

After an RFID tag is encoded on a carton, a second companion label can be printed showing the EPC as text and QR code for audit trail and visual inspection at goods receiving.

🏥 Hospital Asset Tracking

Medical equipment is tagged with RFID. The QR code on the same label links directly to the asset management system. Staff can scan with a phone even when RFID readers are not available.

🚚 Supply Chain Serialisation

RFID tags are pre-encoded by the inlay manufacturer. At the production line the printer reads the existing tag, confirms the EPC, and prints it as text alongside the standard GS1 barcode on the same label pass.

How the Read-Then-Print Workflow Works

1
Label is positioned over the RFID antenna
The printer feeds the RFID label to the antenna position without printing. The NOMOTION option in PGL prevents the label from advancing past the print head until the read is complete.
2
RFRTAG command reads the EPC
The RFRTAG command interrogates the tag over UHF radio, reads the specified number of bits from the specified memory bank (EPC, TID or USER), and stores the result in a Dynamic Field variable.
3
Dynamic Field is referenced in print commands
The stored EPC value in DF1 (or equivalent) is referenced in TEXT and BARCODE commands. The printer renders the same data as human-readable text and as a QR code on the label.
✓
Label prints with EPC as text and QR code
The label exits with the encoded RFID tag, the EPC printed as a hex string, and the EPC as a scannable QR code — all in a single label pass, no external system needed.

Example 1 — Printronix PGL: Read Tag and Print EPC as Text and QR Code

Compatible printers: Printronix T6000e RFID (T6204e, T6304e, T6606e RFID), T8000 (T8204, T8304 with ODV RFID), T4000 RFID, T800 RFID
Printer language: PGL (Printronix Graphics Language)
Communication: Send to printer IP:9100 via TCP/IP, or via serial port

Step 1 — Printer Initialisation

Send this once when connecting to the printer to set paper parameters. Values are for a standard 100mm × 150mm label at 203 DPI. Adjust ENGINE-WIDTH for your label width in dots (203 DPI: 1 dot = 0.125mm, so 100mm = 800 dots = 03200).

!PTX_SETUP
; Set print width in dots for 100mm label at 203 DPI
ENGINE-WIDTH;03200.
PTX_END

; Reset to normal mode and clear any existing jobs
~NORMAL
~PIOFF
~DELETE LOGO;*ALL

; Set paper parameters
; INTENSITY: print darkness 1-9 | MEDIA 1: die-cut gaps | FEED SHIFT: fine-tune
~PAPER;INTENSITY 8;MEDIA 1;FEED SHIFT 0

Step 2 — Read the RFID Tag EPC (NOMOTION Job)

This job reads the 96-bit EPC from the tag without advancing the label. NOMOTION keeps the label over the antenna until the read is complete. The EPC is stored as hexadecimal in Dynamic Field DF1.

; Create a job called READTAG
; NOMOTION = do NOT advance the label after this job
~CREATE;READTAG;NOMOTION

  ; RFRTAG = Read Tag
  ; 96     = number of bits to read (96-bit EPC is standard for Gen2)
  ; EPC   = memory bank to read from (EPC / TID / USER)
  RFRTAG;96;EPC

  ; Store the 96 bits in Dynamic Field 1 (DF1) as Hex (H)
  ; Format options: H = hexadecimal, D = decimal, A = ASCII
  96;DF1;H

STOP

; Execute the READTAG job immediately
~EXECUTE;READTAG
Note on EPC bit length: Standard Gen2 RFID tags use a 96-bit EPC (24 hex characters). Some chips support 128-bit EPC. Check the calibration result from your printer menu (RFID > Calibration) to confirm the EPC field length for your specific tag inlay. Change 96 to 128 if using 128-bit tags.

Step 3 — Print the EPC as Text and QR Code

Now create and execute the print job. DF1 contains the EPC read in Step 2. We reference it in both a TEXT command (human-readable hex string) and a QR code BARCODE command. Coordinates are in dots from top-left (X, Y). Adjust for your label size.

; Create the print job
~CREATE;PRINTLABEL

  ; ---- HEADER TEXT ----
  ; TEXT;;;;;;
  ; Font 5 = standard font | size 2 = 10pt approx | rotation 0 = normal
  TEXT;5;2;0;50;30;RFID ASSET TAG

  ; ---- PRINT EPC AS HUMAN-READABLE HEX TEXT ----
  ; <IDF1> merges the content of DF1 (the EPC hex string) into the field
  TEXT;5;2;0;50;80;EPC: <IDF1>

  ; ---- PRINT EPC AS QR CODE ----
  ; BARCODE;;;;;;;
  ; Type QR = QR Code | height/size parameter sets cell size
  ; Confirmed working: QR code with EPC hex content only
  BARCODE;50;150;QR;3;N;0;<IDF1>

  ; ---- OPTIONAL: PRINT A STANDARD BARCODE ALONGSIDE ----
  ; Code 128 barcode from the same EPC data
  BARCODE;50;400;128;80;Y;0;2;2;<IDF1>

STOP

; Print 1 copy
~PRINT;1;1
✓ Confirmed working from real-world implementation: QR code with the raw EPC hex string as content works correctly on Printronix T4000 and T6000e RFID printers using PGL. The QR code scanner reads back the EPC hex string (e.g. E28011710000000000001234). If you need the QR code to contain a URL with the EPC embedded (e.g. https://yourdomain.com/rfid/E28011710...), this is a known PGL limitation — string concatenation with a static prefix is not directly supported in the label job. Use a middleware layer or PrintNet to pre-build the URL string before sending to the printer.

Complete PGL Program — Read Tag, Print Text and QR Code

The complete program combining all steps above. Send to printer_ip:9100 via netcat, Python socket, or any TCP client.

; ===================================================
; Printronix PGL: Read RFID EPC, Print Text + QR Code
; Tested on: T4000 RFID, T6204e RFID, T6304e RFID
; Label size: 100mm x 150mm at 203 DPI
; ===================================================

; -- INITIALISE PRINTER --
!PTX_SETUP
ENGINE-WIDTH;03200.
PTX_END
~NORMAL
~PIOFF
~DELETE LOGO;*ALL
~PAPER;INTENSITY 8;MEDIA 1;FEED SHIFT 0

; -- JOB 1: READ RFID TAG (do not advance label) --
~CREATE;READTAG;NOMOTION
  RFRTAG;96;EPC
  96;DF1;H
STOP
~EXECUTE;READTAG

; -- JOB 2: PRINT LABEL WITH EPC AS TEXT AND QR CODE --
~CREATE;PRINTLABEL
  TEXT;5;2;0;50;30;RFID ASSET TAG
  TEXT;5;1;0;50;70;Infinite Solutions, New Delhi
  TEXT;5;2;0;50;110;EPC: <IDF1>
  BARCODE;50;170;QR;3;N;0;<IDF1>
  BARCODE;50;470;128;80;Y;0;2;2;<IDF1>
STOP
~PRINT;1;1

Note: All PGL commands are from the official Printronix PGL Programmers Reference Manual (PTX_PRM_PGL). Coordinate system: X = horizontal distance from left edge in dots, Y = vertical distance from top in dots. At 203 DPI, 1mm = 8 dots.

Read TID Instead of EPC — PGL Variant

The TID (Tag Identifier) is a factory-programmed read-only unique identifier burned into the chip during manufacturing. It cannot be changed. For asset tracking applications where you want to store the chip’s permanent unique ID (not the user-programmed EPC), read TID instead:

; Read TID (factory-unique, read-only chip identifier)
; TID is typically 64 or 96 bits depending on chip model
~CREATE;READTID;NOMOTION
  RFRTAG;64;TID
  64;DF2;H
STOP
~EXECUTE;READTID

~CREATE;PRINTLABEL
  TEXT;5;2;0;50;30;CHIP TID (PERMANENT ID)
  TEXT;5;2;0;50;80;TID: <IDF2>
  BARCODE;50;150;QR;3;N;0;<IDF2>
STOP
~PRINT;1;1

Key PGL RFID Commands Reference

Command Syntax Description
RFRTAG RFRTAG;<bits>;<bank> Read bits from RFID tag memory bank. Banks: EPC, TID, USER, RESERVED
RFWTAG RFWTAG;<bits>;<bank>;<data> Write data to RFID tag memory bank
<bits>;<DFn>;<fmt> 96;DF1;H Store bits from RFRTAG into Dynamic Field n. Format: H=hex, D=decimal, A=ASCII
<IDFn> <IDF1> Inline merge of Dynamic Field n content into a print command. Used in TEXT and BARCODE commands
NOMOTION ~CREATE;<name>;NOMOTION Job option: do not advance the label after completing this job. Required for read-before-print workflow
~EXECUTE ~EXECUTE;<jobname> Execute a previously created job immediately
~PRINT ~PRINT;<copies>;<sets> Print n copies of the current job
TEXT TEXT;<font>;<size>;<rot>;<X>;<Y>;<data> Print text at position X,Y with specified font, size and rotation
BARCODE BARCODE;<X>;<Y>;<type>;<params>;<data> Print barcode or QR code at X,Y. Types include QR, 128, CODE39, EAN13, ITF etc.

Example 2 — TSC TSPL: Read RFID Tag and Print Text + QR Code

⚠ TSPL RFID applies to specific TSC RFID-capable printer models only: TSC MB241 RFID, Alpha-40L RFID, Alpha-40 RFID. The TSC desktop series (TH240, TH340 etc.) and non-RFID industrial models do NOT have RFID hardware and cannot use these commands. The TSPL RFID command set is documented in each model’s TSPL RFID Programming Manual available from usca.tscprinters.com/en/support.

TSC RFID-capable printers support RFID commands as extensions to TSPL/TSPL2. The MB241 RFID also supports a subset of ZPL RFID commands, making it easy to migrate from Zebra RFID applications.

TSPL: Write EPC, Read It Back, Print as Text and QR Code

; ===================================================
; TSC TSPL: Write RFID EPC, Read Back, Print Text + QR
; Compatible with: MB241 RFID, Alpha-40L RFID
; Label size: 100mm x 150mm
; ===================================================

; -- LABEL SETUP --
SIZE 100 mm, 150 mm
GAP 3 mm, 0 mm
DIRECTION 0,0
CLS

; -- RFID: WRITE EPC TO TAG --
; Write a 96-bit EPC (24 hex characters) to the tag
; Replace the hex string with your system-generated EPC
RFID WRITE EPC,"3000295B030000000000ABCD"

; -- RFID: READ BACK EPC INTO VARIABLE --
; READ syntax: RFID READ <bank>,<start-byte>,<byte-count>,<variable>
; EPC bank, starting at byte 0, read 12 bytes (96 bits), store in @EPC
RFID READ EPC,0,12,"@EPC"

; -- PRINT HEADER TEXT (static) --
; TEXT <X>,<Y>,"<font>",<rotation>,<xscale>,<yscale>,"<content>"
TEXT 50,30,"3",0,1,1,"RFID ASSET TAG"
TEXT 50,65,"3",0,1,1,"Infinite Solutions, New Delhi"

; -- PRINT EPC AS HUMAN-READABLE TEXT --
; @EPC contains the hex string read from the tag
TEXT 50,110,"3",0,1,1,"EPC: "
TEXT 200,110,"3",0,1,1,@EPC

; -- PRINT EPC AS QR CODE --
; QRCODE <X>,<Y>,<error-correction>,<cell-width>,<mode>,<rotation>,<data>
; H=high correction | 4=cell width dots | A=auto mode | 0=no rotation
QRCODE 50,160,H,4,A,0,@EPC

; -- OPTIONAL: ADD CODE 128 BARCODE --
BARCODE 50,460,"128",80,1,0,2,2,@EPC

; -- PRINT 1 COPY --
PRINT 1,1

TSPL: Read an Existing Pre-Encoded Tag (Without Writing First)

If the RFID inlay already has an EPC programmed by the inlay manufacturer (most commercial RFID labels ship with a unique pre-encoded TID and sometimes a pre-set EPC), skip the RFID WRITE command and only read:

; ===================================================
; TSPL: Read Pre-Encoded EPC, Print Text + QR Code
; For labels where the RFID chip already has an EPC
; ===================================================

SIZE 100 mm, 150 mm
GAP 3 mm, 0 mm
CLS

; Read existing EPC (no write command needed)
RFID READ EPC,0,12,"@EPC"

; Read TID (permanent chip ID, factory-programmed)
RFID READ TID,0,8,"@TID"

TEXT 50,30,"3",0,1,1,"PRE-ENCODED RFID LABEL"
TEXT 50,80,"3",0,1,1,"EPC: "
TEXT 200,80,"3",0,1,1,@EPC
TEXT 50,120,"3",0,1,1,"TID: "
TEXT 200,120,"3",0,1,1,@TID

; QR Code of EPC
QRCODE 50,160,H,4,A,0,@EPC

PRINT 1,1

Important: Verify exact TSPL RFID command syntax against your specific model’s TSPL RFID Programming Manual from usca.tscprinters.com/en/support. Command syntax may differ slightly between the MB241 RFID, Alpha-40L RFID and other TSPL RFID-capable models.

PGL vs TSPL — Which Language for Which Printer?

Language Printer Models RFID Read Command Notes
PGL T6000e RFID, T8000 RFID, T4000 RFID, T800 RFID RFRTAG;96;EPC Native Printronix language. Most comprehensive RFID feature set
ZGL (ZPL emulation) T6000e RFID, T8000 RFID, T4000 RFID, T800 RFID ^RF R,E Use when migrating from Zebra ZPL application. Same printer hardware
TSPL MB241 RFID, Alpha-40L RFID, Alpha-40 RFID RFID READ EPC,0,12,"@var" TSC desktop/industrial RFID models. MB241 RFID also supports ZPL RFID subset
TSPL-EZD TH240, TH340, TH220, MH241, MX241P — No RFID hardware on these models. RFID commands not available

Frequently Asked Questions

Can I embed the EPC in a URL and print as QR code in PGL?
Not directly within a single label job. PGL does not support string concatenation (joining a static URL prefix with the dynamic EPC value) within the label program itself. A real-world practitioner confirmed: QR code with raw EPC content works, but URL + EPC does not. The workaround is to build the full URL string in your host application before sending it to the printer, or use PrintNet Enterprise to pre-process the data.
Can multiple RFRTAG commands be in the same job?
Yes. Multiple RFRTAG commands are allowed in the same form, but the same DFn field cannot be defined multiple times in the same job. Use DF1, DF2, DF3 etc. for different read operations (e.g. read EPC into DF1, read TID into DF2).
How do I send PGL commands to the printer?
Send raw text to port 9100 on the printer’s IP address via any TCP client. On Linux/Mac: nc 192.168.1.100 9100 < myjob.pgl. On Windows: use RawPrint, NiceLabel, or a Python socket. In Python: socket.connect((ip, 9100)); socket.sendall(pgl_string.encode())
Where can I find the complete PGL and TSPL reference manuals?
Official programming manuals are available from TSC Printronix Auto ID support: usca.tscprinters.com/en/support (US/CA/India) or apac.tscprinters.com/en/support (APAC). Search for PTX_PRM_PGL for the PGL manual and your printer model name + TSPL for the TSPL manual. The RFID Labeling Reference Manual covering T800, T4000 and T6000e is at fs.tscprinters.com/system/files/p220002o_prm_rfid.pdf

Need Help Integrating an RFID Printer?

Infinite Solutions supplies and supports Printronix T6000e RFID, T8000 RFID, T4000 RFID, T800 RFID and TSC MB241 RFID in India. We provide printer commissioning, RFID calibration, PGL/TSPL integration support and PrintNet Enterprise configuration. GST invoice with GSTIN 07AFEPB0340P1ZO.

Infinite Solutions · 312 Vishwadeep Building, Janakpuri, New Delhi 110058 · GSTIN: 07AFEPB0340P1ZO