0

In my application when i click print button print will come from the Bluetooth printer, right now i am able to print the data...

But suddenly i recognize that this (Zebra MZ320 printer) doesn't support Hindi language.

i need to print Hindi data also in the printer , so the only option i have is Convert the string(Hindi) data into image and then printing that image.

For that i need to know how to convert an string into image and also i don't want to save that image whenever printing is completes then i want to delete it...

Can any one guide me how to acheive this , i already started with Base64 encoding and decoding but not succeed(means how to do). i am using the below code to convert my string into image but i am getting Skimage Decoder--Factory returned null

String cpclConfigLabel = "Purchy No:";
             byte[]  configLabel = cpclConfigLabel.getBytes();
             Log.e("Befire Bimta",""+configLabel);

             Bitmap bitmap = BitmapFactory.decodeByteArray(configLabel , 0, configLabel .length);

for every valuable reply i will give kudos....

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
Kiran_b
  • 199
  • 7
  • 15
  • nice app idea..if find any code please let me know.. – MKJParekh Nov 08 '11 at 10:59
  • Dear Frankenstein just inform me if you have any idea about converting string into image remaining i can do... – Kiran_b Nov 08 '11 at 11:33
  • I dont know..but I have seen something like this..is this can be useful to you..http://stackoverflow.com/questions/7763667/create-bitmap-image-from-edittext-its-content – MKJParekh Nov 08 '11 at 11:43
  • Possible duplicate of [Android Thermal printer Arabic Issue](https://stackoverflow.com/questions/53909331/android-thermal-printer-arabic-issue) – Martin Zeitler Sep 21 '19 at 08:49

1 Answers1

1

You can use Base64Encoder.java or for 2.2 onwards this

You can render the text to a TextView and save that into a bmp

Like so:

View viewToBeConverted;
// do stuff on the View    
viewToBeConverted.buildDrawingCache(true);
Bitmap bitmap = widget.getDrawingCache(true);
viewToBeConverted.destroyDrawingCache();

See: buildDrawingCache()

Reno
  • 33,594
  • 11
  • 89
  • 102
  • hmm Frankenstein is right, if you can render the text on the screen, you can get a bitmap out of the drawing cache. I'll look for other options. – Reno Nov 08 '11 at 12:37
  • i am using the below code but i am getting null in BitmapFactory String cpclConfigLabel = "Purchy No:"; byte[] configLabel = cpclConfigLabel.getBytes(); Log.e("Befire Bimta",""+configLabel); Bitmap bitmap = BitmapFactory.decodeByteArray(configLabel , 0, configLabel .length); – Kiran_b Nov 08 '11 at 14:23
  • If you can render hindi text on a TextView, you can print the image generated from that TextView on the printer. – Reno Nov 08 '11 at 14:41
  • ok but i am getting Illegal Argument Exception if i use below code TextView viewToBeConverted = new TextView(this); viewToBeConverted.setText(cpclConfigLabel); Bitmap viewBitmap = Bitmap.createBitmap(viewToBeConverted.getWidth(), viewToBeConverted.getHeight(),Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(viewBitmap); viewToBeConverted.draw(canvas); – Kiran_b Nov 08 '11 at 14:59
  • This [question](http://stackoverflow.com/questions/14530058/how-can-i-print-an-image-on-a-bluetooth-printer-in-android) could helps you – Leonardo Sapuy May 30 '13 at 16:37