Spanish Etiquetas de codigo de barras

elsanto

Member
Licensed User
Longtime User
Me podrias por favor ayudar a entender como aplicar uno de estos:

ESC d n
[Name] Print and feed n lines
[Format] ASCII ESC d n
Hex 1B 64 n
Decimal 27 100 n
[Range] 0 n 255
[Description] Prints the data in the print buffer and feeds n lines.
[Notes] This command sets the print starting position to the beginning of the line.
 This command does not affect the line spacing set by ESC 2 or ESC3.
 The maximum paper feed amount is 1016 mm (40 inches). If the
paper feed amount (n line spacing) of more than 1016 mm
(40 inches) is specified, the printer feeds the paper only 1016 mm (40 inches).
[Reference] ESC 2, ESC 3

ESC J n
[Name] Print and feed paper
[Format] ASCII ESC J n
Hex 1B 4A n
Decimal 27 74 n
[Range] 0 n 255
[Description] Prints the data in the print buffer and feeds the paper [nX0.125 mm (0.0049”)].
[Notes] After printing is completed, this command sets the print starting position to the beginning of the line.
 The paper feed amount set by this command does not affect the values set by ESC 2 or ESC 3.
 In standard mode, the printer uses the vertical motion unit (y).

ESC d n
B4X:
Dim ESC As String = Chr(27)
Dim n  As Int  ' lineas
WriteString(ESC & "d")
Dim param as byte
params = n 
WriteBytes(params)
Algo como esto
 

TILogistic

Expert
Licensed User
Longtime User
[QUOTE = "elsanto1970, publicación: 787258, miembro: 20963"]
ESC dn
[CODE = b4x] Atenuar ESC como cadena = Chr (27)
Dim n As Int 'lineas
WriteString (ESC y "d")
Dim param como byte
params = n
WriteBytes (parámetros) [/ CODE]
Algo como esto
[/CITAR]

ESC dn = PrintAndFeedPaper (este es ESC J n Imprimir y alimentar n puntos de papel)

ESC d n = Print and Feed n lines (no existe en la clase)

La cantidad máxima de alimentación de papel es de 1016 mm (40 pulgadas). Si se especifica una
cantidad de alimentación de papel (n espacio entre líneas) de más de 1016 mm
(40 pulgadas), la impresora alimenta el papel solo 1016 mm (40 pulgadas)
 

TILogistic

Expert
Licensed User
Longtime User
Este comando no afecta el espaciado de línea establecido por ESC 2 o ESC 3.

Clase: setLineSpacing
 

elsanto

Member
Licensed User
Longtime User
[QUOTE = "elsanto1970, publicación: 787258, miembro: 20963"]
ESC dn
[CODE = b4x] Atenuar ESC como cadena = Chr (27)
Dim n As Int 'lineas
WriteString (ESC y "d")
Dim param como byte
params = n
WriteBytes (parámetros) [/ CODE]
Algo como esto
[/CITAR]

ESC dn = PrintAndFeedPaper (este es ESC J n Imprimir y alimentar n puntos de papel)

ESC d n = Print and Feed n lines (no existe en la clase)

La cantidad máxima de alimentación de papel es de 1016 mm (40 pulgadas). Si se especifica una
cantidad de alimentación de papel (n espacio entre líneas) de más de 1016 mm
(40 pulgadas), la impresora alimenta el papel solo 1016 mm (40 pulgadas)
Hola Omar
La puede agregar a la clase si la necesita, yo tuve que modificar la clase para imprimir QR
 

TILogistic

Expert
Licensed User
Longtime User
Hola Omar
La puede agregar a la clase si la necesita, yo tuve que modificar la clase para imprimir QR

Eso trato de explicarle que puede agregar los comandos que no están en la clase ya que es genérica

Nosotros separamos clases, en módulos de conexiones (USB, Wifi, BLE, etc) y otros modulos de comandos (ZPL, ESC/P, etc)

Como el ejemplo de la APP que publique RTprinter.
 

Tico.13

Member
ESC d n
B4X:
Dim ESC As String = Chr(27)
Dim n  As Int  ' lineas
WriteString(ESC & "d")
Dim param as byte
params = n
WriteBytes(params)
Algo como esto

