XML2ESCPOS 0.6.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package XML2ESCPOS --version 0.6.3                
NuGet\Install-Package XML2ESCPOS -Version 0.6.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XML2ESCPOS" Version="0.6.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add XML2ESCPOS --version 0.6.3                
#r "nuget: XML2ESCPOS, 0.6.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install XML2ESCPOS as a Cake Addin
#addin nuget:?package=XML2ESCPOS&version=0.6.3

// Install XML2ESCPOS as a Cake Tool
#tool nuget:?package=XML2ESCPOS&version=0.6.3                

XML2ESCPOS

Net Standard library that provides a simple XML Template engine with support for images, variables and loops. For ESC / POS Thermal Printers. You can print to Windows printers (using the print queue so windows takes care of waiting for it to turn on or have paper) or directly to network printers.

Example:

XML2ESCPOS.Engine xML2ESCPOS = new XML2ESCPOS.Engine
{
     Template = "<C><RESET/><CENTER/>Hello!<BR><BR><END/></C>",
     PrinterName = "Epson"
};
xML2ESCPOS.Print();

Printer print:

                                Hello!
Engine Properties:

PrinterName: Windows Printer Name. When PrinterName is set, PrinterIP is disabled

PrinterIP: Printer IP Address. When PrinterIP is set, PrinterName is disabled

Plantilla: String with the Template

PrintJobName: (Default is "PrintJob") Print job name

CodePage: (Default is 858) Codepage that has the thermal printer configured. https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers

Vars: (List<KeyValuePair<string, string>>) List of the variables that you are going to use with their name and value. More Info

BubleVars: (List<KeyValuePair<string, string>>) List of variables that are the lists that you will use with each loop with its name More Info

XML Codes:

<RESET/> Initialize printer

<LEFT/> Left justification. This command is enabled only when processed at the beginning of the line. Settings of this command are effective until <RIGHT/> or <CENTER/> or <RESET/> or power off

<CENTER/> Center justification. This command is enabled only when processed at the beginning of the line. Settings of this command are effective until <LEFT/> or <CENTER/> or <RESET/> or power off

<RIGHT/> Right justification. This command is enabled only when processed at the beginning of the line. Settings of this command are effective until <LEFT/> or <RIGHT/> or <RESET/> or power off

<END/> Feed and cut paper

<BR/> or <BR> New Line

<TAB/> or <TAB> Next Tab

<B> </B> Emphasized Text

<U> </U> Underline Text

<U2> </U2> Underline 2-points Text

<DHEIGHT> </DHEIGHT> Double Height Text

<DWIDTH> </DWIDTH> Double Width Text

<IMAGE PATH='path' F='f'/> Print Image. PATH: path relative to current directory. F: size factor (integer), depent on printer model.

Example in Template: <IMAGE PATH='wwwroot\img\logo.jpg' F='200'/>

<DEFTABS N1='n1' N2='n2' .../> Set horizontal tab positions. Settings of this command are effective until another <DEFTABS/> or<RESET/> or power off

Example in Template: <DEFTABS N1='2' N2='15' N3='25'/>

<IFNOTNULL VARNAME='varname'> </IFNOTNULL> Print the inside only if the variable is not null or empty or only white spaces

Example:

string plantilla = "<C><RESET/><LEFT/><IFNOTNULL VARNAME='MyName'><B>Hello <![CDATA[MyName]]>!</B></IFNOTNULL><BR>" +

	"<IFNOTNULL VARNAME='MyName'><B>Hello <![CDATA[YourName]]>!</B></IFNOTNULL><BR><END/></C>";

XML2ESCPOS.Engine xML2ESCPOS = new XML2ESCPOS.Engine
        {
            Template = plantilla,
            PrinterName = "Epson"
        };

xML2ESCPOS.Vars.Add(new KeyValuePair<string, string>("MyName", "Jesus"));
xML2ESCPOS.Vars.Add(new KeyValuePair<string, string>("YourName", "  "));

xML2ESCPOS.Print();

Printer Print:

Hello Jesus!

Vars:

Example:

XML2ESCPOS.Engine xML2ESCPOS = new XML2ESCPOS.Engine
    {
        Template = "<C><RESET/><LEFT/><B>Hello <![CDATA[MyName]]>!</B><BR><BR><END/></C>",
        PrinterName = "Epson"
    };
xML2ESCPOS.Vars.Add(new KeyValuePair<string, string>("MyName", "Jesus"));
xML2ESCPOS.Print();

Printer print:

Hello Jesus!

BucleVars:

Example:

public class Client
{
    public string Name { get; set; }
}

XML2ESCPOS.Engine xML2ESCPOS = new XML2ESCPOS.Engine
        {
            Template = "<C><RESET/><LEFT/><FOREACH VARNAME='clientes'><B>Hello <![CDATA[clientes.Name]]>!</B><BR></FOREACH><BR><END/></C>",
            PrinterName = "Epson"
        };

List<Client> lc = new List<Client>();
lc.Add(new Client { Name = "Jesus" });
lc.Add(new Client { Name = "Juan" });

xML2ESCPOS.BucleVars.Add(new KeyValuePair<string, object>("clientes", lc));
xML2ESCPOS.Print();

Printer print:

Hello Jesus!

Hello Juan!

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.6.4 2,355 5/21/2021
0.6.3 368 4/17/2021
0.6.2 354 4/17/2021
0.6.1 330 4/15/2021
0.6.0 335 4/14/2021
0.5.2 315 4/14/2021
0.5.1 337 4/14/2021
0.5.0 342 4/14/2021