Get Printer Information
This method returns the printer name and online status.
Code Samples
CWS
Request
method string | required | getPrinterInfo |
requestId string | required | Transaction Request ID |
targetType string | required | api |
parameters JSONObject | required | All relevant parameters for retrieving the printer information. |
Response
requestId
string
|
Transaction Request ID
As specified in the request.
|
statusDetails
string
|
Request Status
|
data
JSONObject
|
Object holding various responses.
|
printerInfo
JSONObject
|
Object holding printer information responses.
|
printerName
string
|
Printer Name
Name and model of the connected printer.
|
online
boolean
|
Online Status
Indicates whether or not the printer is available.
Valid values:
|
completed
boolean
|
Request Result
Retrieve printer infomation request result.
|
Example
Request
{
"method" : "getPrinterInfo",
"requestId" : "1676300556",
"targetType" : "api",
"version" : "1.0",
"parameters" : { }
}
Response
{
"requestId" : "1676300556",
"statusDetails" : "REQUEST_ACCEPTED",
"data" : {
"printerInfo" : {
"printerName" : "Star TSP650II Cutter (TSP654II) (Copy 1)",
"online" : true
},
"completed" : true
}
}
Java
ECLDevicesInterface<ECLPrinterInterface> commercePrinters = null;
ECLAccountInterface account;
commercePrinters = account.getPrinters();
ECLPrinterInterface pi = commercePrinters.getSelectedDevice();
if (null != pi)
{
/* Use pi */
}
/* ECLPrinterInterface has these methods */
public interface ECLPrinterInterface extends ECLDeviceInterface
{
// brief Print the text using special format. For receipts, instead use ECLReceiptProcessorInterface to print receipts.
// param formattedText text that contains "~0A" for newline, "~12" for red text, and "~0i" to wrap base64 encoded image.
// param listener Delegate to send notifications
public void printFormattedText(String formattedText, ECLPrinterListener listener);
// brief Not supported at this time.
// param image Base 64 encoded image
// param listener Delegate to send notifications
public void printImage(deckard.graphics.Bitmap image, ECLPrinterListener listener);
// brief Is printer online. This will automatically be called during a print of a receipt so no need to call before printing receipts.
public boolean isPrinterOnline();
// brief Name of the printer
public String getPrinterName();
// brief Width of printer in number of character
public int getPaperSize();
// brief Validate the printer is usable. This will automatically be called during a print of a receipt so no need to call before printing receipts.
public ECLCommerceError validate();
}
C#
/* Asynchronous */
m_CWS.StartPrinterInfo(MyNotifyCWSEvent, MyPrinterInfoComplete);
/* Synchronous */
PrinterInfoResults pir = m_CWS.PrinterInfo(null);
MyPrinterInfoComplete(pir);
/* Use the results */
public void MyPrinterInfoComplete(PrinterInfoResults psr)
{
Log("----------- PrinterInfo Complete ------------");
PrinterInfo ps = psr.PrinterInfo;
if (null != ps)
{
Log(String.Format("Name: {0}, Online: {1}", ps.printerName, ps.online));
}
else
{
Log("No PrinterInfo");
}