//**************************************************************
// C# .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:
// 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/
//
//*****************************************************************


using System;
using System.Globalization;
using System.Text;

namespace IDAutomation.NetStandard.Linear.FontEncoder
{

    /// <summary>
    /// Summary description for Linear class.
    /// </summary>
    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>An array representation of barcode's image.</returns>
        public byte[] Code128(string DataToEncode, bool ApplyTilde = true, int QuietZone = 2, int ModuleSize = 1, int BarsHeight = 20)
        {
            string code;
            code = "0011010010000110001000101011000100010100011000100111100101001111010010001111010111101110101001011000010011110100100001101001000111101011000010100111001100101100011101011000000";
            return _rasterOutput(code, QuietZone, ModuleSize, BarsHeight);
        }


        /// <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="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 string Code128(string DataToEncode, bool ApplyTilde = true, VectorTypes VectorType = VectorTypes.VecEPS, string NewLine = null, int QuietZone = 2, int ModuleSize = 2, int BarsHeight = 20)
        {
            string code;
            code = "0011010010000110001000101011000100010100011000100111100101001111010010001111010111101110101001011000010011110100100001101001000111101011000010100111001100101100011101011000000";
            return _vectorOutput(code, VectorType, NewLine, QuietZone, ModuleSize, BarsHeight);
        }


        /// <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="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>Encoded text for use with the barcode font.</returns>
        public string Code128(string DataToEncode, bool ApplyTilde = true, OutputTypes OutputType = OutputTypes.IDAUniXSFont, string NewLine = null, int BarsHeight = 20)
        {
            String _newline;
            string code;

            code = "EBDGCAAGCACGBNABMBCMAMIABAHBMBDEBCMAHABJFAGIAH";

            //allows user to set an end-of-line (EOL) string
            if (NewLine == null) NewLine = Environment.NewLine; //default
            _newline = NewLine;

            if (OutputType == OutputTypes.IDAMonospaceFont)
                return "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" ;
            else
                return code;

        }//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 barcode's image.</returns>
        public byte[] Code128a(string DataToEncode, int QuietZone = 2, int ModuleSize = 1, int BarsHeight = 20)
        {
            string code;
            code = "0011010010000110001000101011000100010100011000100111100101001111010010001111010111101110101001011000010011110100100001101001000111101011000010100111001100101100011101011000000";
            return _rasterOutput(code, QuietZone, ModuleSize, BarsHeight);
        }


        /// <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="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 string Code128a(string DataToEncode, VectorTypes VectorType = VectorTypes.VecEPS, string NewLine = null, int QuietZone = 2, int ModuleSize = 2, int BarsHeight = 20)
        {
            string code;
            code = "0011010010000110001000101011000100010100011000100111100101001111010010001111010111101110101001011000010011110100100001101001000111101011000010100111001100101100011101011000000";
            return _vectorOutput(code, VectorType, NewLine, QuietZone, ModuleSize, BarsHeight);
        }


        /// <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="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>Encoded text for use with the barcode font.</returns>
        public string Code128a(string DataToEncode, OutputTypes OutputType = OutputTypes.IDAUniXSFont, string NewLine = null, int BarsHeight = 20)
        {
            String _newline;
            string code;

            code = "EBDGCAAGCACGBNABMBCMAMIABAHBMBDEBCMAHABJFAGIAH";

            //allows user to set an end-of-line (EOL) string
            if (NewLine == null) NewLine = Environment.NewLine; //default
            _newline = NewLine;

            if (OutputType == OutputTypes.IDAMonospaceFont)
                return "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" ;
            else
                return code;


        }//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 byte[] Code128b(string DataToEncode, int QuietZone = 2, int ModuleSize = 1, int BarsHeight = 20)
        {
            string code;
            code = "0011010010000110001000101011000100010100011000100111100101001111010010001111010111101110101001011000010011110100100001101001000111101011000010100111001100101100011101011000000";
            return _rasterOutput(code, QuietZone, ModuleSize, BarsHeight);
        }


        /// <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="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 string Code128b(string DataToEncode, VectorTypes VectorType = VectorTypes.VecEPS, string NewLine = null, int QuietZone = 2, int ModuleSize = 2, int BarsHeight = 20)
        {
            string code;
            code = "0011010010000110001000101011000100010100011000100111100101001111010010001111010111101110101001011000010011110100100001101001000111101011000010100111001100101100011101011000000";
            return _vectorOutput(code, VectorType, NewLine, QuietZone, ModuleSize, BarsHeight);
        }


