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.
byte[].toString()onObjectprints things like[B@a4d4cefif it is not overridden by a subclass. Note thatWebViewhas no built-in ability to display a PDF.Log.e()line, delete that line. Beyond that, save your PDF to a file and usestartActivity()withACTION_VIEWto allow the user to view the PDF with their preferred PDF viewer.