-1

Im Using Citizen POSPrinter to print Digital Signature from my android application using bluetooth. But it prints only the byte[] array in the printer instead of printing the signature. I dono where im wrong. help me. Thanks in advance..

    ESCPOSPrinter posPtr = new ESCPOSPrinter();
    String root = Environment.getExternalStorageDirectory().toString();

    String fname = "Sign.jpg";
    file = new File (root, fname);
    path = file.getAbsolutePath();

    if (file.exists())
        file.delete();
    try {
        out = new FileOutputStream(file);
        signature.compress(Bitmap.CompressFormat.PNG, 90, out);
        out.flush();
        out.close();

    } catch (Exception e) {
        e.printStackTrace();
    }

    try {

        posPtr.printBitmap("//sdcard//Sign.jpg", CMPPrint.CMP_ALIGNMENT_RIGHT);

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
tomash
  • 12,742
  • 15
  • 64
  • 81
Raja45
  • 181
  • 1
  • 3
  • 10

1 Answers1

1

You're saving the file with a .jpg extension, but using Bitmap.CompressFormat.PNG. That seems unlikely to work. Also, you have catch blocks that don't actually handle the exception, but let the program continue in an erroneous state. If you get any I/O errors, your program will suffer mysterious, hard-to-debug errors later on - like the one you're trying to find.

I strongly suggest you work out how to handle exceptions properly before attempting to continue.

Dan Hulme
  • 14,779
  • 3
  • 46
  • 95
  • ya sure.. I ll learn how to handle it. But i get some special characters in the receipt. How to solve it.. – Raja45 Aug 07 '13 at 11:38