Click here to Skip to main content
15,890,512 members
Articles / Programming Languages / Visual Basic
Article

Zebra EPL2 Printing in .Net

Rate me:
Please Sign up or sign in to vote.
2.57/5 (9 votes)
7 Jul 2006CPOL 315.8K   12.2K   39   53
Print to zebra printers using EPL2 commands

Introduction

Attached is a good example on how to print to Zebra printers using the EPL2 commands in .Net.  In the attached file you will find 2 VB.Net 2003 Projects.  The project ZebraPrint is a good reuseable dll file (or you could just use the class) that you can use in VB.Net 2003 or 2005.  The project ZebraTest demonstrates how to print using ZebraPrint.  I have tested it using a Zebra TLP 2844 over a TCP/IP network.  I have not tested it over a COM or Parallel port yet, but in theory it should work.

 

Referances:

https://support.zebra.com/cpws/docs/zpl/zpl_elp_vbnet.htm

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionprinterPath is exactly what Pin
Rahul A18-May-17 7:29
Rahul A18-May-17 7:29 
SuggestionHow to print Chinese character?? Pin
hysen_hu21-Feb-12 1:02
hysen_hu21-Feb-12 1:02 
QuestionHelp me todo same in c# . i dont know vb.net Pin
suhaskumar86.sg10-Feb-12 3:30
suhaskumar86.sg10-Feb-12 3:30 
QuestionHow to generate .lbl file in asp.net using c# Pin
Harishkavita3-Aug-11 23:54
Harishkavita3-Aug-11 23:54 
QuestionWin7 problem Pin
TN_DK22-Feb-11 0:32
TN_DK22-Feb-11 0:32 
AnswerRe: Win7 problem Pin
EdMee7-Apr-11 13:05
EdMee7-Apr-11 13:05 
GeneralRe: Win7 problem Pin
Chi Nghia7-Dec-11 4:55
Chi Nghia7-Dec-11 4:55 
GeneralMy vote of 1 Pin
Dave Kreskowiak28-Feb-10 17:01
mveDave Kreskowiak28-Feb-10 17:01 
GeneralTHANKS VERY MUCH!!!!!!! [modified] Pin
w3rm18-May-09 9:24
w3rm18-May-09 9:24 
GeneralPrinting Asian Characters Pin
b_basa19-Mar-09 4:29
b_basa19-Mar-09 4:29 
GeneralZebra Track I Pin
VHOGUE28-Jan-09 16:42
VHOGUE28-Jan-09 16:42 
QuestionAccess to object C:\WINNT\System32\spool\PRINTERS\00004.SPL was blocked by rule Anti-virus Standard Protection:Prevent remote creation/modification of executable and configuration files. Pin
Mihai Antofi23-Jan-09 5:05
Mihai Antofi23-Jan-09 5:05 
Generalprinting from web app- Invalid handle. Parameter name: handle Pin
GeniousSal15-Jan-09 2:44
GeniousSal15-Jan-09 2:44 
GeneralRe: printing from web app- Invalid handle. Parameter name: handle Pin
GeniousSal15-Jan-09 23:38
GeniousSal15-Jan-09 23:38 
GeneralProblem Printing in QL420 Printer Pin
ajsri778-Oct-07 22:25
ajsri778-Oct-07 22:25 
GeneralRe: Problem Printing in QL420 Printer Pin
sarria88@gmail.com25-Feb-09 7:03
sarria88@gmail.com25-Feb-09 7:03 
QuestionNew FileStream(hPortP, FileAccess.Write) Pin
TheRealRhodieboy25-Sep-07 8:27
TheRealRhodieboy25-Sep-07 8:27 
AnswerRe: New FileStream(hPortP, FileAccess.Write) Pin
Member 46736974-Jun-09 11:23
Member 46736974-Jun-09 11:23 
GeneralRe: New FileStream(hPortP, FileAccess.Write) Pin
Shoaib Mateen11-May-10 18:34
Shoaib Mateen11-May-10 18:34 
Hello and thank you for making it easy for others to use it.

Just one query,

Using vs 2008 for development, and is trying to use the code that you have mentioned.

Dim Texxxt As String

Dim SA As SECURITY_ATTRIBUTES

Dim handle As SafeFileHandle

Dim outFile As FileStream, hPortP As IntPtr

LPTPORT = "USB002"

Texxxt = Me.RichTextBox1.Text


hPort = CreateFile(LPTPORT, GENERIC_WRITE, FILE_SHARE_WRITE, SA, OPEN_EXISTING, 0, 0)
handle = New SafeFileHandle(New IntPtr(hPort), True)
' hPortP = New IntPtr(hPort) 'convert Integer to IntPtr

outFile = New FileStream(handle, FileAccess.Write) 'Create FileStream using Handle



Dim fileWriter As New StreamWriter(outFile)



fileWriter.WriteLine(" ")

fileWriter.WriteLine("N")

fileWriter.Write("A50,50,0,4,1,1,N,")

fileWriter.Write(Chr(34))

fileWriter.Write("Zebra")

fileWriter.Write(Chr(34))

fileWriter.Write(Chr(13))

fileWriter.Write(Chr(10))

fileWriter.Write("A50,100,0,4,1,1,N,")

fileWriter.Write(Chr(34))

fileWriter.Write("Tech Support")

fileWriter.Write(Chr(34))

fileWriter.Write(Chr(13))

fileWriter.Write(Chr(10))

fileWriter.WriteLine("P1")

fileWriter.Flush()

fileWriter.Close()

outFile.Close()



retval = CloseHandle(hPort)


End Sub

That is the code that i am trying to use, inorder to print my barcodes to a zebra TPL 2844 printer connected to my USB port.

The value of hport is coming -1 , that means nothing is being assigned to it, that's what i think.

Getting the same error, argumentexception, invalid handler.

Please reply to this as soon as possible for you..

Regards
GeneralRe: New FileStream(hPortP, FileAccess.Write) Pin
Guido Nicolas Quadrini9-Apr-17 11:58
Guido Nicolas Quadrini9-Apr-17 11:58 
QuestionCAn anyone lend me ahand ? Pin
DevForRent6-Sep-07 5:28
DevForRent6-Sep-07 5:28 
AnswerRe: CAn anyone lend me ahand ? Pin
DevForRent6-Sep-07 5:42
DevForRent6-Sep-07 5:42 
QuestionVariable and Template? Pin
NewZebraUser17-Jul-07 8:47
NewZebraUser17-Jul-07 8:47 
AnswerRe: Variable and Template? Pin
Sing Abend23-Aug-07 10:49
professionalSing Abend23-Aug-07 10:49 
AnswerRe: Variable and Template? Pin
Sing Abend24-Aug-07 10:39
professionalSing Abend24-Aug-07 10:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.