-
-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image Not Printing #30
Comments
your pîcture |
Path : |
Thank you so much for your reply and nicely explaining it to me. I am pretty new in Android / Java programming. I didn't understand the density & folder thing before. Again, thanks for your support. It's a really nice library. My problem is solved so I'm closing this issue. |
I am sorry, I have got one more question. does the library print images only from the drawable? I am trying to print a generated bitmap image using this library: iZettle/android-html2bitmap But it's not printing any receipt. Here is my code: `
` Can you please suggest something for me. |
Read the logcat. The problem may coming from html2bitmap. Find the error, and past it here. |
Thank you so much for replying. Yes, there was an error in the Logcat. I filter the Logcat by "Html2Bitmap" 2020-07-20 23:21:54.748 23435-23435/com.example.android_esc_pos E/Html2Bitmap: []
2020-07-20 23:21:39.659 23435-23435/com.example.android_esc_pos D/HwFLClassLoader: get used feature list :/feature/used-list failed! The bold lines were in red color in logcat. |
iZettle/android-html2bitmap#32 Don't call this in the main thread. Try this : new Thread(new Runnable() {
public void run() {
String html = "<html><body><p>Hello world!</p><br/>Html bitmap</body><html>";
Bitmap ppp = new Html2Bitmap.Builder().setContext(this).setContent(WebViewContent.html(html)).build().getBitmap();
try {
EscPosPrinter printer = new EscPosPrinter(new TcpConnection("192.168.1.5", 9100), 203, 80f, 48);
printer
.printFormattedTextAndCut(
"[C]<img>" + PrinterTextParserImg.bitmapToHexadecimalString(printer, ppp) + "</img>\n" +
"[L]\n" +
"[C]<u><font size='big'>ORDER N°045</font></u>\n" +
........... |
Isn't my code the same? Here is the complete code of mine. What should i change? ` package com.example.android_esc_pos; public class MainActivity extends AppCompatActivity {
} ` I am sorry, I might be asking silly questions. |
no, look : Yours are outside, so in the Main Thread. |
Oh! Sorry. Now, I have understood. Tried just like your example. This error came up:
there is a red error here ".setContext(this)". if i remove the whole ".setContext(this)" part. the app doesn't run. |
Main thread is used to render the user interface, and Android don't like we use it to do heavy task. So we have to create new thread that execute code in parallel of the main thread. The main thread continue to render UI in same time that other stuff is processing heavy task. |
Ah yes, my bad : final Context context = this;
new Thread(new Runnable() {
public void run() {
String html = "<html><body><p>Hello world!</p><br/>Html bitmap</body><html>";
Bitmap ppp = new Html2Bitmap.Builder().setContext(context).setContent(WebViewContent.html(html)).build().getBitmap();
try {
EscPosPrinter printer = new EscPosPrinter(new TcpConnection("192.168.1.5", 9100), 203, 80f, 48);
printer
.printFormattedTextAndCut(
"[C]<img>" + PrinterTextParserImg.bitmapToHexadecimalString(printer, ppp) + "</img>\n" +
"[L]\n" +
"[C]<u><font size='big'>ORDER N°045</font></u>\n" +
........... |
OMG!!!!!!!!!! I don't believe it. I am really surprised. |
Star the repository ;) |
Done. I will follow you from now on. |
Thx, I hope you will create everything you want :) |
@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
The text was updated successfully, but these errors were encountered: