GithubHelp home page GithubHelp logo

dantsu / escpos-thermalprinter-android Goto Github PK

View Code? Open in Web Editor NEW
1.1K 30.0 342.0 340 KB

Useful library to help Android developpers to print with (Bluetooth, TCP, USB) ESC/POS thermal printer.

License: MIT License

Java 100.00%
escpos escpos-printer android android-library thermal-printer thermal-printing bluetooth-printer usb-printer tcp-printer qrcode

escpos-thermalprinter-android's Introduction

escpos-thermalprinter-android's People

Contributors

areeb111 avatar dantsu avatar doyouevenbacon avatar lumber1000 avatar mcarland avatar ozone89 avatar snorsnor9998 avatar steamerstudio avatar yoviekaputra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

escpos-thermalprinter-android's Issues

Can I use this with serial printers?

Hi, can I use this library to print on a thermal printer connected via serial port?
I am developing an app that runs on a android device that has a thermal printer integrated and internally
the android device is connected to the printer with serial port.
Is there some way I can send print commands to that printer using this library?
Thank you.

Japanese Character Print

@DantSu

Hi,
This is my second issue.
I need to print Japanese characters.
My printer can support Japanese characters and has the same codepage as EPSON.
I tried many different variations but I was unable to print simple Japanese characters.
Can you please give me some suggestions?
How should I write the EscPosCharsetEncoding function?
Thank you.

Not able to print euro sign €

Hey, I'm using this great lib since a couple of months ago and I just figured out that I was not able to print the euro sign : '€'. This symbol is replaced by a question mark.
My printer is a Munbyn.
Do you face the same issue ?

Thanks.
Regards

QR Code issues

I am very grateful for making the library available, it has been very useful.

But I'm facing some issues while printing QR Code.
I'm using version 2.0.5 of the library.
Here are the details:

Successful prints using sizes 20 and 27:

[L]<qrcode size='20'>http://www.developpeur-web.dantsu.com/</qrcode>
[L]<qrcode size='27'>http://www.developpeur-web.dantsu.com/</qrcode>

Unsuccessful prints using sizes greater than 27:

Error 1:
[L]<qrcode size='28'>http://www.developpeur-web.dantsu.com/</qrcode>

Library throws exception:

java.lang.ArrayIndexOutOfBoundsException: length=29; index=29
at com.dantsu.escposprinter.EscPosPrinterCommands.QRCodeDataToBytes(EscPosPrinterCommands.java:167)
at com.dantsu.escposprinter.textparser.PrinterTextParserQRCode.initConstructor(PrinterTextParserQRCode.java:32)
at com.dantsu.escposprinter.textparser.PrinterTextParserQRCode.(PrinterTextParserQRCode.java:40)
at com.dantsu.escposprinter.textparser.PrinterTextParserColumn.appendQRCode(PrinterTextParserColumn.java:266)
at com.dantsu.escposprinter.textparser.PrinterTextParserColumn.(PrinterTextParserColumn.java:77)
at com.dantsu.escposprinter.textparser.PrinterTextParserLine.(PrinterTextParserLine.java:46)
at com.dantsu.escposprinter.textparser.PrinterTextParser.parse(PrinterTextParser.java:173)
at com.dantsu.escposprinter.EscPosPrinter.printFormattedText(EscPosPrinter.java:95)
at com.dantsu.escposprinter.EscPosPrinter.printFormattedText(EscPosPrinter.java:77)

Using the same size but with another content, the QR Code prints normally:
[L]<qrcode size='28'>http://www.google.com/</qrcode>

I think the problem is not only related to the size, but also to the content of QR Code.

Error 2:
[L]<qrcode size='35'>http://www.developpeur-web.dantsu.com/</qrcode>

QR Code starts to be printed, but before completing, some characters are printed instead of the content and the printer continues to feed these characters repeatedly until I switch off manually. See the result:

IMG_20200807_120127673

I made an even bigger QR Code print through another app that doesn’t use the library and it managed to print normally, see the image:

IMG_20200807_120156827

So we can tell that the problem while printing large QR Codes is not related to the printer device.

Text align wrong when too long

I tried to test with this, but the number 9.99 was aligned left
"[L]<b>BEAUTIFUL SHIRT BEAUTIFUL SHIRT BEAUTIFUL SHIRT BEAUTIFUL SHIRT</b>[R]9.99e\n"

