ESCPOS 1.2.4

dotnet add package ESCPOS --version 1.2.4                
NuGet\Install-Package ESCPOS -Version 1.2.4                
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="ESCPOS" Version="1.2.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ESCPOS --version 1.2.4                
#r "nuget: ESCPOS, 1.2.4"                
#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 ESCPOS as a Cake Addin
#addin nuget:?package=ESCPOS&version=1.2.4

// Install ESCPOS as a Cake Tool
#tool nuget:?package=ESCPOS&version=1.2.4                

SourceLink Build Status GitHub code size in bytes NuGet GitHub FOSSA Status

ESCPOS

A ESC/POS Printer Commands Helper.

Installing via NuGet Package

The NuGet Package can be found here and you can install it with:

PM> Install-Package ESCPOS

Usage

All command methods will return a byte array that you should concatenate with the bytes of your data, and then send it all to your printer using the Print extension method, which will send a byte array to the informed printer address. It can be something like COM3, LPT1, \\127.0.0.1\printer, 192.168.0.100:9100, etc. or even a path to a text file like ./print.txt.

There is also 2 extension methods, Add and ToBytes, located in the namespace ESCPOS.Utils. The first one can be used in byte arrays, so you can concatenate 2 or more byte arrays just like this:

byte[] result = array1.Add(array2, array3, ..., arrayN);

In addition there's an overload to the mentioned Add method that will accept string parameters instead of byte arrays. It appends all strings into one new string and then converts it to a byte array. And yet another overload to accept the mix of byte arrays and strings parameters, but since it's accepting an object type parameter, this will ignore any parameter that is not string or byte[] (e.g. int).

With ToBytes method you can convert a UTF-8 string to a byte array:

byte[] result = "Some string".ToBytes();

Alternatively you can choose whatever Encoding you wish to use for that:

byte[] result = "汉字".ToBytes(Encoding.GetEncoding("GBK"));

*Just make sure your Printer has a corresponding CodePage for that Encoding!

Examples

All examples will assume the using statements below:

using static ESCPOS.Commands;
using ESCPOS;
using ESCPOS.Utils;

QRCode

byte[] qrCodeCommand = QRCode("Some data");
qrCodeCommand.Print("COM2");

Or using the Extension Method

string data = "Some data";
data.ToQRCode().Print("COM2");

Barcode

byte[] barCodeCommand = Barcode(BarCodeType.EAN13, "9780201379624");
barCodeCommand.Print("192.168.0.100:9100");

Or using the Extension Method

string code = "9780201379624";
code.ToBarcode(BarCodeType.EAN13).Print("192.168.0.100:9100");

Formatted Text

byte[] cmd = AlignToCenter.Add(CharSizeDoubleHeight, "Fancy Title");
cmd.Print("\\127.0.0.1\printer");
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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ESCPOS:

Package Downloads
DemoPOS

Lightweight and easy to use fluent-style usb thermal printer wrapper based on ESCPOS and RawPrint

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.4 933 1/23/2024
1.2.3 2,481 11/24/2022
1.2.2 1,636 4/28/2021
1.2.1 951 9/15/2020
1.2.0 772 3/18/2020
1.1.2 666 1/7/2020
1.1.1 595 12/19/2019
1.1.0 861 8/28/2019
1.0.3 540 8/27/2019
1.0.2 534 8/27/2019
1.0.1 531 8/27/2019
1.0.0 555 8/26/2019