0

I am trying to display PDF into Android WebView, I found a lot of tutorials but in all tutorials, they have URL for their PDF, in my case I'm getting PDF as file in HTTP request. Is possible to show that in WebView?

My PDF response:

1 0 obj
    [/PDF /Text /ImageB /ImageC /ImageI]
    endobj
    13 0 obj
    << /Length 1600 /Filter /FlateDecode >> stream
    x��X�nSG�_�w�����K���BmD q�D�K|�:q�:�Jy�>B���̜�o

So I need the function for displaying that take response.body as parametar

Niklaus
  • 159
  • 1
  • 2
  • 11
  • did you checked [this](https://stackoverflow.com/questions/2655972/how-can-i-display-a-pdf-document-into-a-webview) – Mohammed Alaa Dec 16 '19 at 11:19
  • 1
    A WebView cannot display a .pdf file. – blackapps Dec 16 '19 at 11:20
  • @MohammedAlaa this is with URL – Niklaus Dec 16 '19 at 11:24
  • Does this answer your question? [How can I display a pdf document into a Webview?](https://stackoverflow.com/questions/2655972/how-can-i-display-a-pdf-document-into-a-webview) – Saeed Dec 16 '19 at 12:04
  • "Is possible to show that in WebView?" -- not directly. You can hack a version of Mozilla's PDF.js to be able to display a local PDF. It would be simpler to use a PDF rendering library. See https://commonsware.com/blog/2017/01/04/options-viewing-pdfs.html for more. – CommonsWare Dec 16 '19 at 13:29
  • @CommonsWare is there some tutorial that can explain to me how to implement that – Niklaus Dec 16 '19 at 14:24
  • @Niklaus: [This book](https://commonsware.com/Android/) has a chapter on rendering PDFs. The related sample code is [here](https://github.com/commonsguy/cw-omnibus/tree/FINAL/PDF). – CommonsWare Dec 16 '19 at 14:59

0 Answers0