anggastudio / printama Goto Github PK
View Code? Open in Web Editor NEWA very well documented android library for bluetooth thermal printer. Tested for 2 inch printers
License: Apache License 2.0
A very well documented android library for bluetooth thermal printer. Tested for 2 inch printers
License: Apache License 2.0
how can i make dynamically set paper size and print it?
My old application is dependent on this library, but since some time it showing error and worked now , The bluetooth printer is connected fine but not print the receipt, the every function of printer util like printtext, printline etc. I cloned the printama android demo project and showing same error. so Please resolve this issue.
Here is the Android logs:-
2023-06-05 19:00:30.583 18376-18376/com.anggastudio.sample W/System.err: java.io.IOException: Broken pipe
2023-06-05 19:00:30.584 18376-18376/com.anggastudio.sample W/System.err: at android.net.LocalSocketImpl.writeba_native(Native Method)
2023-06-05 19:00:30.584 18376-18376/com.anggastudio.sample W/System.err: at android.net.LocalSocketImpl.access$500(LocalSocketImpl.java:37)
2023-06-05 19:00:30.584 18376-18376/com.anggastudio.sample W/System.err: at android.net.LocalSocketImpl$SocketOutputStream.write(LocalSocketImpl.java:144)
2023-06-05 19:00:30.584 18376-18376/com.anggastudio.sample W/System.err: at android.bluetooth.BluetoothSocket.write(BluetoothSocket.java:786)
2023-06-05 19:00:30.584 18376-18376/com.anggastudio.sample W/System.err: at android.bluetooth.BluetoothOutputStream.write(BluetoothOutputStream.java:79)
2023-06-05 19:00:30.584 18376-18376/com.anggastudio.sample W/System.err: at java.io.OutputStream.write(OutputStream.java:122)
2023-06-05 19:00:30.584 18376-18376/com.anggastudio.sample W/System.err: at com.anggastudio.printama.PrinterUtil.printUnicode(PrinterUtil.java:94)
2023-06-05 19:00:30.585 18376-18376/com.anggastudio.sample W/System.err: at com.anggastudio.printama.PrinterUtil.addNewLine(PrinterUtil.java:166)
2023-06-05 19:00:30.585 18376-18376/com.anggastudio.sample W/System.err: at com.anggastudio.printama.PrinterUtil.feedPaper(PrinterUtil.java:290)
2023-06-05 19:00:30.585 18376-18376/com.anggastudio.sample W/System.err: at com.anggastudio.printama.Printama.feedPaper(Printama.java:184)
2023-06-05 19:00:30.585 18376-18376/com.anggastudio.sample W/System.err: at com.anggastudio.printama.Printama.lambda$printTest$2(Printama.java:127)
2023-06-05 19:00:30.585 18376-18376/com.anggastudio.sample W/System.err: at com.anggastudio.printama.-$$Lambda$Printama$RmuijsPIw_E46bsFguHyZkOvvNI.onConnected(Unknown Source:0)
2023-06-05 19:00:30.585 18376-18376/com.anggastudio.sample W/System.err: at com.anggastudio.printama.Printama.lambda$connect$0$Printama(Printama.java:102)
2023-06-05 19:00:30.585 18376-18376/com.anggastudio.sample W/System.err: at com.anggastudio.printama.-$$Lambda$Printama$8huuBLTLR2MZ4RxuJjF9x13epEw.onConnected(Unknown Source:4)
2023-06-05 19:00:30.585 18376-18376/com.anggastudio.sample W/System.err: at com.anggastudio.printama.PrinterUtil$1.onConnected(PrinterUtil.java:63)
2023-06-05 19:00:30.585 18376-18376/com.anggastudio.sample W/System.err: at com.anggastudio.printama.PrinterUtil$ConnectAsyncTask.onPostExecute(PrinterUtil.java:327)
2023-06-05 19:00:30.585 18376-18376/com.anggastudio.sample W/System.err: at com.anggastudio.printama.PrinterUtil$ConnectAsyncTask.onPostExecute(PrinterUtil.java:294)
2023-06-05 19:00:30.585 18376-18376/com.anggastudio.sample W/System.err: at android.os.AsyncTask.finish(AsyncTask.java:771)
2023-06-05 19:00:30.586 18376-18376/com.anggastudio.sample W/System.err: at android.os.AsyncTask.access$900(AsyncTask.java:199)
2023-06-05 19:00:30.586 18376-18376/com.anggastudio.sample W/System.err: at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788)
2023-06-05 19:00:30.586 18376-18376/com.anggastudio.sample W/System.err: at android.os.Handler.dispatchMessage(Handler.java:106)
2023-06-05 19:00:30.586 18376-18376/com.anggastudio.sample W/System.err: at android.os.Looper.loopOnce(Looper.java:226)
2023-06-05 19:00:30.586 18376-18376/com.anggastudio.sample W/System.err: at android.os.Looper.loop(Looper.java:313)
2023-06-05 19:00:30.586 18376-18376/com.anggastudio.sample W/System.err: at android.app.ActivityThread.main(ActivityThread.java:8751)
2023-06-05 19:00:30.586 18376-18376/com.anggastudio.sample W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2023-06-05 19:00:30.586 18376-18376/com.anggastudio.sample W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
2023-06-05 19:00:30.586 18376-18376/com.anggastudio.sample W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
Please help me! when i changed to android studio debugger says : * What went wrong:
Execution failed for task ':printama:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
Can't print arabic text
How can I return as a for loop?
When i was clicked save button .
Hi, I just mailed you about this issue.
You set PRINTER_WIDTH = 384 (which is fixed). That doesn't care about the actual printer paper width. Instead of that, can't we detect printer paper size from socket data? or you can add a paper size option on choose printer dialog. So, if we set 58mm/80mm/custom width, then it will be used as printer width throughout the app for that selected printer.
I am testing this library on JP-Q2i POS Terminal PDA (Embedded printer is configured as Bluetooth device)
but I cannot print a text.
Printama.with(this).connect(new Printama.OnConnected() {
@Override
public void onConnected(Printama printama) {
printama.printText("TEST");
}
});
Library connect with MPT-II but not start a print
Before this happened, I tried to print an image (logo) with several text below it, and its works verry well with no issue, but after I added QR Code (Bitmap) to be printed with, the logo just printed half and half more becomes unreadable character (image below)
Here it is the code that i used for :
val logo = Printama.getBitmapFromVector(activity, R.drawable.logo_black)
val nota = "Some Text"
Printama.with(activity).connect({ printama: Printama ->
printama.printImage(logo, 200)
printama.addNewLine()
printama.printTextln(Printama.CENTER, "Title Text")
printama.setNormalText()
printama.printTextln(
Printama.CENTER,
"Some Text"
)
printama.printDashedLine()
val writer = QRCodeWriter()
val bitMatrix = writer.encode(nota, BarcodeFormat.QR_CODE, 300, 300)
val width = bitMatrix.width
val height = bitMatrix.height
val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565)
for (x in 0 until width) {
for (y in 0 until height) {
bitmap.setPixel(x, y, if (bitMatrix.get(x, y)) Color.BLACK else Color.WHITE)
}
}
bitmap?.let {
printama.printImage(it)
}
printama.addNewLine()
printama.feedPaper()
printama.close()
}) { message: String? -> activity.toast(message) }
Hi, I'm just wondering how to Set the DPI and Font Style
I download a apk "RawBT" it can change the font to True Type Font and DPI to 304
when i try to print full bitmap image in 58mm printer
print Chinese char
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not find com.github.anggastudio:Printama:0.9.7.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/github/anggastudio/Printama/0.9.7/Printama-0.9.7.pom
- https://repo.maven.apache.org/maven2/com/github/anggastudio/Printama/0.9.7/Printama-0.9.7.pom
- https://jcenter.bintray.com/com/github/anggastudio/Printama/0.9.7/Printama-0.9.7.pom
Required by:
project :app
Please provide support for reginal language, like hindi.
can i connect more than one print?
Just create another instance of printama?
Someone can help me?
@derohimat @isfaaghyth @utsmannn @anggastudio
W/System.err: java.io.IOException: read failed, socket might closed or timeout, read ret: -1
BluetoothDevice device = bluetoothDevices[0];
UUID uuid;
if (device != null) {
ParcelUuid[] uuids = device.getUuids();
uuid = (uuids != null && uuids.length > 0) ? uuids[0].getUuid() : UUID.randomUUID();
} else {
return null;
}
BluetoothSocket socket = null;
boolean connected = true;
try {
socket = device.createRfcommSocketToServiceRecord(uuid);
socket.connect();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e2) {
connected = false;
}
return connected ? socket : null;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.