0

I am calling a json API from which I am getting a pdf element , it looks like this , this file is only for example as it is corrupted but looks like this :

JVBERi0xLjUNCiW1tbW1DQoxIDAgb2JqDQo8PC9UeXBlL0NhdGFsb2cvUGFnZXMgMiAwIFIvTGFuZyhlbi1VUykgL1N0cnVjdFRyZWVSbDQTRGRTNBQ0MxQTg5PjwxOTIzMDRGMTgwOTZCMzQ0QjExQ0E0RkUzQUNDMUE4OT5dIC9QcmV2IDk3NjgwL1hSZWZTdG0gOTY0MTg+Pg0Kc3RhcnR4cmVmDQoxMDgzNzgNCiUlRU9G

I want to convert it into pdf to display it into web view in my application.

My tried Code:

String fileUrl = response.getPdf();
byte[] bytes = null;
    try {
         bytes = fileUrl.getBytes("UTF-8");
        Log.e("Byte Array",bytes.toString());
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }

It Converts into [B@a4d4cef. After this i am not understanding what to do.

Any help would be appreciated. Thanks.

3
  • "It Converts into [B@a4d4cef" -- it converts into a byte[]. toString() on Object prints things like [B@a4d4cef if it is not overridden by a subclass. Note that WebView has no built-in ability to display a PDF. Commented Apr 17, 2021 at 10:39
  • So, what should i do? Commented Apr 17, 2021 at 11:20
  • Do about... what? If your concern is the Log.e() line, delete that line. Beyond that, save your PDF to a file and use startActivity() with ACTION_VIEW to allow the user to view the PDF with their preferred PDF viewer. Commented Apr 17, 2021 at 12:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.