Esto es para agregar o modificar en la clase o directamente en el codigo de mi app?

Directo en el codigo de mi app, puse esto:
B4X:
        Dim ESC As String = Chr(27)
        Dim n  As Int = 1' lineas
        Printer1.WriteString(ESC & "d")
        Dim params As Byte
        params = n
        Printer1.WriteBytes(params As Byte)
Pero me da este error:
main2 - 369: Cannot cast type: {Type=Byte,Rank=0, RemoteObject=True} to: {Type=Byte,Rank=1, RemoteObject=True}
 

elsanto

Member
Licensed User
Longtime User
Esto es para agregar o modificar en la clase o directamente en el codigo de mi app?

Directo en el codigo de mi app, puse esto:
B4X:
        Dim ESC As String = Chr(27)
        Dim n  As Int = 1' lineas
        Printer1.WriteString(ESC & "d")
        Dim params As Byte
        params = n
        Printer1.WriteBytes(params As Byte)
Pero me da este error:
main2 - 369: Cannot cast type: {Type=Byte,Rank=0, RemoteObject=True} to: {Type=Byte,Rank=1, RemoteObject=True}
Si lo trabajas como te contesto @Erel , lo pones directo en el codigo , si no deberias agregar una funcion publica en la clase
B4X:
Dim n As Int = 1
    
    Printer1.WriteBytes(Array As Byte(27)) ' ESC
    Printer1.WriteBytes(Array As Byte(100)) 'd
    Printer1.WriteBytes(Array As Byte(n))
 

TILogistic

Expert
Licensed User
Longtime User
Si lo trabajas como te contesto @Erel , lo pones directo en el codigo , si no deberias agregar una funcion publica en la clase
B4X:
Dim n As Int = 1
   
    Printer1.WriteBytes(Array As Byte(27)) ' ESC
    Printer1.WriteBytes(Array As Byte(100)) 'd
    Printer1.WriteBytes(Array As Byte(n))

Otra forma de usar:

Printer1.WriteBytes(Array As Byte(27,100,n))

El parametro WriteBytes es un arreglo de bytes
 

TILogistic

Expert
Licensed User
Longtime User
NOTA:

B4X:
' Send the contents of an array of bytes to the printer
' Remember that if the printer is expecting text the bytes will be printed as characters in the current code page
Public Sub WriteBytes(data() As Byte)
    If Connected Then
        Astream.Write(data)
    End If
End Sub

Send the string to the printer in IBM437 encoding which is the original PC DOS codepage
B4X:
' Send the string to the printer in IBM437 encoding which is the original PC DOS codepage
' This is usually the default codepage for a printer and is CodePage = 0
' Beware of using WriteString with Chr() to send numeric values as they may be affected by Unicode to codepage translations
' Most character level operations are pre-defined as UPPERCASE string variables for easy concatenation with other string data
Public Sub WriteString(data As String)
    WriteString2(data, "IBM437")
End Sub

o enviar otro encoding
B4X:
' Send the string to the printer in the specified encoding
' You also need to set the printer to a  matching encoding using the CodePage property
' Beware of using WriteString2 with Chr() to send numeric values as they may be affected by codepage substitutions
' Most character level operations are pre-defined as UPPERCASE string variables for easy concatenatipon with other string data
Public Sub WriteString2(data As String, encoding As String)
    Try
        If Connected Then
            Astream.Write(data.GetBytes(encoding))
        End If
    Catch
        Log("Printer error : " & LastException.Message)
        AStream_Error
    End Try
End Sub
 
Last edited:

TILogistic

Expert
Licensed User
Longtime User
Esto es para agregar o modificar en la clase o directamente en el codigo de mi app?

Directo en el codigo de mi app, puse esto:
B4X:
        Dim ESC As String = Chr(27)
        Dim n  As Int = 1' lineas
        Printer1.WriteString(ESC & "d")
        Dim params As Byte
        params = n
        Printer1.WriteBytes(params As Byte)
Pero me da este error:
main2 - 369: Cannot cast type: {Type=Byte,Rank=0, RemoteObject=True} to: {Type=Byte,Rank=1, RemoteObject=True}

Correccion:
Dim params(1) As Byte
params(0) = n
 

Tico.13

