Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have install Epson SDK to android, and added the below code"

   
how to print direct to Epson PDF


What I have tried:

Printer printer = null;
    try {
        printer = new Printer(Printer.TM_M30, Printer.MODEL_ANK, this);
    }
    catch (Epos2Exception e) {
        //Displays error messages
    }

 //new
    final Context mContext = this;
    printer.setReceiveEventListener(new ReceiveListener() {
        @Override
        public void onPtrReceive(Printer printer, int code, PrinterStatusInfo printerStatusInfo, 
String s) {
            if (code == com.epson.epos2.Epos2CallbackCode.CODE_SUCCESS){

            }else{
                Toast.makeText(mContext, "Printer can't be connected. Please try again", 
Toast.LENGTH_SHORT).show();
            }
        }
    });
Posted
Updated 20-May-20 4:56am
Comments
Richard MacCutchan 20-May-20 9:39am    
Do you have a question?
Member 4773987 20-May-20 10:30am    
I need to print pdf file direct to printer, i don’t know how?

1 solution

 
Share this answer
 
Comments
Member 4773987 23-May-20 17:31pm    
The below code build without any errors, also i did all configuration successful,

While run the application in mobile does not connect to printer it is return erros, fine.

But when i run it in the connected Tablet with the same network with Epson Tm-M30 printer it is not print and no error appear. Please i need help why it is not print?

enter code here

final Context sContext = this;
Printer printer = null;
try {
printer = new Printer(Printer.TM_M30, Printer.MODEL_ANK, this);
}
catch (Epos2Exception e) {
//Displays error messages
Toast.makeText(sContext, "Error1", Toast.LENGTH_SHORT).show();
}

//new
final Context mContext = this;
printer.setReceiveEventListener(new ReceiveListener() {
@Override
public void onPtrReceive(Printer printer, int code, PrinterStatusInfo printerStatusInfo,
String s) {
if (code == com.epson.epos2.Epos2CallbackCode.CODE_SUCCESS){

}else{
Toast.makeText(mContext, "Printer can't be connected. Please try again",
Toast.LENGTH_SHORT).show();
}
}
});

try {
printer.addTextAlign(Printer.ALIGN_CENTER);
printer.addText("Hello World");
}
catch (Epos2Exception e) {
Toast.makeText(mContext, "Can't print Hello World. Please try again",
Toast.LENGTH_SHORT).show();
}

try {
printer.connect("TCP:192.168.100.21", Printer.PARAM_DEFAULT);
}
catch (Epos2Exception e) {
Toast.makeText(mContext, "Error1", Toast.LENGTH_SHORT).show();
}

try {
printer.sendData(Printer.PARAM_DEFAULT);
}
catch (Epos2Exception e) {
Toast.makeText(mContext, "Error2", Toast.LENGTH_SHORT).show();
// Abort process
}
//public void onPtrReceive(final Printer printerObj, final int code, final PrinterStatusInfo
status,
//final String printJobId) {
ReceiveListener printrecieve_listener = new ReceiveListener() {
@Override
public void onPtrReceive(final Printer printerObj, final int code, PrinterStatusInfo
printerStatusInfo, String printJobId) {
runOnUiThread(new Runnable() {
@Override
public synchronized void run() {
if (code == com.epson.epos2.Epos2CallbackCode.CODE_SUCCESS) {

} else {
Toast.makeText(mContext, "Error3", Toast.LENGTH_SHORT).show();

}
}
});
new Thread(new Runnable() {
@Override
public synchronized void run() {

}
}).start();
Richard MacCutchan 24-May-20 3:58am    
If the code fails on one system but not the other then you need to use the debug tools to find out why. It is impossible for anyone here to do that for you. Are you sure that you are not missing a Toast message? Also I notice that you do not check the details of the exception in any of your catch statements so you may be missing some other information. Are you sure that there are not other checks that you need to make when calling the various Printer methods?
Member 4773987 25-May-20 11:51am    
I checked all details, everything is fine, the tablet which connect to printer does not return any error and does not print
Richard MacCutchan 25-May-20 11:59am    
Sorry, but there is nothing anyone here can do. You need to check with the people who wrote the Epson SDK.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900