How to Send EPL commands to a USB TLP2824

Zebra TLP2824 USB Printer How to print EPL commands

Page 1 of 1

2 Replies - 7090 Views - Last Post: 27 December 2010 - 09:54 PM Rate Topic: -----

#1 jccabezas  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 26-December 10

How to Send EPL commands to a USB TLP2824

Posted 26 December 2010 - 09:15 PM

I have a Zebra TLP2824 Printer and I want to know how to send the EPL commands from a VB.Net Windows Form application.
Is This A Good Question/Topic? 0
  • +

Replies To: How to Send EPL commands to a USB TLP2824

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9059
  • View blog
  • Posts: 34,018
  • Joined: 12-June 08

Re: How to Send EPL commands to a USB TLP2824

Posted 26 December 2010 - 09:40 PM

Moved to the VB.NET forum per the OP.

OP - do you have any work done or specific issues you are having problems with?


Mind the rules about this is not a code writing service..


Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.
Was This Post Helpful? 0
  • +
  • -

#3 jccabezas  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 26-December 10

Re: How to Send EPL commands to a USB TLP2824

Posted 27 December 2010 - 09:54 PM

I found this code and make a little changes to manage savehandler and I'm trying to implement it. The problem is that the CreateFile Function returns -1

I have Windows 7 Pro and USB Zebra TLP2824.

Imports System.IO
Imports System.Runtime.InteropServices
Imports Microsoft.Win32.SafeHandles
Public Class EPLPrint
    Private Const GENERIC_WRITE As Integer = &H40000000
    Private Const OPEN_EXISTING As Integer = 3
    Private Const FILE_SHARE_WRITE As Integer = &H2

    Private _fileWriter As StreamWriter
    Private _outFile As FileStream
    Private _hPort As Integer
    Dim handle As SafeFileHandle

    <StructLayout(LayoutKind.Sequential)> Public Structure SECURITY_ATTRIBUTES
        Private nLength As Integer
        Private lpSecurityDescriptor As Integer
        Private bInheritHandle As Integer
    End Structure

    'Define Win32 functions
    Public Declare Function CloseHandle Lib "kernel32" Alias "CloseHandle" (ByVal hObject As Integer) As Integer
    Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, ByRef lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal dwCreationDisposition As Integer, ByVal dwFlagsAndAttributes As Integer, ByVal hTemplateFile As Integer) As Integer

    ''' <summary>
    ''' This function must be called first.  Printer path must be a COM Port or a UNC path.
    ''' </summary>
    Public Sub StartWrite(ByVal printerPath As String)
        Dim SA As SECURITY_ATTRIBUTES
        'Dim hPortP As IntPtr
        Dim hPortP As Integer
        'Dim retval As Integer

        'Create connection
        _hPort = CreateFile(printerPath, GENERIC_WRITE, FILE_SHARE_WRITE, SA, OPEN_EXISTING, 0, 0)


        'Get unsafe pointer
        hPortP = New IntPtr(_hPort) 'convert Integer to IntPtr 
        handle = New SafeFileHandle(New IntPtr(_hPort), True)

        'Create file stream
        _outFile = New FileStream(handle, FileAccess.Write)

        'Create stream writer
        _fileWriter = New StreamWriter(_outFile)

    End Sub
    ''' <summary>
    ''' This will write a command to the printer.
    ''' </summary>
    Public Sub Write(ByVal rawLine As String)
        _fileWriter.WriteLine(rawLine)
    End Sub
    ''' <summary>
    ''' This function must be called after writing to the zebra printer.
    ''' </summary>
    Public Sub EndWrite()
        'Clean up
        _fileWriter.Flush()
        _fileWriter.Close()
        _outFile.Close()
        CloseHandle(_hPort)
    End Sub

End Class

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Create object
        Dim print As New EPLPrint

        'Print on the computer PC-0556 with printer name VantageT
        'print.StartWrite("\\pc-0556\\VantageT")
        print.StartWrite("\\JCABEZAS-X301\TLP2824")

        'Do this because the zebra manual says so
        print.Write("")
        print.Write("N")

        'Write Text
        print.Write("A30,90,0,4,1,1,N,""" & "Hello" & """")

        'Write bar code
        print.Write("B30,20,0,1,2,5,50,N,""" & "World" & """")

        'Print a single copy
        print.Write("P1")

        'Clean up
        print.EndWrite()
    End Sub
End Class



Was This Post Helpful? 0
  • +
  • -

Page 1 of 1