Member
Hola a todos, alguien me podria ayudar a traducir a 4A este ejemplo que brinda TSC para imprimir desde android a impresoras TSC utilizando la libreria serial o la clase esc/pos:

Android Example for TSC Bluetooth

import com.example.tscdll.TSCActivity;
public class MainActivity extends Activity {

TSCActivity TscDll = new TSCActivity();

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

TscDll.openport("00:19:0E:A0:04:E1");
TscDll.downloadpcx("UL.PCX");
TscDll.downloadbmp("Triangle.bmp");
TscDll.downloadttf("ARIAL.TTF");
TscDll.setup(70, 110, 4, 4, 0, 0, 0);
TscDll.clearbuffer();
TscDll.sendcommand("SET TEAR ON\n");
TscDll.sendcommand("SET COUNTER @1 1\n");
TscDll.sendcommand("@1 = \"0001\"\n");
TscDll.sendcommand("TEXT 100,300,\"3\",0,1,1,@1\n");
TscDll.sendcommand("PUTPCX 100,300,\"UL.PCX\"\n");
TscDll.sendcommand("PUTBMP 100,520,\"Triangle.bmp\"\n");
TscDll.sendcommand("TEXT 100,760,\"ARIAL.TTF\",0,15,15,\"THIS IS ARIAL FONT\"\n");
TscDll.barcode(100, 100, "128", 100, 1, 0, 3, 3, "123456789");
TscDll.printerfont(100, 250, "3", 0, 1, 1, "987654321");
String status = TscDll.printerstatus();
text1.setText(status);
TscDll.printlabel(2, 1);
//TscDll.sendfile("zpl.txt");
TscDll.closeport(5000);
}
}
 

TILogistic

Expert
Licensed User
Longtime User
Hola a todos, alguien me podria ayudar a traducir a 4A este ejemplo que brinda TSC para imprimir desde android a impresoras TSC utilizando la libreria serial o la clase esc/pos:

Android Example for TSC Bluetooth

import com.example.tscdll.TSCActivity;
public class MainActivity extends Activity {

TSCActivity TscDll = new TSCActivity();

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

TscDll.openport("00:19:0E:A0:04:E1");
TscDll.downloadpcx("UL.PCX");
TscDll.downloadbmp("Triangle.bmp");
TscDll.downloadttf("ARIAL.TTF");
TscDll.setup(70, 110, 4, 4, 0, 0, 0);
TscDll.clearbuffer();
TscDll.sendcommand("SET TEAR ON\n");
TscDll.sendcommand("SET COUNTER @1 1\n");
TscDll.sendcommand("@1 = \"0001\"\n");
TscDll.sendcommand("TEXT 100,300,\"3\",0,1,1,@1\n");
TscDll.sendcommand("PUTPCX 100,300,\"UL.PCX\"\n");
TscDll.sendcommand("PUTBMP 100,520,\"Triangle.bmp\"\n");
TscDll.sendcommand("TEXT 100,760,\"ARIAL.TTF\",0,15,15,\"THIS IS ARIAL FONT\"\n");
TscDll.barcode(100, 100, "128", 100, 1, 0, 3, 3, "123456789");
TscDll.printerfont(100, 250, "3", 0, 1, 1, "987654321");
String status = TscDll.printerstatus();
text1.setText(status);
TscDll.printlabel(2, 1);
//TscDll.sendfile("zpl.txt");
TscDll.closeport(5000);
}
}
estimado,

Esta tratando de usar las api SDK tscsdk.jar???


Inicie otro hilo como dice @José J. Aguilar para esta impresora.

PD.
Estas impresoras emulan Esc/P, eso quieres decir que puede utilizar la clase que ya ha consultado.
he revisa el tscsdk.jar y hace llamadas al igual que esta clase.


saludos.
 
Last edited:

Tico.13

Member
@oparra, fijate que la gente de Rongta me indico que para papel continuo, la impresora debe estar en modo Esc/Pos pero para Etiquetas debe estar en modo TSC, probe con la aplicacion que me indicaste y en efecto, en modo TSC respeta el gap entre etiquetas, en modo Esc/Pos No.

PD, abri otro hilo en el foro como me indicaron.

Saludos
 
Top