Blue Bamboo P25 Printer Android Demo Application With Source Code

Blue Bamboo P25 printer is a lightweight and portable thermal printer that provides low cost printing in mobile and wireless environments. It supports mobile application printing over Bluetooth, USB or Serial port (RS-232). It also has a good connectivity with Android device, makes printing from Android becomes very easy and fast.

P25 Printer Android

Blue Bamboo also provides a sample Android project to show how to build an application that supports printing using P25 printer over Bluetooth. The source code itself is quite old so i made a slight modification with fresh UI and easy to read source code so developers can easily implement the codes into their projects.

P25 Android Application Demo

This sample code shows how to print text, image, barcode and receipt into P25 printer using Bluetooth connectivity. The source code is available on Github repo, you can find it at the bottom of this post.

Print Text

private void printText(String text) {
	byte[] line 	= Printer.printfont(text + "\n\n", FontDefine.FONT_32PX, FontDefine.Align_CENTER, (byte) 0x1A, PocketPos.LANGUAGE_ENGLISH);
	byte[] senddata = PocketPos.FramePack(PocketPos.FRAME_TOF_PRINT, line, 0, line.length);


Use Printer.printFont(String content, byte fonttype, byte fontalign,byte linespace, byte language) method to format and position the text. For font types and text alignment, see and for language definition, see Also call the PocketPos.FramePack(byte typeFrame, byte[] srcBuff, int srcOffset, int srcLen) to create frame data before sending to printer.

See P25 development guide page 60-63 for more information.

Print 1D Barcode

private void print1DBarcode() {
	String content	= "6901234567892";

	byte[] formats	= {(byte) 0x1d, (byte) 0x6b, (byte) 0x02, (byte) 0x0d};
	byte[] contents	= content.getBytes();

	byte[] bytes	= new byte[formats.length + contents.length];

	System.arraycopy(formats, 0, bytes, 0, formats.length);
	System.arraycopy(contents, 0, bytes, formats.length, contents.length);


	byte[] newline 	= Printer.printfont("\n\n",FontDefine.FONT_32PX,FontDefine.Align_CENTER,(byte)0x1A,PocketPos.LANGUAGE_ENGLISH);


1D barcode printing format is: 1d 6b 02 0d [barcode data]. So to print “6901234567892″ barcode data, the bytes would be:

{(byte) 0x1d, (byte) 0x6b, (byte) 0×02, (byte) 0x0d}

See P25 development guide page 59-60 for more information.

Print 2D Barcode

private void print2DBarcode() {
	String content 	= "Lorenz Blog -";

	byte[] formats	= {(byte) 0x1d, (byte) 0x6b, (byte) 0x10, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
						  (byte) 0x00, (byte) 0x1f};
	byte[] contents	= content.getBytes();
	byte[] bytes	= new byte[formats.length + contents.length];

	System.arraycopy(formats, 0, bytes, 0, formats.length);
	System.arraycopy(contents, 0, bytes, formats.length, contents.length);


	byte[] newline 	= Printer.printfont("\n\n",FontDefine.FONT_32PX,FontDefine.Align_CENTER,(byte)0x1A,PocketPos.LANGUAGE_ENGLISH);


2D barcode printing format is: 1d 6b 10 00 00 00 00 00 1f + barcode data. So to print “Lorenz Blog –” text, the bytes would be:

{(byte) 0x1d, (byte) 0x6b, (byte) 0×10, (byte) 0×00, (byte) 0×00, (byte) 0×00, (byte) 0×00, (byte) 0×00, (byte) 0x1f}
“Lorenz Blog –”.getBytes()

See P25 development guide page 60 for more information

Print Image

private void printImage() {
	try {
		byte[] formats	= { (byte)0x1B, (byte)0x58, (byte)0x31, (byte)0x24, (byte)0x2D };

		//bluebamboo logo
		byte[] image = {(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, ....... (byte)0x00};


		byte[] newline 	= Printer.printfont("\n\n",FontDefine.FONT_32PX,FontDefine.Align_CENTER,(byte)0x1A,PocketPos.LANGUAGE_ENGLISH);

	} catch (Exception e) {

Image printing format is: 1B 58 31 xx yy + {image data in bitmap monochrome format} where xx is width in pixels/8 and yy is height of image in pixels.

So to print 200×45 pixels of image, the format would be :

{ (byte)0x1B, (byte)0×58, (byte)0×31, (byte)0×24, (byte)0x2D } + { bytes of bitmap monochrome image}

Width = 200pixels/8bit = 25 in decimals = 0×24 in hexa
Height= 45 pixels in decimal = 0x2D in hexa

See for more information on how to print image and P25 development guide page 18-13 and 63.

Print Sample Receipt

private void printStruk() {
		String titleStr	= "STRUK PEMBAYARAN TAGIHAN LISTRIK" + "\n\n";

		StringBuilder contentSb	= new StringBuilder();

		contentSb.append("IDPEL     : 435353535435353" + "\n");
		contentSb.append("NAMA      : LORENSIUS WLT" + "\n");
		contentSb.append("TRF/DAYA  : 50/12244 VA" + "\n");
		contentSb.append("BL/TH     : 02/14" + "\n");
		contentSb.append("ST/MTR    : 0293232" + "\n");
		contentSb.append("RP TAG    : Rp. 100.000" + "\n");
		contentSb.append("JPA REF   :" + "\n");

		StringBuilder content2Sb = new StringBuilder();

		content2Sb.append("ADM BANK  : Rp. 1.600" + "\n");
		content2Sb.append("RP BAYAR  : Rp. 101.600,00" + "\n");

		String jpaRef	= "XXXX-XXXX-XXXX-XXXX" + "\n";
		String message	= "PLN menyatakan struk ini sebagai bukti pembayaran yang sah." + "\n";
		String message2	= "Rincian tagihan dapat diakses di Informasi Hubungi Call Center: "
						+ "123 Atau Hub PLN Terdekat: 444" + "\n";

		long milis		= System.currentTimeMillis();
		String date		= DateUtil.timeMilisToString(milis, "dd-MM-yy / HH:mm")  + "\n\n";

		byte[] titleByte	= Printer.printfont(titleStr, FontDefine.FONT_24PX,FontDefine.Align_CENTER,
								(byte)0x1A, PocketPos.LANGUAGE_ENGLISH);

		byte[] content1Byte	= Printer.printfont(contentSb.toString(), FontDefine.FONT_24PX,FontDefine.Align_LEFT,
								(byte)0x1A, PocketPos.LANGUAGE_ENGLISH);

		byte[] refByte		= Printer.printfont(jpaRef, FontDefine.FONT_24PX,FontDefine.Align_CENTER,  (byte)0x1A,

		byte[] messageByte	= Printer.printfont(message, FontDefine.FONT_24PX,FontDefine.Align_CENTER,  (byte)0x1A,

		byte[] content2Byte	= Printer.printfont(content2Sb.toString(), FontDefine.FONT_24PX,FontDefine.Align_LEFT,
								(byte)0x1A, PocketPos.LANGUAGE_ENGLISH);

		byte[] message2Byte	= Printer.printfont(message2, FontDefine.FONT_24PX,FontDefine.Align_CENTER,  (byte)0x1A,

		byte[] dateByte		= Printer.printfont(date, FontDefine.FONT_24PX,FontDefine.Align_LEFT, (byte)0x1A,

		byte[] totalByte	= new byte[titleByte.length + content1Byte.length + refByte.length + messageByte.length +
		                	           content2Byte.length + message2Byte.length + dateByte.length];

		int offset = 0;
		System.arraycopy(titleByte, 0, totalByte, offset, titleByte.length);
		offset += titleByte.length;

		System.arraycopy(content1Byte, 0, totalByte, offset, content1Byte.length);
		offset += content1Byte.length;

		System.arraycopy(refByte, 0, totalByte, offset, refByte.length);
		offset += refByte.length;

		System.arraycopy(messageByte, 0, totalByte, offset, messageByte.length);
		offset += messageByte.length;

		System.arraycopy(content2Byte, 0, totalByte, offset, content2Byte.length);
		offset += content2Byte.length;

		System.arraycopy(message2Byte, 0, totalByte, offset, message2Byte.length);
		offset += message2Byte.length;

		System.arraycopy(dateByte, 0, totalByte, offset, dateByte.length);

		byte[] senddata = PocketPos.FramePack(PocketPos.FRAME_TOF_PRINT, totalByte, 0, totalByte.length);


Print Demo Page

private void printDemoContent(){

		/*********** print head*******/
		String receiptHead = "************************"
				+ "   P25/M Test Print"+"\n"
				+ "************************"
				+ "\n";

		long milis		= System.currentTimeMillis();

		String date		= DateUtil.timeMilisToString(milis, "MMM dd, yyyy");
		String time		= DateUtil.timeMilisToString(milis, "hh:mm a");

		String hwDevice	= Build.MANUFACTURER;
		String hwModel	= Build.MODEL;
		String osVer	= Build.VERSION.RELEASE;
		String sdkVer	= String.valueOf(Build.VERSION.SDK_INT);

		StringBuffer receiptHeadBuffer = new StringBuffer(100);

		receiptHeadBuffer.append(Util.nameLeftValueRightJustify(date, time, DataConstants.RECEIPT_WIDTH) + "\n");

		receiptHeadBuffer.append(Util.nameLeftValueRightJustify("Device:", hwDevice, DataConstants.RECEIPT_WIDTH) + "\n");

		receiptHeadBuffer.append(Util.nameLeftValueRightJustify("Model:",  hwModel, DataConstants.RECEIPT_WIDTH) + "\n");
		receiptHeadBuffer.append(Util.nameLeftValueRightJustify("OS ver:", osVer, DataConstants.RECEIPT_WIDTH) + "\n");
		receiptHeadBuffer.append(Util.nameLeftValueRightJustify("SDK:", sdkVer, DataConstants.RECEIPT_WIDTH));
		receiptHead = receiptHeadBuffer.toString();

		byte[] header = Printer.printfont(receiptHead + "\n", FontDefine.FONT_32PX,FontDefine.Align_CENTER,(byte)0x1A,PocketPos.LANGUAGE_ENGLISH);

		/*********** print English text*******/
		StringBuffer sb = new StringBuffer();
		for(int i=1; i<128; i++)
		String content = sb.toString().trim();

		byte[] englishchartext24 			= Printer.printfont(content + "\n",FontDefine.FONT_24PX,FontDefine.Align_CENTER,(byte)0x1A,PocketPos.LANGUAGE_ENGLISH);
		byte[] englishchartext32			= Printer.printfont(content + "\n",FontDefine.FONT_32PX,FontDefine.Align_CENTER,(byte)0x1A,PocketPos.LANGUAGE_ENGLISH);
		byte[] englishchartext24underline	= Printer.printfont(content + "\n",FontDefine.FONT_24PX_UNDERLINE,FontDefine.Align_CENTER,(byte)0x1A,PocketPos.LANGUAGE_ENGLISH);

		//2D Bar Code
		byte[] barcode = StringUtil.hexStringToBytes("1d 6b 02 0d 36 39 30 31 32 33 34 35 36 37 38 39 32");

		/*********** print Tail*******/
		String receiptTail =  "Test Completed" + "\n"
				+ "************************" + "\n";

		String receiptWeb =  "** ** " + "\n\n\n";

		byte[] foot = Printer.printfont(receiptTail,FontDefine.FONT_32PX,FontDefine.Align_CENTER,(byte)0x1A,PocketPos.LANGUAGE_ENGLISH);
		byte[] web	= Printer.printfont(receiptWeb,FontDefine.FONT_32PX,FontDefine.Align_CENTER,(byte)0x1A,PocketPos.LANGUAGE_ENGLISH);

		byte[] totladata =  new byte[header.length + englishchartext24.length + englishchartext32.length + englishchartext24underline.length +
		                              + barcode.length
		                             + foot.length + web.length
	 	int offset = 0;
		System.arraycopy(header, 0, totladata, offset, header.length);
		offset += header.length;

		System.arraycopy(englishchartext24, 0, totladata, offset, englishchartext24.length);
		offset+= englishchartext24.length;

		System.arraycopy(englishchartext32, 0, totladata, offset, englishchartext32.length);

		System.arraycopy(englishchartext24underline, 0, totladata, offset, englishchartext24underline.length);

		System.arraycopy(barcode, 0, totladata, offset, barcode.length);

		System.arraycopy(foot, 0, totladata, offset, foot.length);

		System.arraycopy(web, 0, totladata, offset, web.length);

		byte[] senddata = PocketPos.FramePack(PocketPos.FRAME_TOF_PRINT, totladata, 0, totladata.length);


All bytes data to be printed is sent to printer using sendData method from P25Connector class (

private void sendData(byte[] bytes) {
	try {
	} catch (P25ConnectionException e) {

P25Connector is a wrapper class to handle bluetooth operation (connect, disconnect, and bluetooth socket operation)

Demo video

Real life application video

Download source code from Github repo

facebooktwittergoogle_plusredditpinterestlinkedinmailby feather


  1. Azhar says

    Slmt malam.Pak bisa tlg dibantu cara cek mac address nya. Printer sy Blue Bamboo P25. Pin nya 19734637. No serinya P25_062135_01. Sy sangat perlu sekali pak mac address. Sblm dan sesudahnya sy mengucapkan banyak terima kasih. Kl bisa di email saja pak ke :

  2. phal says

    Hi have gotten a hand of your tutorial. But can’t print any image I pass unto Method getBytesFromAssets in the FileOperation Class.
    The picture is located within the assets folder and still doesn’t work.

  3. Arya Patel says

    please send me demo for Map view inside scroll view & Print recipients for printer for

  4. moiky says

    Great one Loresius,
    From the source code when i printtext, reciept, barcode, or demo there extra strings printed before the actual print, do you know how they can be removed. eg printext > string (“Test”) will Print 1D456Test instead of just Test

  5. ziahaqi says

    tutorialnya bagus mas, oh iya, saya untuk ngeprint image dengan contoh gambar sendiri dengan extensi bitmap monochrome dengan ukuruan seperti yang dijelaskan diatas, tapi masih hancur ya kira2 sebabnya apa yak..? trimakasih

  6. Andy says


    Sebelumnya saya ucapkan terkma kasih atas artkel blognya mengenai printer bluebamboo yg sdh diupload di github. Yang ingin saya tanyakan, apakah memungkinkan sdk tersebut digunakan untuk PHP web base system ?

    Kasusnya begini: di tempat tersbut sudah memilikki aplikasi php web base , jadi rencananya, aplikasi web base tersebut mau dibuka di tablet dan kemudian print menggunskan portable pos bluebamboo. Apakah memungkinkan ?

    Terima kasih sebelumnya

  7. mesut says

    hi i want to develop a app which use zebra imz 320 pinter with bluetooth on android. your project(p25demo) is very helpfull for me. how can i set paper size? can u help me?

  8. kevin says

    thanks for the tutorial. In your image printing, you said the image is 200px wide, but 0×24 is not 25 pixels (rather 36 px). I think you want 0×19.

  9. Innocent HARELIMANA says

    Great post! It’s helping me a lot. Just bought BlueBamboo P10 bluetooth printer and thanks to this post I am able to print!

    Now Dear Lorensius, how do you generate that hex string of the monochrome image?

    Last, I printed the image once and on subsquent printing wierd string are being printed out instead of the image.

    I’d appreciate your help on the above.

    Thanks in advance.


  10. juanda says

    I have the printer but need to download the software on my phone. Is there a link to a download? I changed phones and need to download again. I use a square but use to use intuit as a merchant account. please advise.

  11. juanda says

    need the software to download. I have the printer. changed form iphone to android. used intuit and now using square.

Leave a Reply

Your email address will not be published. Required fields are marked *