        /// <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="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>Encoded text for use with the barcode font.</returns>
        public string Code128b(string DataToEncode, OutputTypes OutputType = OutputTypes.IDAUniXSFont, string NewLine = null, int BarsHeight = 20)
        {
            String _newline;
            string code;

            code = "EBDGCAAGCACGBNABMBCMAMIABAHBMBDEBCMAHABJFAGIAH";

            //allows user to set an end-of-line (EOL) string
            if (NewLine == null) NewLine = Environment.NewLine; //default
            _newline = NewLine;

            if (OutputType == OutputTypes.IDAMonospaceFont)
                return "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" ;
            else
                return code;


        }//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 byte[] Code128c(string DataToEncode, int QuietZone = 2, int ModuleSize = 1, int BarsHeight = 20)
        {
            string code;
            code = "0011010010000110001000101011000100010100011000100111100101001111010010001111010111101110101001011000010011110100100001101001000111101011000010100111001100101100011101011000000";
            return _rasterOutput(code, QuietZone, ModuleSize, BarsHeight);
        }


        /// <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="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 string Code128c(string DataToEncode, VectorTypes VectorType = VectorTypes.VecEPS, string NewLine = null, int QuietZone = 2, int ModuleSize = 2, int BarsHeight = 20)
        {
            string code;
            code = "0011010010000110001000101011000100010100011000100111100101001111010010001111010111101110101001011000010011110100100001101001000111101011000010100111001100101100011101011000000";
            return _vectorOutput(code, VectorType, NewLine, QuietZone, ModuleSize, BarsHeight);
        }


        /// <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="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>Encoded text for use with the barcode font.</returns>
        public string Code128c(string DataToEncode, OutputTypes OutputType = OutputTypes.IDAUniXSFont, string NewLine = null, int BarsHeight = 20)
        {
            String _newline;
            string code;

            code = "EBDGCAAGCACGBNABMBCMAMIABAHBMBDEBCMAHABJFAGIAH";

            //allows user to set an end-of-line (EOL) string
            if (NewLine == null) NewLine = Environment.NewLine; //default
            _newline = NewLine;

            if (OutputType == OutputTypes.IDAMonospaceFont)
                return "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" ;
            else
                return code;


        }//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 byte[] Code39(string DataToEncode, float NDimension = 2, bool Mod43 = false, int QuietZone = 2, int ModuleSize = 1, int BarsHeight = 20)
        {
            string code;
            code = "0011010010000110001000101011000100010100011000100111100101001111010010001111010111101110101001011000010011110100100001101001000111101011000010100111001100101100011101011000000";
            return _rasterOutput(code, QuietZone, ModuleSize, BarsHeight);
        }


        /// <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="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 string Code39(string DataToEncode, float NDimension = 2, bool Mod43 = false, VectorTypes VectorType = VectorTypes.VecEPS, string NewLine = null, int QuietZone = 2, int ModuleSize = 2, int BarsHeight = 20)
        {
            string code;
            code = "0011010010000110001000101011000100010100011000100111100101001111010010001111010111101110101001011000010011110100100001101001000111101011000010100111001100101100011101011000000";
            return _vectorOutput(code, VectorType, NewLine, QuietZone, ModuleSize, BarsHeight);
        }


        /// <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="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>Encoded text for use with the barcode font.</returns>
        public string Code39(string DataToEncode, float NDimension = 2f, bool Mod43 = false, OutputTypes OutputType = OutputTypes.IDAUniXSFont, string NewLine = null, int BarsHeight = 20)
        {
            String _newline;
            string code;

            code = "EBDGCAAGCACGBNABMBCMAMIABAHBMBDEBCMAHABJFAGIAH";

            //allows user to set an end-of-line (EOL) string
            if (NewLine == null) NewLine = Environment.NewLine; //default
            _newline = NewLine;

            if (OutputType == OutputTypes.IDAMonospaceFont)
                return "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline +
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" ;
            else
                return code;


        }//End Function

        /// **************************************************************************************************
        /// Code39 ///


        /// CodeITF ///
        /// **************************************************************************************************

        /// <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 byte[] ITF(string DataToEncode, float NDimension = 2.5f, bool Mod10 = false, int QuietZone = 2, int ModuleSize = 1, int BarsHeight = 20)
        {
            string code;
            code = "0011010010000110001000101011000100010100011000100111100101001111010010001111010111101110101001011000010011110100100001101001000111101011000010100111001100101100011101011000000";
            return _rasterOutput(code, QuietZone, ModuleSize, BarsHeight);
        }


