I have a dot matrix printer to print and I need to send a cut command to the printer from a form (Windows Forms):
The problem is that said command (27,109,0) and it was converted into hexadecimal like this: \ x1b \ x6D \ x0 through a function, but the problem is that it only works from code, I explain:
Function Functional Print:
public void Imprimir()
{
string texto = "Prueba de impresion";
texto += "\x1b\x6D\x0"; // funciona si solo excribo asi en una variable
Imprimir(nombre_impresora, texto);
}
and when I try to call the conversion function the converted value comes out like this: \\ x1b \\ x6D \\ x0 with double bar.
public void Imprimir()
{
string texto = "Prueba de impresion";
texto += ValorHexadecimal("27,191,0"); // retorna \x1b\x6D\x0
Imprimir(nombre_impresora, texto);
}
does not work since it has a double bar
conversion to hexadecimal function:
public static string ValorHexadecimal(string valor)
{
string hex = "";
string[] valores = valor.Split(new string[] { "," }, System.StringSplitOptions.RemoveEmptyEntries);
foreach (string c in valores)
{
System.Convert.ToString(int.Parse(c), 16).ToUpper();
hex += @"\x"+ System.Convert.ToString(int.Parse(c), 16).ToUpper();;
}
return hex;
}
Now how to send decimal values read from a text to a port in hex or unicode:
P.D. 1: Equivalences of VALUES:
Decimal | Unicode | Hexadecimal
27,109.0 | \ u001bm \ 0 | \ x1B \ x6D \ x00
P.D. 2: The Print function is of the RawPrinterHelper class and works