Util Class?

I have my own bluetooth connection class. How do we use the EscPosPrinter class without bluetooth connection? I want to send parsed image and text directly to the printer through my own link class. Therefore, is it possible to use something like Util class that I can convert from image to hex?

Receipt cutting issue

sometimes printing is not completed and did not cut the paper. Printer stucks the paper. can you help me with this?

bold is ignored and if i add font size it stops printing

Hi, I am having a problem on a printer. the is ignored, it just prints normal even if i specify to print in bold.
Also if i add font size the print stops in the middle of the printing, right before the text that has size specifications.
Do you have any idea why this happens?
Thank you

Does not detect broken pipe

Hi guys. There's an enhancement to be made regarding exception propagations.
Indeed, in DeviceConnection.send(), we print stack trace whereas we should throws the raw exception or, better, a custom one.
The result is that the application is not notified of a broken pipe situation and can't request a new connection. This appends when you turn off and on your thermal printer.
I will try to make a PR.
Your comments are welcome.
Cheers

horizontal print

Hello, I've been trying to make my printer, print a bank slip for a long time, but I can't use page mode, do you know any api or can you tell me how to do this ??

Text align

I've cloning this project, run and test without change any code. The output from my printer is different with your output. Here my output

IMG_20200721_121058

Hope you can give me me this solution

Clear Print Buffer/Queue/Cache

Hi,
I am using this library to Print Customer Invoice from my Kotlin App. It prints properly but on second try (actually all subsequent tries), it prints the Invoice twice. I do close the connection after every print but Looks like somehow buffer does not clear after print and every time I send another print, it prints older invoices as well along with new. How can I clear Buffer/Queue/Cache for the Printer?

Is there any ways to know the printer status?

How can we know printer is connected to device? Is there any callback methods to know the printer state : CONNECTED, DISCONNECTED, CONNECTING. Very thank you for your great library and I 'm from Myanmar.I 'm trying to print Myanmar Characters. I bought one chinese 80MM thermal printer Rongta RPP-300.As your encoding method, EscPosCharsetEncoding(String charsetName, int escPosCharsetId), I don't know how to find my charsetName and escPosCharsetId for that. I knew to use "UTF-8" encoding to print myanmar chars. Thanks for your time.

Cut paper

I'm sorry I couldn't find the paper cutting order.

Image printing not work well

image 1
exit1
photo size :256*256 and color bit 8bit

image 2
cup
With image Simultaneous printing feel printer getting slow down
Thank you work well other in side

How to print large image

I am using USB thermal printing method. If I keep image below 256 for width and height, it prints successfully but it does not print anything if I keep any of these above 256. Can someone help?

catch errors

Hi, thanks for your job !

How is the best way to catch errors when you do this ?

EscPosPrinter printer = new EscPosPrinter(BluetoothPrintersConnections.selectFirstPaired(), 203, 48f, 32);

compatibility error

What model of printers does this library support? I am printing from a woosim i250 but if I try with another printer it does not print beforehand thanks

I found the Chinese words, but...