        /// <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="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 string ITF(string DataToEncode, float NDimension = 2.5f, bool Mod10 = false, VectorTypes VectorType = VectorTypes.VecEPS, string NewLine = null, int QuietZone = 2, int ModuleSize = 2, int BarsHeight = 20)
        {
            string code;
            code = "0011010010000110001000101011000100010100011000100111100101001111010010001111010111101110101001011000010011110100100001101001000111101011000010100111001100101100011101011000000";
            return _vectorOutput(code, VectorType, NewLine, QuietZone, ModuleSize, BarsHeight);
        }


        /// <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="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>Encoded text for use with the barcode font.</returns>
        public string ITF(string DataToEncode, float NDimension = 2.5f, bool Mod10 = false, OutputTypes OutputType = OutputTypes.IDAUniXSFont, string NewLine = null, int BarsHeight = 20)
        {
            String _newline;
            string code;

            code = "EBDGCAAGCACGBNABMBCMAMIABAHBMBDEBCMAHABJFAGIAH";

            //allows user to set an end-of-line (EOL) string
            if (NewLine == null) NewLine = Environment.NewLine; //default
            _newline = NewLine;

            if (OutputType == OutputTypes.IDAMonospaceFont)
                return "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline + 
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline + 
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline + 
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline + 
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" + _newline + 
                       "█▐ ▌ ▐▌ ▌ ▌▌█ ▐ ▐▐ ▐▌ ▌▐█▌▐▐ ██▐ ▌ ██▐▐█▌█▌▌▌▐▐▌ ▐ ██▐ ▌ ▐▌▌▐ ▐█▌▌█  ▌▌▐█ █ ▌█ ▐█▐▐▌" ;
            else
                return code;


        }//End Function

        /// **************************************************************************************************
        /// CodeITF ///


        private byte[] _rasterOutput(string Code, int QuietZone = 2, int ModuleSize = 1, int BarsHeight = 20)
        {

            int cols = 0;
            int rows = 0;
            
            cols = Code.Length;
            rows = BarsHeight + 2 * QuietZone;

            byte[] Result = null;

            int k;
            int intPad = 0;
            int pixels = 0;
            int bit = 0;
            int bWidth = 0;

            bWidth = ((int)((cols * ModuleSize) / 8) + ((cols * ModuleSize) % 8 > 0 ? 1 : 0));
            int intTemp = bWidth % 4;
            if (intTemp != 0)
            {
                intPad = 4 - intTemp;
            }

            Result = new byte[64 + rows * ModuleSize * (bWidth + intPad)];

            Result[0] = 0x42;
            Result[1] = 0x4d;
            for (k = 0; k < 8; k++)
            {
                Result[2 + k] = 0;
            }
            Result[10] = 0x3E;
            for (k = 0; k < 3; k++)
            {
                Result[11 + k] = 0;
            }
            Result[14] = 0x28;
            for (k = 0; k < 3; k++)
            {
                Result[15 + k] = 0;
            }

            // width
            Result[18] = (byte)((cols * ModuleSize) % 256);
            Result[19] = (byte)(Math.Floor((double)(cols * ModuleSize) / 256));
            Result[20] = 0;
            Result[21] = 0;

            // height
            Result[22] = (byte)((rows * ModuleSize) % 256);
            Result[23] = (byte)(Math.Floor((double)(rows * ModuleSize) / 256));
            Result[24] = 0; ;
            Result[25] = 0;

            Result[26] = 1;
            Result[27] = 0;
            Result[28] = 1;
            Result[29] = 0;
            for (k = 0; k < 8; k++)
            {
                Result[30 + k] = 0;
            }
            Result[38] = 0x25;
            Result[39] = 0x0e;
            Result[40] = 0;
            Result[41] = 0;

            Result[42] = 0x25;
            Result[43] = 0x0e;
            Result[44] = 0;
            Result[45] = 0;

            for (k = 0; k < 8; k++)
            {
                Result[46 + k] = 0;
            }

            for (k = 0; k < 3; k++)
            {
                Result[54 + k] = 0xff;
            }
            for (k = 0; k < 5; k++)
            {
                Result[57 + k] = 0;
            }

            int pos = 62;
            for (int y = (rows) - 1; y >= 0; y--)
            {

                for (int m = 0; m < ModuleSize; m++)
                {
                    pixels = 0;
                    bit = 8;

                    for (int x = 0; x < (cols); x++)
                    {
                        if (Code.Substring(x, 1) != "0" && (y >= QuietZone) && (y < rows - QuietZone))
                        {

                            for (int l = 0; l < ModuleSize; l++)
                            {
                                bit = bit - 1;
                                pixels = pixels + (int)Math.Pow(2, bit);
                                if (bit == 0)
                                {
                                    Result[pos] = (byte)pixels;
                                    pos++;
                                    bit = 8;
                                    pixels = 0;
                                }
                            }

                        }
                        else
                        {

                            for (int l = 0; l < ModuleSize; l++)
                            {
                                bit = bit - 1;
                                if (bit == 0)
                                {
                                    Result[pos] = (byte)pixels;
                                    pos++;
                                    bit = 8;
                                    pixels = 0;
                                }
                            }



                        }
                    }
                    if (bit != 8)
                    {
                        Result[pos] = (byte)pixels;
                        pos++;
                    }
                    pos = pos + intPad;
                }
            }

            return Result;


        }

