Android: Bluetooth printing

I have to develop an App for Android tablets that demands printing files to a Bluetooth printer. Printing over Bluetooth is one of the most important features of my app. Unfortunately, there's not a lot of information about this subject so I'd like to ask for advice.

As far as I know it's not possible to print over Bluetooth on Android (using native calls), as Android's BT Stack doesn't implement BPP (Basic Printing Profile). Doing a little research I've found the following alternatives:

SDKs/Libraries

  • Sybase-iAnywhere-Blue-SDK-for-Android : Commercial SDK that supports a lot of BT profiles. Developed by a large company (good support I guess). I have not found a lot of information about this one. Is there some documentation,API or examples on how to use this SDK? Does anybody know how to download the demo version? (link seems to be broken last time I tried)
  • iPrint SDK: Commercial SDK. Some examples on their website but nothing else.
  • Zebralink: Only for Zebra printers (naturally). Other manufacturers probably have APIs for their printers too.

Google Play Apps

  • PrinterShare: Commercial (Premium key)
  • Bluetooth Smart Printing: Free and lightweight. Claims to print to Bluetooth printers.

Ideally I wouldn't want to be tied to a specific brand or printer model. Now the questions:

  • What do you think it would be the best choice?
  • Do you know any other alternative that I've missed?
  • Can I easily print files from my App using an external App?
  • What format should I use for my files to be able to print them over Bluetooth? (pdf,images,etc.)
  • Any advices on printer manufacturer and models?
  • Have you had any real experience printing over Bluetooth on Android?
  • Is there any plans in the immediate future to implement Bluetooth printing on Android?

Thanks in advance for your help ;)

Answers


Star Micronics has an SDK for Android printing via Bluetooth (as well as ethernet and USB). You can download it here: http://www.starmicronics.com/support/SDKDocumentation.aspx.

As you mentioned, you can't print natively at this point in time so the alternate solutions you found are your options today.

In my experience, it's best to use an API and not an external application. The biggest reason is you get total control over printer behavior. It's easy too if the API is built intelligently. Using an external app is limiting because you can't customize your print outs the way you want to.

The Star SDK I linked you to has a really nice sample app that lets you test and customize a lot of printer functions to see them in action. Each function is documented in the source code. The commands and their parameters are also available in the app itself as a quick on screen reference which is convenient. On top of all that, it's well documented.

Star's a great company to work with because you can get a free demo printer of your choice to use for your development.

If you choose this way, you can send plain text to the printer along with commands. The API handles converting the data into what the printer can understand.


The possibility of printing to BlueTooth printer depends highly on the model of printer you are trying to use.

For instance, I use CITIZEN CMP-10BT printer which can be controled by sending specific sequences of bytes which can easily be done using Android API. I even built a framework on top of that.

The problem lies only in the fact you can not tell for sure which printer models will be used by end-users so some ultimate SDK will definitely be of great need.


You can download this component: https://components.xamarin.com/view/ocpp-thermal-printer-usb it Works like a charm in most usb and bluetooth generic printers. I créate a class to send most usual esc commands. Usage: outerInstance.mService.Write(modes.pordefecto());

public class modes
{
    public static byte[] condensado()
    {
        byte[] cmd = new byte[3];
        cmd[0] = 0x1b;
        cmd[1] = 0x21;
        cmd[2] |= 0x01;

        return cmd;
    }

    public static byte[] pordefecto()
    {
        byte[] cmd = new byte[3];
        cmd[0] = 0x1b;
        cmd[1] = 0x21;
        cmd[2] |= 0x00;
        return cmd;
    }

    public static byte[] negrita()
    {
        byte[] cmd = new byte[3];
        cmd[0] = 0x1b;
        cmd[1] = 0x21;
        cmd[2] |= 0x08;
        return cmd;
    }

    public static byte[] lineamenor()
    {
        byte[] cmd = new byte[3];
        cmd[0] = 0x1b;
        cmd[1] = 0x33;
        cmd[2] |= 0x14;
        return cmd;
    }

    public static byte[] cancelalinea()
    {
        byte[] cmd = new byte[2];
        cmd[0] = 0x1b;
        cmd[1] = 0x32;
        return cmd;
    }

    public static byte[] centra()
    {
        byte[] cmd = new byte[3];
        cmd[0] = 0x1b;
        cmd[1] = 0x61;
        cmd[2] |= 0x01;
        return cmd;
    }

    public static byte[] quitacentro()
    {
        byte[] cmd = new byte[3];
        cmd[0] = 0x1b;
        cmd[1] = 0x61;
        cmd[2] |= 0x00;
        return cmd;
    }

    public static byte[] codepage()
    {
        byte[] cmd = new byte[5];
        cmd[0] = 0x1f;
        cmd[1] = 0x1b;
        cmd[2] = 0x1f;
        cmd[3] |= 0xfe;
        cmd[4] |= 0x01;
        return cmd;
    }

    public static byte[] latino()
    {
        byte[] cmd = new byte[5];
        cmd[0] = 0x1f;
        cmd[1] = 0x1b;
        cmd[2] = 0x1f;
        cmd[3] |= 0xff;
        cmd[4] |= 0x12;
        return cmd;
    }
    public static byte[] logo()
    {
        byte[] cmd = new byte[4];
        cmd[0] = 0x1c;
        cmd[1] = 0x70;
        cmd[2] = 0x01;
        cmd[3] |= 0x00;

        return cmd;
    }
}

Use Printooth library for any kind of printers, With zero configurations, simple usage and well documentation

https://github.com/mazenrashed/Printooth

Here is a sample code to print a simple line :

var printables = ArrayList<Printable>()
var printable = Printable.PrintableBuilder()  
    .setImage(image) 
    .setNewLinesAfter(1) // To provide n lines after sentence
    .build()
printables.add(printable)
BluetoothPrinter.printer().print(printables)

You can continue reading here : https://github.com/mazenrashed/Printooth/blob/master/README.md


Need Your Help

Is there a good charting library for iPhone?

ios cocoa cocoa-touch charts core-plot

I have a need to render and display charts (bar charts for now, but more types may be needed later) in an iPhone app I'm working on. I've done some looking around and it doesn't look like there are...

Yii2 dropdownlist WITHOUT $model

php drop-down-menu yii2

I have searched the web far and wide for a solution to this problem. I already know the Yii2 dropdown way is this: