Madhu Madhu - 8 months ago 87
JSON Question

How to Use Dynamic Image(URL) form json in bitmap

I followed this to print Sample Reciepts..

This is my Json data

"response": {
"status": ""

Here I have parsed JOSN in some other activity..and passed that in a intent.
and I assigned that url/json response to a string "Test22"

Test22 =

So I want to add this string in the Bitmap.. so that i can print..

Over there in EPSON sample code for printing image from a Location they have used this

Bitmap logoData = BitmapFactory.decodeResource(getResources(),;
StringBuilder textData = new StringBuilder();
final int barcodeWidth = 2;
final int barcodeHeight = 100;

Here sample is printing Image from R.drawable But I want to Print it from URL
if its storing after printing It should delete Image...

Can any one suggest me what I need to add at R.drawable in this case...

Actually Its a Pdf I am converting it to a image..
Can any one suggest me PDF to bitmap or Print a Image...


R.drawable is only from images packed in app.

public static Bitmap getBitmapFromURL(String src) {
    try {
        URL url = new URL(src);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        InputStream input = connection.getInputStream();
        Bitmap myBitmap = BitmapFactory.decodeStream(input);
        return myBitmap;
    } catch (IOException e) {
        // Log exception
        return null;


Replace from EPSON code

Bitmap logoData = BitmapFactory.decodeResource(getResources(),;


Bitmap logoData = getBitmapFromURL("‌​mmands-from-PHP-directly-to-the-client-printer/php-print-esc-pos-sample-receipt.p‌​ng");