        private string _vectorOutput(string Code, VectorTypes VectorType = VectorTypes.VecEPS, string NewLine = null, int QuietZone = 2, int ModuleSize = 2, int BarsHeight = 20)
        {

            int cols = 0;
            int rows = 0;
            string _newline;

            cols = Code.Length;
            rows = BarsHeight + 2 * QuietZone;

            //allows user to set an end-of-line (EOL) string
            if (NewLine == null)  NewLine = Environment.NewLine; //default
            _newline = NewLine;

            StringBuilder strOut = new StringBuilder("");
            string tempW = "";
            string tempH = "";
            if (VectorType == VectorTypes.VecSVG)  ModuleSize = ModuleSize * 10;
            tempW = (cols * ModuleSize).ToString();
            tempH = (rows * ModuleSize).ToString();

            if (VectorType == VectorTypes.VecSVG)
            {


                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 viewbox='0 0 " + tempW + " " + tempH + "' version='1.1' xmlns='http://www.w3.org/2000/svg'>" + _newline);
                strOut.Append("  <g transform='scale(0.1)' 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 (int y = 0; y < rows; y++)
                {
                    for (int x = 0; x < cols; x++)
                    {
                        if ( Code.Substring(x, 1) != "0" && (y >= QuietZone) && (y < rows - QuietZone))
                        {
                            strOut.Append("    <g id='R" + y + "C" + x + "' >" + _newline);
                            strOut.Append("      <rect x='" + (x * ModuleSize).ToString() + "' y='" + (y * ModuleSize).ToString() + "' width='" + (ModuleSize).ToString() + "' height='" + (ModuleSize).ToString() + "' />" + _newline);
                            strOut.Append("    </g>" + _newline);
                        }
                    }
                }
                strOut.Append("    </g>" + _newline);
                strOut.Append("  </g>" + _newline);
                strOut.Append("</svg>" + _newline);
            }
            else if (VectorType == VectorTypes.VecEPS)
            {

                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);

                int n = rows * ModuleSize;
                strOut.Append("0.000 0.000 0.000 1.000 k" + _newline);
                for (int y = 0; y < rows; y++)
                {
                    for (int x = 0; x < cols; x++)
                    {
                        if (Code.Substring(x, 1) != "0" && (y >= QuietZone) && (y < rows - QuietZone))
                        {
                            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);
                        }
                    }
                }

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

            }
            else if (VectorType == VectorTypes.VecHTML)
            {
                strOut.Append("<div style='font-size:0;background-color:#ffffff;position:relative;width:" + tempW + "px;height:" + tempH + "px;'>" + _newline);
                for (int y = 0; y < rows; y++)
                {
                    for (int x = 0; x < cols; x++)
                    {
                        if (Code.Substring(x, 1) != "0" && (y >= QuietZone) && (y < rows - QuietZone))
                        {
                            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);
                        }
                    }
                }

                strOut.Append("</div>" + _newline);
            }

            return strOut.ToString();

        }




    }//End class


}//End


/// <summary>
/// Various types of output.
/// </summary>
public enum OutputTypes
{

    /// <summary>
    /// For use with IDAutomation UNI XS or Barcode Fonts. Returns barcode encoded text. 
    /// </summary>
    IDAUniXSFont,

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

}


/// <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,

}

