简体   繁体   中英

Open pdf in external app

I have and android app. It has a pdf in assets folder. I written a code to view this pdf in external app(like adobe pdf viewer). It is working fine but problem is that there is Share option in Adobe pdf viewer. I dont want that user can distribute this pdf.

My problem is that there is an important pdf book and I want user can read only but can not share or redistribute it. Please give an idea. I will change my code.

I am using following code:

Uri path = Uri.fromFile(new File(str,
                "lemmelibroandroid.pdf")); 
Intent pdfIntent = new Intent(Intent.ACTION_VIEW);
pdfIntent.setDataAndType(path, "application/pdf");
pdfIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(pdfIntent);

I dont think it is possible to limit the capabilities of the external application used to open the pdf

Have a look at http://asmncl.blogspot.in/2012/06/android-open-pdf-file-in-webview.html to see how to open the pdf in a WebView

It is not possible,so the best option here will be to show your content in your own app.
I am sure that you will find a proper way to display it some how in activity.
Maybe you should change the format of PDF to HTML and it will be easier to show.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM