igorocampos / escpos Goto Github PK
View Code? Open in Web Editor NEWA ESC/POS Printer Commands Helper
A ESC/POS Printer Commands Helper
Igoro,
I'm curious why you started a new .net printer library? Were there some architecture/design decisions in ESCPOS_NET that you didn't agree with?
It already has some momentum so it would be nice if we could work together, but if there are some fundamental differences or some reason it doesn't meet your needs, that's fine too.
Best,
-Luke
PrintBarCode
and PrintQRCode
should be renamed as they don't actually print anything, but rather create the necessary command for a barcode/qrcode.
New name should be just Barcode
and QRCode
As this is clearly a breaking change, we should first create the new Barcode()
and QRCode()
methods which will contain the actual code and the previous PrintBarCode
and PrintQRCode
must be marked as obsolete methods and instead of containing code, they must only call the newly created methods.
After this change is deployed, version should be bumped to 1.2.4
and the usage of the obsolete methods should just generate a warning by decorating the methods with the Obsolete attribute as shown below.
[Obsolete(nameof(PrintBarCode) + " is deprecated, please use "+ nameof(Barcode) + " instead.")]
On the next version, it must be bumped to 1.3.0
and the Obsolete attribute must be changed in order to throw a compilation error if the old method is used. This can be done by adding a new bool parameter to the attribute
[Obsolete(nameof(PrintBarCode) + " is deprecated, please use "+ nameof(Barcode) + " instead.", true)]
And then, on version 1.3.1 we can just get rid of the old methods :)
Dependent on #29
Once the new Barcode and QRCode methods are created, we can create methods that will extend a string (the barcode data) like this
public static byte[] ToBarcode(this string barcode, BarCodeType barCodeType, int heightInDots = 162, BarcodeWidth barcodeWidth = BarcodeWidth.Normal )
=> Commands.Barcode(barCodeType, barcode, heightInDots, barcodeWidth);
Hello Igor.
I am trying to print tickets with Spanish accents, for example, the word "address", instead of printing "ó" it prints strange characters.
I tried using "SelectInternationalCharacterSet(CharSet.SpainI)" but it doesn't work, what else can I try?
Saludos, Luis.
Olá, estou tentando usar seu código para impressão em impressoras térmicas, mas estou com problemas de acentos, você pode me ajudar?
Já tentei usar todo tipo de conversão de encoding e não consigo imprimir corretamente.
Olá Igor,
primeiramente parabéns pela sua biblioteca ! Show de bola !
Baixei sua biblioteca para uso no Windows C# .Net Framework 4.7.2 e já fiz alguns testes com sucesso, porém, não consigo imprimir o código de barras CODE128 (para usar no CFe)...
Já testei na Epson TM-T88, na Bematech MP 2800TH, na SWEDA SI-300 e na Gertec G250.
O código ITF vai normal, o QRCODE também mas o CODE128 simplesmente não imprime. (Fica em branco)
Curioso é que eu também tentei a biblioteca ESP-POS-NET do colega Luke e o resultado foi exatamente o mesmo.
Tenho certeza que essas impressoras conseguem imprimir esse código porque usando a biblioteca (DLL) específica de cada uma delas funciona.
Vc consegue dar alguma luz ?
Abaixo o programa de "teste" que estou utilizando:
byte[] barCodeCommand = PrintBarCode(BarCodeType.ITF, "1234567890");
barCodeCommand.Print("192.168.34.250:9100");
byte[] barCodeCommand2 = PrintBarCode(BarCodeType.CODE128, "1234567890");
barCodeCommand2.Print("192.168.34.250:9100");
Muito agradecido
Daniel Constantinov
Hi, anyone already printed via USB (RAW) using this ESCPOS library ?
On main page of ESCPOS there are examples like:
"... 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."
but are no mention on RAW USB...
All this devices (except LPT1) I tested and is OK, AND when a USB is mapped to Serial Port too, but there is some printers that map only USB device without emulation of serial... (USB001, USB002, etc)
I can´t print on this ports (USB). Anyone could help me ?
Maybe a specific string that I have not used... (??? \USB001 ???)
Thanks
As stated in the manual:
When using the CODE 128 in this printer, take the following points into account for data transmission: The top of the bar code data string must be code set selection character (any of CODE A, CODE B or CODE C) which selects the first code set.
Your settings for CODE 128 would then be:
0x1D, 0x6B, 0x49, (byte)(barCode.Length + 2), 0x7B, 0x41
I like both ESCPOS and ESCPOS_NET.
Hello,
can you please help me with code table for windows-1256
enum CodeTable already has Windows1252 with value of 16
what is the value of Windows1256 ?
Thanks
Hi igorocampos, I noticed your these two commands share the same GS code.
SelectCharSizeHeight(CharSizeHeight charSize)
SelectCharSizeWidth(CharSizeWidth charSize)
0x1D, 0x21, (byte)charSize
When I tried to SelectCharSizeHeight and SelectCharSizeWidth one after another, the previous charSize
is lost.
Please see this photo: (I set it to 7(Octuple) for Height and 112(Octuple) for Width with two separate commands)
Effectively, the two commands are:
0x1D, 0x21, 7
0x1D, 0x21, 112
However, when I combine the value 112+7 as 119, with this single command:
0x1D, 0x21, 119
Then only I get the correct 8x + 8x character size:
I tried to workaround with your library by ORing the CharSizeWidth and CharSizeHeight but cannot, because the argument type is either one.
Please look into this... Have a good day!
Simple ESC/POS Commands are actually just static properties of Commands class. And they are easy on the eye when used.
On the other hand, full commands require parameters, which is good for flexibility but can create a little bit of wordy command concatenation.
The proposal here is to have the class split into 2 files (as a partial Command
class), one for the Simple commands and another that will hold all the Commands that are not static properties.
In addition, to be easier on the eye we should create a number of simple commands (static properties) that can be used for the most used combination of parameters used in the full commands. For Example:
SelectPrintMode(PrintMode printMode)
will have the following static properties as aliases
PrintModeReset
PrintModeFontB
PrintModeEmphasis
SelectUnderlineMode(UnderlineMode underlineMode)
will have the following static properties as aliases
UnderlineModeOff
UnderlineModeOn
Please beware that not all possible combinations should have an alias, only the most used ones. The existing full command methods are not to be deprecated and can still be used for a full usage of the combinations.
Aliases properties should just call the existing full commands as shown below
public static byte[] UnderlineModeOff => SelectUnderlineMode(UnderlineMode.Off);
public static byte[] UnderlineModeOn => SelectUnderlineMode(UnderlineMode.OneDotThick);
Now a list with the name of all simple methods that should be created
é possivel imprimir em modo paisagem ?
As the title suggests, I want to search for available printers in the PC so the address will be dynamic.
Implementation of Dockerfile to build the solution with docker
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.