I am getting a response from the server which starts from %PDF-1.7
. I believe that it is a base64 string(correct if I am wrong). Now while decoding the data using kotlin I am getting an error.What I want to achieve is I want to parse the response and open it into a pdfviewer.Help is appreciated.Thank you.
Asked
Active
Viewed 854 times
0

Chinmaay
- 153
- 1
- 2
- 10
-
No base64 but just the pdf document. There is nothing to decode. – blackapps May 28 '21 at 05:27
-
Use a byte reader/writer instead of character reader/writer and you're good to go. – Darkman May 28 '21 at 05:30
1 Answers
0
To all those who are still stuck in this.I have cracked this in the below way
Summary before I start
- I have used volley string request.
- I have used third party library
implementation 'com.github.barteksc:android-pdf-viewer:2.8.2
Layout file
<com.github.barteksc.pdfviewer.PDFView
android:id="@+id/pdfViewer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"/>
Kotlin code
override fun parseNetworkResponse(response: NetworkResponse): Response<String?>? {
val data = response.data
return super.parseNetworkResponse(response)
}
and then in your response listener
binding?.pdfViewer?.fromBytes(data)?.load()
Happy coding.

Chinmaay
- 153
- 1
- 2
- 10