EscPosPrinter printer = new EscPosPrinter(new TcpConnection(iIPaddress, iPort), 203, 48f,32, new EscPosCharsetEncoding("CP-950", 16)

While I am using "CP-950" that I can print out Chinese words, but...

  1. what does the second param means??? EscPosCharsetEncoding("",16)

  2. when I using [C]<u><font size='big'>LINE@線上點餐</font></u>\n, the font size does not work.

USB can be disabled ?

Hi, one question again.
Is it possible that you have this inside the library ?

<uses-feature android:name="android.hardware.usb.host" />

Because this significantly reduce the number of devices supported.
Is there a way to dasactive this feature?

thanks

Problema letras acentuadas al usar <font size='small'>

Good day,

I have read the problem when not using the correct encoding, but I am having a problem when using font size small, instead of placing the accented letter, it adds a symbol like a diamond, this does not happen to me with the other font sizes, only with small.

Thanks!

how to add new bluetooth device?

I want to connect to new bluetooth device or make the pairing process inside my app how to do this manually even if i will do the bluetooth connection myself

Mixed print

Hello, thanks for your work on this.
I've noticed that using "printFormattedTextAndCut" more time consequentially result in mixed character on print and just one cut a the end... Is there a way to get a print finished info or to manage queue?

Not able to print Latin letter

I am trying to print Latin letter For Ex.
Ç, ü, é, â, ä, à, å, ç, ê, ë, è, ï, î, ì, Ä, Å, É, æ, Æ, ô, ö, ò, û, ù, ÿ, Ö, Ü, ¢, £, ¥, ?, ƒ, á, í, ó, ú, ñ, Ñ,
but it's change to something else
image

Image Not Printing

@DantSu

Hi,
First of all, Thanks for making such a wonderful thing.

I am planning to use this library in an application but the first image is not getting printed.
Everything else is printing properly except for the top image.

I have confirmed that I have that "logo.png" image in my drawable.
Can you please suggest me any solutions.
Thank you.

Here is my code

new Thread(new Runnable() {
public void run() {
try {
EscPosPrinter printer = new EscPosPrinter(new TcpConnection("192.168.1.5", 9100), 203, 80f, 48);
printer
.printFormattedTextAndCut(
"[C]" + PrinterTextParserImg.bitmapToHexadecimalString(printer, getApplicationContext().getResources().getDrawableForDensity(R.drawable.logo, DisplayMetrics.DENSITY_MEDIUM)) + "\n" +
"[L]\n" +
"[C]ORDER N°045\n" +
"[L]\n" +
"[C]================================\n" +
"[L]\n" +
"[L]BEAUTIFUL SHIRT[R]9.99e\n" +
"[L] + Size : 12/33\n" +
"[L]\n" +
"[L]AWESOME HAT[R]24.99e\n" +
"[L] + Size : 57/58\n" +
"[L]\n" +
"[C]--------------------------------\n" +
"[R]TOTAL PRICE :[R]34.98e\n" +
"[R]TAX :[R]4.23e\n" +
"[L]\n" +
"[C]================================\n"
);
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();

Inbuilt printer FB3550

I have a mobile smart POS device, which has an inbuilt printer, how do i use this library with it, because its not connecting using bluetooth

Printer has to pe reset after a few copies

Hi, I'm having an issue when I'm printing on lan printers.
At some point the print command stops working, it fives me "printer not found error" and it only starts printing again if I restart the printer. It happens on different printer models that did not have this issue before I started to use the library.
Do you know if this is a known bug or maybe I'm doing something wrong.
I am using the print command like in yout examples.
Thank you

Is there a way to use the library without having to tell it the printer dimensions?

Hi, I'm writing an app that should be able to connect to different types of printer, for example 58mm bluetooth printers or 80mm tcp printers. Is there a way to send the print command without having to specify printer dpi, width or characters per line? simply because the user could connect to a printer and not know all this details.
Thank you

Need a few easy steps to connect to printer

I tried to print sample image, I turn off bluetooth, but it does not request any bluetooth enable request.Connecting to printer process is not smooth and sometimes app crash, because of Attempt to read from null array
Screenshot 2020-05-22 at 11 41 55 PM
But, https://github.com/iYaroslav/esc-pos-android this one is implemented for the easy and simply way to connect to printer, we can forget about connecting process, but it does not support image and QR code printing yet

Small Font Black Background

When I use the small font option and try to print, the text background is black and the font color is white but there is no such problem in the medium font option.

What is the reason of this? I'm printing in the format you mentioned on the wiki.

Print scrollview bitmap

Hello, I'm trying to print a bitmap of a scrollview. The scrollview has a tablelayout inside it, when there are less than 5 rows in the tablelayout it prints the bitmap without any problems but when there are more than 5 rows it does not print anything. could you help me with this ?

thank you.

Text position change

Hey, as you can see from image, It always changes text position. What problem may it be? And also change dpi isn't change anything...
image

Just simple code

val printer = EscPosPrinter(
        BluetoothPrintersConnections.selectFirstPaired(), 103, 70f, 46,
        EscPosCharsetEncoding("cp866", 17)
    )

    fun printS() {
        printer
            .printFormattedText(
                "[C]    <b>1</b>[R]24.99e\n" +
                        "[C]  <b>2</b>2\n" +
                        "[C]     <b>3</b>\n" +
                        "[C]         <b>4</b>[R]24.99e\n" +
                        "[C]        <b>5</b>\n" +
                        "[C]        <b>6</b>"
            )
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.