'**************************************************************
' VB .NET Standard Linear Barcode Generator V.2020
' © Copyright, 2020 IDAutomation.com, Inc. All rights reserved.
' Portions of this program utilize IDAutomation USA Patent 7,637,436
'
'*****************************************************************
' Limitations of the Demo Version:
' The demo version of this product includes a fully
' functional font and is designed only for the
' purpose of testing the font in various applications
' and point sizes. To generate dynamic symbols,
' a font encoder is required to format the data being
' encoded into the symbol.
' Only static data can be provided for the encoders
' in the demo version, because providing a working
' encoder would reveal the complete source code,
' which is only available in the licensed version.
' 
'*****************************************************************
'
' Please refer to the User Manual and Included Examples
' https://www.idautomation.com/barcode-components/dotnet-standard/
'
'*****************************************************************

Imports System.Text

Public Class Linear


    '' Code128 ''
    '' **************************************************************************************************

    '' <summary>
    '' Function, which creates a barcode, depending on the various input options chosen. 
    '' </summary>
    '' <param name="DataToEncode">The data that Is encoded in the barcode.</param>
    '' <param name="ApplyTilde">Enables processing of tilde And parentheses characters for purposes of encoding ASCII functions And GS1 application identifiers.</param>
    '' <param name="QuietZone">Define the size of a blank zone around the code.</param>
    '' <param name="ModuleSize">Define the size of each module.</param>
    '' <param name="BarsHeight">Define the height of barcode.</param>
    '' <returns>A array representation of barcode's image.</returns>
    Public Function Code128(DataToEncode As String, Optional ApplyTilde As Boolean = True, Optional QuietZone As Integer = 2, Optional ModuleSize As Integer = 1, Optional BarsHeight As Integer = 20)

        Dim code As String
        code = "0011010010000110001000101011000100010100011000100111100101001111010010001111010111101110101001011000010011110100100001101001000111101011000010100111001100101100011101011000000"
        Return _rasterOutput(code, QuietZone, ModuleSize, BarsHeight)

    End Function


    '' <summary>
    '' Function, which creates a barcode barcode, depending on the various input options chosen. 
    '' </summary>
    '' <param name="DataToEncode">The data that Is encoded in the barcode.</param>
    '' <param name="ApplyTilde">Enables processing of tilde And parentheses characters for purposes of encoding ASCII functions And GS1 application identifiers.</param>
    '' <param name="VectorType">Define the type of vector image for output.</param>
    '' <param name="NewLine">String indicating EOL character. Defaults to the operating system EOL character if left NULL.</param>
    '' <param name="QuietZone">Define the size of a blank zone around the code.</param>
    '' <param name="ModuleSize">Define the size of each module.</param>
    '' <param name="BarsHeight">Define the height of barcode.</param>
    '' <returns>A string representation of vector barcode's image.</returns>
    Public Function Code128(DataToEncode As String, Optional ApplyTilde As Boolean = True, Optional VectorType As VectorTypes = VectorTypes.VecEPS, Optional NewLine As String = "", Optional QuietZone As Integer = 2, Optional ModuleSize As Integer = 2, Optional BarsHeight As Integer = 20)

        Dim code As String
        code = "0011010010000110001000101011000100010100011000100111100101001111010010001111010111101110101001011000010011110100100001101001000111101011000010100111001100101100011101011000000"
        Return _vectorOutput(code, VectorType, NewLine, QuietZone, ModuleSize, BarsHeight)

    End Function


    '' <summary>
    '' Function, which creates a barcode barcode, depending on the various input options chosen. 
    '' </summary>
    '' <param name="DataToEncode">The data that Is encoded in the barcode.</param>
    '' <param name="ApplyTilde">Enables processing of tilde And parentheses characters for purposes of encoding ASCII functions And GS1 application identifiers.</param>
    '' <param name="OutputType">Indicates the encoded text output for the barcode font.</param>
    '' <param name="NewLine">String indicating EOL character. Defaults to the operating system EOL character if left NULL.</param>
    '' <param name="BarsHeight">Define the height of barcode.</param>
    '' <returns>A string representation of vector barcode's image.</returns>
    Public Function Code128(DataToEncode As String, Optional ApplyTilde As Boolean = True, Optional OutputType As OutputTypes = OutputTypes.IDAUniXSFont, Optional NewLine As String = "", Optional BarHeight As Integer = 20) As String

        Dim code As String
        Dim _newline As String

        code = "EBDGCAAGCACGBNABMBCMAMIABAHBMBDEBCMAHABJFAGIAH"

        '' allows user to set an end-of-line (EOL) string
        If (NewLine = "") Then NewLine = Environment.NewLine '' Default
        _newline = NewLine

        If OutputType = OutputTypes.IDAMonospaceFont Then
            Return "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌"
        Else
            Return code

        End If

    End Function

    '' **************************************************************************************************
    '' Code128 ''


    '' Code128a '' 
    '' **************************************************************************************************

    '' <summary>
    '' Function, which creates a barcode, depending on the various input options chosen. 
    '' </summary>
    '' <param name="DataToEncode">The data that Is encoded in the barcode.</param>
    '' <param name="QuietZone">Define the size of a blank zone around the code.</param>
    '' <param name="ModuleSize">Define the size of each module.</param>
    '' <param name="BarsHeight">Define the height of barcode.</param>
    '' <returns>An array representation of Code 128's image.</returns>
    Public Function Code128a(DataToEncode As String, Optional QuietZone As Integer = 2, Optional ModuleSize As Integer = 1, Optional BarsHeight As Integer = 20)

        Dim code As String
        code = "0011010010000110001000101011000100010100011000100111100101001111010010001111010111101110101001011000010011110100100001101001000111101011000010100111001100101100011101011000000"
        Return _rasterOutput(code, QuietZone, ModuleSize, BarsHeight)

    End Function


    '' <summary>
    '' Function, which creates a barcode barcode, depending on the various input options chosen. 
    '' </summary>
    '' <param name="DataToEncode">The data that Is encoded in the barcode.</param>
    '' <param name="VectorType">Define the type of vector image for output.</param>
    '' <param name="NewLine">String indicating EOL character. Defaults to the operating system EOL character if left NULL.</param>
    '' <param name="QuietZone">Define the size of a blank zone around the code.</param>
    '' <param name="ModuleSize">Define the size of each module.</param>
    '' <param name="BarsHeight">Define the height of barcode.</param>
    '' <returns>A string representation of vector barcode's image.</returns>
    Public Function Code128a(DataToEncode As String, Optional VectorType As VectorTypes = VectorTypes.VecEPS, Optional NewLine As String = "", Optional QuietZone As Integer = 2, Optional ModuleSize As Integer = 2, Optional BarsHeight As Integer = 20)

        Dim code As String
        code = "0011010010000110001000101011000100010100011000100111100101001111010010001111010111101110101001011000010011110100100001101001000111101011000010100111001100101100011101011000000"
        Return _vectorOutput(code, VectorType, NewLine, QuietZone, ModuleSize, BarsHeight)

    End Function


    '' <summary>
    '' Function, which creates a barcode barcode, depending on the various input options chosen. 
    '' </summary>
    '' <param name="DataToEncode">The data that Is encoded in the barcode.</param>
    '' <param name="OutputType">Indicates the encoded text output for the barcode font.</param>
    '' <param name="NewLine">String indicating EOL character. Defaults to the operating system EOL character if left NULL.</param>
    '' <param name="BarsHeight">Define the height of barcode.</param>
    '' <returns>A string representation of vector barcode's image.</returns>
    Public Function Code128a(DataToEncode As String, Optional OutputType As OutputTypes = OutputTypes.IDAUniXSFont, Optional NewLine As String = "", Optional BarsHeight As Integer = 20) As String

        Dim code As String
        Dim _newline As String

        code = "EBDGCAAGCACGBNABMBCMAMIABAHBMBDEBCMAHABJFAGIAH"

        '' allows user to set an end-of-line (EOL) string
        If (NewLine = "") Then NewLine = Environment.NewLine '' Default
        _newline = NewLine

        If OutputType = OutputTypes.IDAMonospaceFont Then
            Return "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌"
        Else
            Return code

        End If

    End Function

    '' **************************************************************************************************
    '' Code128a ''


    '' Code128b '' 
    '' **************************************************************************************************

    '' <summary>
    '' Function, which creates a barcode, depending on the various input options chosen. 
    '' </summary>
    '' <param name="DataToEncode">The data that Is encoded in the barcode.</param>
    '' <param name="QuietZone">Define the size of a blank zone around the code.</param>
    '' <param name="ModuleSize">Define the size of each module.</param>
    '' <param name="BarsHeight">Define the height of barcode.</param>
    '' <returns>An array representation of barcode's image.</returns>
    Public Function Code128b(DataToEncode As String, Optional QuietZone As Integer = 2, Optional ModuleSize As Integer = 1, Optional BarsHeight As Integer = 20)

        Dim code As String
        code = "0011010010000110001000101011000100010100011000100111100101001111010010001111010111101110101001011000010011110100100001101001000111101011000010100111001100101100011101011000000"
        Return _rasterOutput(code, QuietZone, ModuleSize, BarsHeight)

    End Function


    '' <summary>
    '' Function, which creates a barcode barcode, depending on the various input options chosen. 
    '' </summary>
    '' <param name="DataToEncode">The data that Is encoded in the barcode.</param>
    '' <param name="VectorType">Define the type of vector image for output.</param>
    '' <param name="NewLine">String indicating EOL character. Defaults to the operating system EOL character if left NULL.</param>
    '' <param name="QuietZone">Define the size of a blank zone around the code.</param>
    '' <param name="ModuleSize">Define the size of each module.</param>
    '' <param name="BarsHeight">Define the height of barcode.</param>
    '' <returns>A string representation of vector barcode's image.</returns>
    Public Function Code128b(DataToEncode As String, Optional VectorType As VectorTypes = VectorTypes.VecEPS, Optional NewLine As String = "", Optional QuietZone As Integer = 2, Optional ModuleSize As Integer = 2, Optional BarsHeight As Integer = 20)

        Dim code As String
        code = "0011010010000110001000101011000100010100011000100111100101001111010010001111010111101110101001011000010011110100100001101001000111101011000010100111001100101100011101011000000"
        Return _vectorOutput(code, VectorType, NewLine, QuietZone, ModuleSize, BarsHeight)

    End Function


    '' <summary>
    '' Function, which creates a barcode barcode, depending on the various input options chosen. 
    '' </summary>
    '' <param name="DataToEncode">The data that Is encoded in the barcode.</param>
    '' <param name="OutputType">Indicates the encoded text output for the barcode font.</param>
    '' <param name="NewLine">String indicating EOL character. Defaults to the operating system EOL character if left NULL.</param>
    '' <param name="BarsHeight">Define the height of barcode.</param>
    '' <returns>A string representation of vector barcode's image.</returns>
    Public Function Code128b(DataToEncode As String, Optional OutputType As OutputTypes = OutputTypes.IDAUniXSFont, Optional NewLine As String = "", Optional BarsHeight As Integer = 20) As String

        Dim code As String
        Dim _newline As String

        code = "EBDGCAAGCACGBNABMBCMAMIABAHBMBDEBCMAHABJFAGIAH"

        '' allows user to set an end-of-line (EOL) string
        If (NewLine = "") Then NewLine = Environment.NewLine '' Default
        _newline = NewLine

        If OutputType = OutputTypes.IDAMonospaceFont Then
            Return "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌"
        Else
            Return code

        End If

    End Function

    '' **************************************************************************************************
    '' Code128b ''


    '' Code128c '' 
    '' **************************************************************************************************

    '' <summary>
    '' Function, which creates a barcode, depending on the various input options chosen. 
    '' </summary>
    '' <param name="DataToEncode">The data that Is encoded in the barcode.</param>
    '' <param name="QuietZone">Define the size of a blank zone around the code.</param>
    '' <param name="ModuleSize">Define the size of each module.</param>
    '' <param name="BarsHeight">Define the height of barcode.</param>
    '' <returns>An array representation of barcode's image.</returns>
    Public Function Code128c(DataToEncode As String, Optional QuietZone As Integer = 2, Optional ModuleSize As Integer = 1, Optional BarsHeight As Integer = 20)

        Dim code As String
        code = "0011010010000110001000101011000100010100011000100111100101001111010010001111010111101110101001011000010011110100100001101001000111101011000010100111001100101100011101011000000"
        Return _rasterOutput(code, QuietZone, ModuleSize, BarsHeight)

    End Function


    '' <summary>
    '' Function, which creates a barcode barcode, depending on the various input options chosen. 
    '' </summary>
    '' <param name="DataToEncode">The data that Is encoded in the barcode.</param>
    '' <param name="VectorType">Define the type of vector image for output.</param>
    '' <param name="NewLine">String indicating EOL character. Defaults to the operating system EOL character if left NULL.</param>
    '' <param name="QuietZone">Define the size of a blank zone around the code.</param>
    '' <param name="ModuleSize">Define the size of each module.</param>
    '' <param name="BarsHeight">Define the height of barcode.</param>
    '' <returns>A string representation of vector barcode's image.</returns>
    Public Function Code128c(DataToEncode As String, Optional VectorType As VectorTypes = VectorTypes.VecEPS, Optional NewLine As String = "", Optional QuietZone As Integer = 2, Optional ModuleSize As Integer = 2, Optional BarsHeight As Integer = 20)

        Dim code As String
        code = "0011010010000110001000101011000100010100011000100111100101001111010010001111010111101110101001011000010011110100100001101001000111101011000010100111001100101100011101011000000"
        Return _vectorOutput(code, VectorType, NewLine, QuietZone, ModuleSize, BarsHeight)

    End Function


    '' <summary>
    '' Function, which creates a barcode barcode, depending on the various input options chosen. 
    '' </summary>
    '' <param name="DataToEncode">The data that Is encoded in the barcode.</param>
    '' <param name="OutputType">Indicates the encoded text output for the barcode font.</param>
    '' <param name="NewLine">String indicating EOL character. Defaults to the operating system EOL character if left NULL.</param>
    '' <param name="BarsHeight">Define the height of barcode.</param>
    '' <returns>A string representation of vector barcode's image.</returns>
    Public Function Code128c(DataToEncode As String, Optional OutputType As OutputTypes = OutputTypes.IDAUniXSFont, Optional NewLine As String = "", Optional BarsHeight As Integer = 20) As String

        Dim code As String
        Dim _newline As String

        code = "EBDGCAAGCACGBNABMBCMAMIABAHBMBDEBCMAHABJFAGIAH"

        '' allows user to set an end-of-line (EOL) string
        If (NewLine = "") Then NewLine = Environment.NewLine '' Default
        _newline = NewLine

        If OutputType = OutputTypes.IDAMonospaceFont Then
            Return "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌"
        Else
            Return code

        End If

    End Function

    '' **************************************************************************************************
    '' Code128c ''


    '' Code39 '' 
    '' **************************************************************************************************

    '' <summary>
    '' Function, which creates a barcode, depending on the various input options chosen. 
    '' </summary>
    '' <param name="DataToEncode">The data that Is encoded in the barcode.</param>
    '' <param name="NDimension">Define the NDimension parameter.</param>
    '' <param name="Mod43">Enables processing of Mod 43 check digit.</param>
    '' <param name="QuietZone">Define the size of a blank zone around the code.</param>
    '' <param name="ModuleSize">Define the size of each module.</param>
    '' <param name="BarsHeight">Define the height of barcode.</param>
    '' <returns>An array representation of barcode's image.</returns>
    Public Function Code39(DataToEncode As String, Optional NDimension As Single = 2, Optional Mod43 As Boolean = False, Optional QuietZone As Integer = 2, Optional ModuleSize As Integer = 1, Optional BarsHeight As Integer = 20)

        Dim code As String
        code = "0011010010000110001000101011000100010100011000100111100101001111010010001111010111101110101001011000010011110100100001101001000111101011000010100111001100101100011101011000000"
        Return _rasterOutput(code, QuietZone, ModuleSize, BarsHeight)

    End Function


    '' <summary>
    '' Function, which creates a barcode barcode, depending on the various input options chosen. 
    '' </summary>
    '' <param name="DataToEncode">The data that Is encoded in the barcode.</param>
    '' <param name="NDimension">Define the NDimension parameter.</param>
    '' <param name="Mod43">Enables processing of Mod 43 check digit.</param>
    '' <param name="VectorType">Define the type of vector image for output.</param>
    '' <param name="NewLine">String indicating EOL character. Defaults to the operating system EOL character if left NULL.</param>
    '' <param name="QuietZone">Define the size of a blank zone around the code.</param>
    '' <param name="ModuleSize">Define the size of each module.</param>
    '' <param name="BarsHeight">Define the height of barcode.</param>
    '' <returns>A string representation of vector barcode's image.</returns>
    Public Function Code39(DataToEncode As String, Optional NDimension As Single = 2, Optional Mod43 As Boolean = False, Optional VectorType As VectorTypes = VectorTypes.VecEPS, Optional NewLine As String = "", Optional QuietZone As Integer = 2, Optional ModuleSize As Integer = 2, Optional BarsHeight As Integer = 20)

        Dim code As String
        code = "0011010010000110001000101011000100010100011000100111100101001111010010001111010111101110101001011000010011110100100001101001000111101011000010100111001100101100011101011000000"
        Return _vectorOutput(code, VectorType, NewLine, QuietZone, ModuleSize, BarsHeight)

    End Function


    '' <summary>
    '' Function, which creates a barcode barcode, depending on the various input options chosen. 
    '' </summary>
    '' <param name="DataToEncode">The data that Is encoded in the barcode.</param>
    '' <param name="NDimension">Define the NDimension parameter.</param>
    '' <param name="Mod43">Enables processing of Mod 43 check digit.</param>
    '' <param name="OutputType">Indicates the encoded text output for the barcode font.</param>
    '' <param name="NewLine">String indicating EOL character. Defaults to the operating system EOL character if left NULL.</param>
    '' <param name="BarsHeight">Define the height of barcode.</param>
    '' <returns>A string representation of vector barcode's image.</returns>
    Public Function Code39(DataToEncode As String, Optional NDimension As Single = 2, Optional Mod43 As Boolean = False, Optional OutputType As OutputTypes = OutputTypes.IDAUniXSFont, Optional NewLine As String = "", Optional BarHeight As Integer = 20) As String

        Dim code As String
        Dim _newline As String

        code = "EBDGCAAGCACGBNABMBCMAMIABAHBMBDEBCMAHABJFAGIAH"

        '' allows user to set an end-of-line (EOL) string
        If (NewLine = "") Then NewLine = Environment.NewLine '' Default
        _newline = NewLine

        If OutputType = OutputTypes.IDAMonospaceFont Then
            Return "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌"
        Else
            Return code

        End If

    End Function

    '' **************************************************************************************************
    '' Code39 ''

    '' ITF '' 
    '' **************************************************************************************************

    '' <summary>
    '' Function, which creates a barcode, depending on the various input options chosen. 
    '' </summary>
    '' <param name="DataToEncode">The data that Is encoded in the barcode.</param>
    '' <param name="NDimension">Define the NDimension parameter.</param>
    '' <param name="Mod10">Enables processing of Mod 10 check digit.</param>
    '' <param name="QuietZone">Define the size of a blank zone around the code.</param>
    '' <param name="ModuleSize">Define the size of each module.</param>
    '' <param name="BarsHeight">Define the height of barcode.</param>
    '' <returns>An array representation of barcode's image.</returns>
    Public Function ITF(DataToEncode As String, Optional NDimension As Single = 2.5, Optional Mod10 As Boolean = False, Optional QuietZone As Integer = 2, Optional ModuleSize As Integer = 1, Optional BarsHeight As Integer = 20)

        Dim code As String
        code = "0011010010000110001000101011000100010100011000100111100101001111010010001111010111101110101001011000010011110100100001101001000111101011000010100111001100101100011101011000000"
        Return _rasterOutput(code, QuietZone, ModuleSize, BarsHeight)

    End Function


    '' <summary>
    '' Function, which creates a barcode barcode, depending on the various input options chosen. 
    '' </summary>
    '' <param name="DataToEncode">The data that Is encoded in the barcode.</param>
    '' <param name="NDimension">Define the NDimension parameter.</param>
    '' <param name="Mod10">Enables processing of Mod 10 check digit.</param>
    '' <param name="VectorType">Define the type of vector image for output.</param>
    '' <param name="NewLine">String indicating EOL character. Defaults to the operating system EOL character if left NULL.</param>
    '' <param name="QuietZone">Define the size of a blank zone around the code.</param>
    '' <param name="ModuleSize">Define the size of each module.</param>
    '' <param name="BarsHeight">Define the height of barcode.</param>
    '' <returns>A string representation of vector barcode's image.</returns>
    Public Function ITF(DataToEncode As String, Optional NDimension As Single = 2.5, Optional Mod10 As Boolean = False, Optional VectorType As VectorTypes = VectorTypes.VecEPS, Optional NewLine As String = "", Optional QuietZone As Integer = 2, Optional ModuleSize As Integer = 2, Optional BarsHeight As Integer = 20)

        Dim code As String
        code = "0011010010000110001000101011000100010100011000100111100101001111010010001111010111101110101001011000010011110100100001101001000111101011000010100111001100101100011101011000000"
        Return _vectorOutput(code, VectorType, NewLine, QuietZone, ModuleSize, BarsHeight)

    End Function


    '' <summary>
    '' Function, which creates a barcode barcode, depending on the various input options chosen. 
    '' </summary>
    '' <param name="DataToEncode">The data that Is encoded in the barcode.</param>
    '' <param name="NDimension">Define the NDimension parameter.</param>
    '' <param name="Mod10">Enables processing of Mod 10 check digit.</param>
    '' <param name="OutputType">Indicates the encoded text output for the barcode font.</param>
    '' <param name="NewLine">String indicating EOL character. Defaults to the operating system EOL character if left NULL.</param>
    '' <param name="BarsHeight">Define the height of barcode.</param>
    '' <returns>A string representation of vector barcode's image.</returns>
    Public Function ITF(DataToEncode As String, Optional NDimension As Single = 2.5, Optional Mod10 As Boolean = False, Optional OutputType As OutputTypes = OutputTypes.IDAUniXSFont, Optional NewLine As String = "", Optional BarsHeight As Integer = 20) As String

        Dim code As String
        Dim _newline As String

        code = "EBDGCAAGCACGBNABMBCMAMIABAHBMBDEBCMAHABJFAGIAH"

        '' allows user to set an end-of-line (EOL) string
        If (NewLine = "") Then NewLine = Environment.NewLine '' Default
        _newline = NewLine

        If OutputType = OutputTypes.IDAMonospaceFont Then
            Return "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" & _newline _
                 & "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌"
        Else
            Return code

        End If

    End Function

    '' **************************************************************************************************
    '' ITF ''


    Private Function _vectorOutput(Code As String, Optional VectorType As VectorTypes = VectorTypes.VecEPS, Optional NewLine As String = "", Optional QuietZone As Integer = 2, Optional ModuleSize As Integer = 2, Optional BarsHeight As Integer = 20)

        Dim cols As Integer = 0
        Dim rows As Integer = 0
        Dim _newline As String

        cols = Code.Length()
        rows = BarsHeight

        '' allows user to set an end-of-line (EOL) string
        If (NewLine = "") Then NewLine = Environment.NewLine '' Default
        _newline = NewLine

        Dim strOut As StringBuilder = New StringBuilder("")
        Dim tempW As String
        Dim tempH As String
        Dim x As Integer
        Dim y As Integer

        ModuleSize = ModuleSize * 4
        tempW = (cols * ModuleSize).ToString()
        tempH = (rows * ModuleSize).ToString()

        If (VectorType = VectorTypes.VecSVG) Then

            strOut.Append("<?xml version='1.0' standalone='no'?>" + _newline)
            strOut.Append("<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>" + _newline)
            strOut.Append("<svg width='" + tempW + "' height='" + tempH + "' version='1.1' xmlns='http://www.w3.org/2000/svg'>" + _newline)
            strOut.Append("  <g id='linear'>" + _newline)
            strOut.Append("    <g id='background' fill='#ffffff' stroke='#ffffff'>" + _newline)
            strOut.Append("      <rect x='0' y='0' width='" + tempW + "' height='" + tempH + "' />" + _newline)
            strOut.Append("    </g>" + _newline)
            strOut.Append("    <g id='pattern' fill='#000000' stroke='#000000'>" + _newline)

            For y = 0 To rows - 1
                For x = 1 To cols
                    If ((Mid(Code, x, 1) <> "0") And (y >= QuietZone And (y < rows - QuietZone))) Then
                        strOut.Append("    <g id='R" + y.ToString() + "C" + x.ToString() + "' >" + _newline)
                        strOut.Append("      <rect x='" + (x * ModuleSize).ToString() + "' y='" + (y * ModuleSize).ToString() + "' width='" + (ModuleSize).ToString() + "' height='" + (ModuleSize).ToString() + "' />" + _newline)
                        strOut.Append("    </g>" + _newline)
                    End If
                Next
            Next
            strOut.Append("    </g>" + _newline)
            strOut.Append("  </g>" + _newline)
            strOut.Append("</svg>" + _newline)

        ElseIf (VectorType = VectorTypes.VecEPS) Then
            strOut.Append("%!PS-Adobe-3.0 EPSF-3.0" + _newline)
            strOut.Append("%%Creator: IDAutomation.com" + _newline)
            strOut.Append("%%Title: linear" + _newline)
            strOut.Append("%%CreationDate: " + DateTime.Now.ToString("ddd mmm d hh:mm:ss yyyy") + _newline)
            strOut.Append("%%BoundingBox: 0 0 " + tempW + " " + tempH + _newline)
            strOut.Append("%%DocumentData: Clean7Bit" + _newline)
            strOut.Append("%%EndComments" + _newline)
            strOut.Append("%%BeginProlog" + _newline)
            strOut.Append("/bd { bind def } bind def" + _newline)
            strOut.Append("/incompound false def" + _newline)
            strOut.Append("/m { moveto } bd" + _newline)
            strOut.Append("/l { lineto } bd" + _newline)
            strOut.Append("/*U { /incompound false def f} bd" + _newline)
            strOut.Append("/k { setcmykcolor } bd" + _newline)

            strOut.Append("/c { curveto } bd" + _newline)
            strOut.Append("/F { incompound not {fill} if } bd" + _newline)
            strOut.Append("/f { closepath F } bd" + _newline)
            strOut.Append("/S { stroke } bd" + _newline)
            strOut.Append("/*u { /incompound true def } bd" + _newline)
            strOut.Append("/K { k } bd" + _newline)

            strOut.Append("%%EndProlog" + _newline)
            strOut.Append("%%BeginSetup" + _newline)
            strOut.Append("%%EndSetup" + _newline)
            strOut.Append("0.000 0.000 0.000 0.000 k" + _newline)
            strOut.Append("0 0 m" + _newline)
            strOut.Append("0 0 l" + _newline)
            strOut.Append(tempW + " 0 l" + _newline)
            strOut.Append(tempW + " " + tempH + " l" + _newline)
            strOut.Append("0 " + tempH + " l" + _newline)
            strOut.Append("f" + _newline)
            strOut.Append("*U" + _newline)

            Dim n As Integer = rows * ModuleSize
            strOut.Append("0.000 0.000 0.000 1.000 k" + _newline)
            For y = 0 To rows - 1
                For x = 1 To cols
                    If ((Mid(Code, x, 1) <> "0") And (y >= QuietZone And (y < rows - QuietZone))) Then
                        strOut.Append((x * ModuleSize).ToString() + " " + (n - y * ModuleSize).ToString() + " m" + _newline)
                        strOut.Append((x * ModuleSize).ToString() + " " + (n - y * ModuleSize).ToString() + " l" + _newline)
                        strOut.Append(((x + 1) * ModuleSize).ToString() + " " + (n - y * ModuleSize).ToString() + " l" + _newline)
                        strOut.Append(((x + 1) * ModuleSize).ToString() + " " + (n - (y + 1) * ModuleSize).ToString() + " l" + _newline)
                        strOut.Append(((x) * ModuleSize).ToString() + " " + (n - (y + 1) * ModuleSize).ToString() + " l" + _newline)
                        strOut.Append("f" + _newline)
                    End If
                Next
            Next

            strOut.Append("*U" + _newline)
            strOut.Append("%%Trailer" + _newline)
            strOut.Append("%%EOF" + _newline)

        ElseIf (VectorType = VectorTypes.VecHTML) Then
            strOut.Append("<div style='font-size:0;background-color:#ffffff;position:relative;width:" + tempW + "px;height:" + tempH + "px;'>" + _newline)
            For y = 0 To rows - 1
                For x = 1 To cols
                    If ((Mid(Code, x, 1) <> "0") And (y >= QuietZone And (y < rows - QuietZone))) Then
                        strOut.Append("<div style='background-color:#000000;width:" + ModuleSize.ToString() + "px;height:" + ModuleSize.ToString() + "px;position:absolute;left:" + (x * ModuleSize).ToString() + "px;top:" + (y * ModuleSize).ToString() + "px;'>&nbsp</div>" + _newline)
                    End If
                Next
            Next

            strOut.Append("</div>" + _newline)
        End If

        Return strOut.ToString()
    End Function

    Private Function _rasterOutput(Code As String, Optional QuietZone As Integer = 2, Optional ModuleSize As Integer = 1, Optional BarsHeight As Integer = 20)

        Dim cols As Integer = 0
        Dim rows As Integer = 0

        cols = Code.Length()
        rows = BarsHeight + 2 * QuietZone


        Dim Result As Byte()
        Dim k As Integer
        Dim intPad As Integer = 0
        Dim pixels As Integer
        Dim bit As Integer
        Dim bWidth As Integer
        Dim x As Integer
        Dim y As Integer
        Dim m As Integer
        Dim l As Integer



        bWidth = (Math.Floor((cols * ModuleSize) / 8) + (If((cols * ModuleSize) Mod 8 > 0, 1, 0)))
        Dim intTemp As Integer = bWidth Mod 4
        If (intTemp <> 0) Then
            intPad = 4 - intTemp
        End If

        ReDim Result(64 + rows * ModuleSize * (bWidth + intPad) - 1)


        Result(0) = &H42
        Result(1) = &H4D
        For k = 0 To 7
            Result(2 + k) = 0
        Next
        Result(10) = &H3E
        For k = 0 To 2
            Result(11 + k) = 0
        Next
        Result(14) = &H28
        For k = 0 To 2
            Result(15 + k) = 0
        Next

        '' width
        Result(18) = CByte(Math.Floor((cols * ModuleSize) Mod 256))
        Result(19) = CByte(Math.Floor((cols * ModuleSize) / 256))
        Result(20) = 0
        Result(21) = 0

        '' height
        Result(22) = CByte(Math.Floor((rows * ModuleSize) Mod 256))
        Result(23) = CByte(Math.Floor((rows * ModuleSize) / 256))
        Result(24) = 0
        Result(25) = 0

        Result(26) = 1
        Result(27) = 0
        Result(28) = 1
        Result(29) = 0
        For k = 0 To 7
            Result(30 + k) = 0
        Next
        Result(38) = &H25
        Result(39) = &HE
        Result(40) = 0
        Result(41) = 0

        Result(42) = &H25
        Result(43) = &HE
        Result(44) = 0
        Result(45) = 0

        For k = 0 To 7
            Result(46 + k) = 0
        Next

        For k = 0 To 2
            Result(54 + k) = &HFF
        Next
        For k = 0 To 4
            Result(57 + k) = 0
        Next

        Dim pos As Integer = 62

        For y = rows - 1 To 0 Step -1

            For m = 0 To ModuleSize - 1

                pixels = 0
                bit = 8

                For x = 1 To cols


                    If ((Mid(Code, x, 1) <> "0") And (y >= QuietZone And (y < rows - QuietZone))) Then
                        For l = 0 To ModuleSize - 1
                            bit = bit - 1
                            pixels = pixels + Math.Floor(Math.Pow(2, bit))
                            If (bit = 0) Then
                                Result(pos) = CByte(pixels)
                                pos += 1
                                bit = 8
                                pixels = 0
                            End If
                        Next

                    Else
                        For l = 0 To ModuleSize - 1
                            bit = bit - 1
                            If (bit = 0) Then
                                Result(pos) = CByte(pixels)
                                pos += 1
                                bit = 8
                                pixels = 0
                            End If
                        Next

                    End If
                Next
                If (bit <> 8) Then
                    Result(pos) = CByte(pixels)
                    pos += 1
                End If
                pos = pos + intPad
            Next


        Next

        Return Result


    End Function


End Class

'' <summary>
'' Various types of output.
'' </summary>
Public Enum OutputTypes

    '' <summary>
    '' For use with IDAutomation Uni Xs Or Barcode Fonts. Returns encoded text. 
    '' </summary>
    IDAUniXSFont

    '' <summary>
    '' Returns barcode native object. For use with monospaced fonts.
    '' </summary>
    IDAMonospaceFont

End Enum


'' <summary>
'' Various types of vector image output.
'' </summary>
Public Enum VectorTypes

        '' <summary>
        '' Returns a string with the SVG representation. 
        '' </summary>
        VecSVG

        '' <summary>
        '' Return a string with the EPS representation.
        '' </summary>
        VecEPS

        '' <summary>
        '' Return a string with the HTML representation.
        '' </summary>
        VecHTML

    End Enum

