Imports System
Imports System.Runtime.InteropServices
Imports Microsoft.VisualBasic

Module LKPrint

    'You must to set dll file name for your system
    Public Const SEWOODIR As String = "SEWOOP11.dll"

    <DllImport(SEWOODIR, EntryPoint:="OpenPort")> _
    Public Function OpenPort(ByVal PortName As String, ByVal BaudRate As Int32) As Int32
    End Function
    <DllImport(SEWOODIR, EntryPoint:="ClosePort")> _
     Public Function ClosePort() As Int32
    End Function
    <DllImport(SEWOODIR, EntryPoint:="PrintNormal")> _
    Public Function PrintNormal(ByVal Data As String) As Int32
    End Function
    <DllImport(SEWOODIR, EntryPoint:="PrintText")> _
    Public Function PrintText(ByVal Data As String, ByVal Alignment As Int32, ByVal Attribute As Int32, ByVal TextSize As Int32) As Int32
    End Function
    <DllImport(SEWOODIR, EntryPoint:="PrintString")> _
    Public Function PrintString(ByVal Data As String) As Int32
    End Function
    <DllImport(SEWOODIR, EntryPoint:="PrintBitmap")> _
    Public Function PrintBitmap(ByVal BitmapFile As String, ByVal Alignment As Int32, ByVal Mode As Int32) As Int32
    End Function
    <DllImport(SEWOODIR, EntryPoint:="PrintBarCode")> _
    Public Function PrintBarCode(ByVal Data As String, ByVal Symbology As Int32, ByVal Height As Int32, ByVal Width As Int32, ByVal Alignment As Int32, ByVal TextPosition As Int32) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="PrinterCheck")> _
    Public Function PrinterCheck() As Int32
    End Function
    <DllImport(SEWOODIR, EntryPoint:="status")> _
    Public Function status() As Int32
    End Function
    <DllImport(SEWOODIR, EntryPoint:="LineFeed")> _
    Public Function LineFeed(ByVal LFCount As Int32) As Int32
    End Function
    <DllImport(SEWOODIR, EntryPoint:="PrintNVBitmap")> _
    Public Function PrintNVBitmap(ByVal NVImageNumber As Int32) As Int32
    End Function
    <DllImport(SEWOODIR, EntryPoint:="MSRSelectTrack")> _
    Public Function MSRSelectTrack(ByVal SelectTrack As Int32) As Int32
    End Function
    <DllImport(SEWOODIR, EntryPoint:="MSRReadTrack")> _
    Public Function MSRReadTrack(ByVal DataTrack1 As Byte(), ByVal DataTrack2 As Byte(), ByVal DataTrack3 As Byte()) As Int32
    End Function
    <DllImport(SEWOODIR, EntryPoint:="MSRReadTrackDual")> _
    Public Function MSRReadTrackDual(ByVal DataTrack1 As Byte(), ByVal DataTrack2 As Byte(), ByVal DataTrack3 As Byte(), ByVal DataTrack4 As Byte()) As Int32
    End Function
    <DllImport(SEWOODIR, EntryPoint:="MSRReadCancel")> _
    Public Function MSRReadCancel() As Int32
    End Function
    <DllImport(SEWOODIR, EntryPoint:="PrintText2Image")> _
    Public Function PrintText2Image(ByVal TextData As String, ByVal FontFace As String, ByVal FontStyle As Int32, ByVal FontSize As Int32, ByVal Alignment As Int32) As Int32
    End Function
    <DllImport(SEWOODIR, EntryPoint:="BlackMarkON")> _
    Public Function BlackMarkON(ByVal FeedCount As Int32) As Int32
    End Function
    <DllImport(SEWOODIR, EntryPoint:="BlackMarkSearch")> _
    Public Function BlackMarkSearch() As Int32
    End Function

    'Method return value
    Public Const LK_SUCCESS As Integer = 0
    Public Const LK_CREATE_ERROR As Integer = 1
    Public Const LK_NOT_OPENED As Integer = 2
    Public Const LK_FAIL As Integer = -1

    ' Printer Status flag
    Public Const LK_STS_PRINTEROFF As Integer = 128
    Public Const LK_STS_MSR_READ As Integer = 64
    Public Const LK_STS_PAPER_EMPTY As Integer = 32
    Public Const LK_STS_COVER_OPEN As Integer = 16
    Public Const LK_STS_BATTERY_LOW As Integer = 8
    Public Const LK_STS_NORMAL As Integer = 0


    ' Alignment Code
    Public Const LK_ALIGNMENT_LEFT As Integer = 0
    Public Const LK_ALIGNMENT_CENTER As Integer = 1
    Public Const LK_ALIGNMENT_RIGHT As Integer = 2

    ' Bitmap Size
    Public Const LK_BITMAP_NORMAL As Integer = 0
    Public Const LK_BITMAP_WIDTH_DOUBLE As Integer = 1
    Public Const LK_BITMAP_HEIGHT_DOUBLE As Integer = 2
    Public Const LK_BITMAP_WIDTH_HEIGHT_DOUBLE As Integer = 3

    ' Bitmap Image Mode
    Public Const LK_BITMAP_NO_DITHER As Integer = 0
    Public Const LK_BITMAP_ERROR_DIFFUSION As Integer = 1
    Public Const LK_BITMAP_ORDERED_DITHER As Integer = 2

    'Text Attribute
    'Font Attribute default value : not Bold, FontA, not Underline, not reverse
    Public Const LK_FNT_DEFAULT As Integer = 0
    Public Const LK_FNT_FONTB As Integer = 1
    Public Const LK_FNT_BOLD As Integer = 8
    Public Const LK_FNT_UNDERLINE As Integer = 128

    ' Text Size Attribute
    Public Const LK_TXT_1WIDTH As Integer = 0
    Public Const LK_TXT_2WIDTH As Integer = 16
    Public Const LK_TXT_3WIDTH As Integer = 32
    Public Const LK_TXT_4WIDTH As Integer = 48
    Public Const LK_TXT_5WIDTH As Integer = 64
    Public Const LK_TXT_6WIDTH As Integer = 80
    Public Const LK_TXT_7WIDTH As Integer = 96
    Public Const LK_TXT_8WIDTH As Integer = 112

    Public Const LK_TXT_1HEIGHT As Integer = 0
    Public Const LK_TXT_2HEIGHT As Integer = 1
    Public Const LK_TXT_3HEIGHT As Integer = 2
    Public Const LK_TXT_4HEIGHT As Integer = 3
    Public Const LK_TXT_5HEIGHT As Integer = 4
    Public Const LK_TXT_6HEIGHT As Integer = 5
    Public Const LK_TXT_7HEIGHT As Integer = 6
    Public Const LK_TXT_8HEIGHT As Integer = 7

    ' Barcode
    Public Const LK_BCS_PDF417 As Integer = 200
    Public Const LK_BCS_MAXICODE As Integer = 201
    Public Const LK_BCS_QRCODE As Integer = 202
    Public Const LK_BCS_DATAMATRIX As Integer = 203

    Public Const LK_BCS_UPCA As Integer = 101
    Public Const LK_BCS_UPCE As Integer = 102
    Public Const LK_BCS_EAN8 As Integer = 103
    Public Const LK_BCS_EAN13 As Integer = 104
    Public Const LK_BCS_JAN8 As Integer = 105
    Public Const LK_BCS_JAN13 As Integer = 106
    Public Const LK_BCS_ITF As Integer = 107
    Public Const LK_BCS_Codabar As Integer = 108
    Public Const LK_BCS_Code39 As Integer = 109
    Public Const LK_BCS_Code93 As Integer = 110
    Public Const LK_BCS_Code128 As Integer = 111
    Public Const LK_BCS_3OF5 As Integer = 112

    ' Barcode text position
    Public Const LK_HRI_TEXT_NONE As Integer = 0
    Public Const LK_HRI_TEXT_ABOVE As Integer = 1
    Public Const LK_HRI_TEXT_BELOW As Integer = 2

    ' MSR
    Public Const LK_CHECKSUM_ERROR As Integer = 1
    Public Const LK_TIMEOUT_ERROR As Integer = 2

End Module
