public class BluetoothPrinter
extends java.lang.Object
Note: during tests, we found that some printers require to fill their buffer to start printing. So, if you have problems printing, try the following code after you instantiate this class:
cp = new CitizenPrinter(); // or new BluetoothPrinter(); cp.write(new byte[2048]); // fill the buffer cp.newLine(); ...
Modifier and Type | Field and Description |
---|---|
static byte |
ESC |
static byte |
GS |
static byte |
IMAGE_MODE_24_DOUBLE |
static byte |
IMAGE_MODE_24_SINGLE |
static byte |
IMAGE_MODE_8_DOUBLE |
static byte |
IMAGE_MODE_8_SINGLE |
Constructor and Description |
---|
BluetoothPrinter()
Creates a new BluetoothPrinter instance, using PortConnector.BLUETOOTH port at 57600 baud rate.
|
BluetoothPrinter(Stream con)
Creates a new BluetoothPrinter instance, using the given PortConnector as bridge to the printer.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
escape(int command)
Sends an escape command to the printer.
|
void |
escape(int command,
int value1)
Sends an escape command to the printer.
|
void |
escape(int command,
int value1,
int value2)
Sends an escape command to the printer.
|
void |
gs(int command,
int value1)
Sends a GS command to the printer.
|
void |
gs(int command,
int value1,
int value2)
Sends an escape command to the printer.
|
void |
newLine()
Sends a new line to the printer.
|
void |
newLine(int count)
Sends a number of new lines to the printer.
|
void |
print(MonoImage img)
Prints the given MonoImage.
|
void |
print(MonoImage img,
byte imageMode)
Deprecated.
Use the other print method without imageMode parameter.
|
void |
print(java.lang.String str)
Prints the given String.
|
void |
write(byte[] data)
Sends the given raw data to the printer.
|
void |
write(byte[] data,
int ofs,
int len)
Sends the given raw data to the printer.
|
public static final byte ESC
public static final byte GS
public static final byte IMAGE_MODE_8_SINGLE
public static final byte IMAGE_MODE_8_DOUBLE
public static final byte IMAGE_MODE_24_SINGLE
public static final byte IMAGE_MODE_24_DOUBLE
public BluetoothPrinter() throws IOException
IOException
public BluetoothPrinter(Stream con) throws IOException
IOException
public void write(byte[] data) throws IOException
IOException
public void write(byte[] data, int ofs, int len) throws IOException
IOException
public void escape(int command) throws IOException
IOException
public void escape(int command, int value1) throws IOException
IOException
public void escape(int command, int value1, int value2) throws IOException
IOException
public void gs(int command, int value1) throws IOException
IOException
public void gs(int command, int value1, int value2) throws IOException
IOException
public void print(java.lang.String str) throws IOException
IOException
@Deprecated public void print(MonoImage img, byte imageMode) throws ImageException, IOException
ImageException
IOException
public void print(MonoImage img) throws ImageException, IOException
ImageException
IOException
public void newLine() throws IOException
IOException
public void newLine(int count) throws IOException
IOException
public void close() throws IOException
IOException