How to open pdf file in android in web view from sd card

I want to open a PDF file Programmatically without using PDF reader support. Is it possible to open a pdf file with a web view, if so, how?

or if there are other possible ways, please suggest me.

than you.

Kriss

+3
source share
3 answers

I want to open a pdf file Programmatically without using the support of a PDF reader.

By definition, this is not possible. This is similar to saying that you want to view HTML without reading HTML.

Is it possible to open a pdf file with a web view, if so, how?

All he does is try to redirect you to the PDF reader on the device.

, PDF PDF- . Android PDF.

+3

PDF webview, , PDF , . android-pdfview

jar

, PDF , , :

1) jar armeabi-v7a libs

2) PDF

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <com.joanzapata.pdfview.PDFView
        android:id="@+id/pdfView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</LinearLayout>

3) PDF

PDFView pdfView= (PDFView) findViewById(R.id.pdfView);
pdfView.fromAsset("yourPDF.pdf") //you can also load from File using pdfView.fromFile()
.defaultPage(1)
.load(); 

onPageChangeListner, onPageLoadListner, .

0

You can only use installed applications to read PDF files on the device to open pdf

You can use the Google document viewer service to view pdf, ppt content in webview if your document resource is online. create the following HTML line, for example:
String googleDocUrl ="<iframe src='http://docs.google.com/gview?url=" + YOUR_ONLINE_PDF_DOC_URL + "&embedded=true' width='100%' height='100%'style='border: none;'></iframe>";


call webviews method loadData ():

 mWebView.loadData(googleDocUrl ,"text/html","UTF-8");

here it is. as it worked for me in my last project.
Hope this helps you.

-1
